History

SimulationOwner as one property

Andrew Meadows committed 11 years ago

Commit 12fc1801 parent b6d5ada12 files · +435 −332Browse files

Showing the changes to libraries/physics/src/EntityMotionState.cpp (1 of 12 files). Show all

Unified · Split

libraries/physics/src/EntityMotionState.cpp+18−17
@@ -22,7 +22,8 @@ · 21 unmodified lines
2222 #ifdef WANT_DEBUG_ENTITY_TREE_LOCKS
2323 #include "EntityTree.h"
2424 #endif
25−const char* plankyBlock = "PlankyBlock46"; // adebug
25+//const char* plankyBlock = "PlankyBlock46"; // adebug
26+const char* plankyBlock = "magenta"; // adebug
2627
2728 static const float ACCELERATION_EQUIVALENT_EPSILON_RATIO = 0.1f;
2829 static const quint8 STEPS_TO_DECIDE_BALLISTIC = 4;
@@ -97,17 +98,17 @@ void EntityMotionState::updateServerPhysicsVariables() { · 68 unmodified lines
9798 // virtual
9899 void EntityMotionState::handleEasyChanges(uint32_t flags, PhysicsEngine* engine) {
99100 assert(entityTreeIsLocked());
100− if (_entity && _entity->getName() == plankyBlock) {
101− quint64 dt = (usecTimestampNow() - _activationTime) / 1000; // adebug
102− std::cout << "adebug handleEasyChanges flags = 0x" << std::hex << flags << std::dec << " dt = " << dt << std::endl; // adebug
103− }
101+// if (_entity && _entity->getName() == plankyBlock) {
102+// quint64 dt = (usecTimestampNow() - _activationTime) / 1000; // adebug
103+// std::cout << "adebug handleEasyChanges flags = 0x" << std::hex << flags << std::dec << " dt = " << dt << std::endl; // adebug
104+// }
104105 updateServerPhysicsVariables();
105106 ObjectMotionState::handleEasyChanges(flags, engine);
106107
107108 if (flags & EntityItem::DIRTY_SIMULATOR_ID) {
108− if (_entity && _entity->getName() == plankyBlock) {
109− std::cout << "adebug handleEasyChanges() '" << _entity->getName().toStdString() << "' found DIRTY_SIMULATOR_ID flag" << std::endl; // adebug
110− }
109+// if (_entity && _entity->getName() == plankyBlock) {
110+// std::cout << "adebug handleEasyChanges() '" << _entity->getName().toStdString() << "' found DIRTY_SIMULATOR_ID flag" << std::endl; // adebug
111+// }
111112 _loopsWithoutOwner = 0;
112113 if (_entity->getSimulatorID().isNull()) {
113114 // simulation ownership is being removed
@@ -116,9 +117,9 @@ void EntityMotionState::handleEasyChanges(uint32_t flags, PhysicsEngine* engine) · 2 unmodified lines
116117 flags &= ~EntityItem::DIRTY_PHYSICS_ACTIVATION;
117118 // hint to Bullet that the object is deactivating
118119 _body->setActivationState(WANTS_DEACTIVATION);
119− if (_entity && _entity->getName() == plankyBlock) {
120− std::cout << "adebug handleEasyChanges() '" << _entity->getName().toStdString() << "' clearing ownership so _candidatePriority goes to 0" << std::endl; // adebug
121− }
120+// if (_entity && _entity->getName() == plankyBlock) {
121+// std::cout << "adebug handleEasyChanges() '" << _entity->getName().toStdString() << "' clearing ownership so _candidatePriority goes to 0" << std::endl; // adebug
122+// }
122123 _candidatePriority = 0;
123124 if (_expectedOwnership != -1) {
124125 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
128129 _nextOwnershipBid = usecTimestampNow() + USECS_BETWEEN_OWNERSHIP_BIDS;
129130 if (engine->getSessionID() == _entity->getSimulatorID() || _entity->getSimulatorPriority() > _candidatePriority) {
130131 // we own the simulation or our priority looses to remote
131− 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− }
132+// if (_entity && _entity->getName() == plankyBlock) {
133+// std::cout << "adebug handleEasyChanges() '" << _entity->getName().toStdString() << "' we own it so _candidatePriority goes to 0" << std::endl; // adebug
134+// }
134135 if (_expectedOwnership != 1) {
135136 std::cout << "adebug unexpected gain of ownership '" << _entity->getName().toStdString() << "' expected 1 but got " << _expectedOwnership << " _candidatePriority = " << int(_candidatePriority) << std::endl; // adebug
136137 }
@@ -478,14 +479,14 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q · 341 unmodified lines
478479 // we own the simulation but the entity has stopped, so we tell the server that we're clearing simulatorID
479480 // but we remember that we do still own it... and rely on the server to tell us that we don't
480481 std::cout << "adebug releasing ownership of '" << _entity->getName().toStdString() << "' for inactivity" << std::endl; // adebug
481− properties.clearSimulatorOwnership();
482+ properties.clearSimulationOwner();
482483 if (_entity && _entity->getName() == plankyBlock) {
483484 std::cout << "adebug sendUpdate() send clear ownership for '" << _entity->getName().toStdString() << "'" << std::endl; // adebug
484485 }
485486 _expectedOwnership = -1;
486487 } else {
487488 // re-assert the simulation info
488− properties.setSimulatorOwnership(sessionID, _entity->getSimulatorPriority());
489+ properties.setSimulationOwner(sessionID, _entity->getSimulatorPriority());
489490 _expectedOwnership = 0;
490491 }
491492 } else {
@@ -495,7 +496,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q · 3 unmodified lines
495496 if (_entity && _entity->getName() == plankyBlock) {
496497 std::cout << "adebug sendUpdate() bid for ownership of '" << _entity->getName().toStdString() << "' dt = " << dt << " with priority " << int(bidPriority) << std::endl; // adebug
497498 }
498− properties.setSimulatorOwnership(sessionID, glm::max<uint8_t>(_candidatePriority, VOLUNTEER_SIMULATOR_PRIORITY));
499+ properties.setSimulationOwner(sessionID, glm::max<uint8_t>(_candidatePriority, VOLUNTEER_SIMULATOR_PRIORITY));
499500 _nextOwnershipBid = now + USECS_BETWEEN_OWNERSHIP_BIDS;
500501 _expectedOwnership = 1;
501502 //_candidatePriority = 0; // TODO: it would be nice to not have to clear this until we get a message back that ownership has changed