| 6115 | //---------------------------------------------------------------------------- |
| 6116 | |
| 6117 | void Player::updateWorkingCollisionSet() |
| 6118 | { |
| 6119 | // First, we need to adjust our velocity for possible acceleration. It is assumed |
| 6120 | // that we will never accelerate more than 20 m/s for gravity, plus 10 m/s for |
| 6121 | // jetting, and an equivalent 10 m/s for jumping. We also assume that the |
| 6122 | // working list is updated on a Tick basis, which means we only expand our |
| 6123 | // box by the possible movement in that tick. |
| 6124 | Point3F scaledVelocity = mVelocity * TickSec; |
| 6125 | F32 len = scaledVelocity.len(); |
| 6126 | F32 newLen = len + (10.0f * TickSec); |
| 6127 | |
| 6128 | // Check to see if it is actually necessary to construct the new working list, |
| 6129 | // or if we can use the cached version from the last query. We use the x |
| 6130 | // component of the min member of the mWorkingQueryBox, which is lame, but |
| 6131 | // it works ok. |
| 6132 | bool updateSet = false; |
| 6133 | |
| 6134 | Box3F convexBox = mConvex.getBoundingBox(getTransform(), getScale()); |
| 6135 | F32 l = (newLen * 1.1f) + 0.1f; // from Convex::updateWorkingList |
| 6136 | const Point3F lPoint( l, l, l ); |
| 6137 | convexBox.minExtents -= lPoint; |
| 6138 | convexBox.maxExtents += lPoint; |
| 6139 | |
| 6140 | // Check containment |
| 6141 | if (mWorkingQueryBox.minExtents.x != -1e9f) |
| 6142 | { |
| 6143 | if (mWorkingQueryBox.isContained(convexBox) == false) |
| 6144 | // Needed region is outside the cached region. Update it. |
| 6145 | updateSet = true; |
| 6146 | } |
| 6147 | else |
| 6148 | { |
| 6149 | // Must update |
| 6150 | updateSet = true; |
| 6151 | } |
| 6152 | // Actually perform the query, if necessary |
| 6153 | if (updateSet == true) { |
| 6154 | const Point3F twolPoint( 2.0f * l, 2.0f * l, 2.0f * l ); |
| 6155 | mWorkingQueryBox = convexBox; |
| 6156 | mWorkingQueryBox.minExtents -= twolPoint; |
| 6157 | mWorkingQueryBox.maxExtents += twolPoint; |
| 6158 | |
| 6159 | disableCollision(); |
| 6160 | |
| 6161 | //We temporarily disable the collisions of anything mounted to us so we don't accidentally walk into things we've attached to us |
| 6162 | for (SceneObject *ptr = mMount.list; ptr; ptr = ptr->getMountLink()) |
| 6163 | { |
| 6164 | ptr->disableCollision(); |
| 6165 | } |
| 6166 | |
| 6167 | mConvex.updateWorkingList(mWorkingQueryBox, |
| 6168 | isGhost() ? sClientCollisionContactMask : sServerCollisionContactMask); |
| 6169 | |
| 6170 | //And now re-enable the collisions of the mounted things |
| 6171 | for (SceneObject *ptr = mMount.list; ptr; ptr = ptr->getMountLink()) |
| 6172 | { |
| 6173 | ptr->enableCollision(); |
| 6174 | } |
nothing calls this directly
no test coverage detected