mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 00:36:30 +02:00
fix mouse equipping while someone else far grabbing
This commit is contained in:
parent
3c441f0312
commit
86b64fe3ab
2 changed files with 26 additions and 5 deletions
|
@ -796,10 +796,11 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
var intersection = Entities.findRayIntersection(pickRay, true);
|
var intersection = Entities.findRayIntersection(pickRay, true);
|
||||||
if (intersection.intersects) {
|
if (intersection.intersects) {
|
||||||
var entityProperties = Entities.getEntityProperties(intersection.entityID, DISPATCHER_PROPERTIES);
|
var entityID = intersection.entityID;
|
||||||
|
var entityProperties = Entities.getEntityProperties(entityID, DISPATCHER_PROPERTIES);
|
||||||
var hasEquipData = getWearableData(entityProperties).joints || getEquipHotspotsData(entityProperties).length > 0;
|
var hasEquipData = getWearableData(entityProperties).joints || getEquipHotspotsData(entityProperties).length > 0;
|
||||||
if (hasEquipData && entityProperties.parentID === EMPTY_PARENT_ID) {
|
if (hasEquipData && entityProperties.parentID === EMPTY_PARENT_ID && !entityIsFarGrabbedByOther(entityID)) {
|
||||||
entityProperties.id = intersection.entityID;
|
entityProperties.id = entityID;
|
||||||
var rightHandPosition = MyAvatar.getJointPosition("RightHand");
|
var rightHandPosition = MyAvatar.getJointPosition("RightHand");
|
||||||
var leftHandPosition = MyAvatar.getJointPosition("LeftHand");
|
var leftHandPosition = MyAvatar.getJointPosition("LeftHand");
|
||||||
var distanceToRightHand = Vec3.distance(entityProperties.position, rightHandPosition);
|
var distanceToRightHand = Vec3.distance(entityProperties.position, rightHandPosition);
|
||||||
|
@ -809,11 +810,11 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
|
||||||
var mouseEquip = true;
|
var mouseEquip = true;
|
||||||
if (rightHandAvailable && (distanceToRightHand < distanceToLeftHand || !leftHandAvailable)) {
|
if (rightHandAvailable && (distanceToRightHand < distanceToLeftHand || !leftHandAvailable)) {
|
||||||
// clear any existing grab actions on the entity now (their later removal could affect bootstrapping flags)
|
// clear any existing grab actions on the entity now (their later removal could affect bootstrapping flags)
|
||||||
clearGrabActions(intersection.entityID);
|
clearGrabActions(entityID);
|
||||||
rightEquipEntity.setMessageGrabData(entityProperties, mouseEquip);
|
rightEquipEntity.setMessageGrabData(entityProperties, mouseEquip);
|
||||||
} else if (leftHandAvailable && (distanceToLeftHand < distanceToRightHand || !rightHandAvailable)) {
|
} else if (leftHandAvailable && (distanceToLeftHand < distanceToRightHand || !rightHandAvailable)) {
|
||||||
// clear any existing grab actions on the entity now (their later removal could affect bootstrapping flags)
|
// clear any existing grab actions on the entity now (their later removal could affect bootstrapping flags)
|
||||||
clearGrabActions(intersection.entityID);
|
clearGrabActions(entityID);
|
||||||
leftEquipEntity.setMessageGrabData(entityProperties, mouseEquip);
|
leftEquipEntity.setMessageGrabData(entityProperties, mouseEquip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,6 +392,26 @@ 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;
|
||||||
|
};
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
makeDispatcherModuleParameters: makeDispatcherModuleParameters,
|
makeDispatcherModuleParameters: makeDispatcherModuleParameters,
|
||||||
|
|
Loading…
Reference in a new issue