Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Shape2D node #6750

Closed
toby3d opened this issue Oct 9, 2016 · 42 comments · Fixed by #37903
Closed

Add Shape2D node #6750

toby3d opened this issue Oct 9, 2016 · 42 comments · Fixed by #37903

Comments

@toby3d
Copy link
Contributor

toby3d commented Oct 9, 2016

The engine is already available CollisionPolygon2D and CollisionShape2D for draw invisible collision zones. The last allows you to assign simple forms to shape such as a square, circle, and so on... But only Polygon2D there to draw for only custom forms.
Why not include a node Shape2D, through which you can quickly create a visual form of squares, triangles, circles and lines? Currently to create a simple circle I must import the sprite, making sure it is large enough so that he had clear edge.

@eon-s
Copy link
Contributor

eon-s commented Oct 9, 2016

Or a "quick shape" button for Polygon2D, since you can create a circle with a polygon (it could be a plugin like Add Primitives, too).

@toby3d
Copy link
Contributor Author

toby3d commented Oct 10, 2016

@eon-s I think it is better to create a separate node for this purpose, so as not to break backward compatibility and also to have a choice as to the forms of collisions.

@toby3d toby3d changed the title [Feature request] Add Shape2D node Add Shape2D node Oct 10, 2016
@bojidar-bg
Copy link
Contributor

@toby3d If it is indeed done like add primitives, then it would just be a menu above the scene viewport, from which you would just click Make Circle, and it would set the polygon's vertices to a circle.

@hubbyist
Copy link

hubbyist commented Oct 10, 2016

Will a polygon for circle adapt to change in size or scaling?

Shape2D must have a level of detail setting to make it adaptable to basic transformations IMO. Shortest/Longest edge setting may works as well, otherwise it will be same as adding a quick shape menu to polygon2D.

@eon-s
Copy link
Contributor

eon-s commented Oct 10, 2016

@hubbyist polygons can be resized and scaled, if you need a dynamic circle shaped polygon that mantain some kind of softness when scaled (which does not sound like a common situation*), it could be done with a custom node.

Check this amazing plugin to see how much can be done with custom nodes, polygons and curves (with custom handles and all).
http://godotengine.org/asset-library/asset/29

*I said that is not common because if you need a circle that resizes all the time and stays as a circle, a sprite is a lot better.

@hubbyist
Copy link

hubbyist commented Oct 11, 2016

I mean without "adaptive level of detail" a Shape2D node will be pointless. Polygon with "quick shape" menu will do the trick.

Polygon can be used for lots of things but if you will alter its size and have to do many times while developing a game this can be tiresome. So an adaptive Shape2D node with parametric properties like radius for circle, semi-major,semi-minor axises for ellipse etc will be handy.

Besides I don't understand the reason of

*I said that is not common because if you need a circle that resizes all the time and stays as a circle, a sprite is a lot better.

I always tend to think that vectoral/parametric shapes will be better for performance than bitmap sprites.

Note: asset29 will be handy for a project I was working on with godot1.1 I was looking forward to port it to 2.x, it will help. 😄

@eon-s
Copy link
Contributor

eon-s commented Oct 11, 2016

@hubbyist for the way Godot works, I think there is no difference on how polygon or a plain sprite is draw, also, with a polygon, if need to change the number of points you need UV corrections too and that could get messy.

That plugin is amazing and gets really good deformations, I have used the animationPlayer on the curve and the texture stays smooth (but lot of Bad Polygon! from the collision polygon)

@hubbyist
Copy link

hubbyist commented Oct 12, 2016

@eon-s I mostly need asset29 for static levels, but may use as a proof of concept for some quick sand fields deformation. I will give information when I have time.

For UV correction issue if it can be done with a simple recalculation, can be added to shape2D node as well I think. I wish I was a C++ programmer to say more about this subject.

@henriiquecampos
Copy link
Contributor

I think that maybe changing Polygon2D to Shape2D would good. Then, Shape2D nodes could draw Curves, Lines, Rectangles, Circles, Cyllinders and other custom Polygons with the current behaviour.

@eon-s
Copy link
Contributor

eon-s commented Oct 13, 2016

Forgot to mention, we can actually _draw quick plain color shapes, even arcs or curves without using Polygon.

ps: maybe the official site could make a "plugin requests or ideas" like Q&A, I don't know where can be proposed.

@toby3d
Copy link
Contributor Author

toby3d commented Jun 15, 2017

Is it still in the plans?

@vnen
Copy link
Member

vnen commented Jun 15, 2017

It seems that nobody ever claimed this issue. Tagging as PR welcome.

@toger5
Copy link
Contributor

toger5 commented Jun 15, 2017

as eon-s mentioned:
It is already possible to make custom drawing for canvas items (controls for example).
this basically allows you to create any shape with a mesh (as vertex array + indeces). there are even functions for circles and rectangles so primitive shapes are easy to achieve.
even preview in editor is possible... (even uv maps are supported!)

I think a 2Dmesh resource would be more valuable. so I can create meshes and reuse them without implementing coustom drawing code.

@eon-s
Copy link
Contributor

eon-s commented Jun 15, 2017

@toger5 as I have mentioned on 7042, making resources could be better but not sure if meshes, polygon resources could have more uses on 2D (collisions shapes, polygons, curves, occluders).

@toger5
Copy link
Contributor

toger5 commented Jun 15, 2017

@eon-s that is interesting! using it for other nodes makes a lot of sense.
maybe a sprite itself just could use a texture OR a mesh? or is the name sprite only correct when used with a texture?

@eon-s
Copy link
Contributor

eon-s commented Jun 15, 2017

@toger5 I think that meshes on sprites (for deformations) are planned for 3.1

@labolado
Copy link

two base features must provided:

1、auto tracing the contour
2、multiple shapes per sprite

@toby3d
Copy link
Contributor Author

toby3d commented Aug 4, 2017

We still need radial shape2D for avoid creating circle by sprite or code.

@toby3d
Copy link
Contributor Author

toby3d commented Nov 5, 2017

Beta is coming: #12543

Any plans?

@eon-s
Copy link
Contributor

eon-s commented Nov 5, 2017

If nobody started this already I doubt it will be for 3.0, but 3.1 is going to modify some things on 2D physics, there will be more chances to see something by then.

@Neicul
Copy link

Neicul commented Jan 23, 2018

This would be really great for fast prototyping. It would remove the need for textures for a small prototype. And make it in turn way faster to play with new gameplay.

@toby3d
Copy link
Contributor Author

toby3d commented Jan 23, 2018

@Neicul Exactly, but it seems that this will not appear in the next releases.

@aaronfranke
Copy link
Member

There is already a Shape2D class: https://godot.readthedocs.io/en/3.0/classes/class_shape2d.html#class-shape2d

Inherited By: RayShape2D, CapsuleShape2D, LineShape2D, CircleShape2D, ConcavePolygonShape2D, ConvexPolygonShape2D, RectangleShape2D, SegmentShape2D

What is missing? It seems that you're already able to create circles etc.

@eon-s
Copy link
Contributor

eon-s commented Nov 22, 2018

@aaronfranke those shapes are limited to collisions, the issue here is for drawing shapes.
If Polygon2D (and other nodes) were more flexible, these could use Shape2D too.

@aaronfranke
Copy link
Member

Perhaps this could be implemented similar to 3D MeshInstance primitives.

@analog-hors
Copy link

It always bugged me how there's a specific collision for shapes but not for actually drawing them

@Calinou
Copy link
Member

Calinou commented Jul 21, 2019

@KSean222 Please don't bump issues without contributing significant new information; use the 👍 reaction button on the first post instead.

@KoBeWi
Copy link
Member

KoBeWi commented Nov 30, 2019

What's the status on this actually? It has "PR Welcome" label, but the implementing PR was closed, because this feature would be better suited as an addon...
Also equivalent feature in GDScript is impossible without making an EditorPlugin.

@eon-s
Copy link
Contributor

eon-s commented Dec 1, 2019

I agree that as addon could be better even if is a commonly used thing, but Godot also need a "standard assets" package to get a set of addons on project creation (for 3D, 2D, etc.) to "close" this kind of requests...

@Calinou
Copy link
Member

Calinou commented Dec 1, 2019

@eon-s See #28142. Also, I think this should be in core as we already have procedural meshes available in 3D. Making them available in 2D would be more consistent with what we already have in 3D.

@pdfrod
Copy link
Contributor

pdfrod commented Dec 12, 2019

As a newbie to Godot I found it confusing that there was no easy way to add a basic 2D shape. Especially because it already has 3D shapes, so why not 2D?

Installing a plugin just to be able to add a basic circle, feels like like too much hassle for something should be very straightforward.

@Shadowblitz16
Copy link

please please add this.
it would make a good way to make 2d circle explosions.

what I would suggest is making it take a draw mode property (line or fill)
and a any shape2D.

I suggest calling this ShapeRenderer2D

@aaronfranke
Copy link
Member

aaronfranke commented Mar 26, 2020

Since nobody has linked it yet, @henriiquecampos has created a Geometry2D node for this purpose: https://github.com/godot-extended-libraries/godot-next/blob/master/addons/godot-next/2d/geometry_2d.gd

@Shadowblitz16
Copy link

this doesn't actully take a shape2D though it only supports 3 shapes

@willnationsdev
Copy link
Contributor

@aaronfranke Also note that @henriiquecampos is the one who wrote that script, not me. :-)

@Neicul
Copy link

Neicul commented Apr 6, 2020

It would also be nice to have a single node with multiple shapes, stored in an array.
That way you can easily draw mockups for characters etc.
Maybe we can get this for 4.0?

@Shadowblitz16
Copy link

please don't do Vector2 arrays make us pass in a actual shape resource

@Xrayez
Copy link
Contributor

Xrayez commented Apr 15, 2020

Note that Shape2D drawing is fairly straighforward with C++:

shape->draw(get_canvas_item(), draw_col);

But what blocks this feature being implemented as a plugin is simply put: the method itself is not exposed to scripting at all. Once this is possible, #16483 can be ported to GDScript easily.

EDIT: see #37903.

@Mrxx99
Copy link

Mrxx99 commented Apr 19, 2020

@aaronfranke

Since nobody has linked it yet, @henriiquecampos has created a Geometry2D node for this purpose: https://github.com/godot-extended-libraries/godot-next/blob/master/addons/godot-next/2d/geometry_2d.gd

I tried the Geometry2D but it seems it's a collision shape and not actual a visual shape.

For this issue:
I also think it is necessary to include simple default shapes. I am a beginner and now googling for an hour how I can create a rectangle with rounded corners.

@Xrayez
Copy link
Contributor

Xrayez commented Apr 19, 2020

I tried the Geometry2D but it seems it's a collision shape and not actual a visual shape.

Moreover, there's a pending proposal which would make the mentioned class collide with the core singleton one, see godotengine/godot-proposals#640 (Geometry may be split to Geometry2D and Geometry3D).

@akien-mga
Copy link
Member

Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!

@Xrayez
Copy link
Contributor

Xrayez commented Jun 30, 2020

Given the number of 👍 on this, it's worth to notify people that this proposal is now tracked at godotengine/godot-proposals#1126.

I'll also take this opportunity and say that I've actually ended up implementing VisualShape2D class in goostengine/goost#2 (still open for feedback). I know about #16483 but I'm confident to say that my particular implementation could suit more use cases. In any case, it would be wrong not to propose an alternative solution for this kind of feature to be available in Godot (in fact there are several reasons why this should be part of the core, like reusing existing polygon editor plugin etc).

There are other solutions ofcourse, like probably allowing people to make collision shapes visible per node (and not globally):

It always bugged me how there's a specific collision for shapes but not for actually drawing them

while allowing to override color for each, which would likely be the most straightforward way to add this kind of feature without bloating the engine with yet another class.

But I feel like the engine is becoming too conservative in this regard personally, it wasn't the case when I first started using Godot, hence godotengine/godot-proposals#575). This is fine but if we don't provide a standard GDScript package officially maintained by core devs to cater user needs (with good accessibility and availability), we'll start accumulate frustrated users, and this proposal is one such example IMO.

This becomes offtopic so please proceed to godotengine/godot-proposals#1126 for further discussion if you'd like to chime in, as most of what I've written here is already mentioned there, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.