add some saftey checks. cleanups

This commit is contained in:
Seth Alves 2017-06-01 16:14:59 -07:00
parent f45db99149
commit 7d21ab88b0
3 changed files with 15 additions and 8 deletions

View file

@ -4423,7 +4423,9 @@ void Application::update(float deltaTime) {
myAvatar->setSpineControllerPosesInSensorFrame(hipsPose.transform(avatarToSensorMatrix), spine2Pose.transform(avatarToSensorMatrix));
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 rightArmPose = userInputMapper->getPoseState(controller::Action::RIGHT_ARM);
@ -4859,9 +4861,13 @@ bool Application::isHMDMode() 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) {
if (ip->isActive() && ip->isHeadController()) {
if (ip && ip->isActive() && ip->isHeadController()) {
return true;
}
}

View file

@ -2328,7 +2328,6 @@ glm::quat MyAvatar::getWorldBodyOrientation() const {
// old school meat hook style
glm::mat4 MyAvatar::deriveBodyFromHMDSensor() const {
// HMD is in sensor space.
const glm::vec3 headPosition = getHeadControllerPoseInSensorFrame().translation;
const glm::quat headOrientation = getHeadControllerPoseInSensorFrame().rotation * Quaternions::Y_180;
const glm::quat headOrientationYawOnly = cancelOutRollAndPitch(headOrientation);
@ -2352,8 +2351,8 @@ glm::mat4 MyAvatar::deriveBodyFromHMDSensor() const {
// apply simplistic head/neck model
// 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.
// while neckToRoot offset is only relative to HMDs yaw.
// eyeToNeck offset is relative to head's full orientation,
// while neckToRoot offset is only relative to head's yaw.
// 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 neckToRoot = headOrientationYawOnly * Quaternions::Y_180 * -localNeck;

View file

@ -221,8 +221,11 @@ bool OculusControllerManager::isHeadController() const {
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();
_poseStateMap.erase(controller::HEAD);
if (!_parent.isHeadController()) {
// if the HMD isn't on someone's head, don't take input from the controllers
return;
@ -258,7 +261,6 @@ void OculusControllerManager::TouchDevice::update(float deltaTime, const control
handleRotationForUntrackedHand(inputCalibrationData, hand, tracking.HandPoses[hand]);
});
_poseStateMap.erase(controller::HEAD);
handleHeadPose(deltaTime, inputCalibrationData, tracking.HeadPose);
using namespace controller;