| 1384 | //---------------------------------------------------------------------------- |
| 1385 | |
| 1386 | bool 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 | //---------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected