| 161 | } |
| 162 | |
| 163 | void KinematicPlatform::updateState(PlatformState& state, PxObstacleContext* obstacleContext, PxReal dtime, bool updateActor) const |
| 164 | { |
| 165 | state.mCurrentTime += dtime; |
| 166 | state.mCurrentRotationTime += dtime; |
| 167 | |
| 168 | // Compute current position on the path |
| 169 | PxReal t = state.mCurrentTime/mTravelTime; |
| 170 | if(t>1.0f) |
| 171 | { |
| 172 | if(mMode==LOOP_FLIP) |
| 173 | { |
| 174 | state.mFlip = !state.mFlip; |
| 175 | // Make it loop |
| 176 | state.mCurrentTime = fmodf(state.mCurrentTime, mTravelTime); |
| 177 | t = state.mCurrentTime/mTravelTime; |
| 178 | } |
| 179 | else |
| 180 | { |
| 181 | PX_ASSERT(mMode==LOOP_WRAP); |
| 182 | // state.mCurrentTime = fmodf(state.mCurrentTime, mTravelTime); |
| 183 | t = 1.0f - t; |
| 184 | state.mCurrentTime = t * mTravelTime; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | PxVec3 currentPos; |
| 189 | if(getPoint(currentPos, state.mFlip ? 1.0f - t : t)) |
| 190 | { |
| 191 | const PxVec3 wp = currentPos; |
| 192 | |
| 193 | PxMat33 rotY; |
| 194 | PxToolkit::setRotX(rotY, state.mCurrentRotationTime*mRotationSpeed); |
| 195 | const PxQuat rotation(rotY); |
| 196 | |
| 197 | const PxTransform tr(wp, mLocalRot * rotation); |
| 198 | |
| 199 | //PxVec3 delta = wp - state.mPrevPos; |
| 200 | //shdfnd::printFormatted("Kine: %f | %f | %f\n", delta.x, delta.y, delta.z); |
| 201 | state.mPrevPose = tr; |
| 202 | if(updateActor) |
| 203 | { |
| 204 | PxSceneWriteLock scopedLock(*mActor->getScene()); |
| 205 | mActor->setKinematicTarget(tr); // * |
| 206 | /*PxVec3 test = mActor->getGlobalPose().p; |
| 207 | test -= tr.p; |
| 208 | shdfnd::printFormatted("%f | %f | %f\n", test.x, test.y, test.z);*/ |
| 209 | } |
| 210 | else if(obstacleContext && mBoxObstacle) |
| 211 | { |
| 212 | PxBoxObstacle localBox = *mBoxObstacle; |
| 213 | localBox.mPos.x = wp.x; |
| 214 | localBox.mPos.y = wp.y; |
| 215 | localBox.mPos.z = wp.z; |
| 216 | localBox.mRot = tr.q; |
| 217 | bool status = obstacleContext->updateObstacle(mObstacle, localBox); |
| 218 | PX_ASSERT(status); |
| 219 | PX_UNUSED(status); |
| 220 | } |
nothing calls this directly
no test coverage detected