reactphysics3d icon indicating copy to clipboard operation
reactphysics3d copied to clipboard

RigidBody collision bug?

Open MatheusZickuhr opened this issue 3 years ago • 4 comments

I have two rigid bodies on a scene, a box (dynamic type) and a floor (static type).

image

When I call physicsWorld->destroyRigidBody(floorRigidBodyPtr) the box colliding with the floor should fall, but it does not.

image

If I destroy the floor`s rigid body before the box hit it, the ploblem does not happen. Is that intended behavior, or it is a bug?

MatheusZickuhr avatar Feb 09 '22 22:02 MatheusZickuhr

Hello,

It could be a bug yes. It might be because the bodies are sleeping and the box is not awaken when the floor is destroyed. Could you try to wake up the box rigid body after the floor is destroyed using the following code?

boxRigidBodyPtr->setIsSleeping(false);

Does it work now?

DanielChappuis avatar Feb 09 '22 22:02 DanielChappuis

Hello,

It could be a bug yes. It might be because the bodies are sleeping and the box is not awaken when the floor is destroyed. Could you try to wake up the box rigid body after the floor is destroyed using the following code?

boxRigidBodyPtr->setIsSleeping(false);

Does it work now?

Hello, boxRigidBodyPtr->setIsSleeping(false); fixed it. Thanks!

MatheusZickuhr avatar Feb 09 '22 23:02 MatheusZickuhr

Ok perfect but it is still a bug. I will need to fix this. Thanks for reporting this.

DanielChappuis avatar Feb 09 '22 23:02 DanielChappuis

This kind of bug is too hard for me to solve it in my simple arcade physics. For you don't wast so many time, I solve it like this: 1-add a vector of the position to the body when the world starts the update (preUpdate) 2-with the oldPosition, check after all bodies update (postUpdate) if the oldPosition, is nearly the currentPosition (updated one). Nearly, I would say, the current position is "almost" the oldPosition, thinking like it is in a threshold. It's aproximately like sleeping, but, it differs that you must check the threshold for each world update, what can be hard for many updated objects.

ghost avatar Apr 20 '22 06:04 ghost

This is now fixed in version v0.10.0 of the library.

DanielChappuis avatar Mar 10 '24 13:03 DanielChappuis