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;
_gpuTextureMemSizeAtLastCheck = 0;
_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());
}

View file

@ -25,7 +25,7 @@ public:
OctreePacketProcessor();
~OctreePacketProcessor();
void startEntitySequence();
void startSafeLanding();
bool isLoadSequenceComplete() const { return _safeLanding->isLoadSequenceComplete(); }
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) {
if (_trackingEntities && _entityTreeRenderer) {
Locker lock(_lock);
@ -109,24 +98,26 @@ void SafeLanding::noteReceivedsequenceNumber(int sequenceNumber) {
bool SafeLanding::isLoadSequenceComplete() {
if ((isEntityLoadingComplete() && isSequenceNumbersComplete()) || qApp->failedToConnectToEntityServer()) {
_trackingEntities = false;
stopTracking();
}
return !_trackingEntities;
}
Locker lock(_lock);
if (_entityTreeRenderer) {
auto entityTree = _entityTreeRenderer->getTree();
disconnect(std::const_pointer_cast<EntityTree>(entityTree).get(),
&EntityTree::addingEntity, this, &SafeLanding::addTrackedEntity);
disconnect(std::const_pointer_cast<EntityTree>(entityTree).get(),
&EntityTree::deletingEntity, this, &SafeLanding::deleteTrackedEntity);
_entityTreeRenderer.reset();
}
_initialStart = INVALID_SEQUENCE;
_initialEnd = INVALID_SEQUENCE;
EntityTreeRenderer::setEntityLoadingPriorityFunction(StandardPriority);
void SafeLanding::stopTracking() {
Locker lock(_lock);
_trackingEntities = false;
if (_entityTreeRenderer) {
auto entityTree = _entityTreeRenderer->getTree();
disconnect(std::const_pointer_cast<EntityTree>(entityTree).get(),
&EntityTree::addingEntity, this, &SafeLanding::addTrackedEntity);
disconnect(std::const_pointer_cast<EntityTree>(entityTree).get(),
&EntityTree::deletingEntity, this, &SafeLanding::deleteTrackedEntity);
_entityTreeRenderer.reset();
}
return !_trackingEntities;
_initialStart = INVALID_SEQUENCE;
_initialEnd = INVALID_SEQUENCE;
EntityTreeRenderer::setEntityLoadingPriorityFunction(StandardPriority);
}
float SafeLanding::loadingProgressPercentage() {

View file

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