Merge pull request #7302 from hyperlogic/tony/wrong-way-overlay

More reliable and usable UI sphere overlay location
This commit is contained in:
Philip Rosedale 2016-03-10 17:43:50 -08:00
commit e87ef52a4c
6 changed files with 37 additions and 2 deletions

View file

@ -4880,7 +4880,10 @@ void Application::updateDisplayMode() {
}
}
emit activeDisplayPluginChanged();
resetSensors();
// reset the avatar, to set head and hand palms back to a resonable default pose.
getMyAvatar()->reset(false);
Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin");
}

View file

@ -464,6 +464,8 @@ Menu::Menu() {
avatar, SLOT(setUseAnimPreAndPostRotations(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::EnableInverseKinematics, 0, true,
avatar, SLOT(setEnableInverseKinematics(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderSensorToWorldMatrix, 0, false,
avatar, SLOT(setEnableDebugDrawSensorToWorldMatrix(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::KeyboardMotorControl,
Qt::CTRL | Qt::SHIFT | Qt::Key_K, true, avatar, SLOT(updateMotionBehaviorFromMenu()),

View file

@ -144,6 +144,7 @@ namespace MenuOption {
const QString RenderResolutionHalf = "1/2";
const QString RenderResolutionThird = "1/3";
const QString RenderResolutionQuarter = "1/4";
const QString RenderSensorToWorldMatrix = "Show SensorToWorld Matrix";
const QString ResetAvatarSize = "Reset Avatar Size";
const QString ResetSensors = "Reset Sensors";
const QString RunningScripts = "Running Scripts...";

View file

@ -444,6 +444,10 @@ void MyAvatar::updateSensorToWorldMatrix() {
lateUpdatePalms();
if (_enableDebugDrawSensorToWorldMatrix) {
DebugDraw::getInstance().addMarker("sensorToWorldMatrix", glmExtractRotation(_sensorToWorldMatrix), extractTranslation(_sensorToWorldMatrix), glm::vec4(1));
}
_sensorToWorldMatrixCache.set(_sensorToWorldMatrix);
}
@ -698,6 +702,14 @@ void MyAvatar::setEnableDebugDrawPosition(bool isEnabled) {
}
}
void MyAvatar::setEnableDebugDrawSensorToWorldMatrix(bool isEnabled) {
_enableDebugDrawSensorToWorldMatrix = isEnabled;
if (!isEnabled) {
DebugDraw::getInstance().removeMarker("sensorToWorldMatrix");
}
}
void MyAvatar::setEnableMeshVisible(bool isEnabled) {
render::ScenePointer scene = qApp->getMain3DScene();
_skeletonModel.setVisibleInScene(isEnabled, scene);

View file

@ -271,6 +271,7 @@ public slots:
void setEnableDebugDrawDefaultPose(bool isEnabled);
void setEnableDebugDrawAnimPose(bool isEnabled);
void setEnableDebugDrawPosition(bool isEnabled);
void setEnableDebugDrawSensorToWorldMatrix(bool isEnabled);
bool getEnableMeshVisible() const { return _skeletonModel.isVisible(); }
void setEnableMeshVisible(bool isEnabled);
void setUseAnimPreAndPostRotations(bool isEnabled);
@ -434,6 +435,7 @@ private:
bool _enableDebugDrawDefaultPose { false };
bool _enableDebugDrawAnimPose { false };
bool _enableDebugDrawSensorToWorldMatrix { false };
AudioListenerMode _audioListenerMode;
glm::vec3 _customListenPosition;

View file

@ -68,6 +68,21 @@ void OpenVrDisplayPlugin::activate() {
_compositor = vr::VRCompositor();
Q_ASSERT(_compositor);
HmdDisplayPlugin::activate();
// set up default sensor space such that the UI overlay will align with the front of the room.
auto chaperone = vr::VRChaperone();
if (chaperone) {
float const UI_RADIUS = 1.0f;
float const UI_HEIGHT = 1.6f;
float const UI_Z_OFFSET = 0.5;
float xSize, zSize;
chaperone->GetPlayAreaSize(&xSize, &zSize);
glm::vec3 uiPos(0.0f, UI_HEIGHT, UI_RADIUS - (0.5f * zSize) - UI_Z_OFFSET);
_sensorResetMat = glm::inverse(createMatFromQuatAndPos(glm::quat(), uiPos));
} else {
qDebug() << "OpenVR: error could not get chaperone pointer";
}
}
void OpenVrDisplayPlugin::deactivate() {
@ -115,7 +130,7 @@ glm::mat4 OpenVrDisplayPlugin::getHeadPose(uint32_t frameIndex) const {
#endif
vr::TrackedDevicePose_t predictedTrackedDevicePose[vr::k_unMaxTrackedDeviceCount];
_system->GetDeviceToAbsoluteTrackingPose(vr::TrackingUniverseSeated, predictedSecondsFromNow, predictedTrackedDevicePose, vr::k_unMaxTrackedDeviceCount);
_system->GetDeviceToAbsoluteTrackingPose(vr::TrackingUniverseStanding, predictedSecondsFromNow, predictedTrackedDevicePose, vr::k_unMaxTrackedDeviceCount);
// copy and process predictedTrackedDevicePoses
for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) {