diff -r 79b516a3803d -r 76b7bd51d64a src/scene.cc --- a/src/scene.cc Fri Nov 30 00:44:51 2007 +0100 +++ b/src/scene.cc Mon Dec 03 01:49:23 2007 +0100 @@ -24,16 +24,16 @@ */ // optimized - float t2 = q.a*q.b; - float t3 = q.a*q.c; - float t4 = q.a*q.d; - float t5 = -q.b*q.b; - float t6 = q.b*q.c; - float t7 = q.b*q.d; - float t8 = -q.c*q.c; - float t9 = q.c*q.d; - float t10 = -q.d*q.d; - float x,y,z; + Float t2 = q.a*q.b; + Float t3 = q.a*q.c; + Float t4 = q.a*q.d; + Float t5 = -q.b*q.b; + Float t6 = q.b*q.c; + Float t7 = q.b*q.d; + Float t8 = -q.c*q.c; + Float t9 = q.c*q.d; + Float t10 = -q.d*q.d; + Float x,y,z; x = 2*( (t8 + t10)*p.x + (t6 - t4)*p.y + (t3 + t7)*p.z ) + p.x; y = 2*( (t4 + t6)*p.x + (t5 + t10)*p.y + (t9 - t2)*p.z ) + p.y; z = 2*( (t7 - t3)*p.x + (t2 + t9)*p.y + (t5 + t8)*p.z ) + p.z; @@ -51,17 +51,17 @@ v.normalize(); } -void Camera::move(const float fw, const float left, const float up) +void Camera::move(const Float fw, const Float left, const Float up) { eye = eye + fw*p + left*u + up*v; } /* http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtinter3.htm */ -bool BBox::intersect(const Ray &ray, float &a, float &b) +bool BBox::intersect(const Ray &ray, Float &a, Float &b) { - float tnear = -FLT_MAX; - float tfar = FLT_MAX; - float t1, t2; + Float tnear = -FLT_MAX; + Float tfar = FLT_MAX; + Float t1, t2; for (int i = 0; i < 3; i++) { @@ -94,11 +94,11 @@ return true; } -bool Sphere::intersect(const Ray &ray, float &dist) +bool Sphere::intersect(const Ray &ray, Float &dist) { Vector3 V = ray.o - center; - register float d = -dot(V, ray.dir); - register float Det = d * d - (dot(V,V) - sqr_radius); + register Float d = -dot(V, ray.dir); + register Float Det = d * d - (dot(V,V) - sqr_radius); if (Det > 0) { d -= sqrtf(Det); if (d > 0 && d < dist) @@ -110,18 +110,18 @@ return false; } -bool Sphere::intersect_all(const Ray &ray, float dist, vector &allts) +bool Sphere::intersect_all(const Ray &ray, Float dist, vector &allts) { - //allts = new vector(); + //allts = new vector(); Vector3 V = ((Ray)ray).o - center; - float Vd = - dot(V, ray.dir); - float Det = Vd * Vd - (dot(V,V) - sqr_radius); + Float Vd = - dot(V, ray.dir); + Float Det = Vd * Vd - (dot(V,V) - sqr_radius); if (Det > 0) { Det = sqrtf(Det); - float t1 = Vd - Det; - float t2 = Vd + Det; + Float t1 = Vd - Det; + Float t2 = Vd + Det; if (t1 < 0) { if (t2 > 0) @@ -152,9 +152,9 @@ return bbox; } -bool Box::intersect(const Ray &ray, float &dist) +bool Box::intersect(const Ray &ray, Float &dist) { - float a,b; + Float a,b; bool res = get_bbox().intersect(ray, a, b); if (res && a < dist) { @@ -216,13 +216,13 @@ int u = (k + 1) % 3; int v = (k + 2) % 3; - float krec = 1.0f / N[k]; + Float krec = 1.0f / N[k]; nu = N[u] * krec; nv = N[v] * krec; nd = dot(N, A) * krec; // first line equation - float reci = 1.0f / (b[u] * c[v] - b[v] * c[u]); + Float reci = 1.0f / (b[u] * c[v] - b[v] * c[u]); bnu = b[u] * reci; bnv = -b[v] * reci; @@ -235,7 +235,7 @@ } // see comment for previous method -bool Triangle::intersect(const Ray &ray, float &dist) +bool Triangle::intersect(const Ray &ray, Float &dist) { Vector3 O = ray.o; Vector3 D = ray.dir; @@ -243,20 +243,20 @@ const int modulo3[5] = {0,1,2,0,1}; const int ku = modulo3[k+1]; const int kv = modulo3[k+2]; - const float lnd = 1.0f / (D[k] + nu * D[ku] + nv * D[kv]); - const float t = (nd - O[k] - nu * O[ku] - nv * O[kv]) * lnd; + const Float lnd = 1.0f / (D[k] + nu * D[ku] + nv * D[kv]); + const Float t = (nd - O[k] - nu * O[ku] - nv * O[kv]) * lnd; if (!(t < dist && t > 0)) return false; - float hu = O[ku] + t * D[ku] - A[ku]; - float hv = O[kv] + t * D[kv] - A[kv]; - float beta = hv * bnu + hu * bnv; + Float hu = O[ku] + t * D[ku] - A[ku]; + Float hv = O[kv] + t * D[kv] - A[kv]; + Float beta = hv * bnu + hu * bnv; if (beta < 0) return false; - float gamma = hu * cnu + hv * cnv; + Float gamma = hu * cnu + hv * cnv; if (gamma < 0) return false;