namespace Msp {
namespace GLtk {
-CachedPart::CachedPart():
- part(0),
- texture(0),
- mesh(0)
-{ }
+CachedPart::CachedPart(CachedPart &&other):
+ part(other.part),
+ texture(other.texture),
+ mesh(other.mesh)
+{
+ other.mesh = nullptr;
+}
-CachedPart::~CachedPart()
+CachedPart &CachedPart::operator=(CachedPart &&other)
{
delete mesh;
+ part = other.part;
+ texture = other.texture;
+ mesh = other.mesh;
+ other.mesh = nullptr;
+ return *this;
}
+CachedPart::~CachedPart()
+{
+ delete mesh;
+}
-PartCache::PartCache():
- rebuilding(false)
-{ }
void PartCache::begin_rebuild()
{
if(!rebuilding)
throw logic_error("!rebuilding");
- for(current=next; current!=parts.end(); ++current)
- if(current->part==&part)
- {
- parts.erase(next, current);
- break;
- }
+ current = find_if(next, parts.end(), [&part](const CachedPart &p){ return p.part==∂ });
+ if(current!=parts.end())
+ parts.erase(next, current);
if(current==parts.end())
current = parts.insert(next, CachedPart());