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

Method updateWorkingCollisionSet

Engine/source/T3D/player.cpp:5988–6035  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5986//----------------------------------------------------------------------------
5987
5988void Player::updateWorkingCollisionSet()
5989{
5990 // First, we need to adjust our velocity for possible acceleration. It is assumed
5991 // that we will never accelerate more than 20 m/s for gravity, plus 10 m/s for
5992 // jetting, and an equivalent 10 m/s for jumping. We also assume that the
5993 // working list is updated on a Tick basis, which means we only expand our
5994 // box by the possible movement in that tick.
5995 Point3F scaledVelocity = mVelocity * TickSec;
5996 F32 len = scaledVelocity.len();
5997 F32 newLen = len + (10.0f * TickSec);
5998
5999 // Check to see if it is actually necessary to construct the new working list,
6000 // or if we can use the cached version from the last query. We use the x
6001 // component of the min member of the mWorkingQueryBox, which is lame, but
6002 // it works ok.
6003 bool updateSet = false;
6004
6005 Box3F convexBox = mConvex.getBoundingBox(getTransform(), getScale());
6006 F32 l = (newLen * 1.1f) + 0.1f; // from Convex::updateWorkingList
6007 const Point3F lPoint( l, l, l );
6008 convexBox.minExtents -= lPoint;
6009 convexBox.maxExtents += lPoint;
6010
6011 // Check containment
6012 if (mWorkingQueryBox.minExtents.x != -1e9f)
6013 {
6014 if (mWorkingQueryBox.isContained(convexBox) == false)
6015 // Needed region is outside the cached region. Update it.
6016 updateSet = true;
6017 }
6018 else
6019 {
6020 // Must update
6021 updateSet = true;
6022 }
6023 // Actually perform the query, if necessary
6024 if (updateSet == true) {
6025 const Point3F twolPoint( 2.0f * l, 2.0f * l, 2.0f * l );
6026 mWorkingQueryBox = convexBox;
6027 mWorkingQueryBox.minExtents -= twolPoint;
6028 mWorkingQueryBox.maxExtents += twolPoint;
6029
6030 disableCollision();
6031 mConvex.updateWorkingList(mWorkingQueryBox,
6032 isGhost() ? sClientCollisionContactMask : sServerCollisionContactMask);
6033 enableCollision();
6034 }
6035}
6036
6037
6038//----------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 4

updateWorkingListMethod · 0.80
lenMethod · 0.45
getBoundingBoxMethod · 0.45
isContainedMethod · 0.45

Tested by

no test coverage detected