| 238 | float clampedDeltaTime = 0.2; |
| 239 | |
| 240 | void MotionThreadFunc(void* userPtr, void* lsMemory) |
| 241 | { |
| 242 | printf("MotionThreadFunc thread started\n"); |
| 243 | //MotionThreadLocalStorage* localStorage = (MotionThreadLocalStorage*) lsMemory; |
| 244 | |
| 245 | MotionArgs* args = (MotionArgs*)userPtr; |
| 246 | //int workLeft = true; |
| 247 | b3Clock clock; |
| 248 | clock.reset(); |
| 249 | b3Clock sleepClock; |
| 250 | bool init = true; |
| 251 | if (init) |
| 252 | { |
| 253 | unsigned int cachedSharedParam = eMotionIsInitialized; |
| 254 | |
| 255 | args->m_cs->lock(); |
| 256 | args->m_cs->setSharedParam(0, eMotionIsInitialized); |
| 257 | args->m_cs->unlock(); |
| 258 | |
| 259 | double deltaTimeInSeconds = 0; |
| 260 | int numCmdSinceSleep1ms = 0; |
| 261 | unsigned long long int prevTime = clock.getTimeMicroseconds(); |
| 262 | |
| 263 | do |
| 264 | { |
| 265 | { |
| 266 | b3Clock::usleep(0); |
| 267 | } |
| 268 | |
| 269 | { |
| 270 | if (sleepClock.getTimeMilliseconds() > 1) |
| 271 | { |
| 272 | sleepClock.reset(); |
| 273 | numCmdSinceSleep1ms = 0; |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | unsigned long long int curTime = clock.getTimeMicroseconds(); |
| 278 | unsigned long long int dtMicro = curTime - prevTime; |
| 279 | prevTime = curTime; |
| 280 | #if 1 |
| 281 | double dt = double(dtMicro) / 1000000.; |
| 282 | #else |
| 283 | double dt = double(clock.getTimeMicroseconds()) / 1000000.; |
| 284 | clock.reset(); |
| 285 | #endif |
| 286 | deltaTimeInSeconds += dt; |
| 287 | |
| 288 | { |
| 289 | //process special controller commands, such as |
| 290 | //VR controller button press/release and controller motion |
| 291 | |
| 292 | for (int c = 0; c < MAX_VR_CONTROLLERS; c++) |
| 293 | { |
| 294 | btVector3 from = args->m_vrControllerPos[c]; |
| 295 | btMatrix3x3 mat(args->m_vrControllerOrn[c]); |
| 296 | |
| 297 | btScalar pickDistance = 1000.; |
nothing calls this directly
no test coverage detected