mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01: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);
|
||||
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));
|
||||
qCDebug(interfaceapp) << "sensor space head pos " << sensorHeadPoseDebug.getTranslation().y;
|
||||
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.
|
||||
// then mix it with head facing direction to determine rotation recenter
|
||||
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) {
|
||||
// do a height reset
|
||||
setResetMode(true);
|
||||
//_follow.activate(FollowHelper::Vertical);
|
||||
// _follow.activate(FollowHelper::Vertical);
|
||||
// disable cg behaviour in this case.
|
||||
//setIsInSittingState(true);
|
||||
// setIsInSittingState(true);
|
||||
}
|
||||
return counterBalancedCg;
|
||||
}
|
||||
|
@ -4090,7 +4100,7 @@ bool MyAvatar::FollowHelper::shouldActivateVertical(MyAvatar& myAvatar, const gl
|
|||
return true;
|
||||
} else if (offset.y > CYLINDER_TOP) {
|
||||
// if we recenter upwards then no longer in sitting state
|
||||
myAvatar.setIsInSittingState(false);
|
||||
// myAvatar.setIsInSittingState(false);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -4110,15 +4120,20 @@ void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat
|
|||
glm::vec3 headDefaultPos = myAvatar.getAbsoluteDefaultJointTranslationInObjectFrame(myAvatar.getJointIndex("Head"));
|
||||
if (myAvatar.getControllerPoseInAvatarFrame(controller::Action::HEAD).getTranslation().y < (headDefaultPos.y - 0.05f)) {
|
||||
_squatCount++;
|
||||
if ((_squatCount > 300) && !isActive(Vertical) && !isActive(Horizontal)) {
|
||||
activate(Horizontal);
|
||||
activate(Vertical);
|
||||
_squatCount = 0;
|
||||
if ((_squatCount > 600) && !isActive(Vertical) && !isActive(Horizontal)) {
|
||||
if (myAvatar.getIsInSittingState()) {
|
||||
// activate(Horizontal);
|
||||
activate(Vertical);
|
||||
_squatCount = 0;
|
||||
} else {
|
||||
activate(Horizontal);
|
||||
_squatCount = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_squatCount = 0;
|
||||
}
|
||||
|
||||
|
||||
if (!isActive(Rotation) && (shouldActivateRotation(myAvatar, desiredBodyMatrix, currentBodyMatrix) || hasDriveInput)) {
|
||||
activate(Rotation);
|
||||
myAvatar.setHeadControllerFacingMovingAverage(myAvatar.getHeadControllerFacing());
|
||||
|
|
|
@ -1728,7 +1728,7 @@ private:
|
|||
std::atomic<bool> _forceActivateVertical { false };
|
||||
std::atomic<bool> _forceActivateHorizontal { false };
|
||||
std::atomic<bool> _toggleHipsFollowing { true };
|
||||
int _squatCount{ 0 };
|
||||
int _squatCount { 0 };
|
||||
};
|
||||
FollowHelper _follow;
|
||||
|
||||
|
@ -1760,6 +1760,7 @@ private:
|
|||
glm::quat _customListenOrientation;
|
||||
|
||||
AtRestDetector _hmdAtRestDetector;
|
||||
bool _lastFrameHMDMode { false } ;
|
||||
bool _lastIsMoving { false };
|
||||
|
||||
// all poses are in sensor-frame
|
||||
|
@ -1804,7 +1805,7 @@ private:
|
|||
ThreadSafeValueCache<float> _sprintSpeed { AVATAR_SPRINT_SPEED_SCALAR };
|
||||
float _walkSpeedScalar { AVATAR_WALK_SPEED_SCALAR };
|
||||
bool _isInWalkingState { false };
|
||||
bool _isInSittingState { false };
|
||||
bool _isInSittingState { true };
|
||||
|
||||
// load avatar scripts once when rig is ready
|
||||
bool _shouldLoadScripts { false };
|
||||
|
|
|
@ -79,18 +79,19 @@ private:
|
|||
if (!OVR_SUCCESS(ovr_Initialize(&initParams))) {
|
||||
qCWarning(oculusLog) << "Failed to initialze Oculus SDK" << ovr::getError();
|
||||
return;
|
||||
} else {
|
||||
qCWarning(oculusLog) << "successful init of oculus!!!!!!!!";
|
||||
ovrTrackingOrigin fred;
|
||||
fred = ovr_GetTrackingOriginType(session);
|
||||
qCWarning(oculusLog) << (int)fred;
|
||||
|
||||
}
|
||||
|
||||
ovrGraphicsLuid luid;
|
||||
if (!OVR_SUCCESS(ovr_Create(&session, &luid))) {
|
||||
qCWarning(oculusLog) << "Failed to acquire Oculus session" << ovr::getError();
|
||||
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