mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:58:51 +02:00
added the floor at 0.0 in sensor space for oculus. to do: vive
This commit is contained in:
parent
4f9de1be1c
commit
fa9abf0fff
3 changed files with 35 additions and 18 deletions
|
@ -477,10 +477,20 @@ void MyAvatar::update(float deltaTime) {
|
||||||
auto sensorHeadPoseDebug = getControllerPoseInSensorFrame(controller::Action::HEAD);
|
auto sensorHeadPoseDebug = getControllerPoseInSensorFrame(controller::Action::HEAD);
|
||||||
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));
|
||||||
|
qCDebug(interfaceapp) << "sensor space head pos " << sensorHeadPoseDebug.getTranslation().y;
|
||||||
if ((acosHead > 0.98f) && !getIsInSittingState() && (sensorHeadPoseDebug.getTranslation().y < -0.5f)) {
|
if ((acosHead > 0.98f) && !getIsInSittingState() && (sensorHeadPoseDebug.getTranslation().y < -0.5f)) {
|
||||||
qCDebug(interfaceapp) << "we are going to sitting state because it looks like we should" << sensorHeadPoseDebug.getTranslation().y;
|
//qCDebug(interfaceapp) << "we are going to sitting state because it looks like we should" << sensorHeadPoseDebug.getTranslation().y;
|
||||||
}
|
}
|
||||||
|
if (!_lastFrameHMDMode && qApp->isHMDMode()) {
|
||||||
|
// we have entered hmd mode, so make the best guess about sitting or standing
|
||||||
|
if (sensorHeadPoseDebug.getTranslation().y < 1.3f) {
|
||||||
|
// then we are sitting.
|
||||||
|
// setIsInSittingState(true);
|
||||||
|
} else {
|
||||||
|
// setIsInSittingState(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// put the average hand azimuth into sensor space.
|
// put the average hand azimuth into sensor space.
|
||||||
// then mix it with head facing direction to determine rotation recenter
|
// then mix it with head facing direction to determine rotation recenter
|
||||||
if (getControllerPoseInAvatarFrame(controller::Action::LEFT_HAND).isValid() && getControllerPoseInAvatarFrame(controller::Action::RIGHT_HAND).isValid()) {
|
if (getControllerPoseInAvatarFrame(controller::Action::LEFT_HAND).isValid() && getControllerPoseInAvatarFrame(controller::Action::RIGHT_HAND).isValid()) {
|
||||||
|
@ -3575,9 +3585,9 @@ glm::vec3 MyAvatar::computeCounterBalance() {
|
||||||
} else if (counterBalancedCg.y < sitSquatThreshold) {
|
} else if (counterBalancedCg.y < sitSquatThreshold) {
|
||||||
// do a height reset
|
// do a height reset
|
||||||
setResetMode(true);
|
setResetMode(true);
|
||||||
//_follow.activate(FollowHelper::Vertical);
|
// _follow.activate(FollowHelper::Vertical);
|
||||||
// disable cg behaviour in this case.
|
// disable cg behaviour in this case.
|
||||||
//setIsInSittingState(true);
|
// setIsInSittingState(true);
|
||||||
}
|
}
|
||||||
return counterBalancedCg;
|
return counterBalancedCg;
|
||||||
}
|
}
|
||||||
|
@ -4090,7 +4100,7 @@ bool MyAvatar::FollowHelper::shouldActivateVertical(MyAvatar& myAvatar, const gl
|
||||||
return true;
|
return true;
|
||||||
} else if (offset.y > CYLINDER_TOP) {
|
} else if (offset.y > CYLINDER_TOP) {
|
||||||
// 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);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -4110,15 +4120,20 @@ void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat
|
||||||
glm::vec3 headDefaultPos = myAvatar.getAbsoluteDefaultJointTranslationInObjectFrame(myAvatar.getJointIndex("Head"));
|
glm::vec3 headDefaultPos = myAvatar.getAbsoluteDefaultJointTranslationInObjectFrame(myAvatar.getJointIndex("Head"));
|
||||||
if (myAvatar.getControllerPoseInAvatarFrame(controller::Action::HEAD).getTranslation().y < (headDefaultPos.y - 0.05f)) {
|
if (myAvatar.getControllerPoseInAvatarFrame(controller::Action::HEAD).getTranslation().y < (headDefaultPos.y - 0.05f)) {
|
||||||
_squatCount++;
|
_squatCount++;
|
||||||
if ((_squatCount > 300) && !isActive(Vertical) && !isActive(Horizontal)) {
|
if ((_squatCount > 600) && !isActive(Vertical) && !isActive(Horizontal)) {
|
||||||
activate(Horizontal);
|
if (myAvatar.getIsInSittingState()) {
|
||||||
activate(Vertical);
|
// activate(Horizontal);
|
||||||
_squatCount = 0;
|
activate(Vertical);
|
||||||
|
_squatCount = 0;
|
||||||
|
} else {
|
||||||
|
activate(Horizontal);
|
||||||
|
_squatCount = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_squatCount = 0;
|
_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());
|
||||||
|
|
|
@ -1728,7 +1728,7 @@ 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 };
|
int _squatCount { 0 };
|
||||||
};
|
};
|
||||||
FollowHelper _follow;
|
FollowHelper _follow;
|
||||||
|
|
||||||
|
@ -1760,6 +1760,7 @@ 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
|
||||||
|
@ -1804,7 +1805,7 @@ 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 };
|
bool _isInSittingState { true };
|
||||||
|
|
||||||
// load avatar scripts once when rig is ready
|
// load avatar scripts once when rig is ready
|
||||||
bool _shouldLoadScripts { false };
|
bool _shouldLoadScripts { false };
|
||||||
|
|
|
@ -79,18 +79,19 @@ private:
|
||||||
if (!OVR_SUCCESS(ovr_Initialize(&initParams))) {
|
if (!OVR_SUCCESS(ovr_Initialize(&initParams))) {
|
||||||
qCWarning(oculusLog) << "Failed to initialze Oculus SDK" << ovr::getError();
|
qCWarning(oculusLog) << "Failed to initialze Oculus SDK" << ovr::getError();
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
qCWarning(oculusLog) << "successful init of oculus!!!!!!!!";
|
|
||||||
ovrTrackingOrigin fred;
|
|
||||||
fred = ovr_GetTrackingOriginType(session);
|
|
||||||
qCWarning(oculusLog) << (int)fred;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ovrGraphicsLuid luid;
|
ovrGraphicsLuid luid;
|
||||||
if (!OVR_SUCCESS(ovr_Create(&session, &luid))) {
|
if (!OVR_SUCCESS(ovr_Create(&session, &luid))) {
|
||||||
qCWarning(oculusLog) << "Failed to acquire Oculus session" << ovr::getError();
|
qCWarning(oculusLog) << "Failed to acquire Oculus session" << ovr::getError();
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
qCWarning(oculusLog) << "successful init of oculus!!!!!!!!";
|
||||||
|
ovrTrackingOrigin fred;
|
||||||
|
//fred = ovr_GetTrackingOriginType(session);
|
||||||
|
ovrResult retTrackingType = ovr_SetTrackingOriginType(session, ovrTrackingOrigin::ovrTrackingOrigin_FloorLevel);
|
||||||
|
fred = ovr_GetTrackingOriginType(session);
|
||||||
|
qCWarning(oculusLog) << OVR_SUCCESS(retTrackingType) << (int)fred;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue