Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all
Unified · Split
| @@ -2495,10 +2495,18 @@ void Application::update(float deltaTime) { · 2494 unmodified lines | ||
| 2495 | 2495 | _myAvatar->setDriveKeys(DOWN, _userInputMapper.getActionState(UserInputMapper::VERTICAL_DOWN)); |
| 2496 | 2496 | _myAvatar->setDriveKeys(LEFT, _userInputMapper.getActionState(UserInputMapper::LATERAL_LEFT)); |
| 2497 | 2497 | _myAvatar->setDriveKeys(RIGHT, _userInputMapper.getActionState(UserInputMapper::LATERAL_RIGHT)); |
| 2498 | − _myAvatar->setDriveKeys(ROT_UP, _userInputMapper.getActionState(UserInputMapper::PITCH_UP)); | |
| 2499 | − _myAvatar->setDriveKeys(ROT_DOWN, _userInputMapper.getActionState(UserInputMapper::PITCH_DOWN)); | |
| 2500 | − _myAvatar->setDriveKeys(ROT_LEFT, _userInputMapper.getActionState(UserInputMapper::YAW_LEFT)); | |
| 2501 | − _myAvatar->setDriveKeys(ROT_RIGHT, _userInputMapper.getActionState(UserInputMapper::YAW_RIGHT)); | |
| 2498 | + if (deltaTime > FLT_EPSILON) { | |
| 2499 | + // For rotations what we really want are meausures of "angles per second" (in order to prevent | |
| 2500 | + // fps-dependent spin rates) so we need to scale the units of the controller contribution. | |
| 2501 | + // (TODO?: maybe we should similarly scale ALL action state info, or change the expected behavior | |
| 2502 | + // controllers to provide a delta_per_second value rather than a raw delta.) | |
| 2503 | + const float EXPECTED_FRAME_RATE = 60.0f; | |
| 2504 | + float timeFactor = EXPECTED_FRAME_RATE * deltaTime; | |
| 2505 | + _myAvatar->setDriveKeys(ROT_UP, _userInputMapper.getActionState(UserInputMapper::PITCH_UP) / timeFactor); | |
| 2506 | + _myAvatar->setDriveKeys(ROT_DOWN, _userInputMapper.getActionState(UserInputMapper::PITCH_DOWN) / timeFactor); | |
| 2507 | + _myAvatar->setDriveKeys(ROT_LEFT, _userInputMapper.getActionState(UserInputMapper::YAW_LEFT) / timeFactor); | |
| 2508 | + _myAvatar->setDriveKeys(ROT_RIGHT, _userInputMapper.getActionState(UserInputMapper::YAW_RIGHT) / timeFactor); | |
| 2509 | + } | |
| 2502 | 2510 | } |
| 2503 | 2511 | _myAvatar->setDriveKeys(BOOM_IN, _userInputMapper.getActionState(UserInputMapper::BOOM_IN)); |
| 2504 | 2512 | _myAvatar->setDriveKeys(BOOM_OUT, _userInputMapper.getActionState(UserInputMapper::BOOM_OUT)); |