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 boolean operations to 2D collision objects #200

Open
define-private-public opened this issue Nov 4, 2019 · 4 comments · Fixed by goostengine/goost#39
Open

Add boolean operations to 2D collision objects #200

define-private-public opened this issue Nov 4, 2019 · 4 comments · Fixed by goostengine/goost#39

Comments

@define-private-public
Copy link

define-private-public commented Nov 4, 2019

Describe the project you are working on:
This feature request stems from this forum post: https://godotforums.org/discussion/21443/is-it-possilble-to-do-boolean-operations-to-construct-collision-objects

Describe the problem or limitation you are having in your project:
Same limitation from #199, I'm trying to make a Colosseum where I need to keep my objects inside of a circle. CollisionShape2D with Circle right now keeps them outside of the said circle. Manually drawing out a collision polygon with perfect curves is a pain (and not that elegant of a solution).

Describe how this feature / enhancement will help you overcome this problem or limitation:
Would be a massive time saver, and much more flexible if I need to make changes in the future.

Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
The diagram here is a good example of what I want: https://en.wikipedia.org/wiki/Boolean_operations_on_polygons

https://en.wikipedia.org/wiki/Constructive_solid_geometry

As for how to make a nice Godot friendly interface, I'm not quite sure.

Describe implementation detail for your proposal (in code), if possible:
N/A.

If this enhancement will not be used often, can it be worked around with a few lines of script?:
N/A

Is there a reason why this should be core and not an add-on in the asset library?:
Super-duper useful (and semi-fundamental) for 2D game developers.

@define-private-public
Copy link
Author

IIRC, the 3D part of Godot has this. Would be really neato to do this in 2D as well

@Calinou
Copy link
Member

Calinou commented Nov 4, 2019

See also godotengine/godot#28987 and godotengine/godot#29881.

@Xrayez
Copy link
Contributor

Xrayez commented Nov 4, 2019

Does colosseum style area looks like a closed donut or does it have an entrance?

If former, then your colosseum have basically two geometric objects (instead of one): the boundary and the hole, which can be both be represented as polygons. Now, it's not really possible to clip a boundary with a hole to produce another polygon, instead you need to triangulate/decompose the boundary polygon in such a way that negates walkable area inside it, producing the collision mesh internally (which is really non-trivial task to do via script).

As @Calinou kindly linked, those geometry methods could already provide some solution to this. The clipping solution may contain both boundaries and holes which can be passed to triangulator/decomposer with holes support. But it's not exposed to editor in any way currently.

godotengine/godot#35929 would be particularly useful for this because you need to pass multiple boundary and holes for them to be clipped perfectly by a single geometry object, for more complex shapes.

@Xrayez
Copy link
Contributor

Xrayez commented Nov 22, 2020

I'm currently implementing 2D boolean operator nodes in Goost: goostengine/goost#39, feedback welcome!

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.

3 participants