get multi-near-grabs working again

This commit is contained in:
Seth Alves 2016-01-29 18:36:22 -08:00
parent 9a16bc7d22
commit 6697b5ae5f

View file

@ -662,7 +662,8 @@ function MyController(hand) {
}; };
this.propsArePhysical = function(props) { this.propsArePhysical = function(props) {
if (!props.dynamic) { if (!props.dynamic && props.parentID != MyAvatar.sessionUUID) {
// if we have parented something, don't do this check on dynamic.
return false; return false;
} }
var isPhysical = (props.shapeType && props.shapeType != 'none'); var isPhysical = (props.shapeType && props.shapeType != 'none');
@ -809,6 +810,7 @@ function MyController(hand) {
for (i = 0; i < candidateEntities.length; i++) { for (i = 0; i < candidateEntities.length; i++) {
var grabbableDataForCandidate = var grabbableDataForCandidate =
getEntityCustomData(GRABBABLE_DATA_KEY, candidateEntities[i], DEFAULT_GRABBABLE_DATA); getEntityCustomData(GRABBABLE_DATA_KEY, candidateEntities[i], DEFAULT_GRABBABLE_DATA);
var grabDataForCandidate = getEntityCustomData(GRAB_USER_DATA_KEY, candidateEntities[i], {});
var propsForCandidate = Entities.getEntityProperties(candidateEntities[i], GRABBABLE_PROPERTIES); var propsForCandidate = Entities.getEntityProperties(candidateEntities[i], GRABBABLE_PROPERTIES);
var isPhysical = this.propsArePhysical(propsForCandidate); var isPhysical = this.propsArePhysical(propsForCandidate);
@ -817,8 +819,12 @@ function MyController(hand) {
// physical things default to grabbable // physical things default to grabbable
grabbable = true; grabbable = true;
} else { } else {
// non-physical things default to non-grabbable // non-physical things default to non-grabbable unless they are already grabbed
grabbable = false; if ("refCount" in grabDataForCandidate && grabDataForCandidate.refCount > 0) {
grabbable = true;
} else {
grabbable = false;
}
} }
if ("grabbable" in grabbableDataForCandidate) { if ("grabbable" in grabbableDataForCandidate) {
// if userData indicates that this is grabbable or not, override the default. // if userData indicates that this is grabbable or not, override the default.
@ -871,7 +877,7 @@ function MyController(hand) {
return; return;
} }
// near grab or equip with action // near grab or equip with action
if (isPhysical && near) { if (near) {
this.setState(this.state == STATE_SEARCHING ? STATE_NEAR_GRABBING : STATE_EQUIP); this.setState(this.state == STATE_SEARCHING ? STATE_NEAR_GRABBING : STATE_EQUIP);
return; return;
} }
@ -899,9 +905,12 @@ function MyController(hand) {
return; return;
} }
// else this thing isn't physical. grab it by reparenting it. // else this thing isn't physical. grab it by reparenting it (but not if we've already
this.setState(this.state == STATE_SEARCHING ? STATE_NEAR_GRABBING : STATE_EQUIP); // grabbed it).
return; if (grabbableData.refCount < 1) {
this.setState(this.state == STATE_SEARCHING ? STATE_NEAR_GRABBING : STATE_EQUIP);
return;
}
} }
//search line visualizations //search line visualizations