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

Method updateWorkingCollisionSet

Engine/source/T3D/rigidShape.cpp:1426–1474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1424//----------------------------------------------------------------------------
1425
1426void RigidShape::updateWorkingCollisionSet(const U32 mask)
1427{
1428 PROFILE_SCOPE( Vehicle_UpdateWorkingCollisionSet );
1429
1430 // First, we need to adjust our velocity for possible acceleration. It is assumed
1431 // that we will never accelerate more than 20 m/s for gravity, plus 30 m/s for
1432 // jetting, and an equivalent 10 m/s for vehicle accel. We also assume that our
1433 // working list is updated on a Tick basis, which means we only expand our box by
1434 // the possible movement in that tick, plus some extra for caching purposes
1435 Box3F convexBox = mConvex.getBoundingBox(getTransform(), getScale());
1436 F32 len = (mRigid.linVelocity.len() + 50) * TickSec;
1437 F32 l = (len * 1.1) + 0.1; // fudge factor
1438 convexBox.minExtents -= Point3F(l, l, l);
1439 convexBox.maxExtents += Point3F(l, l, l);
1440
1441 // Check to see if it is actually necessary to construct the new working list,
1442 // or if we can use the cached version from the last query. We use the x
1443 // component of the min member of the mWorkingQueryBox, which is lame, but
1444 // it works ok.
1445 bool updateSet = false;
1446
1447 // Check containment
1448 if ((sWorkingQueryBoxStaleThreshold == -1 || mWorkingQueryBoxCountDown > 0) && mWorkingQueryBox.minExtents.x != -1e9f)
1449 {
1450 if (mWorkingQueryBox.isContained(convexBox) == false)
1451 // Needed region is outside the cached region. Update it.
1452 updateSet = true;
1453 }
1454 else
1455 {
1456 // Must update
1457 updateSet = true;
1458 }
1459
1460 // Actually perform the query, if necessary
1461 if (updateSet == true)
1462 {
1463 mWorkingQueryBoxCountDown = sWorkingQueryBoxStaleThreshold;
1464
1465 const Point3F lPoint( sWorkingQueryBoxSizeMultiplier * l );
1466 mWorkingQueryBox = convexBox;
1467 mWorkingQueryBox.minExtents -= lPoint;
1468 mWorkingQueryBox.maxExtents += lPoint;
1469
1470 disableCollision();
1471 mConvex.updateWorkingList(mWorkingQueryBox, mask);
1472 enableCollision();
1473 }
1474}
1475
1476//----------------------------------------------------------------------------
1477/** Check collisions with trigger and items

Callers

nothing calls this directly

Calls 5

updateWorkingListMethod · 0.80
Point3FClass · 0.50
getBoundingBoxMethod · 0.45
lenMethod · 0.45
isContainedMethod · 0.45

Tested by

no test coverage detected