mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 04:58:08 +02:00
when a parented equip or grab releases and the object should fall, give it a little velocity so bullet doesn't consider it static
This commit is contained in:
parent
0c5c682887
commit
9a16bc7d22
1 changed files with 25 additions and 4 deletions
|
@ -1532,6 +1532,7 @@ function MyController(hand) {
|
||||||
this.turnLightsOff();
|
this.turnLightsOff();
|
||||||
this.turnOffVisualizations();
|
this.turnOffVisualizations();
|
||||||
|
|
||||||
|
var noVelocity = false;
|
||||||
if (this.grabbedEntity !== null) {
|
if (this.grabbedEntity !== null) {
|
||||||
if (this.actionID !== null) {
|
if (this.actionID !== null) {
|
||||||
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
||||||
|
@ -1550,11 +1551,12 @@ function MyController(hand) {
|
||||||
z: 0
|
z: 0
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
noVelocity = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.deactivateEntity(this.grabbedEntity);
|
this.deactivateEntity(this.grabbedEntity, noVelocity);
|
||||||
this.actionID = null;
|
this.actionID = null;
|
||||||
this.setState(STATE_OFF);
|
this.setState(STATE_OFF);
|
||||||
|
|
||||||
|
@ -1629,19 +1631,38 @@ function MyController(hand) {
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.deactivateEntity = function(entityID) {
|
this.deactivateEntity = function(entityID, noVelocity) {
|
||||||
var data = getEntityCustomData(GRAB_USER_DATA_KEY, entityID, {});
|
var data = getEntityCustomData(GRAB_USER_DATA_KEY, entityID, {});
|
||||||
if (data && data["refCount"]) {
|
if (data && data["refCount"]) {
|
||||||
data["refCount"] = data["refCount"] - 1;
|
data["refCount"] = data["refCount"] - 1;
|
||||||
if (data["refCount"] < 1) {
|
if (data["refCount"] < 1) {
|
||||||
Entities.editEntity(entityID, {
|
var deactiveProps = {
|
||||||
gravity: data["gravity"],
|
gravity: data["gravity"],
|
||||||
collidesWith: data["collidesWith"],
|
collidesWith: data["collidesWith"],
|
||||||
collisionless: data["collisionless"],
|
collisionless: data["collisionless"],
|
||||||
dynamic: data["dynamic"],
|
dynamic: data["dynamic"],
|
||||||
parentID: data["parentID"],
|
parentID: data["parentID"],
|
||||||
parentJointIndex: data["parentJointIndex"]
|
parentJointIndex: data["parentJointIndex"]
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// things that are held by parenting and dropped with no velocity will end up as "static" in bullet. If
|
||||||
|
// it looks like the dropped thing should fall, give it a little velocity.
|
||||||
|
var parentID = Entities.getEntityProperties(entityID, ["parentID"]).parentID;
|
||||||
|
var forceVelocity = false;
|
||||||
|
if (!noVelocity &&
|
||||||
|
parentID == MyAvatar.sessionUUID &&
|
||||||
|
Vec3.length(data["gravity"]) > 0.0 &&
|
||||||
|
data["dynamic"] &&
|
||||||
|
data["parentID"] == NULL_UUID &&
|
||||||
|
!data["collisionless"]) {
|
||||||
|
forceVelocity = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entities.editEntity(entityID, deactiveProps);
|
||||||
|
|
||||||
|
if (forceVelocity) {
|
||||||
|
Entities.editEntity(entityID, {velocity:{x:0, y:0.1, z:0}});
|
||||||
|
}
|
||||||
data = null;
|
data = null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue