diff -r d0d76e8a5203 -r b8232edee786 include/scene.h --- a/include/scene.h Wed Dec 05 18:54:23 2007 +0100 +++ b/include/scene.h Fri Dec 07 14:56:39 2007 +0100 @@ -11,8 +11,18 @@ #include #include "noise.h" +#include "vector.h" -#include "vector.h" +/* +triangle intersection alghoritm +chooses are: +TRI_PLUCKER +TRI_BARI +TRI_BARI_PRE +*/ +#if !defined(TRI_PLUCKER) && !defined(TRI_BARI) && !defined(TRI_BARI_PRE) +# define TRI_BARI_PRE +#endif using namespace std; @@ -140,15 +150,15 @@ virtual ~Shape() {}; // first intersection point - virtual bool intersect(const Ray &ray, Float &dist) = 0; + virtual bool intersect(const Ray &ray, Float &dist) const = 0; // all intersections (only for CSG) - virtual bool intersect_all(const Ray &ray, Float dist, vector &allts) = 0; + virtual bool intersect_all(const Ray &ray, Float dist, vector &allts) const = 0; // normal at point P - virtual Vector3 normal(Vector3 &P) = 0; + virtual Vector3 normal(Vector3 &P) const = 0; - virtual BBox get_bbox() = 0; + virtual BBox get_bbox() const = 0; }; class ShapeList: public vector @@ -166,10 +176,10 @@ Sphere(const Vector3 &acenter, const Float aradius, Material *amaterial): sqr_radius(aradius*aradius), inv_radius(1.0f/aradius), center(acenter), radius(aradius) { material = amaterial; } - bool intersect(const Ray &ray, Float &dist); - bool intersect_all(const Ray &ray, Float dist, vector &allts); - Vector3 normal(Vector3 &P) { return (P - center) * inv_radius; }; - BBox get_bbox(); + bool intersect(const Ray &ray, Float &dist) const; + bool intersect_all(const Ray &ray, Float dist, vector &allts) const; + Vector3 normal(Vector3 &P) const { return (P - center) * inv_radius; }; + BBox get_bbox() const; }; class Box: public Shape @@ -184,26 +194,34 @@ swap(L.cell[i], H.cell[i]); material = amaterial; }; - bool intersect(const Ray &ray, Float &dist); - bool intersect_all(const Ray &ray, Float dist, vector &allts) {return false;}; - Vector3 normal(Vector3 &P); - BBox get_bbox() { return BBox(L, H); }; + bool intersect(const Ray &ray, Float &dist) const; + bool intersect_all(const Ray &ray, Float dist, vector &allts) const { return false; }; + Vector3 normal(Vector3 &P) const; + BBox get_bbox() const { return BBox(L, H); }; }; class Triangle: public Shape { +#ifdef TRI_BARI_PRE + Float nu, nv, nd; int k; // dominant axis - Float nu, nv, nd; Float bnu, bnv; Float cnu, cnv; +#endif +#ifdef TRI_BARI + int k; // dominant axis +#endif +#ifdef TRI_PLUCKER + Float pla[6], plb[6], plc[6]; +#endif public: Vector3 A, B, C, N; Triangle(const Vector3 &aA, const Vector3 &aB, const Vector3 &aC, Material *amaterial); - bool intersect(const Ray &ray, Float &dist); - bool intersect_all(const Ray &ray, Float dist, vector &allts) {return false;}; - Vector3 normal(Vector3 &) { return N; }; - BBox get_bbox(); + bool intersect(const Ray &ray, Float &dist) const; + bool intersect_all(const Ray &ray, Float dist, vector &allts) const {return false;}; + Vector3 normal(Vector3 &) const { return N; }; + BBox get_bbox() const; }; #endif