#ifndef TXS_BARETRI_GUARD #define TXS_BARETRI_GUARD #include "txs_globals.h" namespace TXS { class BareTri { public: Point a, b, c; Vector normal; list edgePlanes; Plane facePlane; BareTri(const Point &a, const Point &b, const Point &c) : a(a), b(b), c(c) { Vector e1 = b - a; Vector e2 = c - b; normal = e1 * e2; BOOL normSuccess = this->normal.Normalize(); if(!normSuccess) __ERROR__("BT.h 23"); facePlane.Set(normal, a); Plane ep; e1 = b - a; ep.Set(normal * e1, a); edgePlanes.push_back(ep); e1 = c - b; ep.Set(normal * e1, b); edgePlanes.push_back(ep); e1 = a - c; ep.Set(normal * e1, c); edgePlanes.push_back(ep); } bool pointInExtrudedInterior(const Point &p) { list::iterator p_iter; for(p_iter = edgePlanes.begin(); p_iter != edgePlanes.end(); ++p_iter) { Plane ep = *p_iter; TXS_REAL dist = (TXS_REAL)Distance(ep, p); if(dist < 0.0) { return false; } } return true; } bool intersectRay(const Point &s, const Vector &d, Point &intxOut) { if(Intersect(facePlane, s, d, intxOut)) { if(pointInExtrudedInterior(intxOut)) { return true; } } return false; } }; } #endif /* TXS_BARETRI_GUARD */