less cruft, more readable

This commit is contained in:
Andrew Meadows 2019-06-26 16:02:00 -07:00
parent 46b3d84be5
commit 496a7f3608
5 changed files with 21 additions and 30 deletions

View file

@ -5915,7 +5915,7 @@ void Application::resetPhysicsReadyInformation() {
_gpuTextureMemSizeStabilityCount = 0; _gpuTextureMemSizeStabilityCount = 0;
_gpuTextureMemSizeAtLastCheck = 0; _gpuTextureMemSizeAtLastCheck = 0;
_physicsEnabled = false; _physicsEnabled = false;
_octreeProcessor.startEntitySequence(); _octreeProcessor.startSafeLanding();
} }

View file

@ -133,6 +133,6 @@ void OctreePacketProcessor::processPacket(QSharedPointer<ReceivedMessage> messag
} }
} }
void OctreePacketProcessor::startEntitySequence() { void OctreePacketProcessor::startSafeLanding() {
_safeLanding->startEntitySequence(qApp->getEntities()); _safeLanding->startEntitySequence(qApp->getEntities());
} }

View file

@ -25,7 +25,7 @@ public:
OctreePacketProcessor(); OctreePacketProcessor();
~OctreePacketProcessor(); ~OctreePacketProcessor();
void startEntitySequence(); void startSafeLanding();
bool isLoadSequenceComplete() const { return _safeLanding->isLoadSequenceComplete(); } bool isLoadSequenceComplete() const { return _safeLanding->isLoadSequenceComplete(); }
float domainLoadingProgress() const { return _safeLanding->loadingProgressPercentage(); } float domainLoadingProgress() const { return _safeLanding->loadingProgressPercentage(); }

View file

@ -57,17 +57,6 @@ void SafeLanding::startEntitySequence(QSharedPointer<EntityTreeRenderer> entityT
} }
} }
void SafeLanding::stopEntitySequence() {
Locker lock(_lock);
_trackingEntities = false;
_maxTrackedEntityCount = 0;
_trackedEntityStabilityCount = 0;
_initialStart = INVALID_SEQUENCE;
_initialEnd = INVALID_SEQUENCE;
_trackedEntities.clear();
_sequenceNumbers.clear();
}
void SafeLanding::addTrackedEntity(const EntityItemID& entityID) { void SafeLanding::addTrackedEntity(const EntityItemID& entityID) {
if (_trackingEntities && _entityTreeRenderer) { if (_trackingEntities && _entityTreeRenderer) {
Locker lock(_lock); Locker lock(_lock);
@ -109,24 +98,26 @@ void SafeLanding::noteReceivedsequenceNumber(int sequenceNumber) {
bool SafeLanding::isLoadSequenceComplete() { bool SafeLanding::isLoadSequenceComplete() {
if ((isEntityLoadingComplete() && isSequenceNumbersComplete()) || qApp->failedToConnectToEntityServer()) { if ((isEntityLoadingComplete() && isSequenceNumbersComplete()) || qApp->failedToConnectToEntityServer()) {
_trackingEntities = false; stopTracking();
}
return !_trackingEntities;
}
Locker lock(_lock); void SafeLanding::stopTracking() {
if (_entityTreeRenderer) { Locker lock(_lock);
auto entityTree = _entityTreeRenderer->getTree(); _trackingEntities = false;
disconnect(std::const_pointer_cast<EntityTree>(entityTree).get(), if (_entityTreeRenderer) {
&EntityTree::addingEntity, this, &SafeLanding::addTrackedEntity); auto entityTree = _entityTreeRenderer->getTree();
disconnect(std::const_pointer_cast<EntityTree>(entityTree).get(), disconnect(std::const_pointer_cast<EntityTree>(entityTree).get(),
&EntityTree::deletingEntity, this, &SafeLanding::deleteTrackedEntity); &EntityTree::addingEntity, this, &SafeLanding::addTrackedEntity);
_entityTreeRenderer.reset(); disconnect(std::const_pointer_cast<EntityTree>(entityTree).get(),
} &EntityTree::deletingEntity, this, &SafeLanding::deleteTrackedEntity);
_entityTreeRenderer.reset();
_initialStart = INVALID_SEQUENCE;
_initialEnd = INVALID_SEQUENCE;
EntityTreeRenderer::setEntityLoadingPriorityFunction(StandardPriority);
} }
return !_trackingEntities; _initialStart = INVALID_SEQUENCE;
_initialEnd = INVALID_SEQUENCE;
EntityTreeRenderer::setEntityLoadingPriorityFunction(StandardPriority);
} }
float SafeLanding::loadingProgressPercentage() { float SafeLanding::loadingProgressPercentage() {

View file

@ -26,7 +26,6 @@ class EntityItemID;
class SafeLanding : public QObject { class SafeLanding : public QObject {
public: public:
void startEntitySequence(QSharedPointer<EntityTreeRenderer> entityTreeRenderer); void startEntitySequence(QSharedPointer<EntityTreeRenderer> entityTreeRenderer);
void stopEntitySequence();
void setCompletionSequenceNumbers(int first, int last); // 'last' exclusive. void setCompletionSequenceNumbers(int first, int last); // 'last' exclusive.
void noteReceivedsequenceNumber(int sequenceNumber); void noteReceivedsequenceNumber(int sequenceNumber);
bool isLoadSequenceComplete(); bool isLoadSequenceComplete();
@ -41,6 +40,7 @@ private:
bool isEntityPhysicsReady(const EntityItemPointer& entity); bool isEntityPhysicsReady(const EntityItemPointer& entity);
void debugDumpSequenceIDs() const; void debugDumpSequenceIDs() const;
bool isEntityLoadingComplete(); bool isEntityLoadingComplete();
void stopTracking();
std::mutex _lock; std::mutex _lock;
using Locker = std::lock_guard<std::mutex>; using Locker = std::lock_guard<std::mutex>;