---------------------------------------------------------------------------- Resolve collision impacts Handle collision impacts, as opposed to contacts. Impulses are calculated based on standard collision resolution formulas. */
| 1268 | on standard collision resolution formulas. |
| 1269 | */ |
| 1270 | bool RigidShape::resolveCollision(Rigid& ns,CollisionList& cList) |
| 1271 | { |
| 1272 | PROFILE_SCOPE(RigidShape_resolveCollision); |
| 1273 | // Apply impulses to resolve collision |
| 1274 | bool collided = false; |
| 1275 | for (S32 i = 0; i < cList.getCount(); i++) |
| 1276 | { |
| 1277 | Collision& c = cList[i]; |
| 1278 | if (c.distance < mDataBlock->collisionTol) |
| 1279 | { |
| 1280 | // Velocity into surface |
| 1281 | Point3F v, r; |
| 1282 | ns.getOriginVector(c.point, &r); |
| 1283 | ns.getVelocity(r, &v); |
| 1284 | F32 vn = mDot(v, c.normal); |
| 1285 | |
| 1286 | // Only interested in velocities greater than sContactTol, |
| 1287 | // velocities less than that will be dealt with as contacts |
| 1288 | // "constraints". |
| 1289 | if (vn < -mDataBlock->contactTol) |
| 1290 | { |
| 1291 | |
| 1292 | // Apply impulses to the rigid body to keep it from |
| 1293 | // penetrating the surface. |
| 1294 | if (c.object->getTypeMask() & VehicleObjectType) |
| 1295 | { |
| 1296 | RigidShape* otherRigid = dynamic_cast<RigidShape*>(c.object); |
| 1297 | if (otherRigid) |
| 1298 | ns.resolveCollision(cList[i].point, cList[i].normal, &otherRigid->mRigid); |
| 1299 | else |
| 1300 | ns.resolveCollision(cList[i].point, cList[i].normal); |
| 1301 | } |
| 1302 | else ns.resolveCollision(cList[i].point, cList[i].normal); |
| 1303 | collided = true; |
| 1304 | |
| 1305 | // Keep track of objects we collide with |
| 1306 | if (!isGhost() && c.object->getTypeMask() & ShapeBaseObjectType) |
| 1307 | { |
| 1308 | ShapeBase* col = static_cast<ShapeBase*>(c.object); |
| 1309 | queueCollision(col, v - col->getVelocity()); |
| 1310 | } |
| 1311 | } |
| 1312 | } |
| 1313 | } |
| 1314 | |
| 1315 | return collided; |
| 1316 | } |
| 1317 | |
| 1318 | //---------------------------------------------------------------------------- |
| 1319 | /** Resolve contact forces |
nothing calls this directly
no test coverage detected