9 CachedPart::CachedPart():
15 CachedPart::~CachedPart()
21 PartCache::PartCache():
25 void PartCache::begin_rebuild()
28 throw logic_error("nested rebuild");
32 current = parts.end();
35 void PartCache::insert_special(const Part &part)
37 if(part.get_name().empty())
38 throw invalid_argument("PartCache::insert_special");
40 throw logic_error("!rebuilding");
42 for(current=next; current!=parts.end(); ++current)
43 if(current->part==&part)
45 parts.erase(next, current);
49 if(current==parts.end())
50 current = parts.insert(next, CachedPart());
52 *current = CachedPart();
53 current->part = ∂
59 GL::Mesh &PartCache::create_mesh(const Part &part, const GL::Texture2D &tex)
62 throw logic_error("!rebuilding");
64 if(current!=parts.end() && current->texture==&tex)
65 return *current->mesh;
67 for(current=next; current!=parts.end(); ++current)
68 if(current->texture==&tex)
70 parts.erase(next, current);
74 if(current==parts.end())
76 current = parts.insert(next, CachedPart());
77 current->texture = &tex;
78 current->mesh = new GL::Mesh((GL::TEXCOORD2, GL::COLOR4_UBYTE, GL::VERTEX2));
81 current->mesh->clear();
82 current->part = ∂
87 return *current->mesh;
90 void PartCache::end_rebuild()
93 parts.erase(next, parts.end());