adjust logic for releasing ownership of simulation

This commit is contained in:
Seth Alves 2015-04-16 15:15:28 -07:00
parent d7059d8f2d
commit d7881f1891
2 changed files with 10 additions and 4 deletions
libraries

View file

@ -41,7 +41,7 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemI
auto nodeList = DependencyManager::get<NodeList>();
QUuid myNodeID = nodeList->getSessionUUID();
QString x = properties.getSimulatorID() == myNodeID ? "me" : properties.getSimulatorID().toString();
qDebug() << "sending update:" << properties.simulatorIDChanged() << properties.getSimulatorID();
qDebug() << "sending update:" << properties.simulatorIDChanged() << x;
//// XXX

View file

@ -251,14 +251,20 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
auto nodeList = DependencyManager::get<NodeList>();
QUuid myNodeID = nodeList->getSessionUUID();
QUuid simulatorID = _entity->getSimulatorID();
// qDebug() << "XXX me =" << (simulatorID == myNodeID)
// << "_numNonMovingUpdates =" << _numNonMovingUpdates
// << "stopped =" << (zeroSpin && zeroSpeed)
// << "active =" << _body->isActive();
if (simulatorID.isNull() && !(zeroSpeed && zeroSpin)) {
// The object is moving and nobody thinks they own the motion. set this Node as the simulator
_entity->setSimulatorID(myNodeID);
properties.setSimulatorID(myNodeID);
} else if (simulatorID == myNodeID && _numNonMovingUpdates >= MAX_NUM_NON_MOVING_UPDATES - 2) {
} else if (simulatorID == myNodeID && zeroSpeed && zeroSpin) {
// we are the simulator and the object has stopped. give up "simulator" status
_entity->setSimulatorID("");
properties.setSimulatorID("");
_entity->setSimulatorID(QUuid());
properties.setSimulatorID(QUuid());
}
// RELIABLE_SEND_HACK: count number of updates for entities at rest so we can stop sending them after some limit.