diff -r e9bb83c2b8b9 -r ffe83ca074f3 src/scene.cc --- a/src/scene.cc Fri Dec 07 16:39:42 2007 +0100 +++ b/src/scene.cc Sat Dec 08 12:37:45 2007 +0100 @@ -165,7 +165,7 @@ return false; } -Vector3 Box::normal(Vector3 &P) const +const Vector3 Box::normal(const Vector3 &P) const { Vector3 N; for (int i = 0; i < 3; i++) @@ -203,22 +203,22 @@ } #endif -Triangle::Triangle(const Vector3 &aA, const Vector3 &aB, const Vector3 &aC, Material *amaterial) - : A(aA), B(aB), C(aC) +Triangle::Triangle(Vertex *aA, Vertex *aB, Vertex *aC, Material *amaterial) + : smooth(false), A(aA), B(aB), C(aC) { material = amaterial; material->reflection = 0; - const Vector3 c = B - A; - const Vector3 b = C - A; + const Vector3 c = B->P - A->P; + const Vector3 b = C->P - A->P; - N = -cross(c, b); + N = cross(c, b); N.normalize(); #ifdef TRI_PLUCKER - Plucker(B,C,pla); - Plucker(C,A,plb); - Plucker(A,B,plc); + Plucker(B->P,C->P,pla); + Plucker(C->P,A->P,plb); + Plucker(A->P,B->P,plc); #endif #if defined(TRI_BARI) || defined(TRI_BARI_PRE) @@ -244,7 +244,7 @@ Float krec = 1.0 / N[k]; nu = N[u] * krec; nv = N[v] * krec; - nd = dot(N, A) * krec; + nd = dot(N, A->P) * krec; // first line equation Float reci = 1.0f / (b[u] * c[v] - b[v] * c[u]); @@ -269,7 +269,7 @@ const bool side2 = Side(plr, plc) >= 0.0; if (side0 != side2) return false; - const Float t = - dot( (ray.o-A), N) / dot(ray.dir,N); + const Float t = - dot( (ray.o - A->P), N) / dot(ray.dir,N); if(t <= Eps || t >= dist) return false; dist = t; @@ -289,15 +289,15 @@ if (t >= dist || t < Eps) return false; - const Float hu = O[u] + t * D[u] - A[u]; - const Float hv = O[v] + t * D[v] - A[v]; + const Float hu = O[u] + t * D[u] - A->P[u]; + const Float hv = O[v] + t * D[v] - A->P[v]; const Float beta = hv * bnu + hu * bnv; if (beta < 0.) return false; const Float gamma = hu * cnv + hv * cnu; - if (gamma < 0. || beta + gamma > 1) + if (gamma < 0. || beta + gamma > 1.) return false; dist = t; @@ -333,19 +333,19 @@ BBox Triangle::get_bbox() const { BBox bbox = BBox(); - bbox.L = A; - if (B.x < bbox.L.x) bbox.L.x = B.x; - if (C.x < bbox.L.x) bbox.L.x = C.x; - if (B.y < bbox.L.y) bbox.L.y = B.y; - if (C.y < bbox.L.y) bbox.L.y = C.y; - if (B.z < bbox.L.z) bbox.L.z = B.z; - if (C.z < bbox.L.z) bbox.L.z = C.z; - bbox.H = A; - if (B.x > bbox.H.x) bbox.H.x = B.x; - if (C.x > bbox.H.x) bbox.H.x = C.x; - if (B.y > bbox.H.y) bbox.H.y = B.y; - if (C.y > bbox.H.y) bbox.H.y = C.y; - if (B.z > bbox.H.z) bbox.H.z = B.z; - if (C.z > bbox.H.z) bbox.H.z = C.z; + bbox.L = A->P; + if (B->P.x < bbox.L.x) bbox.L.x = B->P.x; + if (C->P.x < bbox.L.x) bbox.L.x = C->P.x; + if (B->P.y < bbox.L.y) bbox.L.y = B->P.y; + if (C->P.y < bbox.L.y) bbox.L.y = C->P.y; + if (B->P.z < bbox.L.z) bbox.L.z = B->P.z; + if (C->P.z < bbox.L.z) bbox.L.z = C->P.z; + bbox.H = A->P; + if (B->P.x > bbox.H.x) bbox.H.x = B->P.x; + if (C->P.x > bbox.H.x) bbox.H.x = C->P.x; + if (B->P.y > bbox.H.y) bbox.H.y = B->P.y; + if (C->P.y > bbox.H.y) bbox.H.y = C->P.y; + if (B->P.z > bbox.H.z) bbox.H.z = B->P.z; + if (C->P.z > bbox.H.z) bbox.H.z = C->P.z; return bbox; };