mesh->draw_instanced(renderer, vtx_setup, instance_count);
}
+
+DataFile::Loader::ActionMap InstanceArrayBase::Loader::shared_actions;
+
+InstanceArrayBase::Loader::Loader(InstanceArrayBase &o):
+ ObjectLoader<InstanceArrayBase>(o)
+{
+ set_actions(shared_actions);
+}
+
+void InstanceArrayBase::Loader::init_actions()
+{
+ add("instance", &Loader::instance);
+}
+
} // namespace GL
} // namespace Msp
class InstanceArrayBase: public Renderable, public NonCopyable
{
+protected:
+ class Loader: public DataFile::ObjectLoader<InstanceArrayBase>
+ {
+ private:
+ static ActionMap shared_actions;
+
+ public:
+ Loader(InstanceArrayBase &);
+
+ private:
+ virtual void init_actions();
+
+ protected:
+ virtual void instance() = 0;
+ };
+
private:
struct Block
{
template<typename T = ObjectInstance>
class InstanceArray: public InstanceArrayBase
{
+public:
+ class Loader: public DataFile::DerivedObjectLoader<InstanceArray, InstanceArrayBase::Loader>
+ {
+ public:
+ Loader(InstanceArray &a): DataFile::DerivedObjectLoader<InstanceArray, InstanceArrayBase::Loader>(a) { }
+
+ protected:
+ virtual void instance();
+ };
+
private:
class Instance: public T
{
array.update_instance_matrix(index, *this->get_matrix());
}
+
+template<typename T>
+void InstanceArray<T>::Loader::instance()
+{
+ T &inst = this->obj.append();
+ this->load_sub(inst);
+}
+
} // namespace GL
} // namespace Msp
#include <msp/fs/utils.h>
#include <msp/strings/format.h>
#include "camera.h"
+#include "instancearray.h"
#include "objectinstance.h"
#include "occludedscene.h"
#include "orderedscene.h"
DataFile::CollectionObjectLoader<Scene>(s, &c),
content(m)
{
+ add("array", &Loader::array);
add("object", &Loader::object);
add("object", &Loader::object_tagged);
add("scene", &Loader::scene);
add("scene", &Loader::scene_inline);
}
+void Scene::Loader::array(const string &n)
+{
+ RefPtr<InstanceArray<> > arr = new InstanceArray<>(get_collection().get<GL::Object>(n));
+ load_sub(*arr);
+ get_collection().add(format("_scene_array_%d.array", ++inline_counter), arr.get());
+ obj.add(*arr.release());
+}
+
void Scene::Loader::object(const string &n)
{
object_tagged(n, string());
private:
Loader(Scene &, Collection &, ContentMap *);
+ void array(const std::string &);
void object(const std::string &);
void object_tagged(const std::string &, const std::string &);
void scene(const std::string &);