#ifndef HEIGHTFIELD_H #define HEIGHTFIELD_H #include "shapes.h" #define TILED 1 #define MINMAX 1 #ifdef TILED #define TBITS 3 #define TMASK ((1<>1)&1)) #define ZMAX(x,y,index) Z(x+((index>>2)&1),y+((index>>3)&1)) #endif class Heightfield : public Shape { public: Heightfield(const Transform &o2w, int xcount, int xrepeat, int ycount, int yrepeat, Float *zs); ~Heightfield(); BBox Bound() const; BBox BoundWorldSpace() const; bool Intersect(const Ray &ray, DifferentialGeometry *dg) const; bool IntersectP(const Ray &ray) const; private: Normal VertNorm(int x, int y) const; Normal TriNorm(int x0, int y0, int x1, int y1, int x2, int y2) const; bool TestQuad(const Ray &ray, const Ray &oray, DifferentialGeometry *dg, int X, int Y) const; bool SetDG(const Ray &ray, DifferentialGeometry *dg, const Vector &edge, int X, int Y, int tri, Float u, Float v, Float t) const; Float *z; // heightfield values char *zmm; // packed index to min and max z values int nxgrid, nygrid; // heightfield dataset dimensions int nxcell, nycell; // heightfield dataset cells int nxfullgrid, nyfullgrid; // heightfield replicated grid extent int nxfullcell, nyfullcell; // heightfield replicated cell extent int xmask, ymask; // mask used in address calculations Float zmin, zmax; // heightfield min and max values BBox *bbox; // bounding box structure }; #endif