mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 16:30:39 +02:00
use parenting for near-grabbing
This commit is contained in:
parent
7f11d2a4fe
commit
da7aed8666
1 changed files with 28 additions and 52 deletions
|
@ -90,6 +90,7 @@ var ZERO_VEC = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var NULL_ACTION_ID = "{00000000-0000-0000-000000000000}";
|
var NULL_ACTION_ID = "{00000000-0000-0000-000000000000}";
|
||||||
|
var NULL_PARENT_ID = "{00000000-0000-0000-000000000000}";
|
||||||
var MSEC_PER_SEC = 1000.0;
|
var MSEC_PER_SEC = 1000.0;
|
||||||
|
|
||||||
// these control how long an abandoned pointer line or action will hang around
|
// these control how long an abandoned pointer line or action will hang around
|
||||||
|
@ -672,7 +673,9 @@ function MyController(hand) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//this.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
//this.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
||||||
this.overlayLineOn(distantPickRay.origin, Vec3.sum(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH)), NO_INTERSECT_COLOR);
|
this.overlayLineOn(distantPickRay.origin,
|
||||||
|
Vec3.sum(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH)),
|
||||||
|
NO_INTERSECT_COLOR);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.distanceHolding = function() {
|
this.distanceHolding = function() {
|
||||||
|
@ -696,7 +699,6 @@ function MyController(hand) {
|
||||||
this.radiusScalar = 1.0;
|
this.radiusScalar = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.actionID = NULL_ACTION_ID;
|
|
||||||
this.actionID = Entities.addAction("spring", this.grabbedEntity, {
|
this.actionID = Entities.addAction("spring", this.grabbedEntity, {
|
||||||
targetPosition: this.currentObjectPosition,
|
targetPosition: this.currentObjectPosition,
|
||||||
linearTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
|
linearTimeScale: DISTANCE_HOLDING_ACTION_TIMEFRAME,
|
||||||
|
@ -879,42 +881,27 @@ function MyController(hand) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.actionID = NULL_ACTION_ID;
|
this.actionID = NULL_ACTION_ID;
|
||||||
this.actionID = Entities.addAction("hold", this.grabbedEntity, {
|
Entities.editEntity(this.grabbedEntity, {
|
||||||
hand: this.hand === RIGHT_HAND ? "right" : "left",
|
parentID: MyAvatar.sessionUUID,
|
||||||
timeScale: NEAR_GRABBING_ACTION_TIMEFRAME,
|
parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "RightHand" : "LeftHand")
|
||||||
relativePosition: this.offsetPosition,
|
|
||||||
relativeRotation: this.offsetRotation,
|
|
||||||
ttl: ACTION_TTL,
|
|
||||||
kinematic: NEAR_GRABBING_KINEMATIC,
|
|
||||||
kinematicSetVelocity: true,
|
|
||||||
ignoreIK: this.ignoreIK
|
|
||||||
});
|
});
|
||||||
if (this.actionID === NULL_ACTION_ID) {
|
|
||||||
this.actionID = null;
|
|
||||||
} else {
|
|
||||||
this.actionTimeout = now + (ACTION_TTL * MSEC_PER_SEC);
|
|
||||||
if (this.state == STATE_NEAR_GRABBING) {
|
if (this.state == STATE_NEAR_GRABBING) {
|
||||||
this.setState(STATE_CONTINUE_NEAR_GRABBING);
|
this.setState(STATE_CONTINUE_NEAR_GRABBING);
|
||||||
} else {
|
} else {
|
||||||
// equipping
|
// equipping
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "startEquip", [JSON.stringify(this.hand)]);
|
Entities.callEntityMethod(this.grabbedEntity, "startEquip", [JSON.stringify(this.hand)]);
|
||||||
this.startHandGrasp();
|
this.startHandGrasp();
|
||||||
|
|
||||||
this.setState(STATE_CONTINUE_EQUIP_BD);
|
this.setState(STATE_CONTINUE_EQUIP_BD);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hand === RIGHT_HAND) {
|
if (this.hand === RIGHT_HAND) {
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "setRightHand");
|
Entities.callEntityMethod(this.grabbedEntity, "setRightHand");
|
||||||
} else {
|
} else {
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
||||||
}
|
}
|
||||||
|
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "setHand", [this.hand]);
|
Entities.callEntityMethod(this.grabbedEntity, "setHand", [this.hand]);
|
||||||
|
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "startNearGrab");
|
Entities.callEntityMethod(this.grabbedEntity, "startNearGrab");
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentHandControllerTipPosition =
|
this.currentHandControllerTipPosition =
|
||||||
(this.hand === RIGHT_HAND) ? MyAvatar.rightHandTipPosition : MyAvatar.leftHandTipPosition;
|
(this.hand === RIGHT_HAND) ? MyAvatar.rightHandTipPosition : MyAvatar.leftHandTipPosition;
|
||||||
|
|
||||||
|
@ -961,21 +948,6 @@ function MyController(hand) {
|
||||||
if (this.state === STATE_CONTINUE_EQUIP_BD) {
|
if (this.state === STATE_CONTINUE_EQUIP_BD) {
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "continueEquip");
|
Entities.callEntityMethod(this.grabbedEntity, "continueEquip");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.actionTimeout - now < ACTION_TTL_REFRESH * MSEC_PER_SEC) {
|
|
||||||
// if less than a 5 seconds left, refresh the actions ttl
|
|
||||||
Entities.updateAction(this.grabbedEntity, this.actionID, {
|
|
||||||
hand: this.hand === RIGHT_HAND ? "right" : "left",
|
|
||||||
timeScale: NEAR_GRABBING_ACTION_TIMEFRAME,
|
|
||||||
relativePosition: this.offsetPosition,
|
|
||||||
relativeRotation: this.offsetRotation,
|
|
||||||
ttl: ACTION_TTL,
|
|
||||||
kinematic: NEAR_GRABBING_KINEMATIC,
|
|
||||||
kinematicSetVelocity: true,
|
|
||||||
ignoreIK: this.ignoreIK
|
|
||||||
});
|
|
||||||
this.actionTimeout = now + (ACTION_TTL * MSEC_PER_SEC);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.waitingForBumperRelease = function() {
|
this.waitingForBumperRelease = function() {
|
||||||
|
@ -1187,6 +1159,11 @@ function MyController(hand) {
|
||||||
if (this.actionID !== null) {
|
if (this.actionID !== null) {
|
||||||
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Entities.editEntity(this.grabbedEntity, {
|
||||||
|
parentID: NULL_PARENT_ID,
|
||||||
|
parentJointIndex: 0
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.deactivateEntity(this.grabbedEntity);
|
this.deactivateEntity(this.grabbedEntity);
|
||||||
|
@ -1315,7 +1292,6 @@ function update() {
|
||||||
Messages.subscribe('Hifi-Hand-Disabler');
|
Messages.subscribe('Hifi-Hand-Disabler');
|
||||||
|
|
||||||
handleHandDisablerMessages = function(channel, message, sender) {
|
handleHandDisablerMessages = function(channel, message, sender) {
|
||||||
|
|
||||||
if (sender === MyAvatar.sessionUUID) {
|
if (sender === MyAvatar.sessionUUID) {
|
||||||
if (message === 'left') {
|
if (message === 'left') {
|
||||||
handToDisable = LEFT_HAND;
|
handToDisable = LEFT_HAND;
|
||||||
|
|
Loading…
Reference in a new issue