don't allow someone else to delete an action that I own. reset dynamic property when releasing and entity, even if refCount isn't 0

This commit is contained in:
Seth Alves 2016-05-04 15:01:00 -07:00
parent 382a0c48da
commit 9db839bc13
4 changed files with 13 additions and 7 deletions

View file

@ -1740,6 +1740,7 @@ bool EntityItem::removeActionInternal(const QUuid& actionID, EntitySimulation* s
EntityActionPointer action = _objectActions[actionID];
action->setOwnerEntity(nullptr);
action->setIsMine(false);
_objectActions.remove(actionID);
if (simulation) {
@ -1846,8 +1847,10 @@ void EntityItem::deserializeActionsInternal() {
QUuid id = i.key();
if (!updated.contains(id)) {
EntityActionPointer action = i.value();
// if we've just added this action, don't remove it due to lack of mention in an incoming packet.
if (! action->locallyAddedButNotYetReceived) {
// don't let someone else delete my action.
if (!action->isMine() &&
// if we've just added this action, don't remove it due to lack of mention in an incoming packet.
!action->locallyAddedButNotYetReceived) {
_actionsToRemove << id;
_previouslyDeletedActions.insert(id, now);
}

View file

@ -213,8 +213,8 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
properties.setVelocityChanged(false);
properties.setAngularVelocityChanged(false);
properties.setAccelerationChanged(false);
properties.setParentID(QUuid());
properties.setParentJointIndex(false);
properties.setParentIDChanged(false);
properties.setParentJointIndexChanged(false);
if (wantTerseEditLogging()) {
qCDebug(entities) << (senderNode ? senderNode->getUUID() : "null") << "physical edits suppressed";

View file

@ -45,10 +45,9 @@ bool ObjectActionSpring::getTarget(float deltaTimeStep, glm::quat& rotation, glm
position = _desiredPositionalTarget;
linearVelocity = glm::vec3();
angularVelocity = glm::vec3();
return true;
return true;
}
bool ObjectActionSpring::prepareForSpringUpdate(btScalar deltaTimeStep) {
glm::quat rotation;
glm::vec3 position;
@ -140,10 +139,13 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) {
float speed = glm::min(offsetLength / _linearTimeScale, SPRING_MAX_SPEED);
targetVelocity = (-speed / offsetLength) * offset;
if (speed > rigidBody->getLinearSleepingThreshold()) {
qDebug() << "HERE";
forceBodyNonStatic();
rigidBody->activate();
}
}
// this action is aggresively critically damped and defeats the current velocity
qDebug() << targetVelocity.x() << targetVelocity.y() << targetVelocity.z();
rigidBody->setLinearVelocity(targetVelocity);
}

View file

@ -1895,7 +1895,8 @@ function MyController(hand) {
Entities.editEntity(entityID, deactiveProps);
} else if (noVelocity) {
Entities.editEntity(entityID, {velocity: {x: 0.0, y: 0.0, z: 0.0},
angularVelocity: {x: 0.0, y: 0.0, z: 0.0}});
angularVelocity: {x: 0.0, y: 0.0, z: 0.0},
dynamic: data["dynamic"]});
}
} else {
data = null;