]> git.tdb.fi Git - libs/game.git/blobdiff - source/game/transform.cpp
Convert components to buffered where appropriate
[libs/game.git] / source / game / transform.cpp
index e5655f929765554f87be052a9d23647051e1b617..5b55ab2dc4f05c0833196d549f77405e7f43d26b 100644 (file)
@@ -4,39 +4,40 @@
 namespace Msp::Game {
 
 Transform::Transform(Handle<Entity> e):
-       Component(e)
+       BufferedComponent<TransformData>(e)
 { }
 
 void Transform::set_values(const TransformValues &v)
 {
-       values = v;
+       write().values = v;
 }
 
 void Transform::set_position(const LinAl::Vector<float, 3> &p)
 {
-       values.position = p;
+       write().values.position = p;
 }
 
 void Transform::set_rotation(const Geometry::Quaternion<float> &r)
 {
-       values.rotation = normalize(r);
+       write().values.rotation = normalize(r);
 }
 
 void Transform::set_scale(const LinAl::Vector<float, 3> &s)
 {
-       values.scale = s;
+       write().values.scale = s;
 }
 
 void Transform::update_world_matrix(const Transform *parent)
 {
        using Affine = Geometry::AffineTransform<float, 3>;
 
-       local_matrix = Affine::translation(values.position)*
-               Affine::rotation(values.rotation)*Affine::scaling(values.scale);
+       Data &d = write();
+       d.local_matrix = Affine::translation(d.values.position)*
+               Affine::rotation(d.values.rotation)*Affine::scaling(d.values.scale);
        if(parent)
-               world_matrix = parent->get_world_matrix()*local_matrix;
+               d.world_matrix = parent->get_world_matrix()*d.local_matrix;
        else
-               world_matrix = local_matrix;
+               d.world_matrix = d.local_matrix;
 }
 
 } // namespace Msp::Game