unify WindingExtendBounds logic
This commit is contained in:
parent
902fb46938
commit
bee749118f
|
|
@ -151,13 +151,11 @@ float WindingArea( const winding_t *w ){
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
MinMax WindingBounds( const winding_t *w ){
|
void WindingExtendBounds( const winding_t *w, MinMax& minmax ){
|
||||||
MinMax minmax;
|
for ( int i = 0 ; i < w->numpoints ; ++i )
|
||||||
for ( int i = 0 ; i < w->numpoints ; i++ )
|
|
||||||
{
|
{
|
||||||
minmax.extend( w->p[i] );
|
minmax.extend( w->p[i] );
|
||||||
}
|
}
|
||||||
return minmax;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ Plane3f WindingPlane( const winding_t *w );
|
||||||
void RemoveColinearPoints( winding_t *w );
|
void RemoveColinearPoints( winding_t *w );
|
||||||
EPlaneSide WindingOnPlaneSide( const winding_t *w, const Plane3f& plane );
|
EPlaneSide WindingOnPlaneSide( const winding_t *w, const Plane3f& plane );
|
||||||
void FreeWinding( winding_t *w );
|
void FreeWinding( winding_t *w );
|
||||||
MinMax WindingBounds( const winding_t *w );
|
void WindingExtendBounds( const winding_t *w, MinMax& minmax );
|
||||||
|
|
||||||
void AddWindingToConvexHull( winding_t *w, winding_t **hull, const Vector3& normal );
|
void AddWindingToConvexHull( winding_t *w, winding_t **hull, const Vector3& normal );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,11 +179,9 @@ bool BoundBrush( brush_t *brush ){
|
||||||
for ( int i = 0; i < brush->numsides; i++ )
|
for ( int i = 0; i < brush->numsides; i++ )
|
||||||
{
|
{
|
||||||
const winding_t *w = brush->sides[ i ].winding;
|
const winding_t *w = brush->sides[ i ].winding;
|
||||||
if ( w == NULL ) {
|
if ( w != NULL ) {
|
||||||
continue;
|
WindingExtendBounds( w, brush->minmax );
|
||||||
}
|
}
|
||||||
for ( int j = 0; j < w->numpoints; j++ )
|
|
||||||
brush->minmax.extend( w->p[ j ] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return brush->minmax.valid() && c_worldMinmax.surrounds( brush->minmax );
|
return brush->minmax.valid() && c_worldMinmax.surrounds( brush->minmax );
|
||||||
|
|
@ -291,7 +289,6 @@ bool FixWinding( winding_t *w ){
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
Vector3 vec;
|
Vector3 vec;
|
||||||
float dist;
|
|
||||||
|
|
||||||
|
|
||||||
/* dummy check */
|
/* dummy check */
|
||||||
|
|
@ -311,8 +308,7 @@ bool FixWinding( winding_t *w ){
|
||||||
j = ( i + 1 ) % w->numpoints;
|
j = ( i + 1 ) % w->numpoints;
|
||||||
|
|
||||||
/* degenerate edge? */
|
/* degenerate edge? */
|
||||||
dist = vector3_length( w->p[ i ] - w->p[ j ] );
|
if ( vector3_length( w->p[ i ] - w->p[ j ] ) < DEGENERATE_EPSILON ) {
|
||||||
if ( dist < DEGENERATE_EPSILON ) {
|
|
||||||
valid = false;
|
valid = false;
|
||||||
//Sys_FPrintf( SYS_WRN | SYS_VRBflag, "WARNING: Degenerate winding edge found, fixing...\n" );
|
//Sys_FPrintf( SYS_WRN | SYS_VRBflag, "WARNING: Degenerate winding edge found, fixing...\n" );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -872,12 +872,12 @@ int ConvertBSPMain( int argc, char **argv ){
|
||||||
else if ( striEqual( argv[ i ], "-ne" ) ) {
|
else if ( striEqual( argv[ i ], "-ne" ) ) {
|
||||||
normalEpsilon = atof( argv[ i + 1 ] );
|
normalEpsilon = atof( argv[ i + 1 ] );
|
||||||
i++;
|
i++;
|
||||||
Sys_Printf( "Normal epsilon set to %f\n", normalEpsilon );
|
Sys_Printf( "Normal epsilon set to %lf\n", normalEpsilon );
|
||||||
}
|
}
|
||||||
else if ( striEqual( argv[ i ], "-de" ) ) {
|
else if ( striEqual( argv[ i ], "-de" ) ) {
|
||||||
distanceEpsilon = atof( argv[ i + 1 ] );
|
distanceEpsilon = atof( argv[ i + 1 ] );
|
||||||
i++;
|
i++;
|
||||||
Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon );
|
Sys_Printf( "Distance epsilon set to %lf\n", distanceEpsilon );
|
||||||
}
|
}
|
||||||
else if ( striEqual( argv[ i ], "-shaderasbitmap" ) || striEqual( argv[ i ], "-shadersasbitmap" ) ) {
|
else if ( striEqual( argv[ i ], "-shaderasbitmap" ) || striEqual( argv[ i ], "-shadersasbitmap" ) ) {
|
||||||
shadersAsBitmap = true;
|
shadersAsBitmap = true;
|
||||||
|
|
|
||||||
|
|
@ -365,25 +365,20 @@ void BuildFaceTree_r( node_t *node, face_t *list ){
|
||||||
tree_t *FaceBSP( face_t *list ) {
|
tree_t *FaceBSP( face_t *list ) {
|
||||||
tree_t *tree;
|
tree_t *tree;
|
||||||
face_t *face;
|
face_t *face;
|
||||||
int i;
|
|
||||||
int count;
|
|
||||||
|
|
||||||
Sys_FPrintf( SYS_VRB, "--- FaceBSP ---\n" );
|
Sys_FPrintf( SYS_VRB, "--- FaceBSP ---\n" );
|
||||||
|
|
||||||
tree = AllocTree();
|
tree = AllocTree();
|
||||||
|
|
||||||
count = 0;
|
int count = 0;
|
||||||
for ( face = list; face != NULL; face = face->next )
|
for ( face = list; face != NULL; face = face->next )
|
||||||
{
|
{
|
||||||
|
WindingExtendBounds( face->w, tree->minmax );
|
||||||
count++;
|
count++;
|
||||||
for ( i = 0; i < face->w->numpoints; i++ )
|
|
||||||
{
|
|
||||||
tree->minmax.extend( face->w->p[ i ] );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Sys_FPrintf( SYS_VRB, "%9d faces\n", count );
|
Sys_FPrintf( SYS_VRB, "%9d faces\n", count );
|
||||||
|
|
||||||
for ( i = 0; i < nummapplanes; i++ )
|
for ( int i = 0; i < nummapplanes; i++ )
|
||||||
{
|
{
|
||||||
mapplanes[ i ].counter = 0;
|
mapplanes[ i ].counter = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -587,7 +587,7 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw
|
||||||
splash_w = AllocWinding( rw->numVerts );
|
splash_w = AllocWinding( rw->numVerts );
|
||||||
splash_w->numpoints = rw->numVerts;
|
splash_w->numpoints = rw->numVerts;
|
||||||
for ( i = 0; i < rw->numVerts; i++ )
|
for ( i = 0; i < rw->numVerts; i++ )
|
||||||
splash_w->p[ i ] = normal * si->backsplashDistance + rw->verts[rw->numVerts - 1 - i].xyz;
|
splash_w->p[ i ] = rw->verts[rw->numVerts - 1 - i].xyz + normal * si->backsplashDistance;
|
||||||
splash->w = splash_w;
|
splash->w = splash_w;
|
||||||
|
|
||||||
splash->origin = normal * si->backsplashDistance + light->origin;
|
splash->origin = normal * si->backsplashDistance + light->origin;
|
||||||
|
|
|
||||||
|
|
@ -456,15 +456,13 @@ void SplitNodePortals( node_t *node ){
|
||||||
void CalcNodeBounds( node_t *node ){
|
void CalcNodeBounds( node_t *node ){
|
||||||
portal_t *p;
|
portal_t *p;
|
||||||
int s;
|
int s;
|
||||||
int i;
|
|
||||||
|
|
||||||
// calc mins/maxs for both leafs and nodes
|
// calc mins/maxs for both leafs and nodes
|
||||||
node->minmax.clear();
|
node->minmax.clear();
|
||||||
for ( p = node->portals ; p ; p = p->next[s] )
|
for ( p = node->portals ; p ; p = p->next[s] )
|
||||||
{
|
{
|
||||||
s = ( p->nodes[1] == node );
|
s = ( p->nodes[1] == node );
|
||||||
for ( i = 0 ; i < p->winding->numpoints ; i++ )
|
WindingExtendBounds( p->winding, node->minmax );
|
||||||
node->minmax.extend( p->winding->p[i] );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1212,7 +1212,6 @@ static void AddSurfaceFlare( mapDrawSurface_t *ds, const Vector3& entityOrigin )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void SubdivideFace_r( entity_t *e, brush_t *brush, side_t *side, winding_t *w, int fogNum, float subdivisions ){
|
static void SubdivideFace_r( entity_t *e, brush_t *brush, side_t *side, winding_t *w, int fogNum, float subdivisions ){
|
||||||
int i;
|
|
||||||
int axis;
|
int axis;
|
||||||
MinMax bounds;
|
MinMax bounds;
|
||||||
const float epsilon = 0.1;
|
const float epsilon = 0.1;
|
||||||
|
|
@ -1230,8 +1229,7 @@ static void SubdivideFace_r( entity_t *e, brush_t *brush, side_t *side, winding_
|
||||||
}
|
}
|
||||||
|
|
||||||
/* determine surface bounds */
|
/* determine surface bounds */
|
||||||
for ( i = 0; i < w->numpoints; i++ )
|
WindingExtendBounds( w, bounds );
|
||||||
bounds.extend( w->p[ i ] );
|
|
||||||
|
|
||||||
/* split the face */
|
/* split the face */
|
||||||
for ( axis = 0; axis < 3; axis++ )
|
for ( axis = 0; axis < 3; axis++ )
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user