erebus

changeset 3:a932848de652

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 28 Apr 2014 15:44:59 +0300
parents 474a0244f57d
children 93894c232d65
files liberebus/src/geomobj.h liberebus/src/object.cc liberebus/src/object.h liberebus/src/snode.cc liberebus/src/snode.h
diffstat 5 files changed, 15 insertions(+), 50 deletions(-) [+]
line diff
     1.1 --- a/liberebus/src/geomobj.h	Mon Apr 28 06:31:10 2014 +0300
     1.2 +++ b/liberebus/src/geomobj.h	Mon Apr 28 15:44:59 2014 +0300
     1.3 @@ -1,6 +1,7 @@
     1.4  #ifndef GEOMOBJ_H_
     1.5  #define GEOMOBJ_H_
     1.6  
     1.7 +#include <vector>
     1.8  #include "object.h"
     1.9  #include "brdf.h"
    1.10  
     2.1 --- a/liberebus/src/object.cc	Mon Apr 28 06:31:10 2014 +0300
     2.2 +++ b/liberebus/src/object.cc	Mon Apr 28 15:44:59 2014 +0300
     2.3 @@ -3,7 +3,6 @@
     2.4  Object::Object()
     2.5  {
     2.6  	name = "<unnamed>";
     2.7 -	inv_xform_valid = false;
     2.8  }
     2.9  
    2.10  ObjType Object::get_type() const
    2.11 @@ -21,39 +20,6 @@
    2.12  	return name.c_str();
    2.13  }
    2.14  
    2.15 -void Object::set_xform(const Matrix4x4 &mat)
    2.16 -{
    2.17 -	xform = mat;
    2.18 -	inv_xform_valid = false;
    2.19 -}
    2.20 -
    2.21 -void Object::set_xform(const Matrix4x4 &mat, const Matrix4x4 &inv_mat)
    2.22 -{
    2.23 -	xform = mat;
    2.24 -	inv_xform = inv_mat;
    2.25 -	inv_xform_valid = true;
    2.26 -}
    2.27 -
    2.28 -Matrix4x4 &Object::get_xform()
    2.29 -{
    2.30 -	inv_xform_valid = false;
    2.31 -	return xform;
    2.32 -}
    2.33 -
    2.34 -const Matrix4x4 &Object::get_xform() const
    2.35 -{
    2.36 -	return xform;
    2.37 -}
    2.38 -
    2.39 -const Matrix4x4 &Object::get_inv_xform() const
    2.40 -{
    2.41 -	if(!inv_xform_valid) {
    2.42 -		inv_xform = xform.inverse();
    2.43 -		inv_xform_valid = true;
    2.44 -	}
    2.45 -	return inv_xform;
    2.46 -}
    2.47 -
    2.48  bool Object::intersect(const Ray &ray, RayHit *hit) const
    2.49  {
    2.50  	return false;
     3.1 --- a/liberebus/src/object.h	Mon Apr 28 06:31:10 2014 +0300
     3.2 +++ b/liberebus/src/object.h	Mon Apr 28 15:44:59 2014 +0300
     3.3 @@ -18,9 +18,6 @@
     3.4  class Object {
     3.5  private:
     3.6  	std::string name;
     3.7 -	Matrix4x4 xform;
     3.8 -	mutable Matrix4x4 inv_xform;
     3.9 -	mutable bool inv_xform_valid;
    3.10  
    3.11  public:
    3.12  	Object();
    3.13 @@ -31,13 +28,6 @@
    3.14  	virtual void set_name(const char *name);
    3.15  	virtual const char *get_name() const;
    3.16  
    3.17 -	virtual void set_xform(const Matrix4x4 &mat);
    3.18 -	virtual void set_xform(const Matrix4x4 &mat, const Matrix4x4 &inv_mat);
    3.19 -
    3.20 -	virtual Matrix4x4 &get_xform();	// invalidates inv_xform
    3.21 -	virtual const Matrix4x4 &get_xform() const;
    3.22 -	virtual const Matrix4x4 &get_inv_xform() const;
    3.23 -
    3.24  	virtual bool intersect(const Ray &ray, RayHit *hit = 0) const;
    3.25  };
    3.26  
     4.1 --- a/liberebus/src/snode.cc	Mon Apr 28 06:31:10 2014 +0300
     4.2 +++ b/liberebus/src/snode.cc	Mon Apr 28 15:44:59 2014 +0300
     4.3 @@ -84,12 +84,15 @@
     4.4  
     4.5  void SceneNode::update_node(long msec)
     4.6  {
     4.7 -	node_xform.reset_identity();
     4.8 -	node_xform.translate(pos);
     4.9 -	node_xform.rotate(rot);
    4.10 -	node_xform.scale(scale);
    4.11 +	xform.reset_identity();
    4.12 +	xform.translate(pos);
    4.13 +	xform.rotate(rot);
    4.14 +	xform.scale(scale);
    4.15  
    4.16 -	xform = parent ? parent->xform * node_xform : node_xform;
    4.17 +	if(parent) {
    4.18 +		xform = parent->xform * xform;
    4.19 +	}
    4.20 +	inv_xform = xform.inverse();
    4.21  }
    4.22  
    4.23  void SceneNode::update(long msec)
    4.24 @@ -104,4 +107,5 @@
    4.25  
    4.26  bool SceneNode::intersect(const Ray &ray, RayHit *hit) const
    4.27  {
    4.28 +	Ray local_ray = ray.transformed(inv_xform);
    4.29  }
    4.30 \ No newline at end of file
     5.1 --- a/liberebus/src/snode.h	Mon Apr 28 06:31:10 2014 +0300
     5.2 +++ b/liberebus/src/snode.h	Mon Apr 28 15:44:59 2014 +0300
     5.3 @@ -16,7 +16,8 @@
     5.4  	SceneNode *parent;
     5.5  	std::vector<SceneNode*> children;
     5.6  
     5.7 -	Matrix4x4 node_xform, xform;
     5.8 +	Matrix4x4 xform;
     5.9 +	Matrix4x4 inv_xform;
    5.10  
    5.11  public:
    5.12  	void add_child(SceneNode *node);
    5.13 @@ -37,6 +38,9 @@
    5.14  	Quaternion get_rotation() const;
    5.15  	Vector3 get_scaling() const;
    5.16  
    5.17 +	const Matrix4x4 &get_matrix() const;
    5.18 +	const Matrix4x4 &get_inv_matrix() const;
    5.19 +
    5.20  	void update_node(long msec = 0);
    5.21  	void update(long msec = 0);
    5.22