History

model loading priority updates over time, takes into account out of bounds, avatar entities have higher priority, and fsts can specify to wait for wearables to load before rendering

HifiExperiments committed 2 years ago

Commit fe61d921 parent 93c1ed621 files · +156 −95Browse files

Showing the changes to interface/src/Application.cpp (1 of 21 files). Show all

Unified · Split

interface/src/Application.cpp+24−9
@@ -2277,12 +2277,12 @@ void Application::initialize(const QCommandLineParser &parser) { · 2276 unmodified lines
22772277 auto loadingRequests = ResourceCache::getLoadingRequests();
22782278
22792279 QJsonArray loadingRequestsStats;
2280− for (const auto& request : loadingRequests) {
2280+ for (const auto& requestPair : loadingRequests) {
22812281 QJsonObject requestStats;
2282− requestStats["filename"] = request->getURL().fileName();
2283− requestStats["received"] = request->getBytesReceived();
2284− requestStats["total"] = request->getBytesTotal();
2285− requestStats["attempts"] = (int)request->getDownloadAttempts();
2282+ requestStats["filename"] = requestPair.first->getURL().fileName();
2283+ requestStats["received"] = requestPair.first->getBytesReceived();
2284+ requestStats["total"] = requestPair.first->getBytesTotal();
2285+ requestStats["attempts"] = (int)requestPair.first->getDownloadAttempts();
22862286 loadingRequestsStats.append(requestStats);
22872287 }
22882288
@@ -5731,15 +5731,30 @@ void Application::init() { · 3442 unmodified lines
57315731
57325732 getEntities()->init();
57335733 getEntities()->setEntityLoadingPriorityFunction([this](const EntityItem& item) {
5734− auto dims = item.getScaledDimensions();
5735− auto maxSize = glm::compMax(dims);
5734+ if (item.getEntityHostType() == entity::HostType::AVATAR) {
5735+ return item.isMyAvatarEntity() ? Avatar::MYAVATAR_ENTITY_LOADING_PRIORITY : Avatar::OTHERAVATAR_ENTITY_LOADING_PRIORITY;
5736+ }
57365737
5738+ const float maxSize = glm::compMax(item.getScaledDimensions());
57375739 if (maxSize <= 0.0f) {
57385740 return 0.0f;
57395741 }
57405742
5741− auto distance = glm::distance(getMyAvatar()->getWorldPosition(), item.getWorldPosition());
5742− return atan2(maxSize, distance);
5743+ const glm::vec3 itemPosition = item.getWorldPosition();
5744+ const float distance = glm::distance(getMyAvatar()->getWorldPosition(), itemPosition);
5745+ float result = atan2(maxSize, distance);
5746+
5747+ bool isInView = true;
5748+ {
5749+ QMutexLocker viewLocker(&_viewMutex);
5750+ isInView = _viewFrustum.sphereIntersectsKeyhole(itemPosition, maxSize);
5751+ }
5752+ if (!isInView) {
5753+ const float OUT_OF_VIEW_PENALTY = -M_PI_2;
5754+ result += OUT_OF_VIEW_PENALTY;
5755+ }
5756+
5757+ return result;
57435758 });
57445759
57455760 ObjectMotionState::setShapeManager(&_shapeManager);