I'm currently implementing the effect of explosions (and e.g. of bullets hitting crates) by applying impulse scaled by distance to objects in the vicinity of the explosion.
It works very well, but I want to save computing the exact point in space where the objects are hit by the impact.
Do I understand btRigidBody::applyImpulse() correct in that when
- rb is a btRigidBody,
- i is an impulse,
- s is a scalar,
- rel_pos is a correct relative position,
Code: Select all
rb->applyImpulse(i, rel_pos + i*s);
(Because the implementation computes i.cross(rel_pos + i*s) which reduces to i.cross(rel_pos) ?)
With this argument the following is possible:
When Ob is the origin of the bomb or bullet, the related ray of impact propagation is Ob + i*s.
When Oc is the origin of the hit crate, rel_pos = (Ob + i*s) - Oc for the unknown s.
But as stated above, this reduces to rel_pos = Ob - Oc, saving the computation of s!
Can somebody confirm (or deny) if this is correct?
Any fault or oversight in this use of the applyImpact() method?
Btw., assuming that this is ok, I just tried an experimental implementation in my 3D engine, and it seems to work wonderfully!