mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
clean out resolvecontacts entirely
This commit is contained in:
parent
783a757427
commit
f3af564dee
2 changed files with 0 additions and 68 deletions
|
|
@ -1259,7 +1259,6 @@ bool RigidShape::updateCollision(F32 dt)
|
||||||
|
|
||||||
// Resolve collisions
|
// Resolve collisions
|
||||||
bool collided = resolveCollision(mRigid,mCollisionList, dt);
|
bool collided = resolveCollision(mRigid,mCollisionList, dt);
|
||||||
//resolveContacts(mRigid,mCollisionList,dt);
|
|
||||||
return collided;
|
return collided;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1357,72 +1356,6 @@ bool RigidShape::resolveCollision(Rigid& ns,CollisionList& cList, F32 dt)
|
||||||
return collided;
|
return collided;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
/** Resolve contact forces
|
|
||||||
Resolve contact forces using the "penalty" method. Forces are generated based
|
|
||||||
on the depth of penetration and the moment of inertia at the point of contact.
|
|
||||||
*/
|
|
||||||
bool RigidShape::resolveContacts(Rigid& ns,CollisionList& cList,F32 dt)
|
|
||||||
{
|
|
||||||
PROFILE_SCOPE(RigidShape_resolveContacts);
|
|
||||||
// Use spring forces to manage contact constraints.
|
|
||||||
bool collided = false;
|
|
||||||
Point3F t,p(0,0,0),l(0,0,0);
|
|
||||||
for (S32 i = 0; i < cList.getCount(); i++)
|
|
||||||
{
|
|
||||||
const Collision& c = cList[i];
|
|
||||||
if (c.distance < mDataBlock->collisionTol)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Velocity into the surface
|
|
||||||
Point3F v,r;
|
|
||||||
ns.getOriginVector(c.point,&r);
|
|
||||||
ns.getVelocity(r,&v);
|
|
||||||
F32 vn = mDot(v,c.normal);
|
|
||||||
|
|
||||||
// Only interested in velocities less than mDataBlock->contactTol,
|
|
||||||
// velocities greater than that are dealt with as collisions.
|
|
||||||
if (mFabs(vn) < mDataBlock->contactTol)
|
|
||||||
{
|
|
||||||
collided = true;
|
|
||||||
|
|
||||||
// Penetration force. This is actually a spring which
|
|
||||||
// will seperate the body from the collision surface.
|
|
||||||
F32 zi = 2 * mFabs(mRigid.getZeroImpulse(r,c.normal) / dt);
|
|
||||||
F32 s = (mDataBlock->collisionTol - c.distance) * zi - ((vn / mDataBlock->contactTol) * zi);
|
|
||||||
Point3F f = c.normal * s;
|
|
||||||
|
|
||||||
// Friction impulse, calculated as a function of the
|
|
||||||
// amount of force it would take to stop the motion
|
|
||||||
// perpendicular to the normal.
|
|
||||||
Point3F uv = v - (c.normal * vn);
|
|
||||||
F32 ul = uv.len();
|
|
||||||
if (s > 0 && ul)
|
|
||||||
{
|
|
||||||
uv /= -ul;
|
|
||||||
F32 u = ul * ns.getZeroImpulse(r,uv) / dt;
|
|
||||||
s *= mRigid.friction;
|
|
||||||
if (u > s)
|
|
||||||
u = s;
|
|
||||||
f += uv * u;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Accumulate forces
|
|
||||||
p += f;
|
|
||||||
mCross(r,f,&t);
|
|
||||||
l += t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Contact constraint forces act over time...
|
|
||||||
ns.linMomentum += p * dt;
|
|
||||||
ns.angMomentum += l * dt;
|
|
||||||
ns.updateVelocity();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool RigidShape::resolveDisplacement(Rigid& ns,CollisionState *state, F32 dt)
|
bool RigidShape::resolveDisplacement(Rigid& ns,CollisionState *state, F32 dt)
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,6 @@ class RigidShape: public ShapeBase
|
||||||
void updatePos(F32 dt);
|
void updatePos(F32 dt);
|
||||||
bool updateCollision(F32 dt);
|
bool updateCollision(F32 dt);
|
||||||
bool resolveCollision(Rigid& ns,CollisionList& cList, F32 dt);
|
bool resolveCollision(Rigid& ns,CollisionList& cList, F32 dt);
|
||||||
bool resolveContacts(Rigid& ns,CollisionList& cList, F32 dt);
|
|
||||||
bool resolveDisplacement(Rigid& ns,CollisionState *state,F32 dt);
|
bool resolveDisplacement(Rigid& ns,CollisionState *state,F32 dt);
|
||||||
void checkTriggers();
|
void checkTriggers();
|
||||||
static void findCallback(SceneObject* obj,void * key);
|
static void findCallback(SceneObject* obj,void * key);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue