mirror of
https://github.com/overte-org/overte.git
synced 2025-04-07 21:33:48 +02:00
Merge pull request #1047 from Phil-Palmer/optimisation/myavatar
Small optimisations and tidying related to MyAvatar
This commit is contained in:
commit
4cb9459736
8 changed files with 39 additions and 30 deletions
|
@ -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,
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -1393,15 +1393,9 @@ float loadSetting(Settings& settings, const QString& name, float defaultValue) {
|
|||
}
|
||||
|
||||
void MyAvatar::setToggleHips(bool followHead) {
|
||||
_follow.setToggleHipsFollowing(followHead);
|
||||
}
|
||||
|
||||
void MyAvatar::FollowHelper::setToggleHipsFollowing(bool followHead) {
|
||||
_toggleHipsFollowing = followHead;
|
||||
}
|
||||
|
||||
bool MyAvatar::FollowHelper::getToggleHipsFollowing() const {
|
||||
return _toggleHipsFollowing;
|
||||
Q_UNUSED(followHead);
|
||||
qCDebug(interfaceapp) << "MyAvatar.setToggleHips is deprecated; it no longer does anything; it will soon be removed from the API; "
|
||||
"please update your script";
|
||||
}
|
||||
|
||||
void MyAvatar::setEnableDebugDrawBaseOfSupport(bool isEnabled) {
|
||||
|
@ -2030,7 +2024,6 @@ void MyAvatar::loadData() {
|
|||
allowAvatarLeaningPreferenceStrings[static_cast<uint>(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 +5507,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 +5689,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;
|
||||
|
|
|
@ -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<QString> getScriptUrls();
|
||||
|
@ -2907,8 +2907,6 @@ private:
|
|||
void setForceActivateVertical(bool val);
|
||||
bool getForceActivateHorizontal() const;
|
||||
void setForceActivateHorizontal(bool val);
|
||||
bool getToggleHipsFollowing() const;
|
||||
void setToggleHipsFollowing(bool followHead);
|
||||
std::atomic<bool> _forceActivateRotation { false };
|
||||
std::atomic<bool> _forceActivateVertical { false };
|
||||
std::atomic<bool> _forceActivateHorizontal { false };
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue