mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 16:36:54 +02:00
Merge pull request #528 from ey6es/gyroquat
Added configurable lean scale, fixed loadSetting.
This commit is contained in:
commit
0c80a66f84
4 changed files with 16 additions and 4 deletions
|
@ -880,6 +880,10 @@ void Application::editPreferences() {
|
||||||
headCameraPitchYawScale->setValue(_headCameraPitchYawScale);
|
headCameraPitchYawScale->setValue(_headCameraPitchYawScale);
|
||||||
form->addRow("Head Camera Pitch/Yaw Scale:", headCameraPitchYawScale);
|
form->addRow("Head Camera Pitch/Yaw Scale:", headCameraPitchYawScale);
|
||||||
|
|
||||||
|
QDoubleSpinBox* leanScale = new QDoubleSpinBox();
|
||||||
|
leanScale->setValue(_myAvatar.getLeanScale());
|
||||||
|
form->addRow("Lean Scale:", leanScale);
|
||||||
|
|
||||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
||||||
dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
|
dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
|
||||||
|
@ -893,6 +897,7 @@ void Application::editPreferences() {
|
||||||
sendAvatarVoxelURLMessage(url);
|
sendAvatarVoxelURLMessage(url);
|
||||||
|
|
||||||
_headCameraPitchYawScale = headCameraPitchYawScale->value();
|
_headCameraPitchYawScale = headCameraPitchYawScale->value();
|
||||||
|
_myAvatar.setLeanScale(leanScale->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::pair() {
|
void Application::pair() {
|
||||||
|
|
|
@ -79,6 +79,7 @@ Avatar::Avatar(Agent* owningAgent) :
|
||||||
_thrust(0.0f, 0.0f, 0.0f),
|
_thrust(0.0f, 0.0f, 0.0f),
|
||||||
_speed(0.0f),
|
_speed(0.0f),
|
||||||
_maxArmLength(0.0f),
|
_maxArmLength(0.0f),
|
||||||
|
_leanScale(0.5f),
|
||||||
_pelvisStandingHeight(0.0f),
|
_pelvisStandingHeight(0.0f),
|
||||||
_pelvisFloatingHeight(0.0f),
|
_pelvisFloatingHeight(0.0f),
|
||||||
_distanceToNearestAvatar(std::numeric_limits<float>::max()),
|
_distanceToNearestAvatar(std::numeric_limits<float>::max()),
|
||||||
|
@ -286,7 +287,7 @@ void Avatar::updateHeadFromGyros(float deltaTime, SerialInterface* serialInterfa
|
||||||
_head.setRoll(estimatedRotation.z * AMPLIFY_ROLL);
|
_head.setRoll(estimatedRotation.z * AMPLIFY_ROLL);
|
||||||
|
|
||||||
// Update torso lean distance based on accelerometer data
|
// Update torso lean distance based on accelerometer data
|
||||||
glm::vec3 estimatedPosition = serialInterface->getEstimatedPosition();
|
glm::vec3 estimatedPosition = serialInterface->getEstimatedPosition() * _leanScale;
|
||||||
const float TORSO_LENGTH = 0.5f;
|
const float TORSO_LENGTH = 0.5f;
|
||||||
const float MAX_LEAN = 45.0f;
|
const float MAX_LEAN = 45.0f;
|
||||||
_head.setLeanSideways(glm::clamp(glm::degrees(atanf(-estimatedPosition.x / TORSO_LENGTH)), -MAX_LEAN, MAX_LEAN));
|
_head.setLeanSideways(glm::clamp(glm::degrees(atanf(-estimatedPosition.x / TORSO_LENGTH)), -MAX_LEAN, MAX_LEAN));
|
||||||
|
@ -1223,6 +1224,8 @@ void Avatar::loadData(QSettings* settings) {
|
||||||
|
|
||||||
_voxels.setVoxelURL(settings->value("voxelURL").toUrl());
|
_voxels.setVoxelURL(settings->value("voxelURL").toUrl());
|
||||||
|
|
||||||
|
_leanScale = loadSetting(settings, "leanScale", 0.5f);
|
||||||
|
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1244,6 +1247,8 @@ void Avatar::saveData(QSettings* set) {
|
||||||
|
|
||||||
set->setValue("voxelURL", _voxels.getVoxelURL());
|
set->setValue("voxelURL", _voxels.getVoxelURL());
|
||||||
|
|
||||||
|
set->setValue("leanScale", _leanScale);
|
||||||
|
|
||||||
set->endGroup();
|
set->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ public:
|
||||||
void setMovedHandOffset (glm::vec3 movedHandOffset ) { _movedHandOffset = movedHandOffset;}
|
void setMovedHandOffset (glm::vec3 movedHandOffset ) { _movedHandOffset = movedHandOffset;}
|
||||||
void setThrust (glm::vec3 newThrust ) { _thrust = newThrust; };
|
void setThrust (glm::vec3 newThrust ) { _thrust = newThrust; };
|
||||||
void setDisplayingLookatVectors(bool displayingLookatVectors) { _head.setRenderLookatVectors(displayingLookatVectors);}
|
void setDisplayingLookatVectors(bool displayingLookatVectors) { _head.setRenderLookatVectors(displayingLookatVectors);}
|
||||||
|
void setLeanScale (float scale ) { _leanScale = scale;}
|
||||||
void setGravity (glm::vec3 gravity);
|
void setGravity (glm::vec3 gravity);
|
||||||
void setMouseRay (const glm::vec3 &origin, const glm::vec3 &direction);
|
void setMouseRay (const glm::vec3 &origin, const glm::vec3 &direction);
|
||||||
void setOrientation (const glm::quat& orientation);
|
void setOrientation (const glm::quat& orientation);
|
||||||
|
@ -115,6 +116,7 @@ public:
|
||||||
float getSpeed () const { return _speed;}
|
float getSpeed () const { return _speed;}
|
||||||
float getHeight () const { return _height;}
|
float getHeight () const { return _height;}
|
||||||
AvatarMode getMode () const { return _mode;}
|
AvatarMode getMode () const { return _mode;}
|
||||||
|
float getLeanScale () const { return _leanScale;}
|
||||||
float getAbsoluteHeadYaw () const;
|
float getAbsoluteHeadYaw () const;
|
||||||
float getAbsoluteHeadPitch () const;
|
float getAbsoluteHeadPitch () const;
|
||||||
Head& getHead () {return _head; }
|
Head& getHead () {return _head; }
|
||||||
|
@ -182,7 +184,7 @@ private:
|
||||||
glm::vec3 _thrust;
|
glm::vec3 _thrust;
|
||||||
float _speed;
|
float _speed;
|
||||||
float _maxArmLength;
|
float _maxArmLength;
|
||||||
glm::quat _righting;
|
float _leanScale;
|
||||||
int _driveKeys[MAX_DRIVE_KEYS];
|
int _driveKeys[MAX_DRIVE_KEYS];
|
||||||
float _pelvisStandingHeight;
|
float _pelvisStandingHeight;
|
||||||
float _pelvisFloatingHeight;
|
float _pelvisFloatingHeight;
|
||||||
|
|
|
@ -498,9 +498,9 @@ void runTimingTests() {
|
||||||
}
|
}
|
||||||
|
|
||||||
float loadSetting(QSettings* settings, const char* name, float defaultValue) {
|
float loadSetting(QSettings* settings, const char* name, float defaultValue) {
|
||||||
float value = settings->value(name, 0.0f).toFloat();
|
float value = settings->value(name, defaultValue).toFloat();
|
||||||
if (isnan(value)) {
|
if (isnan(value)) {
|
||||||
value = defaultValue;
|
value = defaultValue;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue