]> git.tdb.fi Git - libs/gl.git/commitdiff
Give meshes a higher priority when loading
authorMikko Rasa <tdb@tdb.fi>
Sat, 14 Nov 2015 22:25:50 +0000 (00:25 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 15 Nov 2015 11:13:19 +0000 (13:13 +0200)
It's better to load all meshes first so the geometry can be seen.

source/mesh.h
source/resource.h
source/resourcemanager.cpp
source/resourcemanager.h

index 7e455cd97211638938daa191b3281925fde1fb31..e9feb675a0635ee67127b5b4cd0f426617be7855 100644 (file)
@@ -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();
index 09d60e44917eb6e6e06a4476e42b3a75d4257bcd..01c604c3f6d41cf70bd7cf5bf20de501f3ec70ed 100644 (file)
@@ -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;
index 481e9a176b00b038b04f412f2c841448ba46dad9..7d5d752b2351a3607e17b953212d981cde1c1792 100644 (file)
@@ -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),
index e7c8c04b3224d87b3eff51686013b9536d2d90a1..399d479abd2111dab7de39b557846d03aa797b2c 100644 (file)
@@ -56,6 +56,7 @@ private:
 
                Resource *resource;
                ResourceLocation location;
+               bool load_priority;
                IO::Seekable *io;
                Resource::AsyncLoader *loader;
                State state;