reactphysics3d icon indicating copy to clipboard operation
reactphysics3d copied to clipboard

Strange collision box vs box in version 0.7.1

Open aliasdevelopment opened this issue 5 years ago • 7 comments

I have observed a strange behavior when multiple boxes hits a larger floor box.

Version 0.7.1 behaves different from 0.6.0, in a way that hint some issue in 0.7.1.

When boxes hits the floor in 0.6.0, then the boxes tumbles around, but in 0.7.1 the boxes bounce in a structured manner and with some weird rotations in the set of boxes.

0.6.0 0.7.1

The only difference in the videos are the version of react. The videos are using the following glm::vec3( 0.0f, 10.0f + i*0.001f, i*1.0f ) as spawn position.

I version 0.7.1 it is possible to control the weird rotation of boxes. This is possible by changing the spawn position of the boxes. If the y-axis is set to i*0.0f the all boxes seems to do the weird rotation and if y-axis uses i*0.2f, then a smaller amount do the weird rotation. Hint, they hit the ground out of 'sync'.

aliasdevelopment avatar Jan 07 '20 15:01 aliasdevelopment

Thanks for reporting this. Could you post the code that you use to create the floor box (position/orientation and size of the BoxShape) and the code that you use to create the smaller boxes (size of the BoxShape) ?

DanielChappuis avatar Jan 07 '20 16:01 DanielChappuis

I will try to show how the boxes are created. The boxes and floor uses the same code, except for the floor to be static and the boxes dynamic, but the code is wrapped into various interfaces.

The boxes is 1, 1, 1 and floor is 100, 1, 100, but tried to make it 10, 1, 10 without any difference. Still got the weird rotation where multiple boxes rotate equally. Rotation is glm::quat( glm::vec3( 0.0f, 0.0f, 0.0f ) ) where the quat is copied into a reactphysics quaternion when the physics object is created.

aliasdevelopment avatar Jan 07 '20 20:01 aliasdevelopment

I added a terrain to see how the objects behave. It seems that some orientation is intermixed following the falling capsule.

Terrain/Capsule

I also changed the order of object creation which changes the behaviour.

I have made a diff of 0.6.0 and 0.7.1 and can see that major changes has been made to the memory management. Can it be assume that I can call getTransform of a list of rp3d::RigidBody pointers in order to get the body transform?

aliasdevelopment avatar Jan 08 '20 10:01 aliasdevelopment

I found an issue with my rendering, which explain the additional rotation seen in the previous gif animation. Now I do not have the additional rotation. Sorry for the noise.

I still get the initial impact rotation when boxes hit each other when the normals of the hitting surfaces are parallel which may be a special case. This can still be seen in the following gif.

Fixed additional rotation/initial box impact rotation

I am unsure if the box impact rotation is expected. I can always as some small random rotation to box creation to avoid the impact rotation shown on the three small boxes hitting the box floor.

aliasdevelopment avatar Jan 08 '20 13:01 aliasdevelopment

Good job for fixing your rendering issue. It seems much better now in your video. I do not really see anything wrong in this video.

Do you also have a video of your first case (box floor) ?

DanielChappuis avatar Jan 08 '20 19:01 DanielChappuis

I have made two videos showing the difference between random rotation on the boxes and boxes without rotation. Boxes are spawned at the same plane.

No rotation Random rotation

aliasdevelopment avatar Jan 09 '20 16:01 aliasdevelopment

I am not sure what is causing this rotation.

DanielChappuis avatar Jan 10 '20 09:01 DanielChappuis