Question about rigid body update/collision detection order?
Posted: Sat Jan 04, 2020 9:54 pm
Hey!
I'm having a situation that is leaving me stumped. I'm not very experienced with Physics engines and have an elementary grasp about physics in general.
I'm trying to simulate a projectile(B) being fired from a moving target (A). I'm creating a new rigid body for B at the rigid body position of A + an offset. I add B to the world and then set its linear velocity to be the linear velocity of A + the intended velocity for B. The linear velocity of B is the same as the maximum linear velocity of A.
E.g: State after adding and setting linear velocity (P = Position, V = Velocity)
However, when checking the collisions after the next tick I get a collision between A & B with the following states:
When I inspect these values I notice that the position of A is extremely close to the spawn position of B. I would assume that since the velocity of B is >= double A this collision would never take place in the first place.
This leaves me wondering whether the collision detection is tied to the order the rigid bodies that are added to world, the update to the linear velocity was not taken into account for the collision calculation during this step or I'm doing something that isn't correct with my setup.
I'm currently using btDbvtBoradPhase, btSequentialImpuseConstraintSolver() and btDiscreteDynamicsWorld. I check for collisions by registering a custom tick callback and iterating over the manifolds after stepSimulation(). Simulation timestep is 1/60.
Any insights/pointers would be helpful to try to understand what's going on.
Thanks.
I'm having a situation that is leaving me stumped. I'm not very experienced with Physics engines and have an elementary grasp about physics in general.
I'm trying to simulate a projectile(B) being fired from a moving target (A). I'm creating a new rigid body for B at the rigid body position of A + an offset. I add B to the world and then set its linear velocity to be the linear velocity of A + the intended velocity for B. The linear velocity of B is the same as the maximum linear velocity of A.
E.g: State after adding and setting linear velocity (P = Position, V = Velocity)
Code: Select all
P:vec3{ x:-917.5590209960937, y:-325.8153991699219, z:-153.44479370117187 }
V:vec3{ x:-1228.0089111328125, y:432.7921142578125, z:3228.3515625 }
Code: Select all
// States recorded after stepSimulation(), not the values of the contact points in the manifolds
B = P: vec3{ x:-938.0258178710937, y:-318.6022033691406, z:-99.63893127441406 }
V:vec3{ x:-1228.0089111328125, y:432.7921142578125, z:3228.3515625 }
A = P:vec3{ x:-920.6774291992187, y:-324.79351806640625, z:-144.39683532714844 }
V:vec3{ x:-509.7142028808594, y:176.45169067382812, z:1375.142822265625 }
This leaves me wondering whether the collision detection is tied to the order the rigid bodies that are added to world, the update to the linear velocity was not taken into account for the collision calculation during this step or I'm doing something that isn't correct with my setup.
I'm currently using btDbvtBoradPhase, btSequentialImpuseConstraintSolver() and btDiscreteDynamicsWorld. I check for collisions by registering a custom tick callback and iterating over the manifolds after stepSimulation(). Simulation timestep is 1/60.
Any insights/pointers would be helpful to try to understand what's going on.
Thanks.