#include "program.h"
#include "programdata.h"
#include "renderer.h"
+#include "resourcemanager.h"
#include "technique.h"
#include "texturing.h"
// Avoid synthesizing ~RefPtr in files including object.h
Object::~Object()
-{ }
+{
+ if(meshes[0])
+ if(ResourceManager *rm = meshes[0]->get_manager())
+ rm->unwatch_resource(*meshes[0], *this);
+}
void Object::set_mesh(unsigned i, const Mesh *m)
{
if(i==meshes.size())
meshes.push_back(m);
else
+ {
+ if(i==0 && meshes[i])
+ if(ResourceManager *rm = meshes[i]->get_manager())
+ rm->unwatch_resource(*meshes[i], *this);
meshes[i] = m;
+ }
meshes[i].keep();
+
+ if(i==0 && m)
+ if(ResourceManager *rm = m->get_manager())
+ rm->watch_resource(*m, *this);
}
void Object::update_bounding_sphere()
return &technique->get_pass(tag);
}
+void Object::resource_loaded(Resource &res)
+{
+ if(!meshes.empty() && &res==meshes.front().get() && bounding_sphere.is_empty())
+ update_bounding_sphere();
+}
+
Object::Loader::Loader(Object &o):
DataFile::CollectionObjectLoader<Object>(o, 0)
#include "bindable.h"
#include "renderable.h"
#include "renderpass.h"
+#include "resourcewatcher.h"
namespace Msp {
namespace GL {
Scene, with different model matrices. ObjectInstances can be used to alter the
rendering of an object on a per-instance basis.
*/
-class Object: public Renderable
+class Object: public Renderable, private ResourceWatcher
{
public:
class Loader: public DataFile::CollectionObjectLoader<Object>
private:
const RenderPass *get_pass(const Tag &) const;
+
+ virtual void resource_loaded(Resource &);
};
} // namespace GL
virtual ~Resource();
void set_manager(ResourceManager *);
+ ResourceManager *get_manager() const { return manager; }
void *get_manager_data() const { return manager_data; }
virtual AsyncLoader *load(IO::Seekable &) = 0;
virtual UInt64 get_data_size() const = 0;