See at the bottom:
http://www.myphysicslab.com/collision.htmlThis is impulse calculation.
Implementation (collision dynamic / static object only) below from Chris Heckers physics tutorial code.
Don't know where it is in newton and if it has some tools for this suff...
All this calculates a instant velocity change (Impulse).
If you want to apply a force (should be more stable), you need to change some things. *)
The dot product you said is part of it (but it applies before calculating the angular responce).
*) Edit:
Ending up with your...
vec3 relVel = bullet.velocity - objectVelAtCollisionPoint;
force = relVel.Dot(collisionNormal) * someConstantContainingBulletMass * coeffOfRestitution;
Vec3 r = position - this->GetPosition();
Vec3 torque = r.Cross(force);
this->AddForce(force);
this->AddTorque(torque);
... looks totally right for me (force integration handles mass/inertia stuff for you).
If you're happy with it, ignore that complex stuff

- Code: Select all
void simulation_world::ResolveCollisions( int ConfigurationIndex )
{
rigid_body &Body = aBodies[CollidingBodyIndex];
rigid_body::configuration &Configuration =
Body.aConfigurations[ConfigurationIndex];
vector_3 Position =
Configuration.aBoundingVertices[CollidingCornerIndex];
vector_3 R = Position - Configuration.CMPosition;
vector_3 Velocity = Configuration.CMVelocity +
CrossProduct(Configuration.AngularVelocity,R);
real ImpulseNumerator = -(r(1) + Body.CoefficientOfRestitution) *
DotProduct(Velocity,CollisionNormal);
real ImpulseDenominator = Body.OneOverMass +
DotProduct(CrossProduct(Configuration.InverseWorldInertiaTensor *
CrossProduct(R,CollisionNormal),R),
CollisionNormal);
vector_3 Impulse = (ImpulseNumerator/ImpulseDenominator) * CollisionNormal;
// apply impulse to primary quantities
Configuration.CMVelocity += Body.OneOverMass * Impulse;
Configuration.AngularMomentum += CrossProduct(R,Impulse);
// compute affected auxiliary quantities
Configuration.AngularVelocity = Configuration.InverseWorldInertiaTensor *
Configuration.AngularMomentum;
}
Edit2: added some stuff i have had forgotten at first.