X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Ftransform.cpp;h=5b55ab2dc4f05c0833196d549f77405e7f43d26b;hb=8420959665d2a2cfeed3e50dc0d706b9b7570414;hp=6af24c0279ea3ebaaab0ba83a0a0cd4203f62053;hpb=c809f54b802727926bae40e9fe67d0e3c94fd2c0;p=libs%2Fgame.git diff --git a/source/game/transform.cpp b/source/game/transform.cpp index 6af24c0..5b55ab2 100644 --- a/source/game/transform.cpp +++ b/source/game/transform.cpp @@ -4,24 +4,40 @@ namespace Msp::Game { Transform::Transform(Handle e): - Component(e) + BufferedComponent(e) { } void Transform::set_values(const TransformValues &v) { - values = v; + write().values = v; +} + +void Transform::set_position(const LinAl::Vector &p) +{ + write().values.position = p; +} + +void Transform::set_rotation(const Geometry::Quaternion &r) +{ + write().values.rotation = normalize(r); +} + +void Transform::set_scale(const LinAl::Vector &s) +{ + write().values.scale = s; } void Transform::update_world_matrix(const Transform *parent) { using Affine = Geometry::AffineTransform; - 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