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

Make CSG nodes able to generate collision using CSG primitives rather than a triangle mesh #2083

Closed
addmix opened this issue Jan 7, 2021 · 4 comments

Comments

@addmix
Copy link

addmix commented Jan 7, 2021

Describe the project you are working on

I am working on a semi-realistic FPS, that focuses on player controls and ergonomics.

Describe the problem or limitation you are having in your project

I want to be able to use CSG objects (specifically tori [torus plural]) for collision. There is no built in option for a torus collision shape, or being able to apply a CSG difference operation on collision shapes, without using mesh collision

Describe the feature / enhancement and how it helps to overcome the problem or limitation

CSG objects having their proper round collision shapes, along with combination CSG primitives in the physics engine, without using tri mesh collision

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

CSG objects are notorious for being easy to raycast, along with raymarching. There are a few papers from the 90s documenting CSG collision. CSG basics outline how boolean operations are handled.

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

no

Is there a reason why this should be core and not an add-on in the asset library?

CSG is very common for prototyping, and is useful for approximate collision shapes of meshes. This should be a core functionality to the physics engine which can be hard to modify in this way, and keep efficiency without custom builds.

@Calinou
Copy link
Member

Calinou commented Jan 7, 2021

Related to #200.

This would require implementing CSG collision shapes in the engine, which has many use cases (even outside of CSG nodes) but also sounds pretty difficult.

cc @madmiraal @AndreaCatania

@Calinou Calinou changed the title CSG collision using CSG primitive rather than trimesh Make CSG nodes able to generate collision using CSG primitives rather than a triangle mesh Jan 7, 2021
@addmix
Copy link
Author

addmix commented Jan 9, 2021

With the way that CSG operations are handled, CSG collisions wouldn't be far off from the current collision shape workflow. Adding more collision shapes to the engine would further expedite a possible inclusion of CSG based collision, as collisions can be tested using logical operators on the results of multiple individual collision bodies.

https://en.wikipedia.org/wiki/Constructive_solid_geometry
image
"CSG objects can be represented by binary trees, where leaves represent primitives, and nodes represent operations."

The only probably issue I can imagine is current CSG may not translate to binary trees, possibly needing reworking.

Using the preexisting collision shapes of the engine, and using the logical and, or, and not operators, we can test for intersections of CSG objects quite easily, while being able to return collision information from individual elements.

@reduz
Copy link
Member

reduz commented May 22, 2021

This is not mathematically possible, sorry. The only technique that can more or less work this way is sphere-SDF collisions, which rules out all other physics shapes (box, convex poly, capsule, etc) and its also not amazingly precise. Physics engines work on the premise of convex shapes, and once you do a union/intersection/subtraction in CSG, it rarely remains convex.

@Calinou
Copy link
Member

Calinou commented May 23, 2021

Closing per the above comment.

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

No branches or pull requests

4 participants