mirror of
https://github.com/overte-org/overte.git
synced 2025-04-11 04:12:09 +02:00
don't worry about head controller being enabled, just check to see if head pose is valid
This commit is contained in:
parent
d91b3700a7
commit
9088e288e0
8 changed files with 33 additions and 50 deletions
|
@ -4429,9 +4429,7 @@ void Application::update(float deltaTime) {
|
|||
myAvatar->setSpineControllerPosesInSensorFrame(hipsPose.transform(avatarToSensorMatrix), spine2Pose.transform(avatarToSensorMatrix));
|
||||
|
||||
controller::Pose headPose = userInputMapper->getPoseState(controller::Action::HEAD);
|
||||
if (headPose.isValid()) {
|
||||
myAvatar->setHeadControllerPoseInSensorFrame(headPose.transform(avatarToSensorMatrix));
|
||||
}
|
||||
myAvatar->setHeadControllerPoseInSensorFrame(headPose.transform(avatarToSensorMatrix));
|
||||
|
||||
controller::Pose leftArmPose = userInputMapper->getPoseState(controller::Action::LEFT_ARM);
|
||||
controller::Pose rightArmPose = userInputMapper->getPoseState(controller::Action::RIGHT_ARM);
|
||||
|
@ -4867,20 +4865,6 @@ bool Application::isHMDMode() const {
|
|||
return getActiveDisplayPlugin()->isHmd();
|
||||
}
|
||||
|
||||
bool Application::isHeadControllerEnabled() const {
|
||||
auto pluginManager = PluginManager::getInstance();
|
||||
if (!pluginManager) {
|
||||
return false;
|
||||
}
|
||||
const InputPluginList& inputPlugins = pluginManager->getInputPlugins();
|
||||
for (auto& ip : inputPlugins) {
|
||||
if (ip && ip->isActive() && ip->isHeadController()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
float Application::getTargetFrameRate() const { return getActiveDisplayPlugin()->getTargetFrameRate(); }
|
||||
|
||||
QRect Application::getDesirableApplicationGeometry() const {
|
||||
|
|
|
@ -248,7 +248,6 @@ public:
|
|||
// rendering of several elements depend on that
|
||||
// TODO: carry that information on the Camera as a setting
|
||||
virtual bool isHMDMode() const override;
|
||||
bool isHeadControllerEnabled() const;
|
||||
glm::mat4 getHMDSensorPose() const;
|
||||
glm::mat4 getEyeOffset(int eye) const;
|
||||
glm::mat4 getEyeProjection(int eye) const;
|
||||
|
|
|
@ -641,9 +641,13 @@ void MyAvatar::updateFromHMDSensorMatrix(const glm::mat4& hmdSensorMatrix) {
|
|||
// Ignore unreasonable HMD sensor data
|
||||
return;
|
||||
}
|
||||
|
||||
_hmdSensorPosition = newHmdSensorPosition;
|
||||
_hmdSensorOrientation = glm::quat_cast(hmdSensorMatrix);
|
||||
_headControllerFacing = getFacingDir2D(_headControllerPoseInSensorFrameCache.get().rotation);
|
||||
auto headPose = _headControllerPoseInSensorFrameCache.get();
|
||||
if (headPose.isValid()) {
|
||||
_headControllerFacing = getFacingDir2D(headPose.rotation);
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::updateJointFromController(controller::Action poseKey, ThreadSafeValueCache<glm::mat4>& matrixCache) {
|
||||
|
@ -1884,7 +1888,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
|||
|
||||
getHead()->setBasePitch(getHead()->getBasePitch() + getDriveKey(PITCH) * _pitchSpeed * deltaTime);
|
||||
|
||||
if (qApp->isHeadControllerEnabled()) {
|
||||
if (getHeadControllerPoseInAvatarFrame().isValid()) {
|
||||
glm::quat localOrientation = getHeadControllerPoseInAvatarFrame().rotation;
|
||||
// these angles will be in radians
|
||||
// ... so they need to be converted to degrees before we do math...
|
||||
|
|
|
@ -52,26 +52,18 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
|||
// input action is the highest priority source for head orientation.
|
||||
auto avatarHeadPose = myAvatar->getHeadControllerPoseInAvatarFrame();
|
||||
if (avatarHeadPose.isValid()) {
|
||||
glm::mat4 rigHeadMat = Matrices::Y_180 * createMatFromQuatAndPos(avatarHeadPose.getRotation(), avatarHeadPose.getTranslation());
|
||||
glm::mat4 rigHeadMat = Matrices::Y_180 *
|
||||
createMatFromQuatAndPos(avatarHeadPose.getRotation(), avatarHeadPose.getTranslation());
|
||||
headParams.rigHeadPosition = extractTranslation(rigHeadMat);
|
||||
headParams.rigHeadOrientation = glmExtractRotation(rigHeadMat);
|
||||
headParams.headEnabled = true;
|
||||
} else {
|
||||
if (qApp->isHMDMode()) {
|
||||
// get HMD position from sensor space into world space, and back into rig space
|
||||
glm::mat4 worldHMDMat = myAvatar->getHeadControllerPoseInWorldFrame().getMatrix();
|
||||
glm::mat4 rigToWorld = createMatFromQuatAndPos(getRotation(), getTranslation());
|
||||
glm::mat4 worldToRig = glm::inverse(rigToWorld);
|
||||
glm::mat4 rigHMDMat = worldToRig * worldHMDMat;
|
||||
_rig.computeHeadFromHMD(AnimPose(rigHMDMat), headParams.rigHeadPosition, headParams.rigHeadOrientation);
|
||||
headParams.headEnabled = true;
|
||||
} else {
|
||||
// even though full head IK is disabled, the rig still needs the head orientation to rotate the head up and down in desktop mode.
|
||||
// preMult 180 is necessary to convert from avatar to rig coordinates.
|
||||
// postMult 180 is necessary to convert head from -z forward to z forward.
|
||||
headParams.rigHeadOrientation = Quaternions::Y_180 * head->getFinalOrientationInLocalFrame() * Quaternions::Y_180;
|
||||
headParams.headEnabled = false;
|
||||
}
|
||||
// even though full head IK is disabled, the rig still needs the head orientation to rotate the head up and
|
||||
// down in desktop mode.
|
||||
// preMult 180 is necessary to convert from avatar to rig coordinates.
|
||||
// postMult 180 is necessary to convert head from -z forward to z forward.
|
||||
headParams.rigHeadOrientation = Quaternions::Y_180 * head->getFinalOrientationInLocalFrame() * Quaternions::Y_180;
|
||||
headParams.headEnabled = false;
|
||||
}
|
||||
|
||||
auto avatarHipsPose = myAvatar->getHipsControllerPoseInAvatarFrame();
|
||||
|
|
|
@ -210,10 +210,8 @@ void OculusControllerManager::RemoteDevice::focusOutEvent() {
|
|||
_buttonPressedMap.clear();
|
||||
}
|
||||
|
||||
bool OculusControllerManager::isHeadController() const {
|
||||
// this plugin is a head controller if the HMD is mounted.
|
||||
bool OculusControllerManager::isHeadControllerMounted() const {
|
||||
ovrSessionStatus status;
|
||||
|
||||
bool success = OVR_SUCCESS(ovr_GetSessionStatus(_session, &status));
|
||||
if (!success) {
|
||||
return false;
|
||||
|
@ -224,12 +222,12 @@ bool OculusControllerManager::isHeadController() const {
|
|||
void OculusControllerManager::TouchDevice::update(float deltaTime,
|
||||
const controller::InputCalibrationData& inputCalibrationData) {
|
||||
_buttonPressedMap.clear();
|
||||
_poseStateMap.erase(controller::HEAD);
|
||||
// _poseStateMap.erase(controller::HEAD);
|
||||
|
||||
if (!_parent.isHeadController()) {
|
||||
// if the HMD isn't on someone's head, don't take input from the controllers
|
||||
return;
|
||||
}
|
||||
// if (!_parent.isHeadControllerMounted()) {
|
||||
// // if the HMD isn't on someone's head, don't take input from the controllers
|
||||
// return;
|
||||
// }
|
||||
|
||||
int numTrackedControllers = 0;
|
||||
quint64 currentTime = usecTimestampNow();
|
||||
|
@ -261,7 +259,11 @@ void OculusControllerManager::TouchDevice::update(float deltaTime,
|
|||
handleRotationForUntrackedHand(inputCalibrationData, hand, tracking.HandPoses[hand]);
|
||||
});
|
||||
|
||||
handleHeadPose(deltaTime, inputCalibrationData, tracking.HeadPose);
|
||||
if (_parent.isHeadControllerMounted()) {
|
||||
handleHeadPose(deltaTime, inputCalibrationData, tracking.HeadPose);
|
||||
} else {
|
||||
_poseStateMap[controller::HEAD].valid = false;
|
||||
}
|
||||
|
||||
using namespace controller;
|
||||
// Axes
|
||||
|
|
|
@ -28,7 +28,8 @@ public:
|
|||
const QString getName() const override { return NAME; }
|
||||
|
||||
bool isHandController() const override { return _touch != nullptr; }
|
||||
bool isHeadController() const override;
|
||||
bool isHeadController() const override { return true; }
|
||||
bool isHeadControllerMounted() const;
|
||||
QStringList getSubdeviceNames() override;
|
||||
|
||||
bool activate() override;
|
||||
|
|
|
@ -164,8 +164,8 @@ void ViveControllerManager::deactivate() {
|
|||
_registeredWithInputMapper = false;
|
||||
}
|
||||
|
||||
bool ViveControllerManager::isHeadController() const {
|
||||
if (_inputDevice && _inputDevice->isHeadController()) {
|
||||
bool ViveControllerManager::isHeadControllerMounted() const {
|
||||
if (_inputDevice && _inputDevice->isHeadControllerMounted()) {
|
||||
return true;
|
||||
}
|
||||
vr::EDeviceActivityLevel activityLevel = _system->GetTrackedDeviceActivityLevel(vr::k_unTrackedDeviceIndex_Hmd);
|
||||
|
|
|
@ -41,7 +41,8 @@ public:
|
|||
const QString getName() const override { return NAME; }
|
||||
|
||||
bool isHandController() const override { return true; }
|
||||
bool isHeadController() const override;
|
||||
bool isHeadController() const override { return true; }
|
||||
bool isHeadControllerMounted() const;
|
||||
|
||||
bool activate() override;
|
||||
void deactivate() override;
|
||||
|
@ -55,7 +56,7 @@ private:
|
|||
class InputDevice : public controller::InputDevice {
|
||||
public:
|
||||
InputDevice(vr::IVRSystem*& system);
|
||||
bool isHeadController() const { return _overrideHead; }
|
||||
bool isHeadControllerMounted() const { return _overrideHead; }
|
||||
private:
|
||||
// Device functions
|
||||
controller::Input::NamedVector getAvailableInputs() const override;
|
||||
|
|
Loading…
Reference in a new issue