add comments to make code more clear

This commit is contained in:
Andrew Meadows 2018-01-04 13:47:31 -08:00
parent a51d83c6e4
commit 01fd6dc8f6

View file

@ -503,19 +503,20 @@ bool EntityMotionState::shouldSendUpdate(uint32_t simulationStep) {
// we don't own the simulation // we don't own the simulation
// NOTE: we do not volunteer to own kinematic or static objects // NOTE: we do not volunteer to own kinematic or static objects
uint8_t insufficientPriority = _body->isStaticOrKinematicObject() ? VOLUNTEER_SIMULATION_PRIORITY : 0; uint8_t volunteerPriority = _body->isStaticOrKinematicObject() ? VOLUNTEER_SIMULATION_PRIORITY : 0;
bool shouldBid = _outgoingPriority > insufficientPriority && // but we would like to own it AND bool shouldBid = _outgoingPriority > volunteerPriority && // but we would like to own it AND
usecTimestampNow() > _nextOwnershipBid; // it is time to bid again usecTimestampNow() > _nextOwnershipBid; // it is time to bid again
if (shouldBid && _outgoingPriority < _entity->getSimulationPriority()) { if (shouldBid && _outgoingPriority < _entity->getSimulationPriority()) {
// we are insufficiently interested so clear our interest // we are insufficiently interested so clear _outgoingPriority
// and reset the bid expiry // and reset the bid expiry
_outgoingPriority = 0; _outgoingPriority = 0;
_nextOwnershipBid = usecTimestampNow() + USECS_BETWEEN_OWNERSHIP_BIDS; _nextOwnershipBid = usecTimestampNow() + USECS_BETWEEN_OWNERSHIP_BIDS;
} }
return shouldBid; return shouldBid;
} else { } else {
// make sure _outgoingPriority is not less than current owned priority // When we own the simulation: make sure _outgoingPriority is not less than current owned priority
// because: an _outgoingPriority of zero indicates that we should drop ownership when we have it.
upgradeOutgoingPriority(_entity->getSimulationPriority()); upgradeOutgoingPriority(_entity->getSimulationPriority());
} }
@ -622,8 +623,10 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
_entity->setPendingOwnershipPriority(_outgoingPriority, now); _entity->setPendingOwnershipPriority(_outgoingPriority, now);
// don't forget to remember that we have made a bid // don't forget to remember that we have made a bid
_entity->rememberHasSimulationOwnershipBid(); _entity->rememberHasSimulationOwnershipBid();
// ...then reset _outgoingPriority in preparation for the next frame // ...then reset _outgoingPriority
_outgoingPriority = 0; _outgoingPriority = 0;
// _outgoingPrioriuty will be re-computed before next bid,
// or will be set to agree with ownership priority should we win the bid
} else if (_outgoingPriority != _entity->getSimulationPriority()) { } else if (_outgoingPriority != _entity->getSimulationPriority()) {
// we own the simulation but our desired priority has changed // we own the simulation but our desired priority has changed
if (_outgoingPriority == 0) { if (_outgoingPriority == 0) {