fixing loading bar

This commit is contained in:
Dante Ruiz 2018-08-22 10:58:55 -07:00
parent 26a30edec9
commit 54236e5c59
2 changed files with 21 additions and 23 deletions

View file

@ -66,23 +66,20 @@ void SafeLanding::addTrackedEntity(const EntityItemID& entityID) {
EntityItemPointer entity = _entityTree->findEntityByID(entityID); EntityItemPointer entity = _entityTree->findEntityByID(entityID);
if (entity && !entity->getCollisionless()) { if (entity && !entity->getCollisionless()) {
const auto& entityType = entity->getType(); static const std::set<ShapeType> downloadedCollisionTypes
if (entityType == EntityTypes::Model) { { SHAPE_TYPE_COMPOUND, SHAPE_TYPE_SIMPLE_COMPOUND, SHAPE_TYPE_STATIC_MESH, SHAPE_TYPE_SIMPLE_HULL };
ModelEntityItem * modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity).get(); bool hasAABox;
static const std::set<ShapeType> downloadedCollisionTypes entity->getAABox(hasAABox);
{ SHAPE_TYPE_COMPOUND, SHAPE_TYPE_SIMPLE_COMPOUND, SHAPE_TYPE_STATIC_MESH, SHAPE_TYPE_SIMPLE_HULL }; if (hasAABox && downloadedCollisionTypes.count(entity->getShapeType()) != 0) {
bool hasAABox; // Only track entities with downloaded collision bodies.
entity->getAABox(hasAABox); _trackedEntities.emplace(entityID, entity);
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(); float trackedEntityCount = (float)_trackedEntities.size();
if (trackedEntityCount > _maxTrackedEntityCount) {
_maxTrackedEntityCount = trackedEntityCount;
} }
qCDebug(interfaceapp) << "Safe Landing: Tracking entity " << entity->getItemName();
} }
} }
} }
@ -123,15 +120,15 @@ bool SafeLanding::isLoadSequenceComplete() {
} }
float SafeLanding::loadingProgressPercentage() { float SafeLanding::loadingProgressPercentage() {
float percentage = 0; Locker lock(_lock);
if (_maxTrackedEntityCount > 0) {
if (_maxTrackedEntityCount != 0) { float trackedEntityCount = (float)_trackedEntities.size();
int trackedEntityCount = _trackedEntities.size(); qDebug() << "pocessed: " << (_maxTrackedEntityCount - trackedEntityCount) << " -> total: " << _maxTrackedEntityCount;
percentage = (_maxTrackedEntityCount - trackedEntityCount) / _maxTrackedEntityCount; qDebug() << ((_maxTrackedEntityCount - trackedEntityCount) / _maxTrackedEntityCount);
return ((_maxTrackedEntityCount - trackedEntityCount) / _maxTrackedEntityCount);
} }
qDebug() << "----------> percentage: " << percentage << " <--------"; return 0.0f;
return percentage;
} }
bool SafeLanding::isSequenceNumbersComplete() { bool SafeLanding::isSequenceNumbersComplete() {
@ -158,6 +155,7 @@ bool SafeLanding::isEntityPhysicsComplete() {
auto entity = entityMapIter->second; auto entity = entityMapIter->second;
if (!entity->shouldBePhysical() || entity->isReadyToComputeShape()) { if (!entity->shouldBePhysical() || entity->isReadyToComputeShape()) {
entityMapIter = _trackedEntities.erase(entityMapIter); entityMapIter = _trackedEntities.erase(entityMapIter);
qDebug() << "--> removing entity <--";
if (entityMapIter == _trackedEntities.end()) { if (entityMapIter == _trackedEntities.end()) {
break; break;
} }

View file

@ -50,7 +50,7 @@ private:
static constexpr int INVALID_SEQUENCE = -1; static constexpr int INVALID_SEQUENCE = -1;
int _initialStart { INVALID_SEQUENCE }; int _initialStart { INVALID_SEQUENCE };
int _initialEnd { INVALID_SEQUENCE }; int _initialEnd { INVALID_SEQUENCE };
int _maxTrackedEntityCount { 0 }; float _maxTrackedEntityCount { 0.0f };
struct SequenceLessThan { struct SequenceLessThan {
bool operator()(const int& a, const int& b) const; bool operator()(const int& a, const int& b) const;