include/scene.h
branchpyrit
changeset 91 9d66d323c354
parent 86 ce6abe0aeeae
child 92 9af5c039b678
--- a/include/scene.h	Tue Apr 29 23:31:08 2008 +0200
+++ b/include/scene.h	Fri May 02 13:27:47 2008 +0200
@@ -41,12 +41,13 @@
 class Ray
 {
 public:
-	Vector3 o, dir;
+	Vector o, dir;
 	Ray(): o(), dir() {};
-	Ray(const Vector3 &ao, const Vector3 &adir):
+	Ray(const Vector &ao, const Vector &adir):
 		o(ao), dir(adir) {};
 };
 
+#ifndef NO_SSE
 /**
  * packet of 4 rays
  */
@@ -55,14 +56,19 @@
 public:
 	VectorPacket o, dir;
 
+	RayPacket(): o(), dir() {};
+	RayPacket(const VectorPacket &ao, const VectorPacket &adir):
+		o(ao), dir(adir) {};
+
 	// index operator - get a ray
 	Ray operator[](int i) const
 	{
 		return Ray(
-			Vector3(o.x[i], o.y[i], o.z[i]),
-			Vector3(dir.x[i], dir.y[i], dir.z[i]));
+			Vector(o.x[i], o.y[i], o.z[i]),
+			Vector(dir.x[i], dir.y[i], dir.z[i]));
 	};
 };
+#endif
 
 /**
  * a camera
@@ -70,31 +76,32 @@
 class Camera
 {
 public:
-	Vector3 eye, p, u, v;
+	Vector eye, p, u, v;
 	Float F;
 
 	Camera(): eye(0,0,10), p(0,0,-1), u(-1,0,0), v(0,1,0), F(2.*tan(M_PI/8.)) {};
-	Camera(const Vector3 &C, const Vector3 &ap, const Vector3 &au, const Vector3 &av):
+	Camera(const Vector &C, const Vector &ap, const Vector &au, const Vector &av):
 		eye(C), p(ap), u(au), v(av), F(2.*tan(M_PI/8.)) {};
-	Camera(const Vector3 &from, const Vector3 &lookat, const Vector3 &up):
+	Camera(const Vector &from, const Vector &lookat, const Vector &up):
 		eye(from), F(2.*tan(M_PI/8.))
 	{
 		p = lookat - from; u = cross(up, p);
 		p.normalize(); u.normalize();
 		v = cross(p, u);
 	};
-	void setEye(const Vector3 &aeye) { eye = aeye; };
+	void setEye(const Vector &aeye) { eye = aeye; };
 	void setAngle(const Float angle) { F = 2.*tan(angle/2.); };
 	void rotate(const Quaternion &q);
 	void move(const Float fw, const Float left, const Float up);
 
 	Ray makeRay(Sample &samp)
 	{
-		Vector3 dir = p - (u*samp.x + v*samp.y)*F;
+		Vector dir = p - (u*samp.x + v*samp.y)*F;
 		dir.normalize();
 		return Ray(eye, dir);
 	};
 
+#ifndef NO_SSE
 	void makeRayPacket(Sample *samples, RayPacket &rays)
 	{
 		__m128 m1x,m1y,m1z;
@@ -145,6 +152,7 @@
 
 		rays.dir.normalize();
 	};
+#endif
 };
 
 /**
@@ -153,13 +161,13 @@
 class Light
 {
 public:
-	Vector3 pos;
+	Vector pos;
 	Colour colour;
 	bool cast_shadows;
 
 	Light():
-		pos(Vector3(0,0,0)), colour(Colour(1,1,1)), cast_shadows(true) {};
-	Light(const Vector3 &position, const Colour &acolour):
+		pos(Vector(0,0,0)), colour(Colour(1,1,1)), cast_shadows(true) {};
+	Light(const Vector &position, const Colour &acolour):
 		pos(position), colour(acolour), cast_shadows(true) {};
 	void castShadows(bool cast) { cast_shadows = cast; };
 };
@@ -170,15 +178,17 @@
 class BBox
 {
 public:
-	Vector3 L;
-	Vector3 H;
+	Vector L;
+	Vector H;
 	BBox(): L(), H() {};
-	BBox(const Vector3 aL, const Vector3 aH): L(aL), H(aH) {};
+	BBox(const Vector aL, const Vector aH): L(aL), H(aH) {};
 	Float w() { return H.x-L.x; };
 	Float h() { return H.y-L.y; };
 	Float d() { return H.z-L.z; };
 	bool intersect(const Ray &ray, Float &a, Float &b);
+#ifndef NO_SSE
 	__m128 intersect_packet(const RayPacket &rays, __m128 &a, __m128 &b);
+#endif
 };
 
 #endif