mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-08 10:47:57 +02:00
don't auto-remove simulation owner unless the Node is gone. put back code that causes interfaces to give up ownership
This commit is contained in:
parent
a057d7dfa3
commit
4c3cbea261
2 changed files with 12 additions and 7 deletions
|
@ -21,15 +21,20 @@ void SimpleEntitySimulation::updateEntitiesInternal(const quint64& now) {
|
|||
// If an Entity has a simulation owner and we don't get an update for some amount of time,
|
||||
// clear the owner. This guards against an interface failing to release the Entity when it
|
||||
// has finished simulating it.
|
||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||
|
||||
SetOfEntities::iterator itemItr = _hasSimulationOwnerEntities.begin();
|
||||
while (itemItr != _hasSimulationOwnerEntities.end()) {
|
||||
EntityItem* entity = *itemItr;
|
||||
if (entity->getSimulatorID().isNull()) {
|
||||
itemItr = _hasSimulationOwnerEntities.erase(itemItr);
|
||||
} else if (now - entity->getLastChangedOnServer() >= AUTO_REMOVE_SIMULATION_OWNER_USEC) {
|
||||
qCDebug(entities) << "auto-removing simulation owner" << entity->getSimulatorID();
|
||||
entity->setSimulatorID(QUuid());
|
||||
itemItr = _hasSimulationOwnerEntities.erase(itemItr);
|
||||
SharedNodePointer ownerNode = nodeList->nodeWithUUID(entity->getSimulatorID());
|
||||
if (ownerNode.isNull() || !ownerNode->isAlive()) {
|
||||
qCDebug(entities) << "auto-removing simulation owner" << entity->getSimulatorID();
|
||||
entity->setSimulatorID(QUuid());
|
||||
itemItr = _hasSimulationOwnerEntities.erase(itemItr);
|
||||
}
|
||||
} else {
|
||||
++itemItr;
|
||||
}
|
||||
|
|
|
@ -346,12 +346,12 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
|
|||
setShouldClaimSimulationOwnership(false);
|
||||
} else if (simulatorID == myNodeID && zeroSpeed && zeroSpin) {
|
||||
// we are the simulator and the entity has stopped. give up "simulator" status
|
||||
// _entity->setSimulatorID(QUuid());
|
||||
// properties.setSimulatorID(QUuid());
|
||||
_entity->setSimulatorID(QUuid());
|
||||
properties.setSimulatorID(QUuid());
|
||||
} else if (simulatorID == myNodeID && !_body->isActive()) {
|
||||
// it's not active. don't keep simulation ownership.
|
||||
// _entity->setSimulatorID(QUuid());
|
||||
// properties.setSimulatorID(QUuid());
|
||||
_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.
|
||||
|
|
Loading…
Reference in a new issue