9 CachedPart::CachedPart(CachedPart &&other):
11 texture(other.texture),
17 CachedPart &CachedPart::operator=(CachedPart &&other)
21 texture = other.texture;
27 CachedPart::~CachedPart()
33 void PartCache::begin_rebuild()
36 throw logic_error("nested rebuild");
40 current = parts.end();
43 void PartCache::insert_special(const Part &part)
45 if(part.get_name().empty())
46 throw invalid_argument("PartCache::insert_special");
48 throw logic_error("!rebuilding");
50 for(current=next; current!=parts.end(); ++current)
51 if(current->part==&part)
53 parts.erase(next, current);
57 if(current==parts.end())
58 current = parts.insert(next, CachedPart());
60 *current = CachedPart();
61 current->part = ∂
67 GL::Mesh &PartCache::create_mesh(const Part &part, const GL::Texture2D &tex)
70 throw logic_error("!rebuilding");
72 if(current!=parts.end() && current->texture==&tex)
73 return *current->mesh;
75 for(current=next; current!=parts.end(); ++current)
76 if(current->texture==&tex)
78 parts.erase(next, current);
82 if(current==parts.end())
84 current = parts.insert(next, CachedPart());
85 current->texture = &tex;
86 current->mesh = new GL::Mesh((GL::TEXCOORD2, GL::COLOR4,GL::UNSIGNED_BYTE, GL::VERTEX2));
89 current->mesh->clear();
90 current->part = ∂
95 return *current->mesh;
98 void PartCache::end_rebuild()
101 parts.erase(next, parts.end());