fix tablet button and gizmos rotation

This commit is contained in:
danteruiz 2019-03-01 14:03:45 -08:00
parent 33e061b09b
commit 618a1d5b83
2 changed files with 12 additions and 15 deletions

View file

@ -413,30 +413,31 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove
overlayProps["dimensions"] = vec3toVariant(ratio * dimensions);
}
if (add || overlayProps.contains("rotation")) {
if (add && !overlayProps.contains("rotation") && !overlayProps.contains("localRotation")) {
glm::quat rotation;
overlayProps["rotation"] = quatToVariant(glm::angleAxis(-(float)M_PI_2, rotation * Vectors::RIGHT) * rotation);
} else if (overlayProps.contains("rotation")) {
glm::quat rotation;
{
auto iter = overlayProps.find("rotation");
if (iter != overlayProps.end()) {
rotation = quatFromVariant(iter.value());
} else if (!add) {
EntityPropertyFlags desiredProperties;
desiredProperties += PROP_ROTATION;
rotation = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(id, desiredProperties).getRotation();
}
}
overlayProps["rotation"] = quatToVariant(glm::angleAxis(-(float)M_PI_2, rotation * Vectors::RIGHT) * rotation);
}
if (add || overlayProps.contains("localRotation")) {
if (overlayProps.contains("localRotation")) {
auto iter = overlayProps.find("localRotation");
if (iter != overlayProps.end()) {
overlayProps.erase(iter);
}
}
} else if (overlayProps.contains("localRotation")) {
glm::quat rotation;
{
auto iter = overlayProps.find("localRotation");
if (iter != overlayProps.end()) {
rotation = quatFromVariant(iter.value());
} else if (!add) {
EntityPropertyFlags desiredProperties;
desiredProperties += PROP_LOCAL_ROTATION;
rotation = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(id, desiredProperties).getLocalRotation();
}
}
overlayProps["localRotation"] = quatToVariant(glm::angleAxis(-(float)M_PI_2, rotation * Vectors::RIGHT) * rotation);

View file

@ -418,13 +418,11 @@ resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride)
var HOME_BUTTON_Z_OFFSET = (tabletDepth / 1.9) * sensorScaleOffsetOverride;
Entities.editEntity(HMD.homeButtonID, {
localPosition: { x: HOME_BUTTON_X_OFFSET, y: HOME_BUTTON_Y_OFFSET, z: -HOME_BUTTON_Z_OFFSET },
localRotation: { x: 0, y: 1, z: 0, w: 0 },
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }
});
Entities.editEntity(HMD.homeButtonHighlightID, {
localPosition: { x: -HOME_BUTTON_X_OFFSET, y: HOME_BUTTON_Y_OFFSET, z: -HOME_BUTTON_Z_OFFSET },
localRotation: { x: 0, y: 1, z: 0, w: 0 },
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }
});
};
@ -482,13 +480,11 @@ reparentAndScaleTablet = function(width, reparentProps) {
var HOME_BUTTON_Z_OFFSET = (tabletDepth / 1.9) * sensorScaleOffsetOverride;
Entities.editEntity(HMD.homeButtonID, {
localPosition: { x: HOME_BUTTON_X_OFFSET, y: HOME_BUTTON_Y_OFFSET, z: -HOME_BUTTON_Z_OFFSET },
localRotation: { x: 0, y: 1, z: 0, w: 0 },
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }
});
Entities.editEntity(HMD.homeButtonHighlightID, {
localPosition: { x: -HOME_BUTTON_X_OFFSET, y: HOME_BUTTON_Y_OFFSET, z: -HOME_BUTTON_Z_OFFSET },
localRotation: { x: 0, y: 1, z: 0, w: 0 },
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }
});
}