erebus

changeset 46:c4d48a21bc4a gmath

in the middle of the vmath->gph-math port
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 24 Feb 2016 00:26:50 +0200
parents bab25c0ce337
children 9971a08f4104
files liberebus/src/brdf.cc liberebus/src/brdf.h liberebus/src/bvol.cc liberebus/src/bvol.h liberebus/src/camera.cc liberebus/src/camera.h liberebus/src/color.h liberebus/src/erebus.cc liberebus/src/erebus_impl.h liberebus/src/geomobj.cc liberebus/src/geomobj.h liberebus/src/object.cc liberebus/src/object.h liberebus/src/rt.cc liberebus/src/scene.cc liberebus/src/snode.cc liberebus/src/snode.h
diffstat 17 files changed, 222 insertions(+), 222 deletions(-) [+]
line diff
     1.1 --- a/liberebus/src/brdf.cc	Tue Dec 29 12:19:53 2015 +0200
     1.2 +++ b/liberebus/src/brdf.cc	Wed Feb 24 00:26:50 2016 +0200
     1.3 @@ -5,32 +5,32 @@
     1.4  #include "erebus_impl.h"
     1.5  
     1.6  // --- class SurfaceGeometry ---
     1.7 -SurfaceGeometry::SurfaceGeometry(const Vector3 &norm, VecLength st)
     1.8 -	: SurfaceGeometry(norm, Vector2(0, 0), st)
     1.9 +SurfaceGeometry::SurfaceGeometry(const Vec3 &norm, VecLength st)
    1.10 +	: SurfaceGeometry(norm, Vec2(0, 0), st)
    1.11  {
    1.12  }
    1.13  
    1.14 -SurfaceGeometry::SurfaceGeometry(const Vector3 &norm, const Vector2 &uvarg, VecLength st)
    1.15 +SurfaceGeometry::SurfaceGeometry(const Vec3 &norm, const Vec2 &uvarg, VecLength st)
    1.16  	: normal(norm), uv(uvarg)
    1.17  {
    1.18  	if(st == unknown) {
    1.19  		normal.normalize();
    1.20  	}
    1.21  
    1.22 -	tangent = Vector3(1.0f, 0.0f, 0.0f);
    1.23 +	tangent = Vec3(1.0f, 0.0f, 0.0f);
    1.24  	if(1.0 - fabs(dot_product(normal, tangent)) < 1e-4f) {
    1.25 -		tangent = Vector3(0.0f, 0.0f, 1.0f);
    1.26 +		tangent = Vec3(0.0f, 0.0f, 1.0f);
    1.27  	}
    1.28 -	Vector3 bitan = cross_product(normal, tangent);
    1.29 +	Vec3 bitan = cross_product(normal, tangent);
    1.30  	tangent = cross_product(bitan, normal);
    1.31  }
    1.32  
    1.33 -SurfaceGeometry::SurfaceGeometry(const Vector3 &norm, const Vector3 &tang, VecLength st)
    1.34 -	: SurfaceGeometry(norm, tang, Vector2(0, 0), st)
    1.35 +SurfaceGeometry::SurfaceGeometry(const Vec3 &norm, const Vec3 &tang, VecLength st)
    1.36 +	: SurfaceGeometry(norm, tang, Vec2(0, 0), st)
    1.37  {
    1.38  }
    1.39  
    1.40 -SurfaceGeometry::SurfaceGeometry(const Vector3 &norm, const Vector3 &tang, const Vector2 &uvarg, VecLength st)
    1.41 +SurfaceGeometry::SurfaceGeometry(const Vec3 &norm, const Vec3 &tang, const Vec2 &uvarg, VecLength st)
    1.42  	: normal(norm), tangent(tang), uv(uvarg)
    1.43  {
    1.44  	if(st == unknown) {
    1.45 @@ -39,26 +39,26 @@
    1.46  	}
    1.47  }
    1.48  
    1.49 -Vector3 SurfaceGeometry::spherical_to_world(float theta, float phi) const
    1.50 +Vec3 SurfaceGeometry::spherical_to_world(float theta, float phi) const
    1.51  {
    1.52  	float x = cos(theta) * sin(phi);
    1.53  	float y = sin(theta) * sin(phi);
    1.54  	float z = cos(phi);
    1.55 -	return sample_to_world(Vector3(x, y, z));
    1.56 +	return sample_to_world(Vec3(x, y, z));
    1.57  }
    1.58  
    1.59 -Vector3 SurfaceGeometry::sample_to_world(const Vector3 &v) const
    1.60 +Vec3 SurfaceGeometry::sample_to_world(const Vec3 &v) const
    1.61  {
    1.62 -	Matrix3x3 xform;
    1.63 +	Mat3x3 xform;
    1.64  	xform.set_column_vector(tangent, 0);
    1.65  	xform.set_column_vector(cross_product(normal, tangent), 1);
    1.66  	xform.set_column_vector(normal, 2);
    1.67  	return v.transformed(xform);
    1.68  }
    1.69  
    1.70 -Vector3 SurfaceGeometry::world_to_sample(const Vector3 &v) const
    1.71 +Vec3 SurfaceGeometry::world_to_sample(const Vec3 &v) const
    1.72  {
    1.73 -	Matrix3x3 xform;
    1.74 +	Mat3x3 xform;
    1.75  	xform.set_row_vector(tangent, 0);
    1.76  	xform.set_row_vector(cross_product(normal, tangent), 1);
    1.77  	xform.set_row_vector(normal, 2);
    1.78 @@ -76,7 +76,7 @@
    1.79  	this->mtl = mtl;
    1.80  }
    1.81  
    1.82 -float Reflectance::sample(const SurfaceGeometry &geom, const Vector3 &outdir, Vector3 *indir) const
    1.83 +float Reflectance::sample(const SurfaceGeometry &geom, const Vec3 &outdir, Vec3 *indir) const
    1.84  {
    1.85  	*indir = sample_dir(geom, outdir);
    1.86  	return eval(geom, outdir, *indir);
    1.87 @@ -94,7 +94,7 @@
    1.88  	valid_checked = false;
    1.89  }
    1.90  
    1.91 -int CompositeRefl::pick_brdf(const SurfaceGeometry &geom, const Vector3 &outdir) const
    1.92 +int CompositeRefl::pick_brdf(const SurfaceGeometry &geom, const Vec3 &outdir) const
    1.93  {
    1.94  	if(sub_brdf.empty()) {
    1.95  		return -1;
    1.96 @@ -158,7 +158,7 @@
    1.97  	"warning: don't call CompositeRefl's sample_dir and eval separately\n"
    1.98  	"         it'll pick different brdfs each time! use sample instead\n";
    1.99  
   1.100 -Vector3 CompositeRefl::sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const
   1.101 +Vec3 CompositeRefl::sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const
   1.102  {
   1.103  	if(!warned_composite_usage) {
   1.104  		fputs(composite_usage_warnstr, stderr);
   1.105 @@ -168,13 +168,13 @@
   1.106  	return sub_brdf[bidx].brdf->sample_dir(geom, outdir);
   1.107  }
   1.108  
   1.109 -float CompositeRefl::sample(const SurfaceGeometry &geom, const Vector3 &outdir, Vector3 *indir) const
   1.110 +float CompositeRefl::sample(const SurfaceGeometry &geom, const Vec3 &outdir, Vec3 *indir) const
   1.111  {
   1.112  	int bidx = pick_brdf(geom, outdir);
   1.113  	return sub_brdf[bidx].brdf->sample(geom, outdir, indir);
   1.114  }
   1.115  
   1.116 -float CompositeRefl::eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const
   1.117 +float CompositeRefl::eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const
   1.118  {
   1.119  	if(!warned_composite_usage) {
   1.120  		fputs(composite_usage_warnstr, stderr);
   1.121 @@ -185,38 +185,38 @@
   1.122  }
   1.123  
   1.124  // --- class LambertRefl ---
   1.125 -Vector3 LambertRefl::sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const
   1.126 +Vec3 LambertRefl::sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const
   1.127  {
   1.128  	// TODO: write a better uniform disk sampling that doesn't rely in rejection
   1.129 -	Vector3 dir;
   1.130 +	Vec3 dir;
   1.131  	do {
   1.132 -		dir = Vector3(randf(-1, 1), randf(-1, 1), 0);
   1.133 +		dir = Vec3(randf(-1, 1), randf(-1, 1), 0);
   1.134  	} while(dir.length_sq() > 1.0);
   1.135  	dir.z = sqrt(1.0 - (dir.x * dir.x + dir.y * dir.y));
   1.136  
   1.137  	return geom.sample_to_world(dir);
   1.138  }
   1.139  
   1.140 -float LambertRefl::eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const
   1.141 +float LambertRefl::eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const
   1.142  {
   1.143  	return dot_product(geom.normal, outdir);
   1.144  }
   1.145  
   1.146  // --- class MirrorRefl ---
   1.147 -Vector3 MirrorRefl::sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const
   1.148 +Vec3 MirrorRefl::sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const
   1.149  {
   1.150  	return outdir.reflection(geom.normal);
   1.151  }
   1.152  
   1.153 -float MirrorRefl::eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const
   1.154 +float MirrorRefl::eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const
   1.155  {
   1.156  	return 1.0f;
   1.157  }
   1.158  
   1.159  // --- class PhongRefl ---
   1.160 -Vector3 PhongRefl::sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const
   1.161 +Vec3 PhongRefl::sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const
   1.162  {
   1.163 -	Vector3 refl = outdir.reflection(geom.normal).normalized();
   1.164 +	Vec3 refl = outdir.reflection(geom.normal).normalized();
   1.165  	SurfaceGeometry refl_geom(refl, SurfaceGeometry::unit);
   1.166  
   1.167  	float shininess = mtl ? mtl->get_attrib_value("shininess", geom.uv.x, geom.uv.y) : 42.0;
   1.168 @@ -227,11 +227,11 @@
   1.169  	return refl_geom.spherical_to_world(theta, phi);
   1.170  }
   1.171  
   1.172 -float PhongRefl::eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const
   1.173 +float PhongRefl::eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const
   1.174  {
   1.175  	float shininess = mtl ? mtl->get_attrib_value("shininess", geom.uv.x, geom.uv.y) : 42.0;
   1.176  
   1.177 -	Vector3 refl = outdir.reflection(geom.normal);
   1.178 +	Vec3 refl = outdir.reflection(geom.normal);
   1.179  	float dot = std::max<float>(dot_product(indir, refl), 0.0f);
   1.180  	return pow(dot, shininess);
   1.181  }
     2.1 --- a/liberebus/src/brdf.h	Tue Dec 29 12:19:53 2015 +0200
     2.2 +++ b/liberebus/src/brdf.h	Wed Feb 24 00:26:50 2016 +0200
     2.3 @@ -8,26 +8,26 @@
     2.4  
     2.5  class SurfaceGeometry {
     2.6  public:
     2.7 -	Vector3 normal, tangent;
     2.8 -	Vector2 uv;
     2.9 +	Vec3 normal, tangent;
    2.10 +	Vec2 uv;
    2.11  
    2.12  	enum VecLength { unit, unknown };
    2.13  
    2.14 -	explicit SurfaceGeometry(const Vector3 &norm, VecLength st = unknown);
    2.15 -	SurfaceGeometry(const Vector3 &norm, const Vector2 &uv, VecLength st = unknown);
    2.16 -	SurfaceGeometry(const Vector3 &norm, const Vector3 &tang, VecLength st = unknown);
    2.17 -	SurfaceGeometry(const Vector3 &norm, const Vector3 &tang, const Vector2 &uv, VecLength st = unknown);
    2.18 +	explicit SurfaceGeometry(const Vec3 &norm, VecLength st = unknown);
    2.19 +	SurfaceGeometry(const Vec3 &norm, const Vec2 &uv, VecLength st = unknown);
    2.20 +	SurfaceGeometry(const Vec3 &norm, const Vec3 &tang, VecLength st = unknown);
    2.21 +	SurfaceGeometry(const Vec3 &norm, const Vec3 &tang, const Vec2 &uv, VecLength st = unknown);
    2.22  
    2.23  	/** create a cartesian direction vector in sample space (zenith = +Z) and
    2.24  	 * transform it to world space.
    2.25  	 * \param theta the horizontal angle (azimuth, in radians) around the Z axis [0, 2pi]
    2.26  	 * \param phi the vertical angle (elevation, in radians) away from the Z axis [0, pi]
    2.27  	 */
    2.28 -	Vector3 spherical_to_world(float theta, float phi) const;
    2.29 +	Vec3 spherical_to_world(float theta, float phi) const;
    2.30  	/// transforms a direction vector from sample space (centered around Z) to world space
    2.31 -	Vector3 sample_to_world(const Vector3 &v) const;
    2.32 +	Vec3 sample_to_world(const Vec3 &v) const;
    2.33  	/// transforms a direction vector from world space to sample space (centered around Z)
    2.34 -	Vector3 world_to_sample(const Vector3 &v) const;
    2.35 +	Vec3 world_to_sample(const Vec3 &v) const;
    2.36  };
    2.37  
    2.38  /// abstract bidirection reflectance distribution function base class
    2.39 @@ -44,14 +44,14 @@
    2.40  	const Material *get_material() const;
    2.41  
    2.42  	/// given an outgoing light direction generate an incidence direction to sample the BRDF
    2.43 -	virtual Vector3 sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const = 0;
    2.44 +	virtual Vec3 sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const = 0;
    2.45  	/// given an outgoing direction, generate an incidence direction, and evaluate its probability
    2.46 -	virtual float sample(const SurfaceGeometry &geom, const Vector3 &outdir, Vector3 *indir) const;
    2.47 +	virtual float sample(const SurfaceGeometry &geom, const Vec3 &outdir, Vec3 *indir) const;
    2.48  	/// given an outgoing direction and an incidence direction, evaluate the probability of this path
    2.49 -	virtual float eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const = 0;
    2.50 +	virtual float eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const = 0;
    2.51  };
    2.52  
    2.53 -typedef float (*CompReflWeightFunc)(const SurfaceGeometry &geom, const Vector3 &outdir);
    2.54 +typedef float (*CompReflWeightFunc)(const SurfaceGeometry &geom, const Vec3 &outdir);
    2.55  
    2.56  /// composite BRDF, with multiple weighted sub-reflectances.
    2.57  class CompositeRefl : public Reflectance {
    2.58 @@ -64,7 +64,7 @@
    2.59  	std::vector<SubRefl> sub_brdf;
    2.60  	mutable bool valid_checked;
    2.61  
    2.62 -	int pick_brdf(const SurfaceGeometry &geom, const Vector3 &outdir) const;
    2.63 +	int pick_brdf(const SurfaceGeometry &geom, const Vec3 &outdir) const;
    2.64  
    2.65  public:
    2.66  	CompositeRefl();
    2.67 @@ -75,30 +75,30 @@
    2.68  
    2.69  	bool check_valid() const;
    2.70  
    2.71 -	Vector3 sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const override;
    2.72 -	float sample(const SurfaceGeometry &geom, const Vector3 &outdir, Vector3 *indir) const override;
    2.73 -	float eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const override;
    2.74 +	Vec3 sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const override;
    2.75 +	float sample(const SurfaceGeometry &geom, const Vec3 &outdir, Vec3 *indir) const override;
    2.76 +	float eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const override;
    2.77  };
    2.78  
    2.79  /// lambertian perfect diffuse reflectance
    2.80  class LambertRefl : public Reflectance {
    2.81  public:
    2.82 -	Vector3 sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const override;
    2.83 -	float eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const override;
    2.84 +	Vec3 sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const override;
    2.85 +	float eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const override;
    2.86  };
    2.87  
    2.88  /// perfect specular reflectance
    2.89  class MirrorRefl : public Reflectance {
    2.90  public:
    2.91 -	Vector3 sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const override;
    2.92 -	float eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const override;
    2.93 +	Vec3 sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const override;
    2.94 +	float eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const override;
    2.95  };
    2.96  
    2.97  /// glossy phong reflectance with lafortune sampling
    2.98  class PhongRefl : public Reflectance {
    2.99  public:
   2.100 -	Vector3 sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const override;
   2.101 -	float eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const override;
   2.102 +	Vec3 sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const override;
   2.103 +	float eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const override;
   2.104  };
   2.105  
   2.106  #endif	// BRDF_H_
     3.1 --- a/liberebus/src/bvol.cc	Tue Dec 29 12:19:53 2015 +0200
     3.2 +++ b/liberebus/src/bvol.cc	Wed Feb 24 00:26:50 2016 +0200
     3.3 @@ -2,8 +2,8 @@
     3.4  
     3.5  bool AABox::intersect(const Ray &ray) const
     3.6  {
     3.7 -	Vector3 param[2] = {vmin, vmax};
     3.8 -	Vector3 inv_dir(1.0 / ray.dir.x, 1.0 / ray.dir.y, 1.0 / ray.dir.z);
     3.9 +	Vec3 param[2] = {vmin, vmax};
    3.10 +	Vec3 inv_dir(1.0 / ray.dir.x, 1.0 / ray.dir.y, 1.0 / ray.dir.z);
    3.11  	int sign[3] = {inv_dir.x < 0, inv_dir.y < 0, inv_dir.z < 0};
    3.12  
    3.13  	float tmin = (param[sign[0]].x - ray.origin.x) * inv_dir.x;
     4.1 --- a/liberebus/src/bvol.h	Tue Dec 29 12:19:53 2015 +0200
     4.2 +++ b/liberebus/src/bvol.h	Wed Feb 24 00:26:50 2016 +0200
     4.3 @@ -5,10 +5,10 @@
     4.4  
     4.5  class AABox {
     4.6  public:
     4.7 -	Vector3 vmin, vmax;
     4.8 +	Vec3 vmin, vmax;
     4.9  
    4.10  	AABox() : vmin(-0.5, -0.5, -0.5), vmax(0.5, 0.5, 0.5) {}
    4.11 -	AABox(const Vector3 &v0, const Vector3 &v1) : vmin(v0), vmax(v1) {}
    4.12 +	AABox(const Vec3 &v0, const Vec3 &v1) : vmin(v0), vmax(v1) {}
    4.13  
    4.14  	bool intersect(const Ray &ray) const;
    4.15  };
     5.1 --- a/liberebus/src/camera.cc	Tue Dec 29 12:19:53 2015 +0200
     5.2 +++ b/liberebus/src/camera.cc	Wed Feb 24 00:26:50 2016 +0200
     5.3 @@ -12,7 +12,7 @@
     5.4  	cached_matrix_valid = false;
     5.5  }
     5.6  
     5.7 -Camera::Camera(const Vector3 &p)
     5.8 +Camera::Camera(const Vec3 &p)
     5.9  	: pos(p)
    5.10  {
    5.11  	vfov = DEFAULT_FOV;
    5.12 @@ -33,18 +33,18 @@
    5.13  	return vfov;
    5.14  }
    5.15  
    5.16 -void Camera::set_position(const Vector3 &pos)
    5.17 +void Camera::set_position(const Vec3 &pos)
    5.18  {
    5.19  	this->pos = pos;
    5.20  	cached_matrix_valid = false;	// invalidate the cached matrix
    5.21  }
    5.22  
    5.23 -const Vector3 &Camera::get_position() const
    5.24 +const Vec3 &Camera::get_position() const
    5.25  {
    5.26  	return pos;
    5.27  }
    5.28  
    5.29 -const Matrix4x4 &Camera::get_matrix() const
    5.30 +const Mat4x4 &Camera::get_matrix() const
    5.31  {
    5.32  	if(!cached_matrix_valid) {
    5.33  		calc_matrix(&cached_matrix);
    5.34 @@ -53,7 +53,7 @@
    5.35  	return cached_matrix;
    5.36  }
    5.37  
    5.38 -Vector2 Camera::calc_sample_pos(int x, int y, int xsz, int ysz, int sample) const
    5.39 +Vec2 Camera::calc_sample_pos(int x, int y, int xsz, int ysz, int sample) const
    5.40  {
    5.41  	float ppos[2];
    5.42  	float aspect = (float)xsz / (float)ysz;
    5.43 @@ -65,12 +65,12 @@
    5.44  	ppos[1] = 1.0 - (float)y * pheight;
    5.45  
    5.46  	calc_sample_pos_rec(sample, pwidth, pheight, ppos);
    5.47 -	return Vector2(ppos[0], ppos[1]);
    5.48 +	return Vec2(ppos[0], ppos[1]);
    5.49  }
    5.50  
    5.51  Ray Camera::get_primary_ray(int x, int y, int xsz, int ysz, int sample) const
    5.52  {
    5.53 -	Vector2 ppos = calc_sample_pos(x, y, xsz, ysz, sample);
    5.54 +	Vec2 ppos = calc_sample_pos(x, y, xsz, ysz, sample);
    5.55  
    5.56  	Ray ray;
    5.57  	ray.origin = pos;
    5.58 @@ -80,7 +80,7 @@
    5.59  	ray.dir.normalize();
    5.60  
    5.61  	// transform the ray direction with the camera matrix
    5.62 -	Matrix4x4 mat = get_matrix();
    5.63 +	Mat4x4 mat = get_matrix();
    5.64  	mat.m[0][3] = mat.m[1][3] = mat.m[2][3] = mat.m[3][0] = mat.m[3][1] = mat.m[3][2] = 0.0;
    5.65  	mat.m[3][3] = 1.0;
    5.66  
    5.67 @@ -90,35 +90,35 @@
    5.68  
    5.69  TargetCamera::TargetCamera() {}
    5.70  
    5.71 -TargetCamera::TargetCamera(const Vector3 &pos, const Vector3 &targ)
    5.72 +TargetCamera::TargetCamera(const Vec3 &pos, const Vec3 &targ)
    5.73  	: Camera(pos), target(targ)
    5.74  {
    5.75  }
    5.76  
    5.77 -void TargetCamera::set_target(const Vector3 &targ)
    5.78 +void TargetCamera::set_target(const Vec3 &targ)
    5.79  {
    5.80  	target = targ;
    5.81  	cached_matrix_valid = false; // invalidate the cached matrix
    5.82  }
    5.83  
    5.84 -const Vector3 &TargetCamera::get_target() const
    5.85 +const Vec3 &TargetCamera::get_target() const
    5.86  {
    5.87  	return target;
    5.88  }
    5.89  
    5.90 -void TargetCamera::calc_matrix(Matrix4x4 *mat) const
    5.91 +void TargetCamera::calc_matrix(Mat4x4 *mat) const
    5.92  {
    5.93 -	Vector3 up{0, 1, 0};
    5.94 -	Vector3 dir = (target - pos).normalized();
    5.95 +	Vec3 up{0, 1, 0};
    5.96 +	Vec3 dir = (target - pos).normalized();
    5.97  
    5.98  	if(1.0 - fabs(dot_product(dir, up)) < 1e-4) {
    5.99 -		up = Vector3(0, 0, 1);
   5.100 +		up = Vec3(0, 0, 1);
   5.101  	}
   5.102  
   5.103 -	Vector3 right = cross_product(up, dir).normalized();
   5.104 +	Vec3 right = cross_product(up, dir).normalized();
   5.105  	up = cross_product(dir, right);
   5.106  
   5.107 -	*mat = Matrix4x4(
   5.108 +	*mat = Mat4x4(
   5.109  			right.x, up.x, dir.x, pos.x,
   5.110  			right.y, up.y, dir.y, pos.y,
   5.111  			right.z, up.z, dir.z, pos.z,
   5.112 @@ -127,11 +127,11 @@
   5.113  
   5.114  void FlyCamera::input_move(float x, float y, float z)
   5.115  {
   5.116 -	static const Vector3 vfwd(0, 0, 1), vright(1, 0, 0);
   5.117 +	static const Vec3 vfwd(0, 0, 1), vright(1, 0, 0);
   5.118  
   5.119 -	Vector3 k = vfwd.transformed(rot);
   5.120 -	Vector3	i = vright.transformed(rot);
   5.121 -	Vector3 j = cross_product(k, i);
   5.122 +	Vec3 k = vfwd.transformed(rot);
   5.123 +	Vec3	i = vright.transformed(rot);
   5.124 +	Vec3 j = cross_product(k, i);
   5.125  
   5.126  	pos += i * x + j * y + k * z;
   5.127  	cached_matrix_valid = false;
   5.128 @@ -139,7 +139,7 @@
   5.129  
   5.130  void FlyCamera::input_rotate(float x, float y, float z)
   5.131  {
   5.132 -	Vector3 axis(x, y, z);
   5.133 +	Vec3 axis(x, y, z);
   5.134  	float axis_len = axis.length();
   5.135  	if(fabs(axis_len) < 1e-5) {
   5.136  		return;
   5.137 @@ -150,14 +150,14 @@
   5.138  	cached_matrix_valid = false;
   5.139  }
   5.140  
   5.141 -void FlyCamera::calc_matrix(Matrix4x4 *mat) const
   5.142 +void FlyCamera::calc_matrix(Mat4x4 *mat) const
   5.143  {
   5.144 -	Matrix4x4 tmat;
   5.145 +	Mat4x4 tmat;
   5.146  	tmat.set_translation(pos);
   5.147  
   5.148 -	Matrix3x3 rmat = rot.get_rotation_matrix();
   5.149 +	Mat3x3 rmat = rot.get_rotation_matrix();
   5.150  
   5.151 -	*mat = tmat * Matrix4x4(rmat);
   5.152 +	*mat = tmat * Mat4x4(rmat);
   5.153  }
   5.154  
   5.155  /* generates a sample position for sample number sidx, in the unit square
     6.1 --- a/liberebus/src/camera.h	Tue Dec 29 12:19:53 2015 +0200
     6.2 +++ b/liberebus/src/camera.h	Wed Feb 24 00:26:50 2016 +0200
     6.3 @@ -5,50 +5,50 @@
     6.4  
     6.5  class Camera {
     6.6  protected:
     6.7 -	Vector3 pos;
     6.8 +	Vec3 pos;
     6.9  	float vfov;	// vertical field of view in radians
    6.10  
    6.11 -	mutable Matrix4x4 cached_matrix;
    6.12 +	mutable Mat4x4 cached_matrix;
    6.13  	mutable bool cached_matrix_valid;
    6.14  
    6.15 -	virtual void calc_matrix(Matrix4x4 *mat) const = 0;
    6.16 +	virtual void calc_matrix(Mat4x4 *mat) const = 0;
    6.17  
    6.18 -	Vector2 calc_sample_pos(int x, int y, int xsz, int ysz, int sample) const;
    6.19 +	Vec2 calc_sample_pos(int x, int y, int xsz, int ysz, int sample) const;
    6.20  
    6.21  public:
    6.22  	Camera();
    6.23 -	Camera(const Vector3 &pos);
    6.24 +	Camera(const Vec3 &pos);
    6.25  	virtual ~Camera();
    6.26  
    6.27  	virtual void set_fov(float vfov);
    6.28  	virtual float get_fov() const;
    6.29  
    6.30 -	virtual void set_position(const Vector3 &pos);
    6.31 -	virtual const Vector3 &get_position() const;
    6.32 -	virtual const Matrix4x4 &get_matrix() const;
    6.33 +	virtual void set_position(const Vec3 &pos);
    6.34 +	virtual const Vec3 &get_position() const;
    6.35 +	virtual const Mat4x4 &get_matrix() const;
    6.36  
    6.37  	virtual Ray get_primary_ray(int x, int y, int xsz, int ysz, int sample = 0) const;
    6.38  };
    6.39  
    6.40  class TargetCamera : public Camera {
    6.41  protected:
    6.42 -	Vector3 target;
    6.43 +	Vec3 target;
    6.44  
    6.45 -	void calc_matrix(Matrix4x4 *mat) const;
    6.46 +	void calc_matrix(Mat4x4 *mat) const;
    6.47  
    6.48  public:
    6.49  	TargetCamera();
    6.50 -	TargetCamera(const Vector3 &pos, const Vector3 &targ);
    6.51 +	TargetCamera(const Vec3 &pos, const Vec3 &targ);
    6.52  
    6.53 -	virtual void set_target(const Vector3 &targ);
    6.54 -	virtual const Vector3 &get_target() const;
    6.55 +	virtual void set_target(const Vec3 &targ);
    6.56 +	virtual const Vec3 &get_target() const;
    6.57  };
    6.58  
    6.59  class FlyCamera : public Camera {
    6.60  protected:
    6.61 -	Quaternion rot;
    6.62 +	Quat rot;
    6.63  
    6.64 -	void calc_matrix(Matrix4x4 *mat) const;
    6.65 +	void calc_matrix(Mat4x4 *mat) const;
    6.66  
    6.67  public:
    6.68  	void input_move(float x, float y, float z);
     7.1 --- a/liberebus/src/color.h	Tue Dec 29 12:19:53 2015 +0200
     7.2 +++ b/liberebus/src/color.h	Wed Feb 24 00:26:50 2016 +0200
     7.3 @@ -3,7 +3,7 @@
     7.4  
     7.5  #include <gmath/gmath.h>
     7.6  
     7.7 -typedef Vector4 Color;
     7.8 +typedef Vec4 Color;
     7.9  
    7.10  inline float color_luminance(const Color &c) { return c[0] * 0.2126 + c[1] * 0.7152 + c[2] * 0.0722; }
    7.11  
     8.1 --- a/liberebus/src/erebus.cc	Tue Dec 29 12:19:53 2015 +0200
     8.2 +++ b/liberebus/src/erebus.cc	Wed Feb 24 00:26:50 2016 +0200
     8.3 @@ -119,13 +119,13 @@
     8.4  	case Option::Type::INT:
     8.5  		{
     8.6  			int ival = ctx->options[opt].ival;
     8.7 -			ctx->options[opt].vval = Vector4(ival, ival, ival, ival);
     8.8 +			ctx->options[opt].vval = Vec4(ival, ival, ival, ival);
     8.9  		}
    8.10  		break;
    8.11  	case Option::Type::FLOAT:
    8.12  		{
    8.13  			float fval = ctx->options[opt].fval;
    8.14 -			ctx->options[opt].vval = Vector4(fval, fval, fval, fval);
    8.15 +			ctx->options[opt].vval = Vec4(fval, fval, fval, fval);
    8.16  		}
    8.17  	default:
    8.18  		break;
    8.19 @@ -343,7 +343,7 @@
    8.20  		case '0':
    8.21  			if(ctx->dbg_nodesel != -1) {
    8.22  				SceneNode *node = ctx->scn->get_node(ctx->dbg_nodesel);
    8.23 -				Vector3 s = node->get_scaling();
    8.24 +				Vec3 s = node->get_scaling();
    8.25  				switch(key) {
    8.26  				case '=':
    8.27  					node->set_scaling(s * 1.1);
    8.28 @@ -352,7 +352,7 @@
    8.29  					node->set_scaling(s * 0.9);
    8.30  					break;
    8.31  				case '0':
    8.32 -					node->set_scaling(Vector3(1, 1, 1));
    8.33 +					node->set_scaling(Vec3(1, 1, 1));
    8.34  					break;
    8.35  				}
    8.36  			}
    8.37 @@ -388,7 +388,7 @@
    8.38  	if(dx || dy) {
    8.39  		TargetCamera *cam = (TargetCamera*)ctx->scn->get_active_camera();
    8.40  		if(cam && ctx->bnstate[0]) {
    8.41 -			Vector3 cpos = cam->get_position();
    8.42 +			Vec3 cpos = cam->get_position();
    8.43  			float mag = cpos.length();
    8.44  
    8.45  			float theta = atan2(cpos.z / mag, cpos.x / mag) - DEG_TO_RAD(dx * 0.5);
     9.1 --- a/liberebus/src/erebus_impl.h	Tue Dec 29 12:19:53 2015 +0200
     9.2 +++ b/liberebus/src/erebus_impl.h	Wed Feb 24 00:26:50 2016 +0200
     9.3 @@ -12,7 +12,7 @@
     9.4  	enum Type { INT, FLOAT, VEC } type;
     9.5  	int ival;
     9.6  	float fval;
     9.7 -	Vector4 vval;
     9.8 +	Vec4 vval;
     9.9  };
    9.10  
    9.11  struct Block {
    10.1 --- a/liberebus/src/geomobj.cc	Tue Dec 29 12:19:53 2015 +0200
    10.2 +++ b/liberebus/src/geomobj.cc	Wed Feb 24 00:26:50 2016 +0200
    10.3 @@ -21,25 +21,25 @@
    10.4  	return false;
    10.5  }
    10.6  
    10.7 -Vector3 GeomObject::gen_surface_point() const
    10.8 +Vec3 GeomObject::gen_surface_point() const
    10.9  {
   10.10 -	return Vector3(0, 0, 0);
   10.11 +	return Vec3(0, 0, 0);
   10.12  }
   10.13  
   10.14 -Vector3 GeomObject::calc_normal(const RayHit &hit) const
   10.15 +Vec3 GeomObject::calc_normal(const RayHit &hit) const
   10.16  {
   10.17  	// when you look at singularities, the singularities always look back at you :)
   10.18  	return -(hit.local_ray.dir).normalized();
   10.19  }
   10.20  
   10.21 -Vector3 GeomObject::calc_tangent(const RayHit &hit) const
   10.22 +Vec3 GeomObject::calc_tangent(const RayHit &hit) const
   10.23  {
   10.24 -	return Vector3(1, 0, 0);	// whatever...
   10.25 +	return Vec3(1, 0, 0);	// whatever...
   10.26  }
   10.27  
   10.28 -Vector2 GeomObject::calc_texcoords(const RayHit &hit) const
   10.29 +Vec2 GeomObject::calc_texcoords(const RayHit &hit) const
   10.30  {
   10.31 -	return Vector2();
   10.32 +	return Vec2();
   10.33  }
   10.34  
   10.35  // --- class Sphere ---
   10.36 @@ -71,42 +71,42 @@
   10.37  	return true;
   10.38  }
   10.39  
   10.40 -Vector3 Sphere::gen_surface_point() const
   10.41 +Vec3 Sphere::gen_surface_point() const
   10.42  {
   10.43  	return sphrand(1.0);
   10.44  }
   10.45  
   10.46 -Vector3 Sphere::calc_normal(const RayHit &hit) const
   10.47 +Vec3 Sphere::calc_normal(const RayHit &hit) const
   10.48  {
   10.49 -	Vector3 pt = hit.local_ray.origin + hit.local_ray.dir * hit.dist;
   10.50 +	Vec3 pt = hit.local_ray.origin + hit.local_ray.dir * hit.dist;
   10.51  	return pt.normalized();
   10.52  }
   10.53  
   10.54 -static inline Vector3 sphvec(float u, float v)
   10.55 +static inline Vec3 sphvec(float u, float v)
   10.56  {
   10.57  	float theta = u * M_PI * 2.0;
   10.58  	float phi = v * M_PI;
   10.59  
   10.60 -	return Vector3(sin(theta) * sin(phi), cos(phi), cos(theta) * sin(phi));
   10.61 +	return Vec3(sin(theta) * sin(phi), cos(phi), cos(theta) * sin(phi));
   10.62  }
   10.63  
   10.64 -Vector3 Sphere::calc_tangent(const RayHit &hit) const
   10.65 +Vec3 Sphere::calc_tangent(const RayHit &hit) const
   10.66  {
   10.67 -	Vector2 uv = calc_texcoords(hit);
   10.68 -	Vector3 pnext = sphvec(uv.x + 0.05, 0.5);
   10.69 -	Vector3 pprev = sphvec(uv.y - 0.05, 0.5);
   10.70 +	Vec2 uv = calc_texcoords(hit);
   10.71 +	Vec3 pnext = sphvec(uv.x + 0.05, 0.5);
   10.72 +	Vec3 pprev = sphvec(uv.y - 0.05, 0.5);
   10.73  	return (pnext - pprev).normalized();
   10.74  }
   10.75  
   10.76 -Vector2 Sphere::calc_texcoords(const RayHit &hit) const
   10.77 +Vec2 Sphere::calc_texcoords(const RayHit &hit) const
   10.78  {
   10.79 -	Vector3 pt = hit.local_ray.origin + hit.local_ray.dir * hit.dist;
   10.80 +	Vec3 pt = hit.local_ray.origin + hit.local_ray.dir * hit.dist;
   10.81  	pt.normalize();
   10.82  
   10.83  	float theta = atan2(pt.z, pt.x);
   10.84  	float phi = acos(pt.y);
   10.85  
   10.86 -	return Vector2(theta / M_PI + 0.5, phi / M_PI);
   10.87 +	return Vec2(theta / M_PI + 0.5, phi / M_PI);
   10.88  }
   10.89  
   10.90  
   10.91 @@ -114,8 +114,8 @@
   10.92  
   10.93  bool Box::intersect(const Ray &ray, RayHit *hit) const
   10.94  {
   10.95 -	Vector3 param[2] = {Vector3{-0.5, -0.5, -0.5}, Vector3{0.5, 0.5, 0.5}};
   10.96 -	Vector3 inv_dir{1.0f / ray.dir.x, 1.0f / ray.dir.y, 1.0f / ray.dir.z};
   10.97 +	Vec3 param[2] = {Vec3{-0.5, -0.5, -0.5}, Vec3{0.5, 0.5, 0.5}};
   10.98 +	Vec3 inv_dir{1.0f / ray.dir.x, 1.0f / ray.dir.y, 1.0f / ray.dir.z};
   10.99  	int sign[3] = {inv_dir.x < 0, inv_dir.y < 0, inv_dir.z < 0};
  10.100  
  10.101  	float tmin = (param[sign[0]].x - ray.origin.x) * inv_dir.x;
  10.102 @@ -159,9 +159,9 @@
  10.103  
  10.104  #define SIGN(x)	(x >= 0.0 ? 1.0 : -1.0)
  10.105  
  10.106 -Vector3 Box::gen_surface_point() const
  10.107 +Vec3 Box::gen_surface_point() const
  10.108  {
  10.109 -	Vector3 rnd{randf(-1, 1), randf(-1, 1), randf(-1, 1)};
  10.110 +	Vec3 rnd{randf(-1, 1), randf(-1, 1), randf(-1, 1)};
  10.111  	float absrnd[3];
  10.112  
  10.113  	absrnd[0] = fabs(rnd.x);
  10.114 @@ -179,26 +179,26 @@
  10.115  }
  10.116  
  10.117  #define BOX_EXT		0.499999
  10.118 -Vector3 Box::calc_normal(const RayHit &hit) const
  10.119 +Vec3 Box::calc_normal(const RayHit &hit) const
  10.120  {
  10.121 -	Vector3 pt = hit.local_ray.origin + hit.local_ray.dir * hit.dist;
  10.122 -	if(pt.x > BOX_EXT) return Vector3(1, 0, 0);
  10.123 -	if(pt.x < -BOX_EXT) return Vector3(-1, 0, 0);
  10.124 -	if(pt.y > BOX_EXT) return Vector3(0, 1, 0);
  10.125 -	if(pt.y < -BOX_EXT) return Vector3(0, -1, 0);
  10.126 -	if(pt.z > BOX_EXT) return Vector3(0, 0, 1);
  10.127 -	if(pt.z < -BOX_EXT) return Vector3(0, 0, -1);
  10.128 -	return Vector3(0, 0, 0);	// shouldn't happen unless numerical precision is fucked
  10.129 +	Vec3 pt = hit.local_ray.origin + hit.local_ray.dir * hit.dist;
  10.130 +	if(pt.x > BOX_EXT) return Vec3(1, 0, 0);
  10.131 +	if(pt.x < -BOX_EXT) return Vec3(-1, 0, 0);
  10.132 +	if(pt.y > BOX_EXT) return Vec3(0, 1, 0);
  10.133 +	if(pt.y < -BOX_EXT) return Vec3(0, -1, 0);
  10.134 +	if(pt.z > BOX_EXT) return Vec3(0, 0, 1);
  10.135 +	if(pt.z < -BOX_EXT) return Vec3(0, 0, -1);
  10.136 +	return Vec3(0, 0, 0);	// shouldn't happen unless numerical precision is fucked
  10.137  }
  10.138  
  10.139 -Vector3 Box::calc_tangent(const RayHit &hit) const
  10.140 +Vec3 Box::calc_tangent(const RayHit &hit) const
  10.141  {
  10.142 -	return Vector3(1, 0, 0);	// TODO
  10.143 +	return Vec3(1, 0, 0);	// TODO
  10.144  }
  10.145  
  10.146 -Vector2 Box::calc_texcoords(const RayHit &hit) const
  10.147 +Vec2 Box::calc_texcoords(const RayHit &hit) const
  10.148  {
  10.149 -	return Vector2(0, 0);	// TODO
  10.150 +	return Vec2(0, 0);	// TODO
  10.151  }
  10.152  
  10.153  // --- class Triangle ---
  10.154 @@ -208,7 +208,7 @@
  10.155  	return false;
  10.156  }
  10.157  
  10.158 -Vector3 Triangle::gen_surface_point() const
  10.159 +Vec3 Triangle::gen_surface_point() const
  10.160  {
  10.161  	// TODO: this is probably not uniform, fix at some point
  10.162  	float bu = randf();
  10.163 @@ -243,8 +243,8 @@
  10.164  	return false;
  10.165  }
  10.166  
  10.167 -Vector3 Mesh::gen_surface_point() const
  10.168 +Vec3 Mesh::gen_surface_point() const
  10.169  {
  10.170  	// this needs some precalculation...
  10.171 -	return Vector3(0, 0, 0);	// TODO
  10.172 +	return Vec3(0, 0, 0);	// TODO
  10.173  }
    11.1 --- a/liberebus/src/geomobj.h	Tue Dec 29 12:19:53 2015 +0200
    11.2 +++ b/liberebus/src/geomobj.h	Wed Feb 24 00:26:50 2016 +0200
    11.3 @@ -17,45 +17,45 @@
    11.4  
    11.5  	bool intersect(const Ray &ray, RayHit *hit = 0) const override;
    11.6  
    11.7 -	virtual Vector3 gen_surface_point() const;
    11.8 +	virtual Vec3 gen_surface_point() const;
    11.9  
   11.10 -	virtual Vector3 calc_normal(const RayHit &hit) const;
   11.11 -	virtual Vector3 calc_tangent(const RayHit &hit) const;
   11.12 -	virtual Vector2 calc_texcoords(const RayHit &hit) const;
   11.13 +	virtual Vec3 calc_normal(const RayHit &hit) const;
   11.14 +	virtual Vec3 calc_tangent(const RayHit &hit) const;
   11.15 +	virtual Vec2 calc_texcoords(const RayHit &hit) const;
   11.16  };
   11.17  
   11.18  class Sphere : public GeomObject {
   11.19  public:
   11.20  	bool intersect(const Ray &ray, RayHit *hit = 0) const override;
   11.21  
   11.22 -	Vector3 gen_surface_point() const override;
   11.23 +	Vec3 gen_surface_point() const override;
   11.24  
   11.25 -	Vector3 calc_normal(const RayHit &hit) const override;
   11.26 -	Vector3 calc_tangent(const RayHit &hit) const override;
   11.27 -	Vector2 calc_texcoords(const RayHit &hit) const override;
   11.28 +	Vec3 calc_normal(const RayHit &hit) const override;
   11.29 +	Vec3 calc_tangent(const RayHit &hit) const override;
   11.30 +	Vec2 calc_texcoords(const RayHit &hit) const override;
   11.31  };
   11.32  
   11.33  class Box : public GeomObject {
   11.34  public:
   11.35  	bool intersect(const Ray &ray, RayHit *hit = 0) const override;
   11.36  
   11.37 -	Vector3 gen_surface_point() const override;
   11.38 +	Vec3 gen_surface_point() const override;
   11.39  
   11.40 -	Vector3 calc_normal(const RayHit &hit) const override;
   11.41 -	Vector3 calc_tangent(const RayHit &hit) const override;
   11.42 -	Vector2 calc_texcoords(const RayHit &hit) const override;
   11.43 +	Vec3 calc_normal(const RayHit &hit) const override;
   11.44 +	Vec3 calc_tangent(const RayHit &hit) const override;
   11.45 +	Vec2 calc_texcoords(const RayHit &hit) const override;
   11.46  };
   11.47  
   11.48  class Triangle : public GeomObject {
   11.49  public:
   11.50 -	Vector3 v[3];
   11.51 -	Vector3 normal;
   11.52 -	Vector3 vnorm[3];
   11.53 -	Vector2 vtex[3];
   11.54 +	Vec3 v[3];
   11.55 +	Vec3 normal;
   11.56 +	Vec3 vnorm[3];
   11.57 +	Vec2 vtex[3];
   11.58  
   11.59  	bool intersect(const Ray &ray, RayHit *hit = 0) const override;
   11.60  
   11.61 -	Vector3 gen_surface_point() const override;
   11.62 +	Vec3 gen_surface_point() const override;
   11.63  };
   11.64  
   11.65  class Mesh : public GeomObject {
   11.66 @@ -71,7 +71,7 @@
   11.67  
   11.68  	bool intersect(const Ray &ray, RayHit *hit = 0) const override;
   11.69  
   11.70 -	Vector3 gen_surface_point() const override;
   11.71 +	Vec3 gen_surface_point() const override;
   11.72  };
   11.73  
   11.74  #endif	// GEOMOBJ_H_
    12.1 --- a/liberebus/src/object.cc	Tue Dec 29 12:19:53 2015 +0200
    12.2 +++ b/liberebus/src/object.cc	Wed Feb 24 00:26:50 2016 +0200
    12.3 @@ -10,25 +10,25 @@
    12.4  	obj = subobj = 0;
    12.5  }
    12.6  
    12.7 -Vector3 RayHit::calc_normal() const
    12.8 +Vec3 RayHit::calc_normal() const
    12.9  {
   12.10  	assert(obj->get_type() == ObjType::geom);
   12.11 -	Vector3 norm = ((const GeomObject*)obj)->calc_normal(*this);
   12.12 +	Vec3 norm = ((const GeomObject*)obj)->calc_normal(*this);
   12.13  
   12.14 -	const Matrix4x4 &xform = node->get_inv_matrix();
   12.15 -	return norm.transformed(Matrix3x3(xform).transposed()).normalized();
   12.16 +	const Mat4x4 &xform = node->get_inv_matrix();
   12.17 +	return norm.transformed(Mat3x3(xform).transposed()).normalized();
   12.18  }
   12.19  
   12.20 -Vector3 RayHit::calc_tangent() const
   12.21 +Vec3 RayHit::calc_tangent() const
   12.22  {
   12.23  	assert(obj->get_type() == ObjType::geom);
   12.24 -	Vector3 tang = ((const GeomObject*)obj)->calc_tangent(*this);
   12.25 +	Vec3 tang = ((const GeomObject*)obj)->calc_tangent(*this);
   12.26  
   12.27 -	const Matrix4x4 &xform = node->get_matrix();
   12.28 -	return tang.transformed(Matrix3x3(xform).transposed());
   12.29 +	const Mat4x4 &xform = node->get_matrix();
   12.30 +	return tang.transformed(Mat3x3(xform).transposed());
   12.31  }
   12.32  
   12.33 -Vector2 RayHit::calc_texcoords() const
   12.34 +Vec2 RayHit::calc_texcoords() const
   12.35  {
   12.36  	assert(obj->get_type() == ObjType::geom);
   12.37  	return ((const GeomObject*)obj)->calc_texcoords(*this);
    13.1 --- a/liberebus/src/object.h	Tue Dec 29 12:19:53 2015 +0200
    13.2 +++ b/liberebus/src/object.h	Wed Feb 24 00:26:50 2016 +0200
    13.3 @@ -17,9 +17,9 @@
    13.4  
    13.5  	RayHit();
    13.6  
    13.7 -	Vector3 calc_normal() const;
    13.8 -	Vector3 calc_tangent() const;
    13.9 -	Vector2 calc_texcoords() const;
   13.10 +	Vec3 calc_normal() const;
   13.11 +	Vec3 calc_tangent() const;
   13.12 +	Vec2 calc_texcoords() const;
   13.13  };
   13.14  
   13.15  enum class ObjType { null, geom, camera };
    14.1 --- a/liberebus/src/rt.cc	Tue Dec 29 12:19:53 2015 +0200
    14.2 +++ b/liberebus/src/rt.cc	Wed Feb 24 00:26:50 2016 +0200
    14.3 @@ -32,16 +32,16 @@
    14.4  	const Ray &ray = hit.world_ray;
    14.5  	//bool entering = true;
    14.6  
    14.7 -	Vector3 pos = ray.origin + ray.dir * hit.dist;
    14.8 +	Vec3 pos = ray.origin + ray.dir * hit.dist;
    14.9  
   14.10 -	Vector3 norm = hit.calc_normal();
   14.11 +	Vec3 norm = hit.calc_normal();
   14.12  	if(dot_product(ray.dir, norm) > 0.0) {
   14.13  		//entering = false;
   14.14  		norm = -norm;
   14.15  	}
   14.16  
   14.17 -	//return norm * 0.5 + Vector3(0.5, 0.5, 0.5);
   14.18 -	Vector2 texcoords = hit.calc_texcoords();
   14.19 +	//return norm * 0.5 + Vec3(0.5, 0.5, 0.5);
   14.20 +	Vec2 texcoords = hit.calc_texcoords();
   14.21  
   14.22  	Color color = mtl->get_attrib_color("diffuse", texcoords.x, texcoords.y);
   14.23  	Color specular = mtl->get_attrib_color("specular", texcoords.x, texcoords.y);
   14.24 @@ -52,7 +52,7 @@
   14.25  
   14.26  	/*
   14.27  	// calculate direct illumination
   14.28 -	Vector3 vdir = -ray.dir.normalized();
   14.29 +	Vec3 vdir = -ray.dir.normalized();
   14.30  	std::list<ObjectInstance> lights = scn->gen_light_list();
   14.31  	auto it = lights.cbegin();
   14.32  	while(it != lights.cend()) {
   14.33 @@ -65,11 +65,11 @@
   14.34  			continue;
   14.35  		}
   14.36  
   14.37 -		const Matrix4x4 &xform = light_node->get_matrix();
   14.38 -		const Matrix4x4 &inv_xform = light_node->get_inv_matrix();
   14.39 -		Vector3 spt = light->gen_surface_point().transformed(xform);
   14.40 +		const Mat4x4 &xform = light_node->get_matrix();
   14.41 +		const Mat4x4 &inv_xform = light_node->get_inv_matrix();
   14.42 +		Vec3 spt = light->gen_surface_point().transformed(xform);
   14.43  
   14.44 -		Vector3 ldir = spt - pos;
   14.45 +		Vec3 ldir = spt - pos;
   14.46  		if(dot_product(ldir, norm) < 0.0) {
   14.47  			continue;
   14.48  		}
   14.49 @@ -91,14 +91,14 @@
   14.50  			shadow_hit.node = inst.node;
   14.51  		}
   14.52  
   14.53 -		Vector2 tc = shadow_hit.calc_texcoords();
   14.54 +		Vec2 tc = shadow_hit.calc_texcoords();
   14.55  		Color lcol = light->mtl.get_attrib_color("emissive", tc.x, tc.y);
   14.56  
   14.57  		ldir.normalize();
   14.58  		norm.normalize();
   14.59  		float ndotl = dot_product(ldir, norm);
   14.60  
   14.61 -		Vector3 refl = ldir.reflection(norm);
   14.62 +		Vec3 refl = ldir.reflection(norm);
   14.63  		float vdotr = dot_product(vdir, refl);
   14.64  
   14.65  		Color direct = ray.energy * lcol * (color * ndotl);// + specular * pow(vdotr, shininess));
   14.66 @@ -107,7 +107,7 @@
   14.67  	}
   14.68  	*/
   14.69  
   14.70 -	Vector3 sample_dir;
   14.71 +	Vec3 sample_dir;
   14.72  	float prob = brdf->sample(SurfaceGeometry(norm), -ray.dir, &sample_dir);
   14.73  	if(randf() <= prob) {
   14.74  		Ray sample_ray;
    15.1 --- a/liberebus/src/scene.cc	Tue Dec 29 12:19:53 2015 +0200
    15.2 +++ b/liberebus/src/scene.cc	Wed Feb 24 00:26:50 2016 +0200
    15.3 @@ -313,7 +313,7 @@
    15.4  				fprintf(stderr, "-position must be followed by 3 numbers\n");
    15.5  				goto err;
    15.6  			}
    15.7 -			node->set_position(Vector3(vec[0], vec[1], vec[2]));
    15.8 +			node->set_position(Vec3(vec[0], vec[1], vec[2]));
    15.9  			i += 3;
   15.10  
   15.11  		} else if(strcmp(argv[i], "-rotation") == 0) {
   15.12 @@ -322,16 +322,16 @@
   15.13  				fprintf(stderr, "-rotation must be followed by axis vector and angle\n");
   15.14  				goto err;
   15.15  			}
   15.16 -			node->set_rotation(Quaternion(Vector3(vec[0], vec[1], vec[2]), vec[3]));
   15.17 +			node->set_rotation(Quat(Vec3(vec[0], vec[1], vec[2]), vec[3]));
   15.18  			i += 4;
   15.19  
   15.20  		} else if(strcmp(argv[i], "-scaling") == 0) {
   15.21  			int nelem = parse_vec(argv + i + 1, vec);
   15.22 -			Vector3 s;
   15.23 +			Vec3 s;
   15.24  			if(nelem == 1) {
   15.25  				s.x = s.y = s.z = vec[0];
   15.26  			} else if(nelem == 3) {
   15.27 -				s = Vector3(vec[0], vec[1], vec[2]);
   15.28 +				s = Vec3(vec[0], vec[1], vec[2]);
   15.29  			} else {
   15.30  				fprintf(stderr, "-scaling must be followed by 1 or 3 numbers\n");
   15.31  				goto err;
   15.32 @@ -361,9 +361,9 @@
   15.33  			int nelem = parse_vec(argv + i + 1, vec);
   15.34  			Color emissive;
   15.35  			if(nelem == 1) {
   15.36 -				emissive = Vector3(1, 1, 1);
   15.37 +				emissive = Vec3(1, 1, 1);
   15.38  			} else if(nelem == 3) {
   15.39 -				emissive = Vector3(vec[0], vec[1], vec[2]);
   15.40 +				emissive = Vec3(vec[0], vec[1], vec[2]);
   15.41  			} else {
   15.42  				fprintf(stderr, "-emissive must be followed by an intensity or a color\n");
   15.43  				goto err;
   15.44 @@ -402,7 +402,7 @@
   15.45  				fprintf(stderr, "-position must be followed by 3 numbers\n");
   15.46  				goto err;
   15.47  			}
   15.48 -			cam->set_position(Vector3(vec[0], vec[1], vec[2]));
   15.49 +			cam->set_position(Vec3(vec[0], vec[1], vec[2]));
   15.50  			i += 3;
   15.51  
   15.52  		} else if(strcmp(argv[i], "-target") == 0) {
   15.53 @@ -411,7 +411,7 @@
   15.54  				fprintf(stderr, "-target must be followed by 3 numbers\n");
   15.55  				goto err;
   15.56  			}
   15.57 -			cam->set_target(Vector3(vec[0], vec[1], vec[2]));
   15.58 +			cam->set_target(Vec3(vec[0], vec[1], vec[2]));
   15.59  			i += 3;
   15.60  
   15.61  		} else if(strcmp(argv[i], "-fov") == 0) {
    16.1 --- a/liberebus/src/snode.cc	Tue Dec 29 12:19:53 2015 +0200
    16.2 +++ b/liberebus/src/snode.cc	Wed Feb 24 00:26:50 2016 +0200
    16.3 @@ -72,59 +72,59 @@
    16.4  	return obj[idx];
    16.5  }
    16.6  
    16.7 -void SceneNode::set_position(const Vector3 &pos)
    16.8 +void SceneNode::set_position(const Vec3 &pos)
    16.9  {
   16.10  	this->pos = pos;
   16.11  }
   16.12  
   16.13 -void SceneNode::set_rotation(const Quaternion &rot)
   16.14 +void SceneNode::set_rotation(const Quat &rot)
   16.15  {
   16.16  	this->rot = rot;
   16.17  }
   16.18  
   16.19 -void SceneNode::set_scaling(const Vector3 &scale)
   16.20 +void SceneNode::set_scaling(const Vec3 &scale)
   16.21  {
   16.22  	this->scale = scale;
   16.23  }
   16.24  
   16.25  
   16.26 -const Vector3 &SceneNode::get_node_position() const
   16.27 +const Vec3 &SceneNode::get_node_position() const
   16.28  {
   16.29  	return pos;
   16.30  }
   16.31  
   16.32 -const Quaternion &SceneNode::get_node_rotation() const
   16.33 +const Quat &SceneNode::get_node_rotation() const
   16.34  {
   16.35  	return rot;
   16.36  }
   16.37  
   16.38 -const Vector3 &SceneNode::get_node_scaling() const
   16.39 +const Vec3 &SceneNode::get_node_scaling() const
   16.40  {
   16.41  	return scale;
   16.42  }
   16.43  
   16.44  
   16.45 -Vector3 SceneNode::get_position() const
   16.46 +Vec3 SceneNode::get_position() const
   16.47  {
   16.48 -	return Vector3{0, 0, 0}.transformed(xform);
   16.49 +	return Vec3{0, 0, 0}.transformed(xform);
   16.50  }
   16.51  
   16.52 -Quaternion SceneNode::get_rotation() const
   16.53 +Quat SceneNode::get_rotation() const
   16.54  {
   16.55  	return rot;	// TODO
   16.56  }
   16.57  
   16.58 -Vector3 SceneNode::get_scaling() const
   16.59 +Vec3 SceneNode::get_scaling() const
   16.60  {
   16.61  	return scale;	// TODO
   16.62  }
   16.63  
   16.64 -const Matrix4x4 &SceneNode::get_matrix() const
   16.65 +const Mat4x4 &SceneNode::get_matrix() const
   16.66  {
   16.67  	return xform;
   16.68  }
   16.69  
   16.70 -const Matrix4x4 &SceneNode::get_inv_matrix() const
   16.71 +const Mat4x4 &SceneNode::get_inv_matrix() const
   16.72  {
   16.73  	return inv_xform;
   16.74  }
    17.1 --- a/liberebus/src/snode.h	Tue Dec 29 12:19:53 2015 +0200
    17.2 +++ b/liberebus/src/snode.h	Wed Feb 24 00:26:50 2016 +0200
    17.3 @@ -7,17 +7,17 @@
    17.4  
    17.5  class SceneNode {
    17.6  private:
    17.7 -	Vector3 pos;
    17.8 -	Quaternion rot;
    17.9 -	Vector3 scale;
   17.10 +	Vec3 pos;
   17.11 +	Quat rot;
   17.12 +	Vec3 scale;
   17.13  
   17.14  	std::vector<Object*> obj;
   17.15  
   17.16  	SceneNode *parent;
   17.17  	std::vector<SceneNode*> children;
   17.18  
   17.19 -	Matrix4x4 xform;
   17.20 -	Matrix4x4 inv_xform;
   17.21 +	Mat4x4 xform;
   17.22 +	Mat4x4 inv_xform;
   17.23  
   17.24  public:
   17.25  	SceneNode();
   17.26 @@ -35,20 +35,20 @@
   17.27  	int get_num_objects() const;
   17.28  	Object *get_object(int idx) const;
   17.29  
   17.30 -	void set_position(const Vector3 &pos);
   17.31 -	void set_rotation(const Quaternion &rot);
   17.32 -	void set_scaling(const Vector3 &scale);
   17.33 +	void set_position(const Vec3 &pos);
   17.34 +	void set_rotation(const Quat &rot);
   17.35 +	void set_scaling(const Vec3 &scale);
   17.36  
   17.37 -	const Vector3 &get_node_position() const;
   17.38 -	const Quaternion &get_node_rotation() const;
   17.39 -	const Vector3 &get_node_scaling() const;
   17.40 +	const Vec3 &get_node_position() const;
   17.41 +	const Quat &get_node_rotation() const;
   17.42 +	const Vec3 &get_node_scaling() const;
   17.43  
   17.44 -	Vector3 get_position() const;
   17.45 -	Quaternion get_rotation() const;
   17.46 -	Vector3 get_scaling() const;
   17.47 +	Vec3 get_position() const;
   17.48 +	Quat get_rotation() const;
   17.49 +	Vec3 get_scaling() const;
   17.50  
   17.51 -	const Matrix4x4 &get_matrix() const;
   17.52 -	const Matrix4x4 &get_inv_matrix() const;
   17.53 +	const Mat4x4 &get_matrix() const;
   17.54 +	const Mat4x4 &get_inv_matrix() const;
   17.55  
   17.56  	void update_node(long msec = 0);
   17.57  	void update(long msec = 0);