Add interface to disable hand controller grab functionality

This commit is contained in:
Ryan Huffman 2016-08-29 10:28:27 -07:00
parent a170436c8c
commit 14323a06b3

View file

@ -184,6 +184,10 @@ var STATE_FAR_TRIGGER = 5;
var STATE_HOLD = 6; var STATE_HOLD = 6;
var STATE_ENTITY_TOUCHING = 7; var STATE_ENTITY_TOUCHING = 7;
var holdEnabled = true;
var nearGrabEnabled = true;
var farGrabEnabled = true;
// "collidesWith" is specified by comma-separated list of group names // "collidesWith" is specified by comma-separated list of group names
// the possible group names are: static, dynamic, kinematic, myAvatar, otherAvatar // the possible group names are: static, dynamic, kinematic, myAvatar, otherAvatar
var COLLIDES_WITH_WHILE_GRABBED = "dynamic,otherAvatar"; var COLLIDES_WITH_WHILE_GRABBED = "dynamic,otherAvatar";
@ -1440,7 +1444,7 @@ function MyController(hand) {
var potentialEquipHotspot = this.chooseBestEquipHotspot(candidateHotSpotEntities); var potentialEquipHotspot = this.chooseBestEquipHotspot(candidateHotSpotEntities);
if (potentialEquipHotspot) { if (potentialEquipHotspot) {
if (this.triggerSmoothedGrab()) { if (this.triggerSmoothedGrab() && holdEnabled) {
this.grabbedHotspot = potentialEquipHotspot; this.grabbedHotspot = potentialEquipHotspot;
this.grabbedEntity = potentialEquipHotspot.entityID; this.grabbedEntity = potentialEquipHotspot.entityID;
this.setState(STATE_HOLD, "equipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'"); this.setState(STATE_HOLD, "equipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'");
@ -1483,7 +1487,7 @@ function MyController(hand) {
// potentialNearTriggerEntity = entity; // potentialNearTriggerEntity = entity;
} }
} else { } else {
if (this.triggerSmoothedGrab()) { if (this.triggerSmoothedGrab() && nearGrabEnabled) {
var props = entityPropertiesCache.getProps(entity); var props = entityPropertiesCache.getProps(entity);
var grabProps = entityPropertiesCache.getGrabProps(entity); var grabProps = entityPropertiesCache.getGrabProps(entity);
var refCount = grabProps.refCount ? grabProps.refCount : 0; var refCount = grabProps.refCount ? grabProps.refCount : 0;
@ -1571,7 +1575,7 @@ function MyController(hand) {
// potentialFarTriggerEntity = entity; // potentialFarTriggerEntity = entity;
} }
} else if (this.entityIsDistanceGrabbable(rayPickInfo.entityID, handPosition)) { } else if (this.entityIsDistanceGrabbable(rayPickInfo.entityID, handPosition)) {
if (this.triggerSmoothedGrab() && !isEditing()) { if (this.triggerSmoothedGrab() && !isEditing() && farGrabEnabled) {
this.grabbedEntity = entity; this.grabbedEntity = entity;
this.setState(STATE_DISTANCE_HOLDING, "distance hold '" + name + "'"); this.setState(STATE_DISTANCE_HOLDING, "distance hold '" + name + "'");
return; return;
@ -1589,7 +1593,9 @@ function MyController(hand) {
equipHotspotBuddy.highlightHotspot(potentialEquipHotspot); equipHotspotBuddy.highlightHotspot(potentialEquipHotspot);
} }
if (farGrabEnabled) {
this.searchIndicatorOn(rayPickInfo.searchRay); this.searchIndicatorOn(rayPickInfo.searchRay);
}
Reticle.setVisible(false); Reticle.setVisible(false);
}; };
@ -2219,9 +2225,11 @@ function MyController(hand) {
if (intersection.intersects) { if (intersection.intersects) {
this.intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection); this.intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection);
} }
if (farGrabEnabled) {
this.searchIndicatorOn(pickRay); this.searchIndicatorOn(pickRay);
} }
} }
}
this.callEntityMethodOnGrabbed("continueFarTrigger"); this.callEntityMethodOnGrabbed("continueFarTrigger");
}; };
@ -2327,7 +2335,9 @@ function MyController(hand) {
} }
this.intersectionDistance = intersectInfo.distance; this.intersectionDistance = intersectInfo.distance;
if (farGrabEnabled) {
this.searchIndicatorOn(intersectInfo.searchRay); this.searchIndicatorOn(intersectInfo.searchRay);
}
Reticle.setVisible(false); Reticle.setVisible(false);
} else { } else {
this.setState(STATE_OFF, "grabbed entity was destroyed"); this.setState(STATE_OFF, "grabbed entity was destroyed");
@ -2681,6 +2691,7 @@ function update(deltaTime) {
entityPropertiesCache.update(); entityPropertiesCache.update();
} }
Messages.subscribe('Hifi-Grab-Disable');
Messages.subscribe('Hifi-Hand-Disabler'); Messages.subscribe('Hifi-Hand-Disabler');
Messages.subscribe('Hifi-Hand-Grab'); Messages.subscribe('Hifi-Hand-Grab');
Messages.subscribe('Hifi-Hand-RayPick-Blacklist'); Messages.subscribe('Hifi-Hand-RayPick-Blacklist');