From: Mikko Rasa Date: Sat, 14 Nov 2015 22:25:50 +0000 (+0200) Subject: Give meshes a higher priority when loading X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=574abfb7aeb77436714ea06bf82713cb3d85204e;p=libs%2Fgl.git Give meshes a higher priority when loading It's better to load all meshes first so the geometry can be seen. --- diff --git a/source/mesh.h b/source/mesh.h index 7e455cd9..e9feb675 100644 --- a/source/mesh.h +++ b/source/mesh.h @@ -95,6 +95,7 @@ public: static void unbind(); + virtual int get_load_priority() const { return 1; } virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0); virtual UInt64 get_data_size() const; virtual void unload(); diff --git a/source/resource.h b/source/resource.h index 09d60e44..01c604c3 100644 --- a/source/resource.h +++ b/source/resource.h @@ -35,6 +35,7 @@ public: void set_manager(ResourceManager *); ResourceManager *get_manager() const { return manager; } void *get_manager_data() const { return manager_data; } + virtual int get_load_priority() const { return 0; } virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) = 0; virtual bool is_loaded() const; virtual UInt64 get_data_size() const = 0; diff --git a/source/resourcemanager.cpp b/source/resourcemanager.cpp index 481e9a17..7d5d752b 100644 --- a/source/resourcemanager.cpp +++ b/source/resourcemanager.cpp @@ -106,7 +106,9 @@ void ResourceManager::load_resource(Resource &r) if(async_loads) { managed.state = ManagedResource::LOAD_QUEUED; - queue.push_back(&managed); + LoadQueue::iterator i; + for(i=queue.begin(); (i!=queue.end() && (*i)->load_priority>=managed.load_priority); ++i) ; + queue.insert(i, &managed); } else { @@ -271,6 +273,7 @@ ResourceManager::ResourceLocation::ResourceLocation(DataFile::Collection &c, con ResourceManager::ManagedResource::ManagedResource(Resource &r): resource(&r), + load_priority(r.get_load_priority()), io(0), loader(0), state(NOT_LOADED), diff --git a/source/resourcemanager.h b/source/resourcemanager.h index e7c8c04b..399d479a 100644 --- a/source/resourcemanager.h +++ b/source/resourcemanager.h @@ -56,6 +56,7 @@ private: Resource *resource; ResourceLocation location; + bool load_priority; IO::Seekable *io; Resource::AsyncLoader *loader; State state;