SirRamEsq / SmartShape2D

A 2D Terrain Tool for Godot
MIT License
1.33k stars 66 forks source link

Add ability to create hollow shapes with shape 2D? #110

Open That-Guy-UKnow opened 2 years ago

That-Guy-UKnow commented 2 years ago

Making levels with closed spaces feels close to impossible with this tool, though in any other regards I feel like this tool is perfect! making levels have never been easier, but sadly we can't seem to find the ability to create a hollow shape with this set up sadly :(

ghost commented 7 months ago

^ Exactly this, It would be extremely useful to have the equivalent of Polygon2D's Invert switch with adjustable exterior border size, I need this right now for creating closed-space levels but encountered the same limitation. It's silly too because it's not necessarily like the system itself wouldn't work completely fine with this, but either: 1- the equivalent of Polygon2D's invert function is missing, or 2- the way of defining the shape has limitations that make it impossible to create closed spaces, and trying to put two separate ones close together to close them creates it's own issues

So far the only walkaround I managed to find was to simply separate the edges from the filling texture and add the fill texture separately later while leaving the edge shapes openedso that they can be slipped underneath one another to cover up potential discontinuity

It would be great if the polygon shapes could work like booleans so that you could just define one big rectangle and cut the interior out with another polygon shape

mphe commented 7 months ago

If I understand this correctly, you want a shape with a fill texture and edge textures, but only with collisions on the edges in order to keep things inside instead of outside. This is actually the same issue as #102, so I'll close #102 in favor of this one.

You can get this kind of collision behavior (with performance drawbacks) by adding collisions to the shape and switching the "Build Mode" property of the CollisionPolygon2D node to "Segments". See also https://github.com/SirRamEsq/SmartShape2D/issues/102#issuecomment-1923843121.

At the moment we have only one way to generate collisions, which is by creating a CollisionPolygon node and assigning the vertices of the shape. I agree there should be functionality to better support interiors without a performance trade-off. One option would be to provide a second collision generation option that arranges one collision shape for each edge, e.g. a capsule. This way we could build efficient edge-only collisions. It is not impossible to do so, but someone has to invest time to implement it, which is the reason this feature does not exist (also because the demand seems rather low).

It would be great if the polygon shapes could work like booleans so that you could just define one big rectangle and cut the interior out with another polygon shape

Allowing users to arbitrarily cut into geometry and recompute meshes and collisions from the remains is an entirely different topic and beyond the scope of this plugin. This goes more into the direction of dynamic terrain shaping.