X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpartcache.h;h=137bce4c37539a8c032f27b36cff0c35afc89f58;hb=81c4024fb6acf37df702a803dc4efdf82a81525a;hp=86a3f364abe21260395493f40580d278f5b5775c;hpb=319cde3c06181ba1c3619567525002926d8b4889;p=libs%2Fgltk.git diff --git a/source/partcache.h b/source/partcache.h index 86a3f36..137bce4 100644 --- a/source/partcache.h +++ b/source/partcache.h @@ -3,6 +3,7 @@ #include #include +#include "mspgltk_api.h" namespace Msp { namespace GLtk { @@ -11,26 +12,39 @@ class Part; struct CachedPart { - const Part *part; - const GL::Texture2D *texture; - GL::Mesh *mesh; + const Part *part = nullptr; + const GL::Texture2D *texture = nullptr; + GL::Mesh *mesh = nullptr; - CachedPart(); ~CachedPart(); }; -class PartCache +class MSPGLTK_API PartCache { public: + class Rebuild + { + private: + PartCache &cache; + + public: + Rebuild(PartCache &c): cache(c) { cache.begin_rebuild(); } + ~Rebuild() { cache.end_rebuild(); } + }; + typedef std::list PartList; private: + bool rebuilding = false; PartList parts; + PartList::iterator next; + PartList::iterator current; public: - void clear(); + void begin_rebuild(); void insert_special(const Part &); GL::Mesh &create_mesh(const Part &, const GL::Texture2D &); + void end_rebuild(); const PartList &get_parts() const { return parts; } };