mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
Merge pull request #9347 from sethalves/tablet-ui-grab-no-patch
remember previous parentID in the script and try to put it back when releasing
This commit is contained in:
commit
85c143e64d
1 changed files with 28 additions and 13 deletions
|
@ -1523,7 +1523,8 @@ function MyController(hand) {
|
|||
this.grabbedEntity = null;
|
||||
this.grabbedOverlay = null;
|
||||
this.isInitialGrab = false;
|
||||
this.shouldResetParentOnRelease = false;
|
||||
this.previousParentID = NULL_UUID;
|
||||
this.previousParentJointIndex = -1;
|
||||
this.preparingHoldRelease = false;
|
||||
|
||||
this.checkForStrayChildren();
|
||||
|
@ -1594,10 +1595,6 @@ function MyController(hand) {
|
|||
// If near something grabbable, grab it!
|
||||
if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && nearGrabEnabled) {
|
||||
this.setState(STATE_NEAR_GRABBING, "near grab '" + name + "'");
|
||||
var props = entityPropertiesCache.getProps(entity);
|
||||
this.shouldResetParentOnRelease = true;
|
||||
this.previousParentID = props.parentID;
|
||||
this.previousParentJointIndex = props.parentJointIndex;
|
||||
return;
|
||||
} else {
|
||||
// potentialNearGrabEntity = entity;
|
||||
|
@ -2271,7 +2268,7 @@ function MyController(hand) {
|
|||
}
|
||||
|
||||
var isPhysical = propsArePhysical(grabbedProperties) || entityHasActions(this.grabbedEntity);
|
||||
if (isPhysical && this.state == STATE_NEAR_GRABBING) {
|
||||
if (isPhysical && this.state == STATE_NEAR_GRABBING && grabbedProperties.parentID === NULL_UUID) {
|
||||
// grab entity via action
|
||||
if (!this.setupHoldAction()) {
|
||||
return;
|
||||
|
@ -2305,6 +2302,15 @@ function MyController(hand) {
|
|||
}
|
||||
Entities.editEntity(this.grabbedEntity, reparentProps);
|
||||
|
||||
this.previousParentID = grabbedProperties.parentID;
|
||||
this.previousParentJointIndex = grabbedProperties.parentJointIndex;
|
||||
if (grabbedProperties.parentID === MyAvatar.sessionUUID &&
|
||||
this.getOtherHandController().state == STATE_NEAR_GRABBING) {
|
||||
// one hand took it from the other
|
||||
this.previousParentID = NULL_UUID;
|
||||
this.previousParentJointIndex = -1;
|
||||
}
|
||||
|
||||
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||
action: 'equip',
|
||||
grabbedEntity: this.grabbedEntity,
|
||||
|
@ -2845,13 +2851,22 @@ function MyController(hand) {
|
|||
Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
|
||||
if (this.actionID !== null) {
|
||||
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
||||
}
|
||||
|
||||
if (this.shouldResetParentOnRelease) {
|
||||
Entities.editEntity(this.grabbedEntity, {
|
||||
parentID: this.previousParentID,
|
||||
parentJointIndex: this.previousParentJointIndex
|
||||
});
|
||||
} else {
|
||||
// no action, so it's a parenting grab
|
||||
if (this.previousParentID === NULL_UUID) {
|
||||
Entities.editEntity(this.grabbedEntity, {
|
||||
parentID: this.previousParentID,
|
||||
parentJointIndex: this.previousParentJointIndex
|
||||
});
|
||||
} else {
|
||||
// we're putting this back as a child of some other parent, so zero its velocity
|
||||
Entities.editEntity(this.grabbedEntity, {
|
||||
parentID: this.previousParentID,
|
||||
parentJointIndex: this.previousParentJointIndex,
|
||||
velocity: {x: 0, y: 0, z: 0},
|
||||
angularVelocity: {x: 0, y: 0, z: 0}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
|
||||
|
|
Loading…
Reference in a new issue