fix reticle depth at different scales and x button click on mouse press

This commit is contained in:
SamGondelman 2017-11-27 17:46:19 -08:00
parent 52039e022b
commit d4a4c8902a
2 changed files with 14 additions and 26 deletions

View file

@ -437,9 +437,11 @@ glm::mat4 CompositorHelper::getReticleTransform(const glm::mat4& eyePose, const
} else { } else {
d = glm::normalize(overlaySurfacePoint); d = glm::normalize(overlaySurfacePoint);
} }
reticlePosition = headPosition + (d * getReticleDepth()); // Our sensor to world matrix always has uniform scale
float sensorSpaceReticleDepth = getReticleDepth() / extractScale(_sensorToWorldMatrix).x;
reticlePosition = headPosition + (d * sensorSpaceReticleDepth);
quat reticleOrientation = cancelOutRoll(glm::quat_cast(_currentDisplayPlugin->getHeadPose())); quat reticleOrientation = cancelOutRoll(glm::quat_cast(_currentDisplayPlugin->getHeadPose()));
vec3 reticleScale = vec3(Cursor::Manager::instance().getScale() * reticleSize * getReticleDepth()); vec3 reticleScale = vec3(Cursor::Manager::instance().getScale() * reticleSize * sensorSpaceReticleDepth);
return glm::inverse(eyePose) * createMatFromScaleQuatAndPos(reticleScale, reticleOrientation, reticlePosition); return glm::inverse(eyePose) * createMatFromScaleQuatAndPos(reticleScale, reticleOrientation, reticlePosition);
} else { } else {
static const float CURSOR_PIXEL_SIZE = 32.0f; static const float CURSOR_PIXEL_SIZE = 32.0f;

View file

@ -514,31 +514,17 @@ WebTablet.prototype.getPosition = function () {
}; };
WebTablet.prototype.mousePressEvent = function (event) { WebTablet.prototype.mousePressEvent = function (event) {
var pickRay = Camera.computePickRay(event.x, event.y); if (!HMD.active) {
var entityPickResults; var pickRay = Camera.computePickRay(event.x, event.y);
entityPickResults = Overlays.findRayIntersection(pickRay, true, [this.tabletEntityID]); var tabletBackPickResults = Overlays.findRayIntersection(pickRay, true, [this.tabletEntityID]);
if (entityPickResults.intersects && (entityPickResults.entityID === this.tabletEntityID || if (tabletBackPickResults.intersects) {
entityPickResults.overlayID === this.tabletEntityID)) { var overlayPickResults = Overlays.findRayIntersection(pickRay, true, [this.webOverlayID, this.homeButtonID]);
var overlayPickResults = Overlays.findRayIntersection(pickRay, true, [this.webOverlayID, this.homeButtonID], []); if (!overlayPickResults.intersects) {
if (overlayPickResults.intersects && overlayPickResults.overlayID === this.homeButtonID) { this.dragging = true;
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var invCameraXform = new Xform(Camera.orientation, Camera.position).inv();
var onHomeScreen = tablet.onHomeScreen(); this.initialLocalIntersectionPoint = invCameraXform.xformPoint(tabletBackPickResults.intersection);
var isMessageOpen = tablet.isMessageDialogOpen(); this.initialLocalPosition = Overlays.getProperty(this.tabletEntityID, "localPosition");
if (onHomeScreen) {
if (isMessageOpen === false) {
HMD.closeTablet();
}
} else {
if (isMessageOpen === false) {
tablet.gotoHomeScreen();
this.setHomeButtonTexture();
}
} }
} else if (!HMD.active && (!overlayPickResults.intersects || overlayPickResults.overlayID !== this.webOverlayID)) {
this.dragging = true;
var invCameraXform = new Xform(Camera.orientation, Camera.position).inv();
this.initialLocalIntersectionPoint = invCameraXform.xformPoint(entityPickResults.intersection);
this.initialLocalPosition = Overlays.getProperty(this.tabletEntityID, "localPosition");
} }
} }
}; };