Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
125 stars 2 forks source link

Boolean Collider / Combined Collider System #1540

Open NukiRaccoon opened 4 months ago

NukiRaccoon commented 4 months ago

Is your feature request related to a problem? Please describe.

When building collider-based systems, I have noticed a set of problems...

Mesh and Convex Hull colliders are not reliable or efficient, nor are they quickly loaded, due to their need to load in an asset after the world's slot-hierarchy has been populated by priority. This makes primitive-shape colliders preferable whenever possible.

When working with primitive colliders, one can combine them to make more complex shapes: operative example, in the Cloud Home and Ground Home, one can fit the building interior inside of a box-collider with two cylinder colliders for each end. This is great if you just need to block movement or check if anyone is in there, but runs into specific problems if you want to utilize more advanced systems such as reparenting: the current collision component fails when you go in and out of the two colliders being used here.

Another issue with primitive colliders is of using them to make concave shapes: in theory, one can make a collider which intersects another, and use "is local user inside" to deactivate the main one when the user is inside it, but this runs into problems of reliability and sync issues. This means the only effective way to do a concave shape out of reliable and efficient primitives is to break it down into smaller ones, which means lots of tiny colliders if you want decent detail, or having only a few colliders which give inaccurate collision, and either case means having a lot of slots just to position and rotate the colliders.

Describe the solution you'd like

A component which takes in two lists of colliders: union and difference. The union list would take colliders which, as a group, count as a positive collision. The difference list would take colliders which represent areas to be excluded from the colliders in the union, creating spaces within the colliders where there is not collision.

This could potentially have a way you could "bake" it into a more streamlined representation of those shapes, stored within that component somehow, but I'm not entirely sure what that would be or how meaningful a feature it would be.

Describe alternatives you've considered

The current workaround for these things is to build a somewhat complicated system of multi-bool drivers and advanced protoflux, and still has issues. It CAN be done, but it is neither a good setup for a new user to be presented with, nor anywhere near as efficient as an internal component would be.

Additional Context

An example of where this becomes very annoying is the landing spot for the cloud home: the platform is surrounded by a set of box-colliders, which part in the center. This could be far better replaced with a cylinder where boolean colliders could be used to cut out the center of the cylinder with another cylinder and the walkway with a box collider.

I can provide an example of this in an existing world, as I ran into the problem trying to add some sort of room-based culling to the Ground Home.

Requesters

Nuki

Frooxius commented 4 months ago

We could only support the "union" in this case - this is called a "Compound Collider". It's a set of colliders that acts as one, that's combination of all the shapes.

However for the difference - this isn't something the BepuPhysicsV2 (the physics engine we use) supports and generally this isn't a functionality that physics engines generally seem to have. Unless BepuPhysicsV2 adds support for this, we won't be able to support it.

NukiRaccoon commented 4 months ago

We could only support the "union" in this case - this is called a "Compound Collider". It's a set of colliders that acts as one, that's combination of all the shapes.

However for the difference - this isn't something the BepuPhysicsV2 (the physics engine we use) supports and generally this isn't a functionality that physics engines generally seem to have. Unless BepuPhysicsV2 adds support for this, we won't be able to support it.

Is this an issue of needing Bepu to support specific colliders, or an issue of it not supporting the needed math? Because if you can give it your own math, I have a few other feature requests I've been meaning to make...

Frooxius commented 4 months ago

It's an issue of BepuPhysicsV2 not supporting it, period. It doesn't matter how, it just doesn't have support for it in any form.

You can't really "give it math" either, it's not how it works.

However BepuPhysicsV2 is open source project, so you can implement additional features to it and open a PR against the master branch to get those merged. If those got accepted, we'd be able to potentially integrate them.