trying to fix loading bar

This commit is contained in:
Dante Ruiz 2018-08-21 18:27:21 -07:00
parent 71e8ccd190
commit 26a30edec9
8 changed files with 37 additions and 29 deletions

View file

@ -232,6 +232,8 @@ public:
bool getPreferAvatarFingerOverStylus() { return false; }
void setPreferAvatarFingerOverStylus(bool value);
float getDomainLoadProgress() { return _octreeProcessor.domainLoadProgress(); }
float getSettingConstrainToolbarPosition() { return _constrainToolbarPosition.get(); }
void setSettingConstrainToolbarPosition(bool setting);

View file

@ -137,3 +137,7 @@ void OctreePacketProcessor::startEntitySequence() {
bool OctreePacketProcessor::isLoadSequenceComplete() const {
return _safeLanding->isLoadSequenceComplete();
}
float OctreePacketProcessor::domainLoadProgress() {
return _safeLanding->loadingProgressPercentage();
}

View file

@ -27,6 +27,7 @@ public:
void startEntitySequence();
bool isLoadSequenceComplete() const;
float domainLoadProgress();
signals:
void packetVersionMismatch();

View file

@ -53,6 +53,7 @@ void SafeLanding::startEntitySequence(QSharedPointer<EntityTreeRenderer> entityT
void SafeLanding::stopEntitySequence() {
Locker lock(_lock);
_trackingEntities = false;
_maxTrackedEntityCount = 0;
_initialStart = INVALID_SEQUENCE;
_initialEnd = INVALID_SEQUENCE;
_trackedEntities.clear();
@ -75,6 +76,11 @@ void SafeLanding::addTrackedEntity(const EntityItemID& entityID) {
if (hasAABox && downloadedCollisionTypes.count(modelEntity->getShapeType()) != 0) {
// Only track entities with downloaded collision bodies.
_trackedEntities.emplace(entityID, entity);
int currentTrackedEntityCount = _trackedEntities.size();
if (currentTrackedEntityCount > _maxTrackedEntityCount) {
_maxTrackedEntityCount = currentTrackedEntityCount;
}
qCDebug(interfaceapp) << "Safe Landing: Tracking entity " << entity->getItemName();
}
}
@ -116,6 +122,18 @@ bool SafeLanding::isLoadSequenceComplete() {
return !_trackingEntities;
}
float SafeLanding::loadingProgressPercentage() {
float percentage = 0;
if (_maxTrackedEntityCount != 0) {
int trackedEntityCount = _trackedEntities.size();
percentage = (_maxTrackedEntityCount - trackedEntityCount) / _maxTrackedEntityCount;
}
qDebug() << "----------> percentage: " << percentage << " <--------";
return percentage;
}
bool SafeLanding::isSequenceNumbersComplete() {
if (_initialStart != INVALID_SEQUENCE) {
Locker lock(_lock);

View file

@ -29,6 +29,7 @@ public:
void setCompletionSequenceNumbers(int first, int last);
void noteReceivedsequenceNumber(int sequenceNumber);
bool isLoadSequenceComplete();
float loadingProgressPercentage();
private slots:
void addTrackedEntity(const EntityItemID& entityID);
@ -49,6 +50,7 @@ private:
static constexpr int INVALID_SEQUENCE = -1;
int _initialStart { INVALID_SEQUENCE };
int _initialEnd { INVALID_SEQUENCE };
int _maxTrackedEntityCount { 0 };
struct SequenceLessThan {
bool operator()(const int& a, const int& b) const;

View file

@ -589,14 +589,6 @@ void WindowScriptingInterface::onMessageBoxSelected(int button) {
}
int WindowScriptingInterface::getPhysicsNearbyEntitiesReadyCount() {
return qApp->getNearbyEntitiesReadyCount();
}
int WindowScriptingInterface::getPhysicsNearbyEntitiesStabilityCount() {
return qApp->getEntitiesStabilityCount();
}
int WindowScriptingInterface::getPhysicsNearbyEntitiesCount() {
return qApp->getNearbyEntitiesCount();
float WindowScriptingInterface::domainLoadingProgress() {
return qApp->getDomainLoadProgress();
}

View file

@ -561,9 +561,7 @@ public slots:
*/
void closeMessageBox(int id);
int getPhysicsNearbyEntitiesReadyCount();
int getPhysicsNearbyEntitiesStabilityCount();
int getPhysicsNearbyEntitiesCount();
float domainLoadingProgress();
private slots:
void onWindowGeometryChanged(const QRect& geometry);

View file

@ -344,26 +344,17 @@
var deltaTime = (thisInterval - lastInterval);
lastInterval = thisInterval;
var nearbyEntitiesReadyCount = Window.getPhysicsNearbyEntitiesReadyCount();
var stabilityCount = Window.getPhysicsNearbyEntitiesStabilityCount();
var nearbyEntitiesCount = Window.getPhysicsNearbyEntitiesCount();
var domainLoadingProgressPercentage = Window.domainLoadingProgress();
var stabilityPercentage = (stabilityCount / STABILITY);
if (stabilityPercentage > 1) {
stabilityPercentage = 1;
}
var stabilityProgress = (MAX_X_SIZE * 0.75) * stabilityPercentage;
var entitiesLoadedPercentage = 1;
if (nearbyEntitiesCount > 0) {
entitiesLoadedPercentage = nearbyEntitiesReadyCount / nearbyEntitiesCount;
}
var entitiesLoadedProgress = (MAX_X_SIZE * 0.25) * entitiesLoadedPercentage;
var progress = stabilityProgress + entitiesLoadedProgress;
var progress = MAX_X_SIZE * domainLoadingProgressPercentage;
print(progress);
if (progress >= target) {
target = progress;
}
if (physicsEnabled && target < MAX_X_SIZE) {
target = MAX_X_SIZE;
}
currentProgress = lerp(currentProgress, target, 0.2);
var properties = {
localPosition: { x: (1.85 - (currentProgress / 2) - (-0.029 * (currentProgress / MAX_X_SIZE))), y: -0.935, z: 0.0 },