add some debugging to handControllerGrab

This commit is contained in:
Seth Alves 2016-02-04 18:10:43 -08:00
parent 27711a04b9
commit ae6a5aa286

View file

@ -19,6 +19,7 @@ Script.include("../libraries/utils.js");
// //
var WANT_DEBUG = false; var WANT_DEBUG = false;
var WANT_DEBUG_STATE = false; var WANT_DEBUG_STATE = false;
var WANT_DEBUG_SEARCH_NAME = null;
// //
// these tune time-averaging and "on" value for analog trigger // these tune time-averaging and "on" value for analog trigger
@ -867,36 +868,58 @@ function MyController(hand) {
grabbable = false; 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.
grabbable = grabbableDataForCandidate.grabbable; grabbable = grabbableDataForCandidate.grabbable;
} }
if (!grabbable && !grabbableDataForCandidate.wantsTrigger) { if (!grabbable && !grabbableDataForCandidate.wantsTrigger) {
if (WANT_DEBUG_SEARCH_NAME && propsForCandidate.name == WANT_DEBUG_SEARCH_NAME) {
print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': not grabbable.");
}
continue; continue;
} }
if (forbiddenTypes.indexOf(propsForCandidate.type) >= 0) { if (forbiddenTypes.indexOf(propsForCandidate.type) >= 0) {
if (WANT_DEBUG_SEARCH_NAME && propsForCandidate.name == WANT_DEBUG_SEARCH_NAME) {
print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': forbidden entity type.");
}
continue; continue;
} }
if (propsForCandidate.locked && !grabbableDataForCandidate.wantsTrigger) { if (propsForCandidate.locked && !grabbableDataForCandidate.wantsTrigger) {
if (WANT_DEBUG_SEARCH_NAME && propsForCandidate.name == WANT_DEBUG_SEARCH_NAME) {
print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': locked and not triggerable.");
}
continue; continue;
} }
if (forbiddenNames.indexOf(propsForCandidate.name) >= 0) { if (forbiddenNames.indexOf(propsForCandidate.name) >= 0) {
if (WANT_DEBUG_SEARCH_NAME && propsForCandidate.name == WANT_DEBUG_SEARCH_NAME) {
print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': forbidden name.");
}
continue; continue;
} }
distance = Vec3.distance(propsForCandidate.position, handPosition); distance = Vec3.distance(propsForCandidate.position, handPosition);
if (distance > PICK_MAX_DISTANCE) { if (distance > PICK_MAX_DISTANCE) {
// too far away, don't grab // too far away, don't grab
if (WANT_DEBUG_SEARCH_NAME && propsForCandidate.name == WANT_DEBUG_SEARCH_NAME) {
print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': too far away.");
}
continue; continue;
} }
if (propsForCandidate.parentID != NULL_UUID && this.state == STATE_EQUIP_SEARCHING) { if (propsForCandidate.parentID != NULL_UUID && this.state == STATE_EQUIP_SEARCHING) {
// don't allow a double-equip // don't allow a double-equip
if (WANT_DEBUG_SEARCH_NAME && propsForCandidate.name == WANT_DEBUG_SEARCH_NAME) {
print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': it's a child");
}
continue; continue;
} }
if (this.state == STATE_SEARCHING && !isPhysical && distance > NEAR_PICK_MAX_DISTANCE) { if (this.state == STATE_SEARCHING && !isPhysical && distance > NEAR_PICK_MAX_DISTANCE) {
// we can't distance-grab non-physical // we can't distance-grab non-physical
if (WANT_DEBUG_SEARCH_NAME && propsForCandidate.name == WANT_DEBUG_SEARCH_NAME) {
print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': not physical and too far for near-grab");
}
continue; continue;
} }
@ -926,6 +949,9 @@ function MyController(hand) {
if ((isPhysical || this.state == STATE_EQUIP_SEARCHING) && !near) { if ((isPhysical || this.state == STATE_EQUIP_SEARCHING) && !near) {
if (entityIsGrabbedByOther(intersection.entityID)) { if (entityIsGrabbedByOther(intersection.entityID)) {
// don't distance grab something that is already grabbed. // don't distance grab something that is already grabbed.
if (WANT_DEBUG_SEARCH_NAME && props.name == WANT_DEBUG_SEARCH_NAME) {
print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': already grabbed by another.");
}
return; return;
} }
this.temporaryPositionOffset = null; this.temporaryPositionOffset = null;
@ -952,6 +978,9 @@ function MyController(hand) {
this.setState(this.state == STATE_SEARCHING ? STATE_NEAR_GRABBING : STATE_EQUIP); this.setState(this.state == STATE_SEARCHING ? STATE_NEAR_GRABBING : STATE_EQUIP);
return; return;
} }
if (WANT_DEBUG_SEARCH_NAME && props.name == WANT_DEBUG_SEARCH_NAME) {
print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': fell through.");
}
} }
//search line visualizations //search line visualizations