diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 471645e342..3a320cc628 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -556,8 +556,6 @@ Menu::Menu() { }); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::FixGaze, 0, false); - addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ToggleHipsFollowing, 0, false, - avatar.get(), SLOT(setToggleHips(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawBaseOfSupport, 0, false, avatar.get(), SLOT(setEnableDebugDrawBaseOfSupport(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawDefaultPose, 0, false, diff --git a/interface/src/Menu.h b/interface/src/Menu.h index cac8e77f9e..5cd4c2112e 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -211,7 +211,6 @@ namespace MenuOption { const QString ThirdPerson = "Third Person Legacy"; const QString ThreePointCalibration = "3 Point Calibration"; const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus"; // FIXME - this value duplicated in Basic2DWindowOpenGLDisplayPlugin.cpp - const QString ToggleHipsFollowing = "Toggle Hips Following"; const QString ToolWindow = "Tool Window"; const QString TransmitterDrive = "Transmitter Drive"; const QString TurnWithHead = "Turn using Head"; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 0f66f3bb41..c40974ac87 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1392,18 +1392,6 @@ float loadSetting(Settings& settings, const QString& name, float defaultValue) { return value; } -void MyAvatar::setToggleHips(bool followHead) { - _follow.setToggleHipsFollowing(followHead); -} - -void MyAvatar::FollowHelper::setToggleHipsFollowing(bool followHead) { - _toggleHipsFollowing = followHead; -} - -bool MyAvatar::FollowHelper::getToggleHipsFollowing() const { - return _toggleHipsFollowing; -} - void MyAvatar::setEnableDebugDrawBaseOfSupport(bool isEnabled) { _enableDebugDrawBaseOfSupport = isEnabled; } @@ -2030,7 +2018,6 @@ void MyAvatar::loadData() { allowAvatarLeaningPreferenceStrings[static_cast(AllowAvatarLeaningPreference::Default)]))); setEnableMeshVisible(Menu::getInstance()->isOptionChecked(MenuOption::MeshVisible)); - _follow.setToggleHipsFollowing (Menu::getInstance()->isOptionChecked(MenuOption::ToggleHipsFollowing)); setEnableDebugDrawBaseOfSupport(Menu::getInstance()->isOptionChecked(MenuOption::AnimDebugDrawBaseOfSupport)); setEnableDebugDrawDefaultPose(Menu::getInstance()->isOptionChecked(MenuOption::AnimDebugDrawDefaultPose)); setEnableDebugDrawAnimPose(Menu::getInstance()->isOptionChecked(MenuOption::AnimDebugDrawAnimPose)); @@ -5514,7 +5501,7 @@ void MyAvatar::setSitStandStateChange(bool stateChanged) { } // Determine if the user's real-world sit/stand state has changed. -float MyAvatar::getSitStandStateChange() const { +bool MyAvatar::getSitStandStateChange() const { return _sitStandStateChange; } @@ -5696,7 +5683,7 @@ bool MyAvatar::FollowHelper::shouldActivateHorizontal_userSitting(const MyAvatar bool stepDetected = false; if (forwardLeanAmount > MAX_FORWARD_LEAN) { stepDetected = true; - } else if (forwardLeanAmount < 0 && forwardLeanAmount < -MAX_BACKWARD_LEAN) { + } else if (forwardLeanAmount < -MAX_BACKWARD_LEAN) { stepDetected = true; } else { stepDetected = fabs(lateralLeanAmount) > MAX_LATERAL_LEAN; diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 3d278cf983..bb7ebb62ba 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -1800,7 +1800,7 @@ public: void setAnalogPlusSprintSpeed(float value); float getAnalogPlusSprintSpeed() const; void setSitStandStateChange(bool stateChanged); - float getSitStandStateChange() const; + bool getSitStandStateChange() const; void updateSitStandState(float newHeightReading, float dt); QVector getScriptUrls(); @@ -2181,13 +2181,6 @@ public slots: */ Q_INVOKABLE void updateMotionBehaviorFromMenu(); - /**jsdoc - * @function MyAvatar.setToggleHips - * @param {boolean} enabled - Enabled. - * @deprecated This function is deprecated and will be removed. - */ - void setToggleHips(bool followHead); - /**jsdoc * Displays the base of support area debug graphics if in HMD mode. If your head goes outside this area your avatar's hips * are moved to counterbalance your avatar, and if your head moves too far then your avatar's position is moved (i.e., a @@ -2907,8 +2900,6 @@ private: void setForceActivateVertical(bool val); bool getForceActivateHorizontal() const; void setForceActivateHorizontal(bool val); - bool getToggleHipsFollowing() const; - void setToggleHipsFollowing(bool followHead); std::atomic _forceActivateRotation { false }; std::atomic _forceActivateVertical { false }; std::atomic _forceActivateHorizontal { false }; diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 9c53060f31..b78c0989e2 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -364,7 +364,7 @@ void setupPreferences() { auto preference = new SpinnerSliderPreference(VR_MOVEMENT, "Camera Sensitivity", getter, setter); preference->setMin(0.01f); preference->setMax(5.0f); - preference->setStep(0.1); + preference->setStep(0.1f); preference->setDecimals(2); preferences->addPreference(preference); } diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index f361e15999..7d8b313377 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -1444,9 +1444,7 @@ int Avatar::getJointIndex(const QString& name) const { } withValidJointIndicesCache([&]() { - if (_modelJointIndicesCache.contains(name)) { - result = _modelJointIndicesCache.value(name) - 1; - } + result = _modelJointIndicesCache.value(name, result + 1) - 1; }); return result; } diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index adb7222ee3..9245f1a4ae 100755 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -1938,6 +1938,10 @@ void AvatarData::clearJointsData() { } int AvatarData::getFauxJointIndex(const QString& name) const { + static constexpr QChar fauxJointFirstChar('_');// The first character of all the faux joint names. + if (!name.startsWith(fauxJointFirstChar)) { + return -1; + }; if (name == "_SENSOR_TO_WORLD_MATRIX") { return SENSOR_TO_WORLD_MATRIX_INDEX; } diff --git a/libraries/physics/src/CharacterController.cpp b/libraries/physics/src/CharacterController.cpp index 777a3d3f87..2eaf771ae2 100755 --- a/libraries/physics/src/CharacterController.cpp +++ b/libraries/physics/src/CharacterController.cpp @@ -696,10 +696,29 @@ void CharacterController::applyMotor(int index, btScalar dt, btVector3& worldVel return; } - // rotate into motor-frame + const bool motorHasRotation = !(motor.rotation == btQuaternion::getIdentity()); btVector3 axis = motor.rotation.getAxis(); btScalar angle = motor.rotation.getAngle(); - btVector3 velocity = worldVelocity.rotate(axis, -angle); + + // Rotate a vector from motor frame to world frame + auto rotateToWorldFrame = [&axis, &angle, &motorHasRotation](const btVector3 vectorInMotorFrame) { + if (motorHasRotation) { + return vectorInMotorFrame.rotate(axis, angle); + } else { + return vectorInMotorFrame; + } + }; + + // Rotate a vector from world frame to motor frame + auto rotateToMotorFrame = [&axis, &angle, &motorHasRotation](const btVector3 vectorInWorldFrame) { + if (motorHasRotation) { + return vectorInWorldFrame.rotate(axis, -angle); + } else { + return vectorInWorldFrame; + } + }; + + btVector3 velocity = rotateToMotorFrame(worldVelocity); int32_t collisionMask = computeCollisionMask(); if (collisionMask == BULLET_COLLISION_MASK_COLLISIONLESS || @@ -712,15 +731,15 @@ void CharacterController::applyMotor(int index, btScalar dt, btVector3& worldVel velocity += tau * (motor.velocity - velocity); // rotate back into world-frame - velocity = velocity.rotate(axis, angle); - _targetVelocity += (tau * motor.velocity).rotate(axis, angle); + velocity = rotateToWorldFrame(velocity); + _targetVelocity += rotateToWorldFrame(tau * motor.velocity); // store the velocity and weight velocities.push_back(velocity); weights.push_back(tau); } else { // compute local UP - btVector3 up = _currentUp.rotate(axis, -angle); + btVector3 up = rotateToMotorFrame(_currentUp); btVector3 motorVelocity = motor.velocity; // save these non-adjusted components for later @@ -729,7 +748,7 @@ void CharacterController::applyMotor(int index, btScalar dt, btVector3& worldVel if (_stepHeight > _minStepHeight && !_steppingUp) { // there is a step --> compute velocity direction to go over step - btVector3 motorVelocityWF = motorVelocity.rotate(axis, angle); + btVector3 motorVelocityWF = rotateToWorldFrame(motorVelocity); if (motorVelocityWF.dot(_stepNormal) < 0.0f) { // the motor pushes against step _steppingUp = true; @@ -764,8 +783,8 @@ void CharacterController::applyMotor(int index, btScalar dt, btVector3& worldVel } // add components back together and rotate into world-frame - velocity = (hVelocity + vVelocity).rotate(axis, angle); - _targetVelocity += maxTau * (hTargetVelocity + vTargetVelocity).rotate(axis, angle); + velocity = rotateToWorldFrame(hVelocity + vVelocity); + _targetVelocity += maxTau * rotateToWorldFrame(hTargetVelocity + vTargetVelocity); // store velocity and weights velocities.push_back(velocity);