Showing the changes to libraries/physics/src/EntityMotionState.cpp (1 of 12 files). Show all
Unified · Split
| @@ -22,7 +22,8 @@ · 21 unmodified lines | |||
| 22 | #ifdef WANT_DEBUG_ENTITY_TREE_LOCKS | 22 | #ifdef WANT_DEBUG_ENTITY_TREE_LOCKS |
| 23 | #include "EntityTree.h" | 23 | #include "EntityTree.h" |
| 24 | #endif | 24 | #endif |
| 25 | const char* plankyBlock = "PlankyBlock46"; // adebug | 25 | //const char* plankyBlock = "PlankyBlock46"; // adebug |
| 26 | const char* plankyBlock = "magenta"; // adebug | ||
| 26 | 27 | ||
| 27 | static const float ACCELERATION_EQUIVALENT_EPSILON_RATIO = 0.1f; | 28 | static const float ACCELERATION_EQUIVALENT_EPSILON_RATIO = 0.1f; |
| 28 | static const quint8 STEPS_TO_DECIDE_BALLISTIC = 4; | 29 | static const quint8 STEPS_TO_DECIDE_BALLISTIC = 4; |
| @@ -97,17 +98,17 @@ void EntityMotionState::updateServerPhysicsVariables() { · 68 unmodified lines | |||
| 97 | // virtual | 98 | // virtual |
| 98 | void EntityMotionState::handleEasyChanges(uint32_t flags, PhysicsEngine* engine) { | 99 | void EntityMotionState::handleEasyChanges(uint32_t flags, PhysicsEngine* engine) { |
| 99 | assert(entityTreeIsLocked()); | 100 | assert(entityTreeIsLocked()); |
| 100 | if (_entity && _entity->getName() == plankyBlock) { | 101 | // if (_entity && _entity->getName() == plankyBlock) { |
| 101 | quint64 dt = (usecTimestampNow() - _activationTime) / 1000; // adebug | 102 | // quint64 dt = (usecTimestampNow() - _activationTime) / 1000; // adebug |
| 102 | std::cout << "adebug handleEasyChanges flags = 0x" << std::hex << flags << std::dec << " dt = " << dt << std::endl; // adebug | 103 | // std::cout << "adebug handleEasyChanges flags = 0x" << std::hex << flags << std::dec << " dt = " << dt << std::endl; // adebug |
| 103 | } | 104 | // } |
| 104 | updateServerPhysicsVariables(); | 105 | updateServerPhysicsVariables(); |
| 105 | ObjectMotionState::handleEasyChanges(flags, engine); | 106 | ObjectMotionState::handleEasyChanges(flags, engine); |
| 106 | 107 | ||
| 107 | if (flags & EntityItem::DIRTY_SIMULATOR_ID) { | 108 | if (flags & EntityItem::DIRTY_SIMULATOR_ID) { |
| 108 | if (_entity && _entity->getName() == plankyBlock) { | 109 | // if (_entity && _entity->getName() == plankyBlock) { |
| 109 | std::cout << "adebug handleEasyChanges() '" << _entity->getName().toStdString() << "' found DIRTY_SIMULATOR_ID flag" << std::endl; // adebug | 110 | // std::cout << "adebug handleEasyChanges() '" << _entity->getName().toStdString() << "' found DIRTY_SIMULATOR_ID flag" << std::endl; // adebug |
| 110 | } | 111 | // } |
| 111 | _loopsWithoutOwner = 0; | 112 | _loopsWithoutOwner = 0; |
| 112 | if (_entity->getSimulatorID().isNull()) { | 113 | if (_entity->getSimulatorID().isNull()) { |
| 113 | // simulation ownership is being removed | 114 | // simulation ownership is being removed |
| @@ -116,9 +117,9 @@ void EntityMotionState::handleEasyChanges(uint32_t flags, PhysicsEngine* engine) · 2 unmodified lines | |||
| 116 | flags &= ~EntityItem::DIRTY_PHYSICS_ACTIVATION; | 117 | flags &= ~EntityItem::DIRTY_PHYSICS_ACTIVATION; |
| 117 | // hint to Bullet that the object is deactivating | 118 | // hint to Bullet that the object is deactivating |
| 118 | _body->setActivationState(WANTS_DEACTIVATION); | 119 | _body->setActivationState(WANTS_DEACTIVATION); |
| 119 | if (_entity && _entity->getName() == plankyBlock) { | 120 | // if (_entity && _entity->getName() == plankyBlock) { |
| 120 | std::cout << "adebug handleEasyChanges() '" << _entity->getName().toStdString() << "' clearing ownership so _candidatePriority goes to 0" << std::endl; // adebug | 121 | // std::cout << "adebug handleEasyChanges() '" << _entity->getName().toStdString() << "' clearing ownership so _candidatePriority goes to 0" << std::endl; // adebug |
| 121 | } | 122 | // } |
| 122 | _candidatePriority = 0; | 123 | _candidatePriority = 0; |
| 123 | if (_expectedOwnership != -1) { | 124 | if (_expectedOwnership != -1) { |
| 124 | std::cout << "adebug unexpected loss of ownership '" << _entity->getName().toStdString() << "' expected -1 but got " << _expectedOwnership << std::endl; // adebug | 125 | std::cout << "adebug unexpected loss of ownership '" << _entity->getName().toStdString() << "' expected -1 but got " << _expectedOwnership << std::endl; // adebug |
| @@ -128,9 +129,9 @@ void EntityMotionState::handleEasyChanges(uint32_t flags, PhysicsEngine* engine) · 3 unmodified lines | |||
| 128 | _nextOwnershipBid = usecTimestampNow() + USECS_BETWEEN_OWNERSHIP_BIDS; | 129 | _nextOwnershipBid = usecTimestampNow() + USECS_BETWEEN_OWNERSHIP_BIDS; |
| 129 | if (engine->getSessionID() == _entity->getSimulatorID() || _entity->getSimulatorPriority() > _candidatePriority) { | 130 | if (engine->getSessionID() == _entity->getSimulatorID() || _entity->getSimulatorPriority() > _candidatePriority) { |
| 130 | // we own the simulation or our priority looses to remote | 131 | // we own the simulation or our priority looses to remote |
| 131 | if (_entity && _entity->getName() == plankyBlock) { | 132 | // if (_entity && _entity->getName() == plankyBlock) { |
| 132 | std::cout << "adebug handleEasyChanges() '" << _entity->getName().toStdString() << "' we own it so _candidatePriority goes to 0" << std::endl; // adebug | 133 | // std::cout << "adebug handleEasyChanges() '" << _entity->getName().toStdString() << "' we own it so _candidatePriority goes to 0" << std::endl; // adebug |
| 133 | } | 134 | // } |
| 134 | if (_expectedOwnership != 1) { | 135 | if (_expectedOwnership != 1) { |
| 135 | std::cout << "adebug unexpected gain of ownership '" << _entity->getName().toStdString() << "' expected 1 but got " << _expectedOwnership << " _candidatePriority = " << int(_candidatePriority) << std::endl; // adebug | 136 | std::cout << "adebug unexpected gain of ownership '" << _entity->getName().toStdString() << "' expected 1 but got " << _expectedOwnership << " _candidatePriority = " << int(_candidatePriority) << std::endl; // adebug |
| 136 | } | 137 | } |
| @@ -478,14 +479,14 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q · 341 unmodified lines | |||
| 478 | // we own the simulation but the entity has stopped, so we tell the server that we're clearing simulatorID | 479 | // we own the simulation but the entity has stopped, so we tell the server that we're clearing simulatorID |
| 479 | // but we remember that we do still own it... and rely on the server to tell us that we don't | 480 | // but we remember that we do still own it... and rely on the server to tell us that we don't |
| 480 | std::cout << "adebug releasing ownership of '" << _entity->getName().toStdString() << "' for inactivity" << std::endl; // adebug | 481 | std::cout << "adebug releasing ownership of '" << _entity->getName().toStdString() << "' for inactivity" << std::endl; // adebug |
| 481 | properties.clearSimulatorOwnership(); | 482 | properties.clearSimulationOwner(); |
| 482 | if (_entity && _entity->getName() == plankyBlock) { | 483 | if (_entity && _entity->getName() == plankyBlock) { |
| 483 | std::cout << "adebug sendUpdate() send clear ownership for '" << _entity->getName().toStdString() << "'" << std::endl; // adebug | 484 | std::cout << "adebug sendUpdate() send clear ownership for '" << _entity->getName().toStdString() << "'" << std::endl; // adebug |
| 484 | } | 485 | } |
| 485 | _expectedOwnership = -1; | 486 | _expectedOwnership = -1; |
| 486 | } else { | 487 | } else { |
| 487 | // re-assert the simulation info | 488 | // re-assert the simulation info |
| 488 | properties.setSimulatorOwnership(sessionID, _entity->getSimulatorPriority()); | 489 | properties.setSimulationOwner(sessionID, _entity->getSimulatorPriority()); |
| 489 | _expectedOwnership = 0; | 490 | _expectedOwnership = 0; |
| 490 | } | 491 | } |
| 491 | } else { | 492 | } else { |
| @@ -495,7 +496,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q · 3 unmodified lines | |||
| 495 | if (_entity && _entity->getName() == plankyBlock) { | 496 | if (_entity && _entity->getName() == plankyBlock) { |
| 496 | std::cout << "adebug sendUpdate() bid for ownership of '" << _entity->getName().toStdString() << "' dt = " << dt << " with priority " << int(bidPriority) << std::endl; // adebug | 497 | std::cout << "adebug sendUpdate() bid for ownership of '" << _entity->getName().toStdString() << "' dt = " << dt << " with priority " << int(bidPriority) << std::endl; // adebug |
| 497 | } | 498 | } |
| 498 | properties.setSimulatorOwnership(sessionID, glm::max<uint8_t>(_candidatePriority, VOLUNTEER_SIMULATOR_PRIORITY)); | 499 | properties.setSimulationOwner(sessionID, glm::max<uint8_t>(_candidatePriority, VOLUNTEER_SIMULATOR_PRIORITY)); |
| 499 | _nextOwnershipBid = now + USECS_BETWEEN_OWNERSHIP_BIDS; | 500 | _nextOwnershipBid = now + USECS_BETWEEN_OWNERSHIP_BIDS; |
| 500 | _expectedOwnership = 1; | 501 | _expectedOwnership = 1; |
| 501 | //_candidatePriority = 0; // TODO: it would be nice to not have to clear this until we get a message back that ownership has changed | 502 | //_candidatePriority = 0; // TODO: it would be nice to not have to clear this until we get a message back that ownership has changed |