Check for collisions in simulation on demand #115
-
It is rather a question. _Setup simulation ('physical' bodies){ CheckForCollisions(bodiesTransforms){ Could somebody give me directions to entry points? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 1 reply
-
There's two high level paths: completely external queries, or monitoring bodies in the simulation. For queries, you request bounds overlaps from the broad phase, then submit the resulting pairs to a collision batcher to collect collision data. This exposes you to some of the more difficult to use internal APIs, but it does work. Check the collision queries demo for an example. You can avoid some of that by instead adding bodies to the simulation for the things you want to track and then setting up INarrowPhaseCallbacks to match. That is: return true from Which one is better/faster depends entirely on your use case; I'd suggest doing whichever one is simpler for you. |
Beta Was this translation helpful? Give feedback.
-
I check the CollisionQueryDemo , BatcherCallbacks.OnPairCompleted: |
Beta Was this translation helpful? Give feedback.
-
The In the demo, it only cares about boolean results, but you could expand it. For each query added through Note that the |
Beta Was this translation helpful? Give feedback.
-
If I understand correctly, Simulation.BroadPhase.GetOverlaps is just to get the objects that may collide the query based on the bounding box. The real collision judgment is BatcherCallbacks.OnPairCompleted function. This means Simulation.BroadPhase.GetOverlaps may have multiple objects, but only part of the objects actually collide the query. but I can't get the collidable refrence from the parameter "pairId" in the function BatcherCallbacks.OnPairCompleted |
Beta Was this translation helpful? Give feedback.
-
In addition, I think CollisionBatcher is better than INarrowPhaseCallbacks, because I don’t necessarily want to query every frame. With CollisionBatcher, I can use it conveniently when I need it. |
Beta Was this translation helpful? Give feedback.
-
Yup.
Yup.
Right; so you'd need to store out the collidable references detected by the EDIT: Should clarify- in the current implementation, the queryId is always aligned with the query, so you get potentially multiple callbacks with the same pairId, but you can modify the value passed for the pairId to encode whatever values you want- that would let you do the lookup. |
Beta Was this translation helpful? Give feedback.
-
Hi, sorry to jump into the middle of the conversation... what I think it could be useful is to have a high level API to check for geometry overlappings, without having to deal with the underlaying complexities of Bepu. Preventing people to having to deal with the lower level details also gives more freedom for reenginering. My case might be similar to the one of @OleksandrVdovychenko ... In the future, I want to use the full simulation provided by Bepu... but one time after another, I find myself dealing with projects that have two requirements: A- Object location is defined by the client, not by the rigid body dynamics engine. B- I only need overlapping notifications (AKA, object 1 is overlapping with object 6) and at best, a crude separation vector ... so in most cases I end up rolling my own sphere-sphere collision check system. @RossNordby Think of an arcade game, in which objects move around using predefined paths, or they're attached to function curves, and when objects collide, either disappear or explode. You really don't need to setup rigid bodies with masses and inertia tensors just to do that. Actually, if I would be me, I would like to begin using Bepu that way, before diving into the deeps of rigid body simulations. |
Beta Was this translation helpful? Give feedback.
-
Guys, thank you all for very constructive discussion! Ross, thank you for so detailed answers! Your answer to @vpenades is actually what I was looking for! So I marked it as an answer. |
Beta Was this translation helpful? Give feedback.
Hi, sorry to jump into the middle of the conversation... what I think it could be useful is to have a high level API to check for geometry overlappings, without having to deal with the underlaying complexities of Bepu. Preventing people to having to deal with the lower level details also gives more freedom for reenginering.
My case might be similar to the one of @OleksandrVdovychenko ... In the future, I want to use the full simulation provided by Bepu... but one time after another, I find myself dealing with projects that have two requirements: A- Object location is defined by the client, not by the rigid body dynamics engine. B- I only need overlapping notifications (AKA, object 1 is ov…