//
//////////////////////////////////////////////////////////////////////
-#include "StdAfx.h"
#include "DWinding.h"
+
+#include <list>
+
+#include "DPoint.h"
#include "DPlane.h"
-#include "misc.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
int DWinding::WindingOnPlaneSide( vec3_t normal, vec_t dist ){
- bool front = FALSE;
- bool back = FALSE;
+ bool front = false;
+ bool back = false;
for ( int i = 0; i < numpoints; i++ )
{
if ( front ) {
return SIDE_CROSS;
}
- back = TRUE;
+ back = true;
continue;
}
if ( d > ON_EPSILON ) {
if ( back ) {
return SIDE_CROSS;
}
- front = TRUE;
+ front = true;
continue;
}
}
vec3_t dir, edgenormal;
if ( numpoints < 3 ) {
- Sys_Printf( "CheckWinding: %i points", numpoints );
+ globalOutputStream() << "CheckWinding: " << numpoints << " points\n";
}
vec_t area = WindingArea();
if ( area < 1 ) {
- Sys_Printf( "CheckWinding: %f area", area );
+ globalOutputStream() << "CheckWinding: " << area << " area\n";
}
DPlane* wPlane = WindingPlane();
int j;
for ( j = 0; j < 3; j++ )
if ( p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE ) {
- Sys_Printf( "CheckFace: BUGUS_RANGE: %f", p1[j] );
+ globalOutputStream() << "CheckFace: BOGUS_RANGE: " << p1[j] << "\n";
}
j = i + 1 == numpoints ? 0 : i + 1;
// check the point is on the face plane
vec_t d = DotProduct( p1, wPlane->normal ) - wPlane->_d;
if ( d < -ON_EPSILON || d > ON_EPSILON ) {
- Sys_Printf( "CheckWinding: point off plane" );
+ globalOutputStream() << "CheckWinding: point off plane\n";
}
// check the edge isnt degenerate
VectorSubtract( p2, p1, dir );
if ( VectorLength( dir ) < ON_EPSILON ) {
- Sys_Printf( "CheckWinding: degenerate edge" );
+ globalOutputStream() << "CheckWinding: degenerate edge\n";
}
CrossProduct( wPlane->normal, dir, edgenormal );
d = DotProduct( p[j], edgenormal );
if ( d > ( edgedist + ON_EPSILON ) ) {
- Sys_Printf( "CheckWinding: non-convex" );
+ globalOutputStream() << "CheckWinding: non-convex\n";
}
}
}
if ( !counts[0] ) {
delete this;
- return FALSE;
+ return false;
}
if ( !counts[1] ) {
- return TRUE;
+ return true;
}
int maxpts = numpoints + 4; // cant use counts[0]+2 because
}
if ( f->numpoints > maxpts ) {
- Sys_Printf( "ClipWinding: points exceeded estimate" );
+ globalOutputStream() << "ClipWinding: points exceeded estimate\n";
}
if ( f->numpoints > MAX_POINTS_ON_WINDING ) {
- Sys_Printf( "ClipWinding: MAX_POINTS_ON_WINDING" );
+ globalOutputStream() << "ClipWinding: MAX_POINTS_ON_WINDING\n";
}
delete[] p;
p = f->p;
f->p = NULL;
delete f;
- return TRUE;
+ return true;
}
void DWinding::ClipWindingEpsilon( DPlane* chopPlane, vec_t epsilon, DWinding **front, DWinding **back ){
}
if ( f->numpoints > maxpts || b->numpoints > maxpts ) {
- Sys_Printf( "ClipWinding: points exceeded estimate" );
+ globalOutputStream() << "ClipWinding: points exceeded estimate\n";
}
if ( f->numpoints > MAX_POINTS_ON_WINDING || b->numpoints > MAX_POINTS_ON_WINDING ) {
- Sys_Printf( "ClipWinding: MAX_POINTS_ON_WINDING" );
+ globalOutputStream() << "ClipWinding: MAX_POINTS_ON_WINDING\n";
}
}
if ( !f ) {
delete this;
- return FALSE;
+ return false;
}
delete[] p;
numpoints = f->numpoints;
delete f;
- return TRUE;
+ return true;
}