X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpartcache.h;h=71684738f0980922de8db5346d88249f53a058b5;hb=aa9b8db38efb9e97460c76e27cecc4d1591b23e5;hp=b856f9da47a486151f3a10b62c51f1f0c60fb02c;hpb=1aa6cd9b865e366737dcc9d2d36c4f8faed5bc4f;p=libs%2Fgltk.git diff --git a/source/partcache.h b/source/partcache.h index b856f9d..7168473 100644 --- a/source/partcache.h +++ b/source/partcache.h @@ -3,19 +3,51 @@ #include #include +#include "mspgltk_api.h" namespace Msp { namespace GLtk { +class Part; + struct CachedPart { - const GL::Texture2D *texture; - GL::Mesh *mesh; + const Part *part = nullptr; + const GL::Texture2D *texture = nullptr; + GL::Mesh *mesh = nullptr; - CachedPart(); + CachedPart() = default; + CachedPart(CachedPart &&); + CachedPart &operator=(CachedPart &&); ~CachedPart(); +}; + +class MSPGLTK_API PartCache +{ +public: + class Rebuild + { + private: + PartCache &cache; + + public: + Rebuild(PartCache &c): cache(c) { cache.begin_rebuild(); } + ~Rebuild() { cache.end_rebuild(); } + }; + +private: + bool rebuilding = false; + std::vector parts; + std::vector::iterator next; + std::vector::iterator current; + +public: + void begin_rebuild(); + void insert_special(const Part &); + GL::Mesh &create_mesh(const Part &, const GL::Texture2D &); + void end_rebuild(); - void clear_mesh(); + const std::vector &get_parts() const { return parts; } }; } // namespace GLtk