mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 21:43:03 +02:00
add some saftey checks. cleanups
This commit is contained in:
parent
f45db99149
commit
7d21ab88b0
3 changed files with 15 additions and 8 deletions
|
@ -4423,7 +4423,9 @@ void Application::update(float deltaTime) {
|
||||||
myAvatar->setSpineControllerPosesInSensorFrame(hipsPose.transform(avatarToSensorMatrix), spine2Pose.transform(avatarToSensorMatrix));
|
myAvatar->setSpineControllerPosesInSensorFrame(hipsPose.transform(avatarToSensorMatrix), spine2Pose.transform(avatarToSensorMatrix));
|
||||||
|
|
||||||
controller::Pose headPose = userInputMapper->getPoseState(controller::Action::HEAD);
|
controller::Pose headPose = userInputMapper->getPoseState(controller::Action::HEAD);
|
||||||
myAvatar->setHeadControllerPoseInSensorFrame(headPose.transform(avatarToSensorMatrix));
|
if (headPose.isValid()) {
|
||||||
|
myAvatar->setHeadControllerPoseInSensorFrame(headPose.transform(avatarToSensorMatrix));
|
||||||
|
}
|
||||||
|
|
||||||
controller::Pose leftArmPose = userInputMapper->getPoseState(controller::Action::LEFT_ARM);
|
controller::Pose leftArmPose = userInputMapper->getPoseState(controller::Action::LEFT_ARM);
|
||||||
controller::Pose rightArmPose = userInputMapper->getPoseState(controller::Action::RIGHT_ARM);
|
controller::Pose rightArmPose = userInputMapper->getPoseState(controller::Action::RIGHT_ARM);
|
||||||
|
@ -4859,9 +4861,13 @@ bool Application::isHMDMode() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::isHeadControllerEnabled() const {
|
bool Application::isHeadControllerEnabled() const {
|
||||||
const InputPluginList& inputPlugins = PluginManager::getInstance()->getInputPlugins();
|
auto pluginManager = PluginManager::getInstance();
|
||||||
|
if (!pluginManager) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const InputPluginList& inputPlugins = pluginManager->getInputPlugins();
|
||||||
for (auto& ip : inputPlugins) {
|
for (auto& ip : inputPlugins) {
|
||||||
if (ip->isActive() && ip->isHeadController()) {
|
if (ip && ip->isActive() && ip->isHeadController()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2328,7 +2328,6 @@ glm::quat MyAvatar::getWorldBodyOrientation() const {
|
||||||
// old school meat hook style
|
// old school meat hook style
|
||||||
glm::mat4 MyAvatar::deriveBodyFromHMDSensor() const {
|
glm::mat4 MyAvatar::deriveBodyFromHMDSensor() const {
|
||||||
|
|
||||||
// HMD is in sensor space.
|
|
||||||
const glm::vec3 headPosition = getHeadControllerPoseInSensorFrame().translation;
|
const glm::vec3 headPosition = getHeadControllerPoseInSensorFrame().translation;
|
||||||
const glm::quat headOrientation = getHeadControllerPoseInSensorFrame().rotation * Quaternions::Y_180;
|
const glm::quat headOrientation = getHeadControllerPoseInSensorFrame().rotation * Quaternions::Y_180;
|
||||||
const glm::quat headOrientationYawOnly = cancelOutRollAndPitch(headOrientation);
|
const glm::quat headOrientationYawOnly = cancelOutRollAndPitch(headOrientation);
|
||||||
|
@ -2352,8 +2351,8 @@ glm::mat4 MyAvatar::deriveBodyFromHMDSensor() const {
|
||||||
// apply simplistic head/neck model
|
// apply simplistic head/neck model
|
||||||
// figure out where the avatar body should be by applying offsets from the avatar's neck & head joints.
|
// figure out where the avatar body should be by applying offsets from the avatar's neck & head joints.
|
||||||
|
|
||||||
// eyeToNeck offset is relative full HMD orientation.
|
// eyeToNeck offset is relative to head's full orientation,
|
||||||
// while neckToRoot offset is only relative to HMDs yaw.
|
// while neckToRoot offset is only relative to head's yaw.
|
||||||
// Y_180 is necessary because rig is z forward and headOrientation is -z forward
|
// Y_180 is necessary because rig is z forward and headOrientation is -z forward
|
||||||
glm::vec3 eyeToNeck = headOrientation * Quaternions::Y_180 * (localNeck - localEyes);
|
glm::vec3 eyeToNeck = headOrientation * Quaternions::Y_180 * (localNeck - localEyes);
|
||||||
glm::vec3 neckToRoot = headOrientationYawOnly * Quaternions::Y_180 * -localNeck;
|
glm::vec3 neckToRoot = headOrientationYawOnly * Quaternions::Y_180 * -localNeck;
|
||||||
|
|
|
@ -221,8 +221,11 @@ bool OculusControllerManager::isHeadController() const {
|
||||||
return status.HmdMounted == ovrTrue;
|
return status.HmdMounted == ovrTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusControllerManager::TouchDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
void OculusControllerManager::TouchDevice::update(float deltaTime,
|
||||||
|
const controller::InputCalibrationData& inputCalibrationData) {
|
||||||
_buttonPressedMap.clear();
|
_buttonPressedMap.clear();
|
||||||
|
_poseStateMap.erase(controller::HEAD);
|
||||||
|
|
||||||
if (!_parent.isHeadController()) {
|
if (!_parent.isHeadController()) {
|
||||||
// if the HMD isn't on someone's head, don't take input from the controllers
|
// if the HMD isn't on someone's head, don't take input from the controllers
|
||||||
return;
|
return;
|
||||||
|
@ -258,7 +261,6 @@ void OculusControllerManager::TouchDevice::update(float deltaTime, const control
|
||||||
handleRotationForUntrackedHand(inputCalibrationData, hand, tracking.HandPoses[hand]);
|
handleRotationForUntrackedHand(inputCalibrationData, hand, tracking.HandPoses[hand]);
|
||||||
});
|
});
|
||||||
|
|
||||||
_poseStateMap.erase(controller::HEAD);
|
|
||||||
handleHeadPose(deltaTime, inputCalibrationData, tracking.HeadPose);
|
handleHeadPose(deltaTime, inputCalibrationData, tracking.HeadPose);
|
||||||
|
|
||||||
using namespace controller;
|
using namespace controller;
|
||||||
|
|
Loading…
Reference in a new issue