]> git.tdb.fi Git - libs/gl.git/commitdiff
Move transform loading to ObjectInstance
authorMikko Rasa <tdb@tdb.fi>
Tue, 4 Jun 2019 09:26:54 +0000 (12:26 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 4 Jun 2019 09:26:54 +0000 (12:26 +0300)
source/animatedobject.cpp
source/animatedobject.h
source/objectinstance.cpp
source/objectinstance.h

index 3a78110009bc2c47b8cf26e9ab7ee59013444b40..390b90b869ce6acc9eb5a5a93a6fbe701776429e 100644 (file)
@@ -6,7 +6,6 @@
 #include "programdata.h"
 #include "renderer.h"
 #include "technique.h"
-#include "transform.h"
 
 using namespace std;
 
@@ -78,11 +77,9 @@ void AnimatedObject::setup_render(Renderer &renderer, const Tag &) const
 
 
 AnimatedObject::Loader::Loader(AnimatedObject &o):
-       DataFile::ObjectLoader<AnimatedObject>(o)
+       DataFile::DerivedObjectLoader<AnimatedObject, ObjectInstance::Loader>(o)
 {
-       add("transform", &Loader::transform);
-
-       // Deprecated; Use the transform statement instead
+       // Deprecated; Use the transform statement defined in ObjectInstance instead
        add("position", &Loader::position);
        add("rotation", &Loader::rotation);
        add("scale", &Loader::scale);
@@ -109,12 +106,5 @@ void AnimatedObject::Loader::scale_uniform(float s)
        obj.matrix.scale(s);
 }
 
-void AnimatedObject::Loader::transform()
-{
-       Transform trn;
-       load_sub(trn);
-       obj.matrix = trn.to_matrix();
-}
-
 } // namespace GL
 } // namespace Msp
index 73c39e2ca8b2a240e5647ef6d8b6ae02914a0609..2b640b763fa1859807f5a2a0736b44c57ca7aa87 100644 (file)
@@ -16,7 +16,7 @@ An object instance that can be animated by an AnimationPlayer.
 class AnimatedObject: public ObjectInstance
 {
 public:
-       class Loader: public DataFile::ObjectLoader<AnimatedObject>
+       class Loader: public DataFile::DerivedObjectLoader<AnimatedObject, ObjectInstance::Loader>
        {
        public:
                Loader(AnimatedObject &);
@@ -26,7 +26,6 @@ public:
                void rotation(float, float, float, float);
                void scale(float, float, float);
                void scale_uniform(float);
-               void transform();
        };
 
 private:
index 912ec05f94424fa367642f1688020b0e4b09d60b..450c810646f23b5b8439de2e6275730432ea73e4 100644 (file)
@@ -1,5 +1,6 @@
 #include "objectinstance.h"
 #include "renderer.h"
+#include "transform.h"
 
 using namespace std;
 
@@ -26,5 +27,19 @@ void ObjectInstance::setup_render(Renderer &renderer, const Tag &) const
        renderer.transform(matrix);
 }
 
+
+ObjectInstance::Loader::Loader(ObjectInstance &o):
+       DataFile::ObjectLoader<ObjectInstance>(o)
+{
+       add("transform", &Loader::transform);
+}
+
+void ObjectInstance::Loader::transform()
+{
+       Transform trn;
+       load_sub(trn);
+       obj.matrix = trn.to_matrix();
+}
+
 } // namespace GL
 } // namespaec Msp
index 906ba2f32785093237c8dbf108e500a655fe3454..7c2cc9a755afca9fe8e8a17981c80ecaf9920c44 100644 (file)
@@ -18,6 +18,16 @@ render all instances of the same object consecutively.
 */
 class ObjectInstance: public PlacedRenderable
 {
+public:
+       class Loader: public DataFile::ObjectLoader<ObjectInstance>
+       {
+       public:
+               Loader(ObjectInstance &);
+
+       private:
+               void transform();
+       };
+
 protected:
        const Object &object;