# HG changeset patch # User John Tsiombikas # Date 1398689099 -10800 # Node ID a932848de6521cefc94574b026c7b7a437e8133a # Parent 474a0244f57d9654c3f04d4730d575798286e84a foo diff -r 474a0244f57d -r a932848de652 liberebus/src/geomobj.h --- a/liberebus/src/geomobj.h Mon Apr 28 06:31:10 2014 +0300 +++ b/liberebus/src/geomobj.h Mon Apr 28 15:44:59 2014 +0300 @@ -1,6 +1,7 @@ #ifndef GEOMOBJ_H_ #define GEOMOBJ_H_ +#include #include "object.h" #include "brdf.h" diff -r 474a0244f57d -r a932848de652 liberebus/src/object.cc --- a/liberebus/src/object.cc Mon Apr 28 06:31:10 2014 +0300 +++ b/liberebus/src/object.cc Mon Apr 28 15:44:59 2014 +0300 @@ -3,7 +3,6 @@ Object::Object() { name = ""; - inv_xform_valid = false; } ObjType Object::get_type() const @@ -21,39 +20,6 @@ return name.c_str(); } -void Object::set_xform(const Matrix4x4 &mat) -{ - xform = mat; - inv_xform_valid = false; -} - -void Object::set_xform(const Matrix4x4 &mat, const Matrix4x4 &inv_mat) -{ - xform = mat; - inv_xform = inv_mat; - inv_xform_valid = true; -} - -Matrix4x4 &Object::get_xform() -{ - inv_xform_valid = false; - return xform; -} - -const Matrix4x4 &Object::get_xform() const -{ - return xform; -} - -const Matrix4x4 &Object::get_inv_xform() const -{ - if(!inv_xform_valid) { - inv_xform = xform.inverse(); - inv_xform_valid = true; - } - return inv_xform; -} - bool Object::intersect(const Ray &ray, RayHit *hit) const { return false; diff -r 474a0244f57d -r a932848de652 liberebus/src/object.h --- a/liberebus/src/object.h Mon Apr 28 06:31:10 2014 +0300 +++ b/liberebus/src/object.h Mon Apr 28 15:44:59 2014 +0300 @@ -18,9 +18,6 @@ class Object { private: std::string name; - Matrix4x4 xform; - mutable Matrix4x4 inv_xform; - mutable bool inv_xform_valid; public: Object(); @@ -31,13 +28,6 @@ virtual void set_name(const char *name); virtual const char *get_name() const; - virtual void set_xform(const Matrix4x4 &mat); - virtual void set_xform(const Matrix4x4 &mat, const Matrix4x4 &inv_mat); - - virtual Matrix4x4 &get_xform(); // invalidates inv_xform - virtual const Matrix4x4 &get_xform() const; - virtual const Matrix4x4 &get_inv_xform() const; - virtual bool intersect(const Ray &ray, RayHit *hit = 0) const; }; diff -r 474a0244f57d -r a932848de652 liberebus/src/snode.cc --- a/liberebus/src/snode.cc Mon Apr 28 06:31:10 2014 +0300 +++ b/liberebus/src/snode.cc Mon Apr 28 15:44:59 2014 +0300 @@ -84,12 +84,15 @@ void SceneNode::update_node(long msec) { - node_xform.reset_identity(); - node_xform.translate(pos); - node_xform.rotate(rot); - node_xform.scale(scale); + xform.reset_identity(); + xform.translate(pos); + xform.rotate(rot); + xform.scale(scale); - xform = parent ? parent->xform * node_xform : node_xform; + if(parent) { + xform = parent->xform * xform; + } + inv_xform = xform.inverse(); } void SceneNode::update(long msec) @@ -104,4 +107,5 @@ bool SceneNode::intersect(const Ray &ray, RayHit *hit) const { + Ray local_ray = ray.transformed(inv_xform); } \ No newline at end of file diff -r 474a0244f57d -r a932848de652 liberebus/src/snode.h --- a/liberebus/src/snode.h Mon Apr 28 06:31:10 2014 +0300 +++ b/liberebus/src/snode.h Mon Apr 28 15:44:59 2014 +0300 @@ -16,7 +16,8 @@ SceneNode *parent; std::vector children; - Matrix4x4 node_xform, xform; + Matrix4x4 xform; + Matrix4x4 inv_xform; public: void add_child(SceneNode *node); @@ -37,6 +38,9 @@ Quaternion get_rotation() const; Vector3 get_scaling() const; + const Matrix4x4 &get_matrix() const; + const Matrix4x4 &get_inv_matrix() const; + void update_node(long msec = 0); void update(long msec = 0);