MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / resolveDisplacement

Method resolveDisplacement

Engine/source/T3D/rigidShape.cpp:1386–1421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1384//----------------------------------------------------------------------------
1385
1386bool RigidShape::resolveDisplacement(Rigid& ns,CollisionState *state, F32 dt)
1387{
1388 SceneObject* obj = (state->mA->getObject() == this)?
1389 state->mB->getObject(): state->mA->getObject();
1390
1391 if (obj->isDisplacable() && ((obj->getTypeMask() & ShapeBaseObjectType) != 0))
1392 {
1393 // Try to displace the object by the amount we're trying to move
1394 Point3F objNewMom = ns.linVelocity * obj->getMass() * 1.1f;
1395 Point3F objOldMom = obj->getMomentum();
1396 Point3F objNewVel = objNewMom / obj->getMass();
1397
1398 Point3F myCenter;
1399 Point3F theirCenter;
1400 getWorldBox().getCenter(&myCenter);
1401 obj->getWorldBox().getCenter(&theirCenter);
1402 if (mDot(myCenter - theirCenter, objNewMom) >= 0.0f || objNewVel.len() < 0.01)
1403 {
1404 objNewMom = (theirCenter - myCenter);
1405 objNewMom.normalize();
1406 objNewMom *= 1.0f * obj->getMass();
1407 objNewVel = objNewMom / obj->getMass();
1408 }
1409
1410 obj->setMomentum(objNewMom);
1411 if (obj->displaceObject(objNewVel * 1.1f * dt) == true)
1412 {
1413 // Queue collision and change in velocity
1414 VectorF dv = (objOldMom - objNewMom) / obj->getMass();
1415 queueCollision(static_cast<ShapeBase*>(obj), dv);
1416 return true;
1417 }
1418 }
1419
1420 return false;
1421}
1422
1423
1424//----------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 12

getTypeMaskMethod · 0.80
mDotFunction · 0.50
getObjectMethod · 0.45
isDisplacableMethod · 0.45
getMassMethod · 0.45
getMomentumMethod · 0.45
getCenterMethod · 0.45
getWorldBoxMethod · 0.45
lenMethod · 0.45
normalizeMethod · 0.45
setMomentumMethod · 0.45
displaceObjectMethod · 0.45

Tested by

no test coverage detected