fix releaseGrab call on grabbed entity when a nearGrab ends

This commit is contained in:
Seth Alves 2019-01-16 15:31:04 -08:00 committed by Andrew Meadows
parent 2bf7ac2745
commit c8e9bff03a
3 changed files with 16 additions and 12 deletions

View file

@ -11,7 +11,7 @@
Entities, enableDispatcherModule, disableDispatcherModule, entityIsGrabbable, makeDispatcherModuleParameters, MSECS_PER_SEC,
HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC,
projectOntoEntityXYPlane, ContextOverlay, HMD, Picks, makeLaserLockInfo, makeLaserParams, AddressManager,
getEntityParents, Selection, DISPATCHER_HOVERING_LIST, unhighlightTargetEntity, Messages, findGroupParent,
getEntityParents, Selection, DISPATCHER_HOVERING_LIST, unhighlightTargetEntity, Messages, findGrabbableGroupParent,
worldPositionToRegistrationFrameMatrix, DISPATCHER_PROPERTIES
*/
@ -308,7 +308,7 @@ Script.include("/~/system/libraries/controllers.js");
var gtProps = Entities.getEntityProperties(targetEntity, DISPATCHER_PROPERTIES);
if (entityIsGrabbable(gtProps)) {
// if we've attempted to grab a child, roll up to the root of the tree
var groupRootProps = findGroupParent(controllerData, gtProps);
var groupRootProps = findGrabbableGroupParent(controllerData, gtProps);
if (entityIsGrabbable(groupRootProps)) {
return groupRootProps;
}

View file

@ -8,9 +8,10 @@
/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex, enableDispatcherModule,
disableDispatcherModule, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE,
makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS, findGroupParent, Vec3, cloneEntity,
entityIsCloneable, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, distanceBetweenPointAndEntityBoundingBox,
getGrabbableData, getEnabledModuleByName, DISPATCHER_PROPERTIES, HMD, NEAR_GRAB_DISTANCE
makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS, findGrabbableGroupParent, Vec3,
cloneEntity, entityIsCloneable, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE,
distanceBetweenPointAndEntityBoundingBox, getGrabbableData, getEnabledModuleByName, DISPATCHER_PROPERTIES, HMD,
NEAR_GRAB_DISTANCE
*/
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@ -80,9 +81,6 @@ Script.include("/~/system/libraries/controllers.js");
this.endNearGrabEntity = function () {
this.endGrab();
this.grabbing = false;
this.targetEntityID = null;
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
Entities.callEntityMethod(this.targetEntityID, "releaseGrab", args);
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
@ -90,6 +88,9 @@ Script.include("/~/system/libraries/controllers.js");
grabbedEntity: this.targetEntityID,
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
}));
this.grabbing = false;
this.targetEntityID = null;
};
this.getTargetProps = function (controllerData) {
@ -110,7 +111,7 @@ Script.include("/~/system/libraries/controllers.js");
if (entityIsGrabbable(props) || entityIsCloneable(props)) {
if (!entityIsCloneable(props)) {
// if we've attempted to grab a non-cloneable child, roll up to the root of the tree
var groupRootProps = findGroupParent(controllerData, props);
var groupRootProps = findGrabbableGroupParent(controllerData, props);
if (entityIsGrabbable(groupRootProps)) {
return groupRootProps;
}

View file

@ -46,7 +46,7 @@
makeLaserLockInfo:true,
entityHasActions:true,
ensureDynamic:true,
findGroupParent:true,
findGrabbableGroupParent:true,
BUMPER_ON_VALUE:true,
getEntityParents:true,
findHandChildEntities:true,
@ -439,7 +439,7 @@ ensureDynamic = function (entityID) {
}
};
findGroupParent = function (controllerData, targetProps) {
findGrabbableGroupParent = function (controllerData, targetProps) {
while (targetProps.grab.grabDelegateToParent &&
targetProps.parentID &&
targetProps.parentID !== Uuid.NULL &&
@ -448,6 +448,9 @@ findGroupParent = function (controllerData, targetProps) {
if (!parentProps) {
break;
}
if (!entityIsGrabbable(parentProps)) {
break;
}
parentProps.id = targetProps.parentID;
targetProps = parentProps;
controllerData.nearbyEntityPropertiesByID[targetProps.id] = targetProps;
@ -614,7 +617,7 @@ if (typeof module !== 'undefined') {
unhighlightTargetEntity: unhighlightTargetEntity,
clearHighlightedEntities: clearHighlightedEntities,
makeRunningValues: makeRunningValues,
findGroupParent: findGroupParent,
findGrabbableGroupParent: findGrabbableGroupParent,
LEFT_HAND: LEFT_HAND,
RIGHT_HAND: RIGHT_HAND,
BUMPER_ON_VALUE: BUMPER_ON_VALUE,