mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 05:42:53 +02:00
fixing loading bar
This commit is contained in:
parent
26a30edec9
commit
54236e5c59
2 changed files with 21 additions and 23 deletions
|
@ -66,23 +66,20 @@ void SafeLanding::addTrackedEntity(const EntityItemID& entityID) {
|
|||
EntityItemPointer entity = _entityTree->findEntityByID(entityID);
|
||||
|
||||
if (entity && !entity->getCollisionless()) {
|
||||
const auto& entityType = entity->getType();
|
||||
if (entityType == EntityTypes::Model) {
|
||||
ModelEntityItem * modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity).get();
|
||||
static const std::set<ShapeType> downloadedCollisionTypes
|
||||
{ SHAPE_TYPE_COMPOUND, SHAPE_TYPE_SIMPLE_COMPOUND, SHAPE_TYPE_STATIC_MESH, SHAPE_TYPE_SIMPLE_HULL };
|
||||
bool hasAABox;
|
||||
entity->getAABox(hasAABox);
|
||||
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;
|
||||
}
|
||||
static const std::set<ShapeType> downloadedCollisionTypes
|
||||
{ SHAPE_TYPE_COMPOUND, SHAPE_TYPE_SIMPLE_COMPOUND, SHAPE_TYPE_STATIC_MESH, SHAPE_TYPE_SIMPLE_HULL };
|
||||
bool hasAABox;
|
||||
entity->getAABox(hasAABox);
|
||||
if (hasAABox && downloadedCollisionTypes.count(entity->getShapeType()) != 0) {
|
||||
// Only track entities with downloaded collision bodies.
|
||||
_trackedEntities.emplace(entityID, entity);
|
||||
|
||||
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 percentage = 0;
|
||||
|
||||
if (_maxTrackedEntityCount != 0) {
|
||||
int trackedEntityCount = _trackedEntities.size();
|
||||
percentage = (_maxTrackedEntityCount - trackedEntityCount) / _maxTrackedEntityCount;
|
||||
Locker lock(_lock);
|
||||
if (_maxTrackedEntityCount > 0) {
|
||||
float trackedEntityCount = (float)_trackedEntities.size();
|
||||
qDebug() << "pocessed: " << (_maxTrackedEntityCount - trackedEntityCount) << " -> total: " << _maxTrackedEntityCount;
|
||||
qDebug() << ((_maxTrackedEntityCount - trackedEntityCount) / _maxTrackedEntityCount);
|
||||
return ((_maxTrackedEntityCount - trackedEntityCount) / _maxTrackedEntityCount);
|
||||
}
|
||||
|
||||
qDebug() << "----------> percentage: " << percentage << " <--------";
|
||||
return percentage;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
bool SafeLanding::isSequenceNumbersComplete() {
|
||||
|
@ -158,6 +155,7 @@ bool SafeLanding::isEntityPhysicsComplete() {
|
|||
auto entity = entityMapIter->second;
|
||||
if (!entity->shouldBePhysical() || entity->isReadyToComputeShape()) {
|
||||
entityMapIter = _trackedEntities.erase(entityMapIter);
|
||||
qDebug() << "--> removing entity <--";
|
||||
if (entityMapIter == _trackedEntities.end()) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
static constexpr int INVALID_SEQUENCE = -1;
|
||||
int _initialStart { INVALID_SEQUENCE };
|
||||
int _initialEnd { INVALID_SEQUENCE };
|
||||
int _maxTrackedEntityCount { 0 };
|
||||
float _maxTrackedEntityCount { 0.0f };
|
||||
|
||||
struct SequenceLessThan {
|
||||
bool operator()(const int& a, const int& b) const;
|
||||
|
|
Loading…
Reference in a new issue