mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
fix mouse equipping while someone else far grabbing
This commit is contained in:
parent
f7723a5bba
commit
8950c31378
2 changed files with 26 additions and 5 deletions
|
@ -802,10 +802,11 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
|
|||
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||
var intersection = Entities.findRayIntersection(pickRay, true);
|
||||
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;
|
||||
if (hasEquipData && entityProperties.parentID === EMPTY_PARENT_ID) {
|
||||
entityProperties.id = intersection.entityID;
|
||||
if (hasEquipData && entityProperties.parentID === EMPTY_PARENT_ID && !entityIsFarGrabbedByOther(entityID)) {
|
||||
entityProperties.id = entityID;
|
||||
var rightHandPosition = MyAvatar.getJointPosition("RightHand");
|
||||
var leftHandPosition = MyAvatar.getJointPosition("LeftHand");
|
||||
var distanceToRightHand = Vec3.distance(entityProperties.position, rightHandPosition);
|
||||
|
@ -815,11 +816,11 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
|
|||
var mouseEquip = true;
|
||||
if (rightHandAvailable && (distanceToRightHand < distanceToLeftHand || !leftHandAvailable)) {
|
||||
// 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);
|
||||
} else if (leftHandAvailable && (distanceToLeftHand < distanceToRightHand || !rightHandAvailable)) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -423,6 +423,26 @@ entityIsEquipped = function(entityID) {
|
|||
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') {
|
||||
module.exports = {
|
||||
makeDispatcherModuleParameters: makeDispatcherModuleParameters,
|
||||
|
|
Loading…
Reference in a new issue