mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:21:24 +02:00
added condition for start up in oculus that gets the correct starting height
This commit is contained in:
parent
ae3ae9ce9a
commit
9ec999e15e
1 changed files with 59 additions and 45 deletions
|
@ -471,7 +471,9 @@ void MyAvatar::update(float deltaTime) {
|
||||||
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 float COSINE_THIRTY_DEGREES = 0.866f;
|
const float COSINE_THIRTY_DEGREES = 0.866f;
|
||||||
const int SITTING_COUNT_THRESHOLD = 300;
|
const float COSINE_TEN_DEGREES = 0.9848f;
|
||||||
|
const int SITTING_COUNT_THRESHOLD = 100;
|
||||||
|
const int STANDING_COUNT_THRESHOLD = 10;
|
||||||
const int SQUATTY_COUNT_THRESHOLD = 600;
|
const int SQUATTY_COUNT_THRESHOLD = 600;
|
||||||
|
|
||||||
float tau = deltaTime / HMD_FACING_TIMESCALE;
|
float tau = deltaTime / HMD_FACING_TIMESCALE;
|
||||||
|
@ -530,59 +532,70 @@ void MyAvatar::update(float deltaTime) {
|
||||||
glm::vec3 worldHips = transformPoint(getTransform().getMatrix(), avatarHips);
|
glm::vec3 worldHips = transformPoint(getTransform().getMatrix(), avatarHips);
|
||||||
glm::vec3 sensorHips = transformPoint(glm::inverse(getSensorToWorldMatrix()), worldHips);
|
glm::vec3 sensorHips = transformPoint(glm::inverse(getSensorToWorldMatrix()), worldHips);
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
const int VELOCITY_COUNT_THRESHOLD = 60;
|
const int VELOCITY_COUNT_THRESHOLD = 60;
|
||||||
// put update sit stand state counts here
|
// put update sit stand state counts here
|
||||||
if (!getIsSitStandStateLocked() && (_follow._velocityCount > VELOCITY_COUNT_THRESHOLD)) {
|
if (!getIsSitStandStateLocked()) {
|
||||||
if (!getIsAway()) {
|
if (!getIsAway()) {
|
||||||
if (getIsInSittingState()) {
|
if ((_follow._velocityCount > VELOCITY_COUNT_THRESHOLD) || (qApp->isHMDMode() && (qApp->getActiveDisplayPlugin()->getName() == "Oculus Rift"))) {
|
||||||
if (newHeightReading.getTranslation().y > (STANDING_HEIGHT_MULTIPLE * _tippingPoint)) {
|
if (getIsInSittingState()) {
|
||||||
// if we recenter upwards then no longer in sitting state
|
if (newHeightReading.getTranslation().y > (STANDING_HEIGHT_MULTIPLE * _tippingPoint)) {
|
||||||
_sitStandStateCount++;
|
// if we recenter upwards then no longer in sitting state
|
||||||
if (_sitStandStateCount > SITTING_COUNT_THRESHOLD) {
|
_sitStandStateCount++;
|
||||||
_sitStandStateCount = 0;
|
if (_sitStandStateCount > STANDING_COUNT_THRESHOLD) {
|
||||||
_squatCount = 0;
|
_sitStandStateCount = 0;
|
||||||
if (newHeightReading.isValid()) {
|
_squatCount = 0;
|
||||||
_sumUserHeightSensorSpace = newHeightReading.getTranslation().y;
|
if (newHeightReading.isValid()) {
|
||||||
_tippingPoint = newHeightReading.getTranslation().y;
|
_sumUserHeightSensorSpace = newHeightReading.getTranslation().y;
|
||||||
|
_tippingPoint = newHeightReading.getTranslation().y;
|
||||||
|
}
|
||||||
|
_averageUserHeightCount = 1;
|
||||||
|
setIsInSittingState(false);
|
||||||
}
|
}
|
||||||
_averageUserHeightCount = 1;
|
} else if ((newHeightReading.getTranslation().y < (SITTING_HEIGHT_MULTIPLE * _tippingPoint)) && (angleHeadUp > COSINE_THIRTY_DEGREES)) {
|
||||||
setIsInSittingState(false);
|
// 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
|
||||||
} else if ((newHeightReading.getTranslation().y < (SITTING_HEIGHT_MULTIPLE * _tippingPoint)) && (angleSpine2 > COSINE_THIRTY_DEGREES)) {
|
_sitStandStateCount++;
|
||||||
_sitStandStateCount++;
|
if (_sitStandStateCount > SITTING_COUNT_THRESHOLD) {
|
||||||
if (_sitStandStateCount > SITTING_COUNT_THRESHOLD) {
|
_sitStandStateCount = 0;
|
||||||
_sitStandStateCount = 0;
|
_squatCount = 0;
|
||||||
_squatCount = 0;
|
if (newHeightReading.isValid()) {
|
||||||
if (newHeightReading.isValid()) {
|
_sumUserHeightSensorSpace = newHeightReading.getTranslation().y;
|
||||||
_sumUserHeightSensorSpace = newHeightReading.getTranslation().y;
|
_tippingPoint = newHeightReading.getTranslation().y;
|
||||||
_tippingPoint = newHeightReading.getTranslation().y;
|
}
|
||||||
|
_averageUserHeightCount = 1;
|
||||||
|
// here we stay in sit state but reset the average height
|
||||||
|
setIsInSittingState(true);
|
||||||
}
|
}
|
||||||
_averageUserHeightCount = 1;
|
} else {
|
||||||
setIsInSittingState(true);
|
_sitStandStateCount = 0;
|
||||||
|
// tipping point is average height when sitting.
|
||||||
|
_tippingPoint = averageSensorSpaceHeight;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_sitStandStateCount = 0;
|
// in the standing state
|
||||||
// tipping point is average height when sitting.
|
if ((newHeightReading.getTranslation().y < (SITTING_HEIGHT_MULTIPLE * _tippingPoint)) && (angleHeadUp > COSINE_THIRTY_DEGREES)) {
|
||||||
_tippingPoint = averageSensorSpaceHeight;
|
_sitStandStateCount++;
|
||||||
}
|
if (_sitStandStateCount > SITTING_COUNT_THRESHOLD) {
|
||||||
} else {
|
_sitStandStateCount = 0;
|
||||||
// in the standing state
|
_squatCount = 0;
|
||||||
if ((newHeightReading.getTranslation().y < (SITTING_HEIGHT_MULTIPLE * _tippingPoint)) && (angleSpine2 > COSINE_THIRTY_DEGREES)) {
|
if (newHeightReading.isValid()) {
|
||||||
_sitStandStateCount++;
|
_sumUserHeightSensorSpace = newHeightReading.getTranslation().y;
|
||||||
if (_sitStandStateCount > SITTING_COUNT_THRESHOLD) {
|
_tippingPoint = newHeightReading.getTranslation().y;
|
||||||
_sitStandStateCount = 0;
|
}
|
||||||
_squatCount = 0;
|
_averageUserHeightCount = 1;
|
||||||
if (newHeightReading.isValid()) {
|
setIsInSittingState(true);
|
||||||
_sumUserHeightSensorSpace = newHeightReading.getTranslation().y;
|
|
||||||
_tippingPoint = newHeightReading.getTranslation().y;
|
|
||||||
}
|
}
|
||||||
_averageUserHeightCount = 1;
|
} else {
|
||||||
setIsInSittingState(true);
|
// use the mode height for the tipping point when we are standing.
|
||||||
|
_tippingPoint = getCurrentStandingHeight();
|
||||||
|
_sitStandStateCount = 0;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// use the mode height for the tipping point when we are standing.
|
|
||||||
_tippingPoint = getCurrentStandingHeight();
|
|
||||||
_sitStandStateCount = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -4240,6 +4253,7 @@ void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat
|
||||||
} else {
|
} else {
|
||||||
if ((glm::length(myAvatar.getControllerPoseInSensorFrame(controller::Action::HEAD).getVelocity()) > MINIMUM_HMD_VELOCITY)) {
|
if ((glm::length(myAvatar.getControllerPoseInSensorFrame(controller::Action::HEAD).getVelocity()) > MINIMUM_HMD_VELOCITY)) {
|
||||||
_velocityCount++;
|
_velocityCount++;
|
||||||
|
qCDebug(interfaceapp) << "velocity count is " << _velocityCount << " is away " << myAvatar.getIsAway() << " hmd mode "<< qApp->isHMDMode() << " " << qApp->getActiveDisplayPlugin()->getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue