| 5119 | } |
| 5120 | |
| 5121 | bool Player::updatePos(const F32 travelTime) |
| 5122 | { |
| 5123 | PROFILE_SCOPE(Player_UpdatePos); |
| 5124 | getTransform().getColumn(3,&mDelta.posVec); |
| 5125 | |
| 5126 | // When mounted to another object, only Z rotation used. |
| 5127 | if (isMounted()) { |
| 5128 | mVelocity = mMount.object->getVelocity(); |
| 5129 | setPosition(Point3F(0.0f, 0.0f, 0.0f), mRot); |
| 5130 | setMaskBits(MoveMask); |
| 5131 | return true; |
| 5132 | } |
| 5133 | |
| 5134 | Point3F newPos; |
| 5135 | |
| 5136 | Collision col; |
| 5137 | dMemset( &col, 0, sizeof( col ) ); |
| 5138 | |
| 5139 | // DEBUG: |
| 5140 | //Point3F savedVelocity = mVelocity; |
| 5141 | |
| 5142 | if ( mPhysicsRep ) |
| 5143 | { |
| 5144 | static CollisionList collisionList; |
| 5145 | collisionList.clear(); |
| 5146 | |
| 5147 | newPos = mPhysicsRep->move( mVelocity * travelTime, collisionList ); |
| 5148 | |
| 5149 | bool haveCollisions = false; |
| 5150 | bool wasFalling = mFalling; |
| 5151 | if (collisionList.getCount() > 0) |
| 5152 | { |
| 5153 | mFalling = false; |
| 5154 | haveCollisions = true; |
| 5155 | } |
| 5156 | |
| 5157 | if (haveCollisions) |
| 5158 | { |
| 5159 | // Pick the collision that most closely matches our direction |
| 5160 | VectorF velNormal = mVelocity; |
| 5161 | velNormal.normalizeSafe(); |
| 5162 | const Collision *collision = &collisionList[0]; |
| 5163 | F32 collisionDot = mDot(velNormal, collision->normal); |
| 5164 | const Collision *cp = collision + 1; |
| 5165 | const Collision *ep = collision + collisionList.getCount(); |
| 5166 | for (; cp != ep; cp++) |
| 5167 | { |
| 5168 | F32 dp = mDot(velNormal, cp->normal); |
| 5169 | if (dp < collisionDot) |
| 5170 | { |
| 5171 | collisionDot = dp; |
| 5172 | collision = cp; |
| 5173 | } |
| 5174 | } |
| 5175 | |
| 5176 | _doCollisionImpact( collision, wasFalling ); |
| 5177 | |
| 5178 | // Modify our velocity based on collisions |
nothing calls this directly
no test coverage detected