Merge pull request #15967 from sabrina-shanman/picks_too-many_grab-enabled

(BUGZ-955) Disable unnecessary picking (conservative subset)
This commit is contained in:
Shannon Romano 2019-07-23 14:57:19 -07:00 committed by GitHub
commit b799abdac1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 7 deletions

View file

@ -285,6 +285,21 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
}
}
// Enable/disable controller raypicking depending on whether we are in HMD
if (HMD.active) {
Pointers.enablePointer(_this.leftPointer);
Pointers.enablePointer(_this.rightPointer);
Pointers.enablePointer(_this.leftHudPointer);
Pointers.enablePointer(_this.rightHudPointer);
Pointers.enablePointer(_this.mouseRayPointer);
} else {
Pointers.disablePointer(_this.leftPointer);
Pointers.disablePointer(_this.rightPointer);
Pointers.disablePointer(_this.leftHudPointer);
Pointers.disablePointer(_this.rightHudPointer);
Pointers.disablePointer(_this.mouseRayPointer);
}
// raypick for each controller
var rayPicks = [
Pointers.getPrevPickResult(_this.leftPointer),
@ -294,7 +309,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
Pointers.getPrevPickResult(_this.leftHudPointer),
Pointers.getPrevPickResult(_this.rightHudPointer)
];
var mouseRayPick = Pointers.getPrevPickResult(_this.mouseRayPick);
var mouseRayPointer = Pointers.getPrevPickResult(_this.mouseRayPointer);
// if the pickray hit something very nearby, put it into the nearby entities list
for (h = LEFT_HAND; h <= RIGHT_HAND; h++) {
@ -365,7 +380,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
nearbyOverlayIDs: nearbyOverlayIDs,
rayPicks: rayPicks,
hudRayPicks: hudRayPicks,
mouseRayPick: mouseRayPick
mouseRayPointer: mouseRayPointer
};
if (PROFILE) {
Script.endProfileRange("dispatch.gather");
@ -530,7 +545,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
hand: RIGHT_HAND
});
this.mouseRayPick = Pointers.createPointer(PickType.Ray, {
this.mouseRayPointer = Pointers.createPointer(PickType.Ray, {
joint: "Mouse",
filter: Picks.PICK_OVERLAYS | Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_NONCOLLIDABLE,
enabled: true
@ -579,7 +594,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
this.cleanup = function () {
Controller.disableMapping(MAPPING_NAME);
_this.pointerManager.removePointers();
Pointers.removePointer(this.mouseRayPick);
Pointers.removePointer(this.mouseRayPointer);
};
}

View file

@ -64,7 +64,7 @@
Reticle.depth = Vec3.distance(reticlePositionOnHUD, HMD.position);
} else {
var APPARENT_MAXIMUM_DEPTH = 100.0;
var result = controllerData.mouseRayPick;
var result = controllerData.mouseRayPointer;
Reticle.depth = result.intersects ? result.distance : APPARENT_MAXIMUM_DEPTH;
}
};

View file

@ -366,7 +366,7 @@ Script.include("/~/system/libraries/controllers.js");
var offset = _this.pickHeightOffset * capsuleRatio;
_this.teleportHandCollisionPick = Picks.createPick(PickType.Collision, {
enabled: true,
enabled: false,
parentID: Pointers.getPointerProperties(_this.teleportParabolaHandCollisions).renderStates["collision"].end,
filter: Picks.PICK_ENTITIES | Picks.PICK_AVATARS,
shape: {
@ -382,7 +382,7 @@ Script.include("/~/system/libraries/controllers.js");
});
_this.teleportHeadCollisionPick = Picks.createPick(PickType.Collision, {
enabled: true,
enabled: false,
parentID: Pointers.getPointerProperties(_this.teleportParabolaHeadCollisions).renderStates["collision"].end,
filter: Picks.PICK_ENTITIES | Picks.PICK_AVATARS,
shape: {

View file

@ -221,6 +221,20 @@ function Grabber() {
});
}
Grabber.prototype.setPicksAndPointersEnabled = function(enabled) {
if (enabled) {
Picks.enablePick(this.mouseRayOverlays);
Pointers.enablePointer(this.mouseRayEntities);
} else {
Picks.disablePick(this.mouseRayOverlays);
Pointers.disablePointer(this.mouseRayEntities);
}
}
Grabber.prototype.displayModeChanged = function(isHMDMode) {
this.setPicksAndPointersEnabled(!isHMDMode);
}
Grabber.prototype.computeNewGrabPlane = function() {
if (!this.isGrabbing) {
return;
@ -488,6 +502,10 @@ Grabber.prototype.cleanup = function() {
var grabber = new Grabber();
function displayModeChanged(isHMDMode) {
grabber.displayModeChanged(isHMDMode);
}
function pressEvent(event) {
grabber.pressEvent(event);
}
@ -517,6 +535,7 @@ Controller.mouseMoveEvent.connect(moveEvent);
Controller.mouseReleaseEvent.connect(releaseEvent);
Controller.keyPressEvent.connect(keyPressEvent);
Controller.keyReleaseEvent.connect(keyReleaseEvent);
HMD.displayModeChanged.connect(displayModeChanged);
Script.scriptEnding.connect(cleanup);
}()); // END LOCAL_SCOPE