overte icon indicating copy to clipboard operation
overte copied to clipboard

Add load priority property to model entities

Open ksuprynowicz opened this issue 1 year ago • 5 comments

Right now loading order is a bit unpredictable

ksuprynowicz avatar Feb 25 '24 10:02 ksuprynowicz

That's a protocol change, right?

daleglass avatar Feb 25 '24 11:02 daleglass

Yes, it would be probably good to add that property during protocol change, even if we don't add feature.

ksuprynowicz avatar Feb 25 '24 11:02 ksuprynowicz

Loosely related: https://github.com/overte-org/overte/issues/254

JulianGro avatar Feb 25 '24 13:02 JulianGro

so the way this currently works is that every network request gets a load priority when it's created (higher starts loading first, but doesn't necessarily finish first):

  • sounds are -7
  • animation graphs are 10
  • skybox textures are 10
  • ktx files are 9
  • except progressive mips are float priority = -(float)_originalKtxDescriptor->header.numberOfMipmapLevels + (float)_lowestKnownPopulatedMip;
  • (I'm not sure if that also applies to the first texture request or if those just have the default priority of 0?)
  • MyAvatar is...PI
  • OtherAvatars are PI - EPSILON
  • attachments (using the old system, not avatar entities, so...idk if they're even still supported) are PI - 2 * EPSILON
  • model entities (normal, local, and avatar) are assigned a priority as soon as their url is set or changes according to this function:
    (const EntityItem& item) => {
        auto dims = item.getScaledDimensions();
        auto maxSize = glm::compMax(dims);

        if (maxSize <= 0.0f) {
            return 0.0f;
        }

        auto distance = glm::distance(getMyAvatar()->getWorldPosition(), item.getWorldPosition());
        return atan2(maxSize, distance);
    });

(this should be a value between 0 and PI/2, based on the largest dimensions and the distance between your avatar and the entity. so closer/larger entities should be prioritized. in practice, I'm not sure there's much variation in these calculated values which might be part of the problem)

  • everything else (I'm not sure what else there is...) is 0

there's several complexities:

  • we have concurrent downloads, so larger files can have higher priorities but take longer to load than smaller, lower priority models
  • we only set the value once, so things don't update as you move around while things load
  • it's still a little dependent on the order in which the entities arrive from the entity server
  • sometimes we want avatar entities to load first (clothes) but sometimes we don't care (maybe?). separate from loading, we probably need a mechanism to not show the avatar until children avatar entities have loaded?

so...what do we want this API to look like? is it just a number model entity property that is directly used as the load priority instead of the distance calculation? if so, we probably need a default value that indicates "fallback to the distance calculation"?

HifiExperiments avatar Mar 02 '24 02:03 HifiExperiments

Personally, I only care about situations where certain avatar attachments need to be loaded before the avatar itself, or other attachments for that matter. Like only seeing ~~Kalilas~~ the avatar after their clothing has loaded.

I am not really opposed to having a priority; I just cannot think of anything where this would be important. Maybe just improving the current system would be good? Like adjusting the priority during loading, based on factors like pressure from higher priority assets, and based on filesize?

JulianGro avatar Mar 02 '24 10:03 JulianGro