mirror of
https://github.com/overte-org/overte.git
synced 2025-04-13 16:05:17 +02:00
cleaning up. putting squat fix in vertical recenter
This commit is contained in:
parent
1a0e2c6ea1
commit
90feeffa9d
4 changed files with 43 additions and 49 deletions
|
@ -484,6 +484,19 @@ void MyAvatar::update(float deltaTime) {
|
||||||
|
|
||||||
glm::vec3 upHead = transformVectorFast(sensorHeadPoseDebug.getMatrix(), glm::vec3(0.0f, 1.0f, 0.0f));
|
glm::vec3 upHead = transformVectorFast(sensorHeadPoseDebug.getMatrix(), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
float acosHead = glm::dot(upHead, glm::vec3(0.0f, 1.0f, 0.0f));
|
float acosHead = glm::dot(upHead, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
||||||
|
glm::vec3 headDefaultPositionAvatarSpace = getAbsoluteDefaultJointTranslationInObjectFrame(getJointIndex("Head"));
|
||||||
|
glm::quat spine2OrientationAvatarSpace = getAbsoluteJointRotationInObjectFrame(getJointIndex("Spine2"));
|
||||||
|
glm::vec3 headCurrentPositionAvatarSpace = getControllerPoseInAvatarFrame(controller::Action::HEAD).getTranslation();
|
||||||
|
glm::vec3 upSpine2 = spine2OrientationAvatarSpace * glm::vec3(0.0f, 1.0f, 0.0f);
|
||||||
|
float angleSpine2 = glm::dot(upSpine2, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
if (headCurrentPositionAvatarSpace.y < (headDefaultPositionAvatarSpace.y - 0.05) && (angleSpine2 > 0.98f)) {
|
||||||
|
_squatCount++;
|
||||||
|
} else {
|
||||||
|
_squatCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// qCDebug(interfaceapp) << "sensor space head pos " << sensorHeadPoseDebug.getTranslation().y;
|
// qCDebug(interfaceapp) << "sensor space head pos " << sensorHeadPoseDebug.getTranslation().y;
|
||||||
|
|
||||||
// put the average hand azimuth into sensor space.
|
// put the average hand azimuth into sensor space.
|
||||||
|
@ -3795,7 +3808,7 @@ bool MyAvatar::getIsInWalkingState() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MyAvatar::getIsInSittingState() const {
|
bool MyAvatar::getIsInSittingState() const {
|
||||||
return _isInSittingState;
|
return _isInSittingState.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
float MyAvatar::getWalkSpeed() const {
|
float MyAvatar::getWalkSpeed() const {
|
||||||
|
@ -3819,7 +3832,7 @@ void MyAvatar::setIsInWalkingState(bool isWalking) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::setIsInSittingState(bool isSitting) {
|
void MyAvatar::setIsInSittingState(bool isSitting) {
|
||||||
_isInSittingState = isSitting;
|
_isInSittingState.set(isSitting);
|
||||||
controller::Pose sensorHeadPoseDebug = getControllerPoseInSensorFrame(controller::Action::HEAD);
|
controller::Pose sensorHeadPoseDebug = getControllerPoseInSensorFrame(controller::Action::HEAD);
|
||||||
_sumUserHeightSensorSpace = sensorHeadPoseDebug.getTranslation().y;
|
_sumUserHeightSensorSpace = sensorHeadPoseDebug.getTranslation().y;
|
||||||
_averageUserHeightCount = 1;
|
_averageUserHeightCount = 1;
|
||||||
|
@ -4064,8 +4077,8 @@ bool MyAvatar::FollowHelper::shouldActivateVertical(MyAvatar& myAvatar, const gl
|
||||||
glm::vec3 headSensorSpace = transformVectorFast(myAvatar.getSensorToWorldMatrix(), headWorldSpace);
|
glm::vec3 headSensorSpace = transformVectorFast(myAvatar.getSensorToWorldMatrix(), headWorldSpace);
|
||||||
//get the mode.
|
//get the mode.
|
||||||
//put it in sensor space.
|
//put it in sensor space.
|
||||||
// if we are 20% higher switch to standing.
|
// if we are 20% higher switch to standing.
|
||||||
// 16.6% lower then switch to sitting.
|
// 16.6% lower then switch to sitting.
|
||||||
// add this !!!! And the head is upright.
|
// add this !!!! And the head is upright.
|
||||||
glm::vec3 upHead = transformVectorFast(sensorHeadPose.getMatrix(), glm::vec3(0.0f, 1.0f, 0.0f));
|
glm::vec3 upHead = transformVectorFast(sensorHeadPose.getMatrix(), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
float acosHead = glm::dot(upHead, glm::vec3(0.0f, 1.0f, 0.0f));
|
float acosHead = glm::dot(upHead, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
@ -4074,8 +4087,9 @@ bool MyAvatar::FollowHelper::shouldActivateVertical(MyAvatar& myAvatar, const gl
|
||||||
glm::vec3 sensorHips = transformVectorFast(myAvatar.getSensorToWorldMatrix(), worldHips);
|
glm::vec3 sensorHips = transformVectorFast(myAvatar.getSensorToWorldMatrix(), worldHips);
|
||||||
float averageSensorSpaceHeight = myAvatar._sumUserHeightSensorSpace / myAvatar._averageUserHeightCount;
|
float averageSensorSpaceHeight = myAvatar._sumUserHeightSensorSpace / myAvatar._averageUserHeightCount;
|
||||||
// we could add a counting here to make sure that a lean forward doesn't accidentally put you in sitting mode.
|
// we could add a counting here to make sure that a lean forward doesn't accidentally put you in sitting mode.
|
||||||
// but maybe so what.
|
// but maybe so what.
|
||||||
// the real test is... can I pick something up in standing mode?
|
// the real test is... can I pick something up in standing mode?
|
||||||
|
|
||||||
|
|
||||||
if (myAvatar.getIsInSittingState()) {
|
if (myAvatar.getIsInSittingState()) {
|
||||||
if (offset.y < SITTING_BOTTOM) {
|
if (offset.y < SITTING_BOTTOM) {
|
||||||
|
@ -4084,22 +4098,27 @@ bool MyAvatar::FollowHelper::shouldActivateVertical(MyAvatar& myAvatar, const gl
|
||||||
} else if (sensorHeadPose.getTranslation().y > (1.2f * averageSensorSpaceHeight)) {
|
} else if (sensorHeadPose.getTranslation().y > (1.2f * averageSensorSpaceHeight)) {
|
||||||
// if we recenter upwards then no longer in sitting state
|
// if we recenter upwards then no longer in sitting state
|
||||||
myAvatar.setIsInSittingState(false);
|
myAvatar.setIsInSittingState(false);
|
||||||
//myAvatar._sumUserHeightSensorSpace = 1.2f * averageSensorSpaceHeight;
|
|
||||||
// myAvatar._averageUserHeightCount = 1;
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// in the standing state
|
// in the standing state
|
||||||
if ((sensorHeadPose.getTranslation().y < (0.83f * averageSensorSpaceHeight)) && (acosHead > 0.98f) && !(sensorHips.y > (0.4f * averageSensorSpaceHeight)) {
|
if ((sensorHeadPose.getTranslation().y < (0.83f * averageSensorSpaceHeight)) && (acosHead > 0.98f) && !(sensorHips.y > (0.4f * averageSensorSpaceHeight))) {
|
||||||
myAvatar.setIsInSittingState(true);
|
myAvatar._sitStandStateCount++;
|
||||||
// myAvatar._sumUserHeightSensorSpace = 0.83f * averageSensorSpaceHeight;
|
if (myAvatar._sitStandStateCount > 300) {
|
||||||
// myAvatar._averageUserHeightCount = 1;
|
myAvatar.setIsInSittingState(true);
|
||||||
return true;
|
myAvatar._sitStandStateCount = 0;
|
||||||
|
myAvatar._squatCount = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return (offset.y > CYLINDER_TOP) || (offset.y < CYLINDER_BOTTOM);
|
if (myAvatar._squatCount > 600) {
|
||||||
|
return true;
|
||||||
|
myAvatar._squatCount = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return (offset.y > CYLINDER_TOP) || (offset.y < CYLINDER_BOTTOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4109,29 +4128,6 @@ void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat
|
||||||
if (myAvatar.getHMDLeanRecenterEnabled() &&
|
if (myAvatar.getHMDLeanRecenterEnabled() &&
|
||||||
qApp->getCamera().getMode() != CAMERA_MODE_MIRROR) {
|
qApp->getCamera().getMode() != CAMERA_MODE_MIRROR) {
|
||||||
|
|
||||||
// debug head hips angle
|
|
||||||
glm::vec3 headDefaultPos = myAvatar.getAbsoluteDefaultJointTranslationInObjectFrame(myAvatar.getJointIndex("Head"));
|
|
||||||
if (myAvatar.getControllerPoseInAvatarFrame(controller::Action::HEAD).getTranslation().y < (headDefaultPos.y - 0.05f)) {
|
|
||||||
_squatCount++;
|
|
||||||
if ((_squatCount > 600) && !isActive(Vertical) && !isActive(Horizontal)) {
|
|
||||||
if (myAvatar.getIsInSittingState()) {
|
|
||||||
// activate(Horizontal);
|
|
||||||
//activate(Vertical);
|
|
||||||
_squatCount = 0;
|
|
||||||
} else {
|
|
||||||
if (myAvatar.getControllerPoseInAvatarFrame(controller::Action::HEAD).getTranslation().y < (headDefaultPos.y - 0.20f)) {
|
|
||||||
//myAvatar.setIsInSittingState(true);
|
|
||||||
//activate(Vertical);
|
|
||||||
} else {
|
|
||||||
//activate(Horizontal);
|
|
||||||
}
|
|
||||||
_squatCount = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_squatCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isActive(Rotation) && (shouldActivateRotation(myAvatar, desiredBodyMatrix, currentBodyMatrix) || hasDriveInput)) {
|
if (!isActive(Rotation) && (shouldActivateRotation(myAvatar, desiredBodyMatrix, currentBodyMatrix) || hasDriveInput)) {
|
||||||
activate(Rotation);
|
activate(Rotation);
|
||||||
myAvatar.setHeadControllerFacingMovingAverage(myAvatar.getHeadControllerFacing());
|
myAvatar.setHeadControllerFacingMovingAverage(myAvatar.getHeadControllerFacing());
|
||||||
|
|
|
@ -1737,7 +1737,6 @@ private:
|
||||||
std::atomic<bool> _forceActivateVertical { false };
|
std::atomic<bool> _forceActivateVertical { false };
|
||||||
std::atomic<bool> _forceActivateHorizontal { false };
|
std::atomic<bool> _forceActivateHorizontal { false };
|
||||||
std::atomic<bool> _toggleHipsFollowing { true };
|
std::atomic<bool> _toggleHipsFollowing { true };
|
||||||
int _squatCount { 0 };
|
|
||||||
};
|
};
|
||||||
FollowHelper _follow;
|
FollowHelper _follow;
|
||||||
|
|
||||||
|
@ -1770,7 +1769,6 @@ private:
|
||||||
glm::quat _customListenOrientation;
|
glm::quat _customListenOrientation;
|
||||||
|
|
||||||
AtRestDetector _hmdAtRestDetector;
|
AtRestDetector _hmdAtRestDetector;
|
||||||
bool _lastFrameHMDMode { false } ;
|
|
||||||
bool _lastIsMoving { false };
|
bool _lastIsMoving { false };
|
||||||
|
|
||||||
// all poses are in sensor-frame
|
// all poses are in sensor-frame
|
||||||
|
@ -1817,7 +1815,9 @@ private:
|
||||||
ThreadSafeValueCache<float> _sprintSpeed { AVATAR_SPRINT_SPEED_SCALAR };
|
ThreadSafeValueCache<float> _sprintSpeed { AVATAR_SPRINT_SPEED_SCALAR };
|
||||||
float _walkSpeedScalar { AVATAR_WALK_SPEED_SCALAR };
|
float _walkSpeedScalar { AVATAR_WALK_SPEED_SCALAR };
|
||||||
bool _isInWalkingState { false };
|
bool _isInWalkingState { false };
|
||||||
bool _isInSittingState { false };
|
ThreadSafeValueCache<bool> _isInSittingState { false };
|
||||||
|
int _sitStandStateCount { 0 };
|
||||||
|
int _squatCount { 0 };
|
||||||
|
|
||||||
// load avatar scripts once when rig is ready
|
// load avatar scripts once when rig is ready
|
||||||
bool _shouldLoadScripts { false };
|
bool _shouldLoadScripts { false };
|
||||||
|
|
|
@ -86,12 +86,10 @@ private:
|
||||||
qCWarning(oculusLog) << "Failed to acquire Oculus session" << ovr::getError();
|
qCWarning(oculusLog) << "Failed to acquire Oculus session" << ovr::getError();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
qCWarning(oculusLog) << "successful init of oculus!!!!!!!!";
|
ovrResult setFloorLevelOrigin = ovr_SetTrackingOriginType(session, ovrTrackingOrigin::ovrTrackingOrigin_FloorLevel);
|
||||||
ovrTrackingOrigin fred;
|
if (!OVR_SUCCESS(setFloorLevelOrigin)) {
|
||||||
//fred = ovr_GetTrackingOriginType(session);
|
qCWarning(oculusLog) << "Failed to set the Oculus tracking origin to floor level" << ovr::getError();
|
||||||
ovrResult retTrackingType = ovr_SetTrackingOriginType(session, ovrTrackingOrigin::ovrTrackingOrigin_FloorLevel);
|
}
|
||||||
fred = ovr_GetTrackingOriginType(session);
|
|
||||||
qCWarning(oculusLog) << OVR_SUCCESS(retTrackingType) << (int)fred;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@ function getMyAvatar() {
|
||||||
function getMyAvatarSettings() {
|
function getMyAvatarSettings() {
|
||||||
return {
|
return {
|
||||||
dominantHand: MyAvatar.getDominantHand(),
|
dominantHand: MyAvatar.getDominantHand(),
|
||||||
collisionsEnabled: MyAvatar.getCollisionsEnabled(),
|
collisionsEnabled : MyAvatar.getCollisionsEnabled(),
|
||||||
sittingEnabled: MyAvatar.isInSittingState,
|
sittingEnabled : MyAvatar.isInSittingState,
|
||||||
collisionSoundUrl : MyAvatar.collisionSoundURL,
|
collisionSoundUrl : MyAvatar.collisionSoundURL,
|
||||||
animGraphUrl: MyAvatar.getAnimGraphUrl(),
|
animGraphUrl: MyAvatar.getAnimGraphUrl(),
|
||||||
animGraphOverrideUrl : MyAvatar.getAnimGraphOverrideUrl(),
|
animGraphOverrideUrl : MyAvatar.getAnimGraphOverrideUrl(),
|
||||||
|
@ -326,7 +326,7 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
|
||||||
MyAvatar.isInSittingState = message.settings.sittingEnabled;
|
MyAvatar.isInSittingState = message.settings.sittingEnabled;
|
||||||
MyAvatar.collisionSoundURL = message.settings.collisionSoundUrl;
|
MyAvatar.collisionSoundURL = message.settings.collisionSoundUrl;
|
||||||
MyAvatar.setAnimGraphOverrideUrl(message.settings.animGraphOverrideUrl);
|
MyAvatar.setAnimGraphOverrideUrl(message.settings.animGraphOverrideUrl);
|
||||||
print("save settings");
|
|
||||||
settings = getMyAvatarSettings();
|
settings = getMyAvatarSettings();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue