X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpartcache.h;h=a10efdd084e2a9b5c463fd3ac555886635bb7c36;hb=394e5c9969a30b604bfaf78fc05a8c2d5c98ab5b;hp=90d1c94f5e36e90a19614cc39a9e8a56033d7945;hpb=2a665655a15f73d59083fd5cc7e5a58ae5f4d377;p=libs%2Fgltk.git diff --git a/source/partcache.h b/source/partcache.h index 90d1c94..a10efdd 100644 --- a/source/partcache.h +++ b/source/partcache.h @@ -1,8 +1,10 @@ #ifndef MSP_GLTK_PARTCACHE_H_ #define MSP_GLTK_PARTCACHE_H_ +#include #include #include +#include "mspgltk_api.h" namespace Msp { namespace GLtk { @@ -11,23 +13,29 @@ class Part; struct CachedPart { - const Part *part; - const GL::Texture2D *texture; - GL::Mesh *mesh; - - CachedPart(); - ~CachedPart(); + const Part *part = nullptr; + const GL::Texture2D *texture = nullptr; + std::unique_ptr mesh; }; -class PartCache +class MSPGLTK_API PartCache { public: - typedef std::list PartList; + class Rebuild + { + private: + PartCache &cache; + + public: + Rebuild(PartCache &c): cache(c) { cache.begin_rebuild(); } + ~Rebuild() { cache.end_rebuild(); } + }; private: - PartList parts; - PartList::iterator next; - PartList::iterator current; + bool rebuilding = false; + std::vector parts; + std::vector::iterator next; + std::vector::iterator current; public: void begin_rebuild(); @@ -35,7 +43,7 @@ public: GL::Mesh &create_mesh(const Part &, const GL::Texture2D &); void end_rebuild(); - const PartList &get_parts() const { return parts; } + const std::vector &get_parts() const { return parts; } }; } // namespace GLtk