mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 22:22:54 +02:00
Merge pull request #6277 from sethalves/adjust-distance-grab
distance grab works better with hmd on
This commit is contained in:
commit
61109d09af
1 changed files with 12 additions and 13 deletions
|
@ -352,14 +352,14 @@ function MyController(hand) {
|
||||||
|
|
||||||
var intersection = Entities.findRayIntersection(pickRayBacked, true);
|
var intersection = Entities.findRayIntersection(pickRayBacked, true);
|
||||||
|
|
||||||
if (intersection.intersects && intersection.properties.locked === 0) {
|
if (intersection.intersects && !intersection.properties.locked) {
|
||||||
// the ray is intersecting something we can move.
|
// the ray is intersecting something we can move.
|
||||||
var intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection);
|
var intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection);
|
||||||
this.grabbedEntity = intersection.entityID;
|
this.grabbedEntity = intersection.entityID;
|
||||||
|
|
||||||
//this code will disabled the beam for the opposite hand of the one that grabbed it if the entity says so
|
//this code will disabled the beam for the opposite hand of the one that grabbed it if the entity says so
|
||||||
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, intersection.entityID, DEFAULT_GRABBABLE_DATA);
|
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, intersection.entityID, DEFAULT_GRABBABLE_DATA);
|
||||||
if (grabbableData["turnOffOppositeBeam"] === true) {
|
if (grabbableData["turnOffOppositeBeam"]) {
|
||||||
if (this.hand === RIGHT_HAND) {
|
if (this.hand === RIGHT_HAND) {
|
||||||
disabledHand = LEFT_HAND;
|
disabledHand = LEFT_HAND;
|
||||||
} else {
|
} else {
|
||||||
|
@ -369,7 +369,7 @@ function MyController(hand) {
|
||||||
disabledHand = 'none';
|
disabledHand = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grabbableData.grabbable === false) {
|
if (!grabbableData.grabbable) {
|
||||||
this.grabbedEntity = null;
|
this.grabbedEntity = null;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ function MyController(hand) {
|
||||||
this.grabbedEntity = null;
|
this.grabbedEntity = null;
|
||||||
} else {
|
} else {
|
||||||
// the hand is far from the intersected object. go into distance-holding mode
|
// the hand is far from the intersected object. go into distance-holding mode
|
||||||
if (intersection.properties.collisionsWillMove === 1) {
|
if (intersection.properties.collisionsWillMove) {
|
||||||
this.setState(STATE_DISTANCE_HOLDING);
|
this.setState(STATE_DISTANCE_HOLDING);
|
||||||
} else {
|
} else {
|
||||||
this.setState(STATE_FAR_GRABBING_NON_COLLIDING);
|
this.setState(STATE_FAR_GRABBING_NON_COLLIDING);
|
||||||
|
@ -409,7 +409,7 @@ function MyController(hand) {
|
||||||
for (i = 0; i < nearbyEntities.length; i++) {
|
for (i = 0; i < nearbyEntities.length; i++) {
|
||||||
var grabbableDataForCandidate =
|
var grabbableDataForCandidate =
|
||||||
getEntityCustomData(GRABBABLE_DATA_KEY, nearbyEntities[i], DEFAULT_GRABBABLE_DATA);
|
getEntityCustomData(GRABBABLE_DATA_KEY, nearbyEntities[i], DEFAULT_GRABBABLE_DATA);
|
||||||
if (grabbableDataForCandidate.grabbable === false) {
|
if (!grabbableDataForCandidate.grabbable) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var propsForCandidate =
|
var propsForCandidate =
|
||||||
|
@ -427,7 +427,7 @@ function MyController(hand) {
|
||||||
}
|
}
|
||||||
if (grabbableData.wantsTrigger) {
|
if (grabbableData.wantsTrigger) {
|
||||||
this.setState(STATE_NEAR_GRABBING_NON_COLLIDING);
|
this.setState(STATE_NEAR_GRABBING_NON_COLLIDING);
|
||||||
} else if (props.locked === 0) {
|
} else if (!props.locked) {
|
||||||
this.setState(STATE_NEAR_GRABBING);
|
this.setState(STATE_NEAR_GRABBING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -446,7 +446,7 @@ function MyController(hand) {
|
||||||
this.currentObjectPosition = grabbedProperties.position;
|
this.currentObjectPosition = grabbedProperties.position;
|
||||||
this.currentObjectRotation = grabbedProperties.rotation;
|
this.currentObjectRotation = grabbedProperties.rotation;
|
||||||
this.currentObjectTime = now;
|
this.currentObjectTime = now;
|
||||||
this.handPreviousPosition = handControllerPosition;
|
this.handRelativePreviousPosition = Vec3.subtract(handControllerPosition, MyAvatar.position);
|
||||||
this.handPreviousRotation = handRotation;
|
this.handPreviousRotation = handRotation;
|
||||||
|
|
||||||
this.actionID = NULL_ACTION_ID;
|
this.actionID = NULL_ACTION_ID;
|
||||||
|
@ -523,11 +523,10 @@ function MyController(hand) {
|
||||||
this.currentAvatarOrientation = currentOrientation;
|
this.currentAvatarOrientation = currentOrientation;
|
||||||
|
|
||||||
// how far did hand move this timestep?
|
// how far did hand move this timestep?
|
||||||
var handMoved = Vec3.subtract(handControllerPosition, this.handPreviousPosition);
|
var handMoved = Vec3.subtract(handToAvatar, this.handRelativePreviousPosition);
|
||||||
this.handPreviousPosition = handControllerPosition;
|
this.handRelativePreviousPosition = handToAvatar;
|
||||||
|
|
||||||
// magnify the hand movement but not the change from avatar movement & rotation
|
// magnify the hand movement but not the change from avatar movement & rotation
|
||||||
handMoved = Vec3.subtract(handMoved, avatarDeltaPosition);
|
|
||||||
handMoved = Vec3.subtract(handMoved, handMovementFromTurning);
|
handMoved = Vec3.subtract(handMoved, handMovementFromTurning);
|
||||||
var superHandMoved = Vec3.multiply(handMoved, radius);
|
var superHandMoved = Vec3.multiply(handMoved, radius);
|
||||||
|
|
||||||
|
@ -570,7 +569,7 @@ function MyController(hand) {
|
||||||
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA);
|
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA);
|
||||||
|
|
||||||
var turnOffOtherHand = grabbableData["turnOffOtherHand"];
|
var turnOffOtherHand = grabbableData["turnOffOtherHand"];
|
||||||
if (turnOffOtherHand === true) {
|
if (turnOffOtherHand) {
|
||||||
//don't activate the second hand grab because the script is handling the second hand logic
|
//don't activate the second hand grab because the script is handling the second hand logic
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -783,11 +782,11 @@ function MyController(hand) {
|
||||||
// we haven't been touched before, but either right or left is touching us now
|
// we haven't been touched before, but either right or left is touching us now
|
||||||
_this.allTouchedIDs[id] = true;
|
_this.allTouchedIDs[id] = true;
|
||||||
_this.startTouch(id);
|
_this.startTouch(id);
|
||||||
} else if ((leftIsTouching || rightIsTouching) && _this.allTouchedIDs[id] === true) {
|
} else if ((leftIsTouching || rightIsTouching) && _this.allTouchedIDs[id]) {
|
||||||
// we have been touched before and are still being touched
|
// we have been touched before and are still being touched
|
||||||
// continue touch
|
// continue touch
|
||||||
_this.continueTouch(id);
|
_this.continueTouch(id);
|
||||||
} else if (_this.allTouchedIDs[id] === true) {
|
} else if (_this.allTouchedIDs[id]) {
|
||||||
delete _this.allTouchedIDs[id];
|
delete _this.allTouchedIDs[id];
|
||||||
_this.stopTouch(id);
|
_this.stopTouch(id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue