Merge pull request #12085 from zfox23/commerce_fixHandControllerInspection

Fix bugs related to inspecting entities with hand controllers
This commit is contained in:
Zach Fox 2018-01-05 15:50:00 -08:00 committed by GitHub
commit 0c38a5598f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 18 deletions

View file

@ -151,7 +151,7 @@ bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID&
glm::vec3 normal;
boundingBox.findRayIntersection(cameraPosition, direction, distance, face, normal);
float offsetAngle = -CONTEXT_OVERLAY_OFFSET_ANGLE;
if (DependencyManager::get<PointerManager>()->isLeftHand(event.getID())) {
if (event.getID() == 1) { // "1" is left hand
offsetAngle *= -1.0f;
}
contextOverlayPosition = cameraPosition +

View file

@ -98,6 +98,7 @@ Script.include("/~/system/libraries/Xform.js");
this.targetObject = null;
this.actionID = null; // action this script created...
this.entityToLockOnto = null;
this.potentialEntityWithContextOverlay = false;
this.entityWithContextOverlay = false;
this.contextOverlayTimer = false;
this.previousCollisionStatus = false;
@ -364,6 +365,7 @@ Script.include("/~/system/libraries/Xform.js");
if (this.entityWithContextOverlay) {
ContextOverlay.destroyContextOverlay(this.entityWithContextOverlay);
this.entityWithContextOverlay = false;
this.potentialEntityWithContextOverlay = false;
}
};
@ -444,9 +446,13 @@ Script.include("/~/system/libraries/Xform.js");
this.targetObject = new TargetObject(entityID, targetProps);
this.targetObject.parentProps = getEntityParents(targetProps);
Script.clearTimeout(this.contextOverlayTimer);
this.contextOverlayTimer = false;
if (entityID !== this.entityWithContextOverlay) {
this.destroyContextOverlay();
}
var targetEntity = this.targetObject.getTargetEntity();
entityID = targetEntity.id;
targetProps = targetEntity.props;
@ -470,26 +476,39 @@ Script.include("/~/system/libraries/Xform.js");
this.startFarGrabAction(controllerData, targetProps);
}
}
} else if (!this.entityWithContextOverlay && !this.contextOverlayTimer) {
} else if (!this.entityWithContextOverlay) {
var _this = this;
_this.contextOverlayTimer = Script.setTimeout(function () {
if (!_this.entityWithContextOverlay && _this.contextOverlayTimer) {
var props = Entities.getEntityProperties(rayPickInfo.objectID);
var pointerEvent = {
type: "Move",
id: this.hand + 1, // 0 is reserved for hardware mouse
pos2D: projectOntoEntityXYPlane(rayPickInfo.objectID, rayPickInfo.intersection, props),
pos3D: rayPickInfo.intersection,
normal: rayPickInfo.surfaceNormal,
direction: Vec3.subtract(ZERO_VEC, rayPickInfo.surfaceNormal),
button: "Secondary"
};
if (ContextOverlay.createOrDestroyContextOverlay(rayPickInfo.objectID, pointerEvent)) {
_this.entityWithContextOverlay = rayPickInfo.objectID;
}
if (_this.potentialEntityWithContextOverlay !== rayPickInfo.objectID) {
if (_this.contextOverlayTimer) {
Script.clearTimeout(_this.contextOverlayTimer);
}
_this.contextOverlayTimer = false;
}, 500);
_this.potentialEntityWithContextOverlay = rayPickInfo.objectID;
}
if (!_this.contextOverlayTimer) {
_this.contextOverlayTimer = Script.setTimeout(function () {
if (!_this.entityWithContextOverlay &&
_this.contextOverlayTimer &&
_this.potentialEntityWithContextOverlay === rayPickInfo.objectID) {
var props = Entities.getEntityProperties(rayPickInfo.objectID);
var pointerEvent = {
type: "Move",
id: _this.hand + 1, // 0 is reserved for hardware mouse
pos2D: projectOntoEntityXYPlane(rayPickInfo.objectID, rayPickInfo.intersection, props),
pos3D: rayPickInfo.intersection,
normal: rayPickInfo.surfaceNormal,
direction: Vec3.subtract(ZERO_VEC, rayPickInfo.surfaceNormal),
button: "Secondary"
};
if (ContextOverlay.createOrDestroyContextOverlay(rayPickInfo.objectID, pointerEvent)) {
_this.entityWithContextOverlay = rayPickInfo.objectID;
}
}
_this.contextOverlayTimer = false;
}, 500);
}
}
} else if (this.distanceRotating) {
this.distanceRotate(otherFarGrabModule);