mirror of
https://github.com/overte-org/overte.git
synced 2025-06-25 12:49:43 +02:00
made all the suggested corrections except the dropdown qml.
This commit is contained in:
parent
cd7af8b605
commit
b9a2f19d30
3 changed files with 62 additions and 38 deletions
|
@ -354,14 +354,36 @@ Rectangle {
|
||||||
// "Lock State" Checkbox
|
// "Lock State" Checkbox
|
||||||
|
|
||||||
HifiControlsUit.CheckBox {
|
HifiControlsUit.CheckBox {
|
||||||
id: lockSitStandStateCheckbox;
|
id: lockSitStandStateCheckbox
|
||||||
visible: activeTab == "nearbyTab";
|
visible: activeTab == "nearbyTab"
|
||||||
anchors.right: reloadNearbyContainer.left;
|
anchors.right: reloadNearbyContainer.left
|
||||||
anchors.rightMargin: 20;
|
anchors.rightMargin: 20
|
||||||
checked: settings.lockStateEnabled;
|
checked: settings.lockStateEnabled
|
||||||
text: "lock";
|
text: "lock"
|
||||||
boxSize: 24;
|
boxSize: 24
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sit stand combo box
|
||||||
|
HifiControlsUit.ComboBox {
|
||||||
|
id: boxy
|
||||||
|
//textRole: "text"
|
||||||
|
currentIndex: 2
|
||||||
|
model: ListModel {
|
||||||
|
id: cbItems
|
||||||
|
ListElement { text: "Force Sitting"; color: "Yellow" }
|
||||||
|
ListElement { text: "Force Standing"; color: "Green" }
|
||||||
|
ListElement { text: "Auto Mode"; color: "Brown" }
|
||||||
|
ListElement { text: "Disable Recentering"; color: "Red" }
|
||||||
|
}
|
||||||
|
//displayText: "fred"
|
||||||
|
//label: cbItems.get(currentIndex).text
|
||||||
|
width: 200
|
||||||
|
onCurrentIndexChanged: {
|
||||||
|
console.debug(cbItems.get(currentIndex).text + ", " + cbItems.get(currentIndex).color)
|
||||||
|
console.debug("line 2")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
|
|
@ -464,20 +464,19 @@ void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::updateSitStandState(float newHeightReading, float angleHeadUp) {
|
void MyAvatar::updateSitStandState(float newHeightReading, float dt) {
|
||||||
const float STANDING_HEIGHT_MULTIPLE = 1.2f;
|
const float STANDING_HEIGHT_MULTIPLE = 1.2f;
|
||||||
const float SITTING_HEIGHT_MULTIPLE = 0.833f;
|
const float SITTING_HEIGHT_MULTIPLE = 0.833f;
|
||||||
const int SITTING_COUNT_THRESHOLD = 240;
|
const float SITTING_TIMEOUT = 4.0f; // 4 seconds
|
||||||
const int STANDING_COUNT_THRESHOLD = 20;
|
const float STANDING_TIMEOUT = 0.3333f; // 1/3 second
|
||||||
const int SQUATTY_COUNT_THRESHOLD = 600;
|
|
||||||
const float SITTING_UPPER_BOUND = 1.52f;
|
const float SITTING_UPPER_BOUND = 1.52f;
|
||||||
|
|
||||||
if (!getIsSitStandStateLocked() && !getIsAway() && qApp->isHMDMode()) {
|
if (!getIsSitStandStateLocked() && !getIsAway() && qApp->isHMDMode()) {
|
||||||
if (getIsInSittingState()) {
|
if (getIsInSittingState()) {
|
||||||
if (newHeightReading > (STANDING_HEIGHT_MULTIPLE * _tippingPoint)) {
|
if (newHeightReading > (STANDING_HEIGHT_MULTIPLE * _tippingPoint)) {
|
||||||
// if we recenter upwards then no longer in sitting state
|
// if we recenter upwards then no longer in sitting state
|
||||||
_sitStandStateCount++;
|
_sitStandStateTimer += dt;
|
||||||
if (_sitStandStateCount > STANDING_COUNT_THRESHOLD) {
|
if (_sitStandStateTimer > STANDING_TIMEOUT) {
|
||||||
_averageUserHeightSensorSpace = newHeightReading;
|
_averageUserHeightSensorSpace = newHeightReading;
|
||||||
_tippingPoint = newHeightReading;
|
_tippingPoint = newHeightReading;
|
||||||
setIsInSittingState(false);
|
setIsInSittingState(false);
|
||||||
|
@ -485,8 +484,8 @@ void MyAvatar::updateSitStandState(float newHeightReading, float angleHeadUp) {
|
||||||
} else if (newHeightReading < (SITTING_HEIGHT_MULTIPLE * _tippingPoint)) {
|
} else if (newHeightReading < (SITTING_HEIGHT_MULTIPLE * _tippingPoint)) {
|
||||||
// if we are mis labelled as sitting but we are standing in the real world this will
|
// if we are mis labelled as sitting but we are standing in the real world this will
|
||||||
// make sure that a real sit is still recognized so we won't be stuck in sitting unable to change state
|
// make sure that a real sit is still recognized so we won't be stuck in sitting unable to change state
|
||||||
_sitStandStateCount++;
|
_sitStandStateTimer += dt;
|
||||||
if (_sitStandStateCount > SITTING_COUNT_THRESHOLD) {
|
if (_sitStandStateTimer > SITTING_TIMEOUT) {
|
||||||
_averageUserHeightSensorSpace = newHeightReading;
|
_averageUserHeightSensorSpace = newHeightReading;
|
||||||
_tippingPoint = newHeightReading;
|
_tippingPoint = newHeightReading;
|
||||||
// here we stay in sit state but reset the average height
|
// here we stay in sit state but reset the average height
|
||||||
|
@ -499,14 +498,14 @@ void MyAvatar::updateSitStandState(float newHeightReading, float angleHeadUp) {
|
||||||
} else {
|
} else {
|
||||||
// tipping point is average height when sitting.
|
// tipping point is average height when sitting.
|
||||||
_tippingPoint = _averageUserHeightSensorSpace;
|
_tippingPoint = _averageUserHeightSensorSpace;
|
||||||
_sitStandStateCount = 0;
|
_sitStandStateTimer = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// in the standing state
|
// in the standing state
|
||||||
if (newHeightReading < (SITTING_HEIGHT_MULTIPLE * _tippingPoint)) {
|
if (newHeightReading < (SITTING_HEIGHT_MULTIPLE * _tippingPoint)) {
|
||||||
_sitStandStateCount++;
|
_sitStandStateTimer += dt;
|
||||||
if (_sitStandStateCount > SITTING_COUNT_THRESHOLD) {
|
if (_sitStandStateTimer > SITTING_TIMEOUT) {
|
||||||
_averageUserHeightSensorSpace = newHeightReading;
|
_averageUserHeightSensorSpace = newHeightReading;
|
||||||
_tippingPoint = newHeightReading;
|
_tippingPoint = newHeightReading;
|
||||||
setIsInSittingState(true);
|
setIsInSittingState(true);
|
||||||
|
@ -514,7 +513,7 @@ void MyAvatar::updateSitStandState(float newHeightReading, float angleHeadUp) {
|
||||||
} else {
|
} else {
|
||||||
// use the mode height for the tipping point when we are standing.
|
// use the mode height for the tipping point when we are standing.
|
||||||
_tippingPoint = getCurrentStandingHeight();
|
_tippingPoint = getCurrentStandingHeight();
|
||||||
_sitStandStateCount = 0;
|
_sitStandStateTimer = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -530,6 +529,7 @@ void MyAvatar::update(float deltaTime) {
|
||||||
const float HMD_FACING_TIMESCALE = getRotationRecenterFilterLength();
|
const float HMD_FACING_TIMESCALE = getRotationRecenterFilterLength();
|
||||||
const float PERCENTAGE_WEIGHT_HEAD_VS_SHOULDERS_AZIMUTH = 0.0f; // 100 percent shoulders
|
const float PERCENTAGE_WEIGHT_HEAD_VS_SHOULDERS_AZIMUTH = 0.0f; // 100 percent shoulders
|
||||||
const float COSINE_THIRTY_DEGREES = 0.866f;
|
const float COSINE_THIRTY_DEGREES = 0.866f;
|
||||||
|
const float SQUATTY_TIMEOUT = 30.0f; // 30 seconds
|
||||||
|
|
||||||
float tau = deltaTime / HMD_FACING_TIMESCALE;
|
float tau = deltaTime / HMD_FACING_TIMESCALE;
|
||||||
setHipToHandController(computeHandAzimuth());
|
setHipToHandController(computeHandAzimuth());
|
||||||
|
@ -575,19 +575,17 @@ void MyAvatar::update(float deltaTime) {
|
||||||
}
|
}
|
||||||
float angleSpine2 = glm::dot(upSpine2, glm::vec3(0.0f, 1.0f, 0.0f));
|
float angleSpine2 = glm::dot(upSpine2, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
if (getControllerPoseInAvatarFrame(controller::Action::HEAD).getTranslation().y < (headDefaultPositionAvatarSpace.y - SQUAT_THRESHOLD) && (angleSpine2 > COSINE_THIRTY_DEGREES)) {
|
if (getControllerPoseInAvatarFrame(controller::Action::HEAD).getTranslation().y < (headDefaultPositionAvatarSpace.y - SQUAT_THRESHOLD) && (angleSpine2 > COSINE_THIRTY_DEGREES)) {
|
||||||
_squatCount++;
|
_squatTimer += deltaTime;
|
||||||
|
if (_squatTimer > SQUATTY_TIMEOUT) {
|
||||||
|
_squatTimer = 0.0f;
|
||||||
|
_follow._squatDetected = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_squatCount = 0;
|
_squatTimer = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 headUp = newHeightReading.getRotation() * glm::vec3(0.0f, 1.0f, 0.0f);
|
|
||||||
if (glm::length(headUp) > 0.0f) {
|
|
||||||
headUp = glm::normalize(headUp);
|
|
||||||
}
|
|
||||||
float angleHeadUp = glm::dot(headUp, glm::vec3(0.0f, 1.0f, 0.0f));
|
|
||||||
|
|
||||||
// put update sit stand state counts here
|
// put update sit stand state counts here
|
||||||
updateSitStandState(newHeightReading.getTranslation().y, angleHeadUp);
|
updateSitStandState(newHeightReading.getTranslation().y, deltaTime);
|
||||||
|
|
||||||
if (_drawAverageFacingEnabled) {
|
if (_drawAverageFacingEnabled) {
|
||||||
auto sensorHeadPose = getControllerPoseInSensorFrame(controller::Action::HEAD);
|
auto sensorHeadPose = getControllerPoseInSensorFrame(controller::Action::HEAD);
|
||||||
|
@ -3893,8 +3891,8 @@ void MyAvatar::setIsInWalkingState(bool isWalking) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::setIsInSittingState(bool isSitting) {
|
void MyAvatar::setIsInSittingState(bool isSitting) {
|
||||||
_sitStandStateCount = 0;
|
_sitStandStateTimer = 0.0f;
|
||||||
_squatCount = 0;
|
_squatTimer = 0.0f;
|
||||||
// on reset height we need the count to be more than one in case the user sits and stands up quickly.
|
// on reset height we need the count to be more than one in case the user sits and stands up quickly.
|
||||||
_isInSittingState.set(isSitting);
|
_isInSittingState.set(isSitting);
|
||||||
setResetMode(true);
|
setResetMode(true);
|
||||||
|
@ -3909,7 +3907,8 @@ void MyAvatar::setIsInSittingState(bool isSitting) {
|
||||||
|
|
||||||
void MyAvatar::setIsSitStandStateLocked(bool isLocked) {
|
void MyAvatar::setIsSitStandStateLocked(bool isLocked) {
|
||||||
_lockSitStandState.set(isLocked);
|
_lockSitStandState.set(isLocked);
|
||||||
_sitStandStateCount = 0;
|
_sitStandStateTimer = 0.0f;
|
||||||
|
_squatTimer = 0.0f;
|
||||||
_averageUserHeightSensorSpace = _userHeight.get();
|
_averageUserHeightSensorSpace = _userHeight.get();
|
||||||
_tippingPoint = _userHeight.get();
|
_tippingPoint = _userHeight.get();
|
||||||
if (!isLocked) {
|
if (!isLocked) {
|
||||||
|
@ -4155,7 +4154,7 @@ bool MyAvatar::FollowHelper::shouldActivateHorizontalCG(MyAvatar& myAvatar) cons
|
||||||
return stepDetected;
|
return stepDetected;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MyAvatar::FollowHelper::shouldActivateVertical(MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const {
|
bool MyAvatar::FollowHelper::shouldActivateVertical(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const {
|
||||||
const float CYLINDER_TOP = 0.1f;
|
const float CYLINDER_TOP = 0.1f;
|
||||||
const float CYLINDER_BOTTOM = -1.5f;
|
const float CYLINDER_BOTTOM = -1.5f;
|
||||||
const float SITTING_BOTTOM = -0.02f;
|
const float SITTING_BOTTOM = -0.02f;
|
||||||
|
@ -4179,8 +4178,7 @@ bool MyAvatar::FollowHelper::shouldActivateVertical(MyAvatar& myAvatar, const gl
|
||||||
// in the standing state
|
// in the standing state
|
||||||
returnValue = (offset.y > CYLINDER_TOP) || (offset.y < CYLINDER_BOTTOM);
|
returnValue = (offset.y > CYLINDER_TOP) || (offset.y < CYLINDER_BOTTOM);
|
||||||
// finally check for squats in standing
|
// finally check for squats in standing
|
||||||
if ((myAvatar._squatCount > SQUATTY_COUNT_THRESHOLD) && !myAvatar.getIsSitStandStateLocked()) {
|
if (_squatDetected) {
|
||||||
myAvatar._squatCount = 0;
|
|
||||||
returnValue = true;
|
returnValue = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4216,6 +4214,9 @@ void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat
|
||||||
}
|
}
|
||||||
if (!isActive(Vertical) && (shouldActivateVertical(myAvatar, desiredBodyMatrix, currentBodyMatrix) || hasDriveInput)) {
|
if (!isActive(Vertical) && (shouldActivateVertical(myAvatar, desiredBodyMatrix, currentBodyMatrix) || hasDriveInput)) {
|
||||||
activate(Vertical);
|
activate(Vertical);
|
||||||
|
if (_squatDetected) {
|
||||||
|
_squatDetected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isActive(Rotation) && getForceActivateRotation()) {
|
if (!isActive(Rotation) && getForceActivateRotation()) {
|
||||||
|
|
|
@ -1116,7 +1116,7 @@ public:
|
||||||
float getSprintSpeed() const;
|
float getSprintSpeed() const;
|
||||||
void setSitStandStateChange(bool stateChanged);
|
void setSitStandStateChange(bool stateChanged);
|
||||||
float getSitStandStateChange() const;
|
float getSitStandStateChange() const;
|
||||||
void updateSitStandState(float newHeightReading, float angleHeadUp);
|
void updateSitStandState(float newHeightReading, float dt);
|
||||||
|
|
||||||
QVector<QString> getScriptUrls();
|
QVector<QString> getScriptUrls();
|
||||||
|
|
||||||
|
@ -1744,7 +1744,7 @@ private:
|
||||||
float getMaxTimeRemaining() const;
|
float getMaxTimeRemaining() const;
|
||||||
void decrementTimeRemaining(float dt);
|
void decrementTimeRemaining(float dt);
|
||||||
bool shouldActivateRotation(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const;
|
bool shouldActivateRotation(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const;
|
||||||
bool shouldActivateVertical(MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const;
|
bool shouldActivateVertical(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const;
|
||||||
bool shouldActivateHorizontal(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const;
|
bool shouldActivateHorizontal(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const;
|
||||||
bool shouldActivateHorizontalCG(MyAvatar& myAvatar) const;
|
bool shouldActivateHorizontalCG(MyAvatar& myAvatar) const;
|
||||||
void prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat4& bodySensorMatrix, const glm::mat4& currentBodyMatrix, bool hasDriveInput);
|
void prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat4& bodySensorMatrix, const glm::mat4& currentBodyMatrix, bool hasDriveInput);
|
||||||
|
@ -1757,6 +1757,7 @@ private:
|
||||||
void setForceActivateHorizontal(bool val);
|
void setForceActivateHorizontal(bool val);
|
||||||
bool getToggleHipsFollowing() const;
|
bool getToggleHipsFollowing() const;
|
||||||
void setToggleHipsFollowing(bool followHead);
|
void setToggleHipsFollowing(bool followHead);
|
||||||
|
bool _squatDetected { false };
|
||||||
std::atomic<bool> _forceActivateRotation { false };
|
std::atomic<bool> _forceActivateRotation { false };
|
||||||
std::atomic<bool> _forceActivateVertical { false };
|
std::atomic<bool> _forceActivateVertical { false };
|
||||||
std::atomic<bool> _forceActivateHorizontal { false };
|
std::atomic<bool> _forceActivateHorizontal { false };
|
||||||
|
@ -1843,8 +1844,8 @@ private:
|
||||||
float _walkSpeedScalar { AVATAR_WALK_SPEED_SCALAR };
|
float _walkSpeedScalar { AVATAR_WALK_SPEED_SCALAR };
|
||||||
bool _isInWalkingState { false };
|
bool _isInWalkingState { false };
|
||||||
ThreadSafeValueCache<bool> _isInSittingState { false };
|
ThreadSafeValueCache<bool> _isInSittingState { false };
|
||||||
int _sitStandStateCount { 0 };
|
float _sitStandStateTimer { 0.0f };
|
||||||
int _squatCount { 0 };
|
float _squatTimer { 0.0f };
|
||||||
float _tippingPoint { _userHeight.get() };
|
float _tippingPoint { _userHeight.get() };
|
||||||
|
|
||||||
// load avatar scripts once when rig is ready
|
// load avatar scripts once when rig is ready
|
||||||
|
|
Loading…
Reference in a new issue