mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
fix SafeLanding start/stop on entity-server connection flow
This commit is contained in:
parent
dfb7ac7044
commit
bf068a3211
6 changed files with 71 additions and 48 deletions
|
@ -6201,7 +6201,9 @@ void Application::update(float deltaTime) {
|
|||
if (isServerlessMode()) {
|
||||
tryToEnablePhysics();
|
||||
} else if (_failedToConnectToEntityServer) {
|
||||
_octreeProcessor.stopSafeLanding();
|
||||
if (_octreeProcessor.safeLandingIsActive()) {
|
||||
_octreeProcessor.stopSafeLanding();
|
||||
}
|
||||
} else {
|
||||
_octreeProcessor.updateSafeLanding();
|
||||
if (_octreeProcessor.safeLandingIsComplete()) {
|
||||
|
@ -7154,13 +7156,17 @@ void Application::resettingDomain() {
|
|||
clearDomainOctreeDetails(false);
|
||||
}
|
||||
|
||||
void Application::nodeAdded(SharedNodePointer node) const {
|
||||
void Application::nodeAdded(SharedNodePointer node) {
|
||||
if (node->getType() == NodeType::EntityServer) {
|
||||
if (!_failedToConnectToEntityServer) {
|
||||
if (_failedToConnectToEntityServer && !_entityServerConnectionTimer.isActive()) {
|
||||
_failedToConnectToEntityServer = false;
|
||||
_octreeProcessor.stopSafeLanding();
|
||||
_octreeProcessor.startSafeLanding();
|
||||
} else if (_entityServerConnectionTimer.isActive()) {
|
||||
_entityServerConnectionTimer.stop();
|
||||
_entityServerConnectionTimer.setInterval(ENTITY_SERVER_CONNECTION_TIMEOUT);
|
||||
_entityServerConnectionTimer.start();
|
||||
}
|
||||
_entityServerConnectionTimer.setInterval(ENTITY_SERVER_CONNECTION_TIMEOUT);
|
||||
_entityServerConnectionTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7170,7 +7176,6 @@ void Application::nodeActivated(SharedNodePointer node) {
|
|||
|
||||
#if !defined(DISABLE_QML)
|
||||
auto offscreenUi = getOffscreenUI();
|
||||
|
||||
if (offscreenUi) {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
||||
|
|
|
@ -527,7 +527,7 @@ private slots:
|
|||
|
||||
void domainURLChanged(QUrl domainURL);
|
||||
void updateWindowTitle() const;
|
||||
void nodeAdded(SharedNodePointer node) const;
|
||||
void nodeAdded(SharedNodePointer node);
|
||||
void nodeActivated(SharedNodePointer node);
|
||||
void nodeKilled(SharedNodePointer node);
|
||||
static void packetSent(quint64 length);
|
||||
|
|
|
@ -63,7 +63,6 @@ void OctreePacketProcessor::processPacket(QSharedPointer<ReceivedMessage> messag
|
|||
// construct a new packet from the piggybacked one
|
||||
auto buffer = std::unique_ptr<char[]>(new char[piggybackBytes]);
|
||||
memcpy(buffer.get(), message->getRawMessage() + statsMessageLength, piggybackBytes);
|
||||
|
||||
auto newPacket = NLPacket::fromReceivedPacket(std::move(buffer), piggybackBytes, message->getSenderSockAddr());
|
||||
message = QSharedPointer<ReceivedMessage>::create(*newPacket);
|
||||
} else {
|
||||
|
@ -80,7 +79,6 @@ void OctreePacketProcessor::processPacket(QSharedPointer<ReceivedMessage> messag
|
|||
|
||||
const QUuid& senderUUID = sendingNode->getUUID();
|
||||
if (!versionDebugSuppressMap.contains(senderUUID, packetType)) {
|
||||
|
||||
qDebug() << "Was stats packet? " << wasStatsPacket;
|
||||
qDebug() << "OctreePacketProcessor - piggyback packet version mismatch on" << packetType << "- Sender"
|
||||
<< senderUUID << "sent" << (int) message->getVersion() << "but"
|
||||
|
@ -113,7 +111,7 @@ void OctreePacketProcessor::processPacket(QSharedPointer<ReceivedMessage> messag
|
|||
case PacketType::EntityData: {
|
||||
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
|
||||
auto renderer = qApp->getEntities();
|
||||
if (renderer) {
|
||||
if (renderer && _safeLanding) {
|
||||
renderer->processDatagram(*message, sendingNode);
|
||||
_safeLanding->addToSequence(renderer->getLastOctreeMessageSequence());
|
||||
}
|
||||
|
@ -124,7 +122,9 @@ void OctreePacketProcessor::processPacket(QSharedPointer<ReceivedMessage> messag
|
|||
// Read sequence #
|
||||
OCTREE_PACKET_SEQUENCE completionNumber;
|
||||
message->readPrimitive(&completionNumber);
|
||||
_safeLanding->finishSequence(0, completionNumber);
|
||||
if (_safeLanding) {
|
||||
_safeLanding->finishSequence(0, completionNumber);
|
||||
}
|
||||
} break;
|
||||
|
||||
default: {
|
||||
|
@ -134,17 +134,30 @@ void OctreePacketProcessor::processPacket(QSharedPointer<ReceivedMessage> messag
|
|||
}
|
||||
|
||||
void OctreePacketProcessor::startSafeLanding() {
|
||||
_safeLanding->startTracking(qApp->getEntities());
|
||||
if (_safeLanding) {
|
||||
_safeLanding->startTracking(qApp->getEntities());
|
||||
}
|
||||
}
|
||||
|
||||
void OctreePacketProcessor::updateSafeLanding() {
|
||||
_safeLanding->updateTracking();
|
||||
if (_safeLanding) {
|
||||
_safeLanding->updateTracking();
|
||||
}
|
||||
}
|
||||
|
||||
void OctreePacketProcessor::stopSafeLanding() {
|
||||
_safeLanding->stopTracking();
|
||||
if (_safeLanding) {
|
||||
_safeLanding->stopTracking();
|
||||
}
|
||||
}
|
||||
|
||||
bool OctreePacketProcessor::safeLandingIsActive() const {
|
||||
return _safeLanding && _safeLanding->isTracking();
|
||||
}
|
||||
|
||||
bool OctreePacketProcessor::safeLandingIsComplete() const {
|
||||
return _safeLanding->trackingIsComplete();
|
||||
if (_safeLanding) {
|
||||
return _safeLanding->trackingIsComplete();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
void startSafeLanding();
|
||||
void updateSafeLanding();
|
||||
void stopSafeLanding();
|
||||
bool safeLandingIsActive() const;
|
||||
bool safeLandingIsComplete() const;
|
||||
|
||||
float domainLoadingProgress() const { return _safeLanding->loadingProgressPercentage(); }
|
||||
|
|
|
@ -100,50 +100,53 @@ void SafeLanding::updateTracking() {
|
|||
if (!_trackingEntities || !_entityTreeRenderer) {
|
||||
return;
|
||||
}
|
||||
Locker lock(_lock);
|
||||
|
||||
bool enableInterstitial = DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
|
||||
|
||||
auto entityMapIter = _trackedEntities.begin();
|
||||
while (entityMapIter != _trackedEntities.end()) {
|
||||
auto entity = entityMapIter->second;
|
||||
bool isVisuallyReady = true;
|
||||
{
|
||||
Locker lock(_lock);
|
||||
bool enableInterstitial = DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
|
||||
auto entityMapIter = _trackedEntities.begin();
|
||||
while (entityMapIter != _trackedEntities.end()) {
|
||||
auto entity = entityMapIter->second;
|
||||
bool isVisuallyReady = true;
|
||||
if (enableInterstitial) {
|
||||
auto entityRenderable = _entityTreeRenderer->renderableForEntityId(entityMapIter->first);
|
||||
if (!entityRenderable) {
|
||||
_entityTreeRenderer->addingEntity(entityMapIter->first);
|
||||
}
|
||||
isVisuallyReady = entity->isVisuallyReady() || (!entityRenderable && !entity->isParentPathComplete());
|
||||
}
|
||||
if (isEntityPhysicsReady(entity) && isVisuallyReady) {
|
||||
entityMapIter = _trackedEntities.erase(entityMapIter);
|
||||
} else {
|
||||
if (!isVisuallyReady) {
|
||||
entity->requestRenderUpdate();
|
||||
}
|
||||
entityMapIter++;
|
||||
}
|
||||
}
|
||||
if (enableInterstitial) {
|
||||
auto entityRenderable = _entityTreeRenderer->renderableForEntityId(entityMapIter->first);
|
||||
if (!entityRenderable) {
|
||||
_entityTreeRenderer->addingEntity(entityMapIter->first);
|
||||
}
|
||||
|
||||
isVisuallyReady = entity->isVisuallyReady() || (!entityRenderable && !entity->isParentPathComplete());
|
||||
_trackedEntityStabilityCount++;
|
||||
}
|
||||
if (isEntityPhysicsReady(entity) && isVisuallyReady) {
|
||||
entityMapIter = _trackedEntities.erase(entityMapIter);
|
||||
} else {
|
||||
if (!isVisuallyReady) {
|
||||
entity->requestRenderUpdate();
|
||||
}
|
||||
entityMapIter++;
|
||||
}
|
||||
}
|
||||
|
||||
if (enableInterstitial) {
|
||||
_trackedEntityStabilityCount++;
|
||||
}
|
||||
|
||||
if (_trackedEntities.empty()) {
|
||||
// no more tracked entities --> check sequenceNumbers
|
||||
if (_initialStart != INVALID_SEQUENCE) {
|
||||
Locker lock(_lock);
|
||||
int sequenceSize = _initialStart <= _initialEnd ? _initialEnd - _initialStart:
|
||||
_initialEnd + SEQUENCE_MODULO - _initialStart;
|
||||
auto startIter = _sequenceNumbers.find(_initialStart);
|
||||
auto endIter = _sequenceNumbers.find(_initialEnd - 1);
|
||||
bool shouldStop = false;
|
||||
{
|
||||
Locker lock(_lock);
|
||||
int sequenceSize = _initialStart <= _initialEnd ? _initialEnd - _initialStart:
|
||||
_initialEnd + SEQUENCE_MODULO - _initialStart;
|
||||
auto startIter = _sequenceNumbers.find(_initialStart);
|
||||
auto endIter = _sequenceNumbers.find(_initialEnd - 1);
|
||||
|
||||
bool missingSequenceNumbers = qApp->isMissingSequenceNumbers();
|
||||
if (sequenceSize == 0 ||
|
||||
bool missingSequenceNumbers = qApp->isMissingSequenceNumbers();
|
||||
shouldStop = (sequenceSize == 0 ||
|
||||
(startIter != _sequenceNumbers.end() &&
|
||||
endIter != _sequenceNumbers.end() &&
|
||||
((distance(startIter, endIter) == sequenceSize - 1) || !missingSequenceNumbers))) {
|
||||
((distance(startIter, endIter) == sequenceSize - 1) || !missingSequenceNumbers)));
|
||||
}
|
||||
if (shouldStop) {
|
||||
stopTracking();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
void startTracking(QSharedPointer<EntityTreeRenderer> entityTreeRenderer);
|
||||
void updateTracking();
|
||||
void stopTracking();
|
||||
bool isTracking() const { return _trackingEntities; }
|
||||
bool trackingIsComplete() const;
|
||||
|
||||
void finishSequence(int first, int last); // 'last' exclusive.
|
||||
|
|
Loading…
Reference in a new issue