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

ConvexPolygonShape2D can't be edited with mouse like CollisionPolygon2D #21394

Closed
Maykeye opened this issue Aug 25, 2018 · 9 comments · Fixed by #40091
Closed

ConvexPolygonShape2D can't be edited with mouse like CollisionPolygon2D #21394

Maykeye opened this issue Aug 25, 2018 · 9 comments · Fixed by #40091
Milestone

Comments

@Maykeye
Copy link
Contributor

Maykeye commented Aug 25, 2018

Godot version:
3.1.dev.f72f744

Issue description:
If you select ConvexPolygonShape2D a as collision shape, you can't draw its points with mouse, you can only manually enter their coordinates in the Inspector, which is tedious.

Compare to CollisionPolygon2D which allows to use mouse to create a polygon.

Steps to reproduce:

  • Create 2D scene
  • Add CollisionShape2D
  • Select ConvexPolygonShape2D as its shape
  • Click anywhere on the scene hoping to start drawing polygon
  • Nothing happens
@eggnot
Copy link

eggnot commented May 6, 2020

It's still true on 3.2.1 stable for both ConcavePolygonShape2D and ConvexPolygonShape2D

@eggnot
Copy link

eggnot commented May 6, 2020

And also on 3.2.2 beta1

@Xrayez
Copy link
Contributor

Xrayez commented Jun 29, 2020

Yeah, I recall myself stumbling upon exact issue, but I'm not sure whether this should be a feature, because for polygon-based shape editing Godot has CollisionPolygon2D node specifically, which also handles:

  • proper orientation of polygon being built (vertices could be set in either clockwise of counterclockwise order, which is important both for rendering and probably physics too, because inertia should be computed from polygon area, see add consideration for 2d physics center_of_mass #29867).
  • convex/concave polygons, where polygons are decomposed into convex or remain segment-based.

So, there are several options to address this issue:

  1. Actually implement it.
  2. Remove ConvexPolygonShape2D and ConcavePolygonShape2D from the resource selection popup.
  3. A mixture of (1) and (2), read on.

For simplistic polygon shape editing (which do not relate to physics, perhaps gameplay needs), this does make sense. Yet there are some inconsistencies between ConvexPolygonShape2D and ConcavePolygonShape2D, namely the former is represented as points, while the latter is represented as discontinuous segments, and makes it somewhat difficult to edit. This might add some extra complexity (which is possible to resolve), yet #32979 aims to fix it anyway.

To be honest, I don't quite see the point of having different convex/concave shapes to begin with, I'd just implement a single PolygonShape2D, add perhaps adding an enum to specify and/or calculate the convexity of polygons, just like in CollisionPolygon2D node with the Build Mode property. -1 class for Godot, less bloat. 😛

@Xrayez
Copy link
Contributor

Xrayez commented Jun 29, 2020

I've also expressed my views in relation to godotengine/godot-proposals#1126 (comment), and could likely work on fixing this already in Godot, just need a blessing from other core devs.

@Xrayez
Copy link
Contributor

Xrayez commented Jul 1, 2020

Figured out how to edit concave (as well as convex) shapes through a similar node: goostengine/goost#2 (comment). I think it would be nice to add this feature to Godot, just because this would promote ease of use for plugins/modules (currently I have to edit the shape through another class, from which the shape is then assigned to CollisionShape2D, or it has to be first saved to disk as a resource and then set for both classes to propagate changes, which is not intuitive).

@Xrayez
Copy link
Contributor

Xrayez commented Jul 2, 2020

Upon further research I figured there's CollisionShape2DEditor which handle most common types except polygon types:

case CONCAVE_POLYGON_SHAPE: {
} break;
case CONVEX_POLYGON_SHAPE: {
} break;

But I find implementing polygon editing directly within this class to be problematic because there's already AbstractPolygon2DEditor which has it's own editing logic for that (both editor and plugin)...

So, might be just better and easier to create CollisionShape2DPolygonEditor and register the plugin alongside CollisionShape2DEditor, and provide some comments about that.

@Xrayez
Copy link
Contributor

Xrayez commented Jul 3, 2020

Some discussion from IRC #godotengine-devel channel:

Xrayez> reduz: does it makes sense to fix/implement #21394?
Xrayez> If so I could work on that. Currently it's only possible to do this via CollisionPolygon2D, but not CollisionShape2D.
reduz> Xrayez: i think there is no benefit in doing that to be honest, this is a shape that only makes sense to use via code
Xrayez> reduz: would it make sense to remove ConvexPolygonShape2D and ConcavePolygonShape2D from the resource popup in CollisionShape2D?
Xrayez> so that users don't get confused, and go straight to CollisionPolygon2D node for that.
reduz> No, I would just put a configuration warning if you put a convexpolygon in a collision shape, saying this type of shape can't be edited manually, and suggest using a CollisionPolygon node instead
reduz> I mean we could make an editor, but whats the point
Xrayez> Well that's fairly easy to add since there's a AbstractPolygonEditor.
Xrayez> That's mainly due to https://github.com/godotengine/godot-proposals/issues/1126
Xrayez> Which wouldn't be solved on the core, but would allow consistency between what the core provides and modules.
reduz> not so easy because you need to ensure the polygon is always convex
reduz> so again I would not bother
reduz> adding a warning to avoid confusion imo is best
Xrayez> Ok I'll go for that.

@akien-mga akien-mga added this to the 4.0 milestone Jul 3, 2020
@0-Kala-0
Copy link

0-Kala-0 commented Nov 3, 2020

I came here after some googling because the warning is actually confusing. I'd vote for removing the option in the droplist. Unless there is a use-case for not removing it ?

@Calinou
Copy link
Member

Calinou commented Nov 4, 2020

@Mayt38 The option can't be removed from the dropdown as the dropdown will always display all resources that inherit from the "expected" type.

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.

7 participants