Frustum.cpp   Frustum.cpp 
skipping to change at line 25 skipping to change at line 25
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "Frustum.hpp" #include "Frustum.hpp"
#include "GLFuncs.hpp" #include "GLFuncs.hpp"
#include <limits> #include <limits>
Frustum::Frustum() : bbox(Vec3f(0),Vec3f(0)),drawBbox(Vec3f(0),Vec3f(0)) Frustum::Frustum()
{ {
for(unsigned int i=0; i<CORNERCOUNT; i++) for(unsigned int i=0; i<CORNERCOUNT; i++)
{ {
corners.push_back(Vec3f(0.0f, 0.0f, 0.0f)); corners.push_back(Vec3f(0.0f, 0.0f, 0.0f));
drawCorners.push_back(Vec3f(0.0f, 0.0f, 0.0f)); drawCorners.push_back(Vec3f(0.0f, 0.0f, 0.0f));
} }
for(unsigned int i=0; i<PLANECOUNT; i++) for(unsigned int i=0; i<PLANECOUNT; i++)
{ {
planes.push_back(new Plane()); planes.push_back(new Plane());
skipping to change at line 111 skipping to change at line 111
corners[FBR] = fbr.toVec3f(); corners[FBR] = fbr.toVec3f();
planes[TOP]->setPoints(corners[NTR], corners[NTL], corners[FTL], SPo lygon::CCW); planes[TOP]->setPoints(corners[NTR], corners[NTL], corners[FTL], SPo lygon::CCW);
planes[BOTTOM]->setPoints(corners[NBL], corners[NBR], corners[FBR], SPolygon::CCW); planes[BOTTOM]->setPoints(corners[NBL], corners[NBR], corners[FBR], SPolygon::CCW);
planes[LEFT]->setPoints(corners[NTL], corners[NBL], corners[FBL], SP olygon::CCW); planes[LEFT]->setPoints(corners[NTL], corners[NBL], corners[FBL], SP olygon::CCW);
planes[RIGHT]->setPoints(corners[NBR], corners[NTR], corners[FBR], S Polygon::CCW); planes[RIGHT]->setPoints(corners[NBR], corners[NTR], corners[FBR], S Polygon::CCW);
planes[NEARP]->setPoints(corners[NTL], corners[NTR], corners[NBR], S Polygon::CCW); planes[NEARP]->setPoints(corners[NTL], corners[NTR], corners[NBR], S Polygon::CCW);
planes[FARP]->setPoints(corners[FTR], corners[FTL], corners[FBL], SP olygon::CCW); planes[FARP]->setPoints(corners[FTR], corners[FTL], corners[FBL], SP olygon::CCW);
//reset bbox //reset bbox
bbox.min = Vec3f(std::numeric_limits<float>::max()); bbox.reset();
bbox.max = Vec3f(-std::numeric_limits<float>::max());
for(unsigned int i=0; i<CORNERCOUNT; i++) for(unsigned int i=0; i<CORNERCOUNT; i++)
{ {
Vec3f curVert = corners[i]; Vec3f curVert = corners[i];
bbox.min = Vec3f(std::min(static_cast<float>(curVert[0]), bb bbox.expand(curVert);
ox.min[0]),
std::min(static_cast<float>(curVert[1]), bb
ox.min[1]),
std::min(static_cast<float>(curVert[2]), bb
ox.min[2]));
bbox.max = Vec3f(std::max(static_cast<float>(curVert[0]), bb
ox.max[0]),
std::max(static_cast<float>(curVert[1]), bb
ox.max[1]),
std::max(static_cast<float>(curVert[2]), bb
ox.max[2]));
} }
} }
int Frustum::pointInFrustum(const Vec3f& p) int Frustum::pointInFrustum(const Vec3f& p)
{ {
int result = INSIDE; int result = INSIDE;
for(int i=0; i<PLANECOUNT; i++) for(int i=0; i<PLANECOUNT; i++)
{ {
if(planes[i]->isBehind(p)) if(planes[i]->isBehind(p))
{ {
return OUTSIDE; return OUTSIDE;
} }
} }
return result; return result;
} }
int Frustum::boxInFrustum(const AABB& bbox) int Frustum::boxInFrustum(const AABBox &bbox)
{ {
int result = INSIDE; int result = INSIDE;
for(unsigned int i=0; i<PLANECOUNT; i++) for(unsigned int i=0; i<PLANECOUNT; i++)
{ {
if(planes[i]->isBehind(bbox.positiveVertex(planes[i]->normal ))) if(planes[i]->isBehind(bbox.positiveVertex(planes[i]->normal )))
{ {
return OUTSIDE; return OUTSIDE;
} }
} }
skipping to change at line 279 skipping to change at line 272
glExtFuncs->glVertex3f(a.v[0],a.v[1],a.v[2]); glExtFuncs->glVertex3f(a.v[0],a.v[1],a.v[2]);
glExtFuncs->glVertex3f(b.v[0],b.v[1],b.v[2]); glExtFuncs->glVertex3f(b.v[0],b.v[1],b.v[2]);
// bottom // bottom
a = (fbr + fbl + nbr + nbl) * 0.25; a = (fbr + fbl + nbr + nbl) * 0.25;
b = a + planes[BOTTOM]->sNormal; b = a + planes[BOTTOM]->sNormal;
glExtFuncs->glVertex3f(a.v[0],a.v[1],a.v[2]); glExtFuncs->glVertex3f(a.v[0],a.v[1],a.v[2]);
glExtFuncs->glVertex3f(b.v[0],b.v[1],b.v[2]); glExtFuncs->glVertex3f(b.v[0],b.v[1],b.v[2]);
glExtFuncs->glEnd(); glExtFuncs->glEnd();
drawBbox.render(); //drawBbox.render();
#endif #endif
} }
 End of changes. 5 change blocks. 
18 lines changed or deleted 5 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/