mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-22 17:03:18 +02:00
grab.js will now ignore click-to-equip entities
This commit is contained in:
parent
e8676f63c6
commit
b5326936d8
3 changed files with 21 additions and 37 deletions
|
@ -6,11 +6,11 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
|
|
||||||
/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, Camera, print,
|
/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, Camera, print, getControllerJointIndex,
|
||||||
getControllerJointIndex, enableDispatcherModule, disableDispatcherModule, entityIsFarGrabbedByOther,
|
enableDispatcherModule, disableDispatcherModule, entityIsFarGrabbedByOther, Messages, makeDispatcherModuleParameters,
|
||||||
Messages, makeDispatcherModuleParameters, makeRunningValues, Settings, entityHasActions,
|
makeRunningValues, Settings, entityHasActions, Vec3, Overlays, flatten, Xform, getControllerWorldLocation, ensureDynamic,
|
||||||
Vec3, Overlays, flatten, Xform, getControllerWorldLocation, ensureDynamic, entityIsCloneable,
|
entityIsCloneable, cloneEntity, DISPATCHER_PROPERTIES, Uuid, unhighlightTargetEntity, isInEditMode, getGrabbableData,
|
||||||
cloneEntity, DISPATCHER_PROPERTIES, Uuid, unhighlightTargetEntity, isInEditMode, getGrabbableData
|
entityIsEquippable
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Script.include("/~/system/libraries/Xform.js");
|
Script.include("/~/system/libraries/Xform.js");
|
||||||
|
@ -767,7 +767,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
|
||||||
var entityProperties = Entities.getEntityProperties(entityID, DISPATCHER_PROPERTIES);
|
var entityProperties = Entities.getEntityProperties(entityID, DISPATCHER_PROPERTIES);
|
||||||
entityProperties.id = entityID;
|
entityProperties.id = entityID;
|
||||||
var hasEquipData = getWearableData(entityProperties);
|
var hasEquipData = getWearableData(entityProperties);
|
||||||
if (hasEquipData && entityProperties.parentID === EMPTY_PARENT_ID && !entityIsFarGrabbedByOther(entityID)) {
|
if (hasEquipData && entityIsEquippable(entityProperties)) {
|
||||||
entityProperties.id = entityID;
|
entityProperties.id = entityID;
|
||||||
var rightHandPosition = MyAvatar.getJointPosition("RightHand");
|
var rightHandPosition = MyAvatar.getJointPosition("RightHand");
|
||||||
var leftHandPosition = MyAvatar.getJointPosition("LeftHand");
|
var leftHandPosition = MyAvatar.getJointPosition("LeftHand");
|
||||||
|
|
|
@ -257,15 +257,12 @@ Grabber.prototype.pressEvent = function(event) {
|
||||||
if (isInEditMode() || HMD.active) {
|
if (isInEditMode() || HMD.active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.button !== "LEFT") {
|
if (event.button !== "LEFT") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.isAlt || event.isMeta) {
|
if (event.isAlt || event.isMeta) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Overlays.getOverlayAtPoint(Reticle.position) > 0) {
|
if (Overlays.getOverlayAtPoint(Reticle.position) > 0) {
|
||||||
// the mouse is pointing at an overlay; don't look for entities underneath the overlay.
|
// the mouse is pointing at an overlay; don't look for entities underneath the overlay.
|
||||||
return;
|
return;
|
||||||
|
@ -287,6 +284,10 @@ Grabber.prototype.pressEvent = function(event) {
|
||||||
// only grab grabbable objects
|
// only grab grabbable objects
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (props.grab.equippable) {
|
||||||
|
// don't mouse-grab click-to-equip entities (let equipEntity.js handle these)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Pointers.setRenderState(this.mouseRayEntities, "grabbed");
|
Pointers.setRenderState(this.mouseRayEntities, "grabbed");
|
||||||
Pointers.setLockEndUUID(this.mouseRayEntities, pickResults.objectID, false);
|
Pointers.setLockEndUUID(this.mouseRayEntities, pickResults.objectID, false);
|
||||||
|
|
|
@ -58,7 +58,6 @@
|
||||||
NEAR_GRAB_DISTANCE: true,
|
NEAR_GRAB_DISTANCE: true,
|
||||||
distanceBetweenPointAndEntityBoundingBox:true,
|
distanceBetweenPointAndEntityBoundingBox:true,
|
||||||
entityIsEquipped:true,
|
entityIsEquipped:true,
|
||||||
entityIsFarGrabbedByOther:true,
|
|
||||||
highlightTargetEntity:true,
|
highlightTargetEntity:true,
|
||||||
clearHighlightedEntities:true,
|
clearHighlightedEntities:true,
|
||||||
unhighlightTargetEntity:true,
|
unhighlightTargetEntity:true,
|
||||||
|
@ -323,16 +322,20 @@ isAnothersChildEntity = function (iaceProps) {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
entityIsGrabbable = function (eigProps) {
|
|
||||||
var grabbable = getGrabbableData(eigProps).grabbable;
|
entityIsEquippable = function (eieProps) {
|
||||||
|
var grabbable = getGrabbableData(eieProps).grabbable;
|
||||||
if (!grabbable ||
|
if (!grabbable ||
|
||||||
eigProps.locked ||
|
isAnothersAvatarEntity(eieProps) ||
|
||||||
isAnothersAvatarEntity(eigProps) ||
|
isAnothersChildEntity(eieProps) ||
|
||||||
isAnothersChildEntity(eigProps) ||
|
FORBIDDEN_GRAB_TYPES.indexOf(eieProps.type) >= 0) {
|
||||||
FORBIDDEN_GRAB_TYPES.indexOf(eigProps.type) >= 0) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
entityIsGrabbable = function (eigProps) {
|
||||||
|
return entityIsEquippable(eigProps) && !eigProps.locked;
|
||||||
};
|
};
|
||||||
|
|
||||||
clearHighlightedEntities = function() {
|
clearHighlightedEntities = function() {
|
||||||
|
@ -561,27 +564,6 @@ entityIsEquipped = function(entityID) {
|
||||||
return equippedInRightHand || equippedInLeftHand;
|
return equippedInRightHand || equippedInLeftHand;
|
||||||
};
|
};
|
||||||
|
|
||||||
entityIsFarGrabbedByOther = function(entityID) {
|
|
||||||
// by convention, a far grab sets the tag of its action to be far-grab-*owner-session-id*.
|
|
||||||
var actionIDs = Entities.getActionIDs(entityID);
|
|
||||||
var myFarGrabTag = "far-grab-" + MyAvatar.sessionUUID;
|
|
||||||
for (var actionIndex = 0; actionIndex < actionIDs.length; actionIndex++) {
|
|
||||||
var actionID = actionIDs[actionIndex];
|
|
||||||
var actionArguments = Entities.getActionArguments(entityID, actionID);
|
|
||||||
var tag = actionArguments.tag;
|
|
||||||
if (tag == myFarGrabTag) {
|
|
||||||
// we see a far-grab-*uuid* shaped tag, but it's our tag, so that's okay.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (tag.slice(0, 9) == "far-grab-") {
|
|
||||||
// we see a far-grab-*uuid* shaped tag and it's not ours, so someone else is grabbing it.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
worldPositionToRegistrationFrameMatrix = function(wptrProps, pos) {
|
worldPositionToRegistrationFrameMatrix = function(wptrProps, pos) {
|
||||||
// get world matrix for intersection point
|
// get world matrix for intersection point
|
||||||
var intersectionMat = new Xform({ x: 0, y: 0, z:0, w: 1 }, pos);
|
var intersectionMat = new Xform({ x: 0, y: 0, z:0, w: 1 }, pos);
|
||||||
|
@ -620,6 +602,7 @@ if (typeof module !== 'undefined') {
|
||||||
BUMPER_ON_VALUE: BUMPER_ON_VALUE,
|
BUMPER_ON_VALUE: BUMPER_ON_VALUE,
|
||||||
TEAR_AWAY_DISTANCE: TEAR_AWAY_DISTANCE,
|
TEAR_AWAY_DISTANCE: TEAR_AWAY_DISTANCE,
|
||||||
propsArePhysical: propsArePhysical,
|
propsArePhysical: propsArePhysical,
|
||||||
|
entityIsEquippable: entityIsEquippable,
|
||||||
entityIsGrabbable: entityIsGrabbable,
|
entityIsGrabbable: entityIsGrabbable,
|
||||||
NEAR_GRAB_RADIUS: NEAR_GRAB_RADIUS,
|
NEAR_GRAB_RADIUS: NEAR_GRAB_RADIUS,
|
||||||
projectOntoOverlayXYPlane: projectOntoOverlayXYPlane,
|
projectOntoOverlayXYPlane: projectOntoOverlayXYPlane,
|
||||||
|
|
Loading…
Reference in a new issue