Significance of collision check loop flag
by Demolishun · in Torque Game Engine · 10/25/2004 (9:32 pm) · 0 replies
Does anyone know the significance of removing the "while" from this loop would be:
The reason I changed the while check is because this was causing my the engine to lock up when the collisionTol was low for my vehicle. If I get rid of this loop continuing on then my vehicle seems to still collide just fine, but it does not lock up.
Thanks,
Frank
bool Vehicle::resolveCollision(Rigid& ns,CollisionList& cList)
{
// Apply impulses to resolve collision
bool colliding, collided = false;
do {
colliding = false;
for (S32 i = 0; i < cList.count; i++) {
Collision& c = cList.collision[i];
if (c.distance < mDataBlock->collisionTol) {
// Velocity into surface
Point3F v,r;
ns.getOriginVector(c.point,&r);
ns.getVelocity(r,&v);
F32 vn = mDot(v,c.normal);
// Only interested in velocities greater than sContactTol,
// velocities less than that will be dealt with as contacts
// "constraints".
if (vn < -mDataBlock->contactTol) {
// Apply impulses to the rigid body to keep it from
// penetrating the surface.
ns.resolveCollision(cList.collision[i].point,
cList.collision[i].normal);
colliding = collided = true;
// Keep track of objects we collide with
if (!isGhost() && c.object->getTypeMask() & ShapeBaseObjectType) {
ShapeBase* col = static_cast<ShapeBase*>(c.object);
queueCollision(col,v - col->getVelocity());
}
}
}
}
} while (colliding && 0); // Test without repeat, this is what I changed
return collided;
}The reason I changed the while check is because this was causing my the engine to lock up when the collisionTol was low for my vehicle. If I get rid of this loop continuing on then my vehicle seems to still collide just fine, but it does not lock up.
Thanks,
Frank
About the author
I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67