From 6638b1deae8c48c1b8006d1d073198bb82682749 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 4 Jan 2018 12:07:00 -0800 Subject: [PATCH] fix bug causing sim ownership thrash --- libraries/physics/src/EntityMotionState.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index a688d521d6..8d6fdc7464 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -155,7 +155,7 @@ void EntityMotionState::handleEasyChanges(uint32_t& flags) { // (1) we own it but may need to change the priority OR... // (2) we don't own it but should bid (because a local script has been changing physics properties) uint8_t newPriority = isLocallyOwned() ? _entity->getSimulationOwner().getPriority() : _entity->getSimulationOwner().getPendingPriority(); - _outgoingPriority = glm::max(_outgoingPriority, newPriority); + upgradeOutgoingPriority(newPriority); // reset bid expiry so that we bid ASAP _nextOwnershipBid = 0; @@ -403,7 +403,8 @@ bool EntityMotionState::remoteSimulationOutOfSync(uint32_t simulationStep) { } if (_entity->dynamicDataNeedsTransmit()) { - _outgoingPriority = _entity->hasActions() ? SCRIPT_GRAB_SIMULATION_PRIORITY : SCRIPT_POKE_SIMULATION_PRIORITY; + uint8_t priority = _entity->hasActions() ? SCRIPT_GRAB_SIMULATION_PRIORITY : SCRIPT_POKE_SIMULATION_PRIORITY; + upgradeOutgoingPriority(priority); return true; } @@ -513,6 +514,9 @@ bool EntityMotionState::shouldSendUpdate(uint32_t simulationStep) { _nextOwnershipBid = usecTimestampNow() + USECS_BETWEEN_OWNERSHIP_BIDS; } return shouldBid; + } else { + // make sure _outgoingPriority is not less than current owned priority + upgradeOutgoingPriority(_entity->getSimulationPriority()); } return remoteSimulationOutOfSync(simulationStep);