namespace GL {
Object::Object():
- lods(1)
+ lods(1),
+ lod0_watched(false)
{ }
Object::Object(const Mesh *m, const Technique *t):
- lods(1)
+ lods(1),
+ lod0_watched(false)
{
set_mesh(m);
set_technique(t);
Object::~Object()
{
- if(lods[0].mesh)
+ if(lods[0].mesh && lod0_watched)
if(ResourceManager *rm = lods[0].mesh->get_manager())
rm->unwatch_resource(*lods[0].mesh, *this);
}
void Object::set_mesh(unsigned i, const Mesh *m)
{
RefPtr<const Mesh> &ptr = get_lod(i, "Object::set_mesh").mesh;
- if(i==0 && ptr)
+ if(i==0 && ptr && lod0_watched)
if(ResourceManager *rm = ptr->get_manager())
rm->unwatch_resource(*ptr, *this);
ptr = m;
ptr.keep();
+ lod0_watched = false;
if(i==0 && m)
if(ResourceManager *rm = m->get_manager())
+ {
rm->watch_resource(*m, *this);
+ lod0_watched = true;
+ }
update_bounding_sphere();
}
update_bounding_sphere();
}
+void Object::resource_removed(Resource &res)
+{
+ if(&res==lods.front().mesh.get())
+ lod0_watched = false;
+}
+
Object::Loader::Loader(Object &o):
LodLoader(o, 0, 0)
std::vector<LevelOfDetail> lods;
Geometry::BoundingSphere<float, 3> bounding_sphere;
+ bool lod0_watched;
public:
Object();
const RenderPass *get_pass(const Tag &, unsigned) const;
virtual void resource_loaded(Resource &);
+ virtual void resource_removed(Resource &);
};
} // namespace GL