try to fix the "-np surfaces disappear" bug
This commit is contained in:
parent
8bff7284c3
commit
323c01a983
|
|
@ -536,7 +536,7 @@ winding_t *ReverseWinding (winding_t *w)
|
||||||
ClipWindingEpsilon
|
ClipWindingEpsilon
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist,
|
void ClipWindingEpsilonStrict (winding_t *in, vec3_t normal, vec_t dist,
|
||||||
vec_t epsilon, winding_t **front, winding_t **back)
|
vec_t epsilon, winding_t **front, winding_t **back)
|
||||||
{
|
{
|
||||||
vec_t dists[MAX_POINTS_ON_WINDING+4];
|
vec_t dists[MAX_POINTS_ON_WINDING+4];
|
||||||
|
|
@ -573,6 +573,10 @@ void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist,
|
||||||
|
|
||||||
*front = *back = NULL;
|
*front = *back = NULL;
|
||||||
|
|
||||||
|
if (!counts[0] && !counts[1])
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!counts[0])
|
if (!counts[0])
|
||||||
{
|
{
|
||||||
*back = CopyWinding (in);
|
*back = CopyWinding (in);
|
||||||
|
|
@ -643,6 +647,15 @@ void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist,
|
||||||
Error ("ClipWinding: MAX_POINTS_ON_WINDING");
|
Error ("ClipWinding: MAX_POINTS_ON_WINDING");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist,
|
||||||
|
vec_t epsilon, winding_t **front, winding_t **back)
|
||||||
|
{
|
||||||
|
ClipWindingEpsilonStrict(in, normal, dist, epsilon, front, back);
|
||||||
|
/* apparently most code expects that in the winding-on-plane case, the back winding is the original winding */
|
||||||
|
if(!*front && !*back)
|
||||||
|
*back = CopyWinding(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ vec_t WindingArea (winding_t *w);
|
||||||
void WindingCenter (winding_t *w, vec3_t center);
|
void WindingCenter (winding_t *w, vec3_t center);
|
||||||
void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist,
|
void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist,
|
||||||
vec_t epsilon, winding_t **front, winding_t **back);
|
vec_t epsilon, winding_t **front, winding_t **back);
|
||||||
|
void ClipWindingEpsilonStrict (winding_t *in, vec3_t normal, vec_t dist,
|
||||||
|
vec_t epsilon, winding_t **front, winding_t **back);
|
||||||
winding_t *ChopWinding (winding_t *in, vec3_t normal, vec_t dist);
|
winding_t *ChopWinding (winding_t *in, vec3_t normal, vec_t dist);
|
||||||
winding_t *CopyWinding (winding_t *w);
|
winding_t *CopyWinding (winding_t *w);
|
||||||
winding_t *ReverseWinding (winding_t *w);
|
winding_t *ReverseWinding (winding_t *w);
|
||||||
|
|
|
||||||
|
|
@ -2035,6 +2035,13 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node )
|
||||||
si->mins[ 1 ] != 0.0f || si->maxs[ 1 ] != 0.0f ||
|
si->mins[ 1 ] != 0.0f || si->maxs[ 1 ] != 0.0f ||
|
||||||
si->mins[ 2 ] != 0.0f || si->maxs[ 2 ] != 0.0f) )
|
si->mins[ 2 ] != 0.0f || si->maxs[ 2 ] != 0.0f) )
|
||||||
{
|
{
|
||||||
|
static qboolean warned = qfalse;
|
||||||
|
if(!warned)
|
||||||
|
{
|
||||||
|
Sys_Printf( "WARNING: this map uses the deformVertexes move hack\n" );
|
||||||
|
warned = qtrue;
|
||||||
|
}
|
||||||
|
|
||||||
/* 'fatten' the winding by the shader mins/maxs (parsed from vertexDeform move) */
|
/* 'fatten' the winding by the shader mins/maxs (parsed from vertexDeform move) */
|
||||||
/* note this winding is completely invalid (concave, nonplanar, etc) */
|
/* note this winding is completely invalid (concave, nonplanar, etc) */
|
||||||
fat = AllocWinding( w->numpoints * 3 + 3 );
|
fat = AllocWinding( w->numpoints * 3 + 3 );
|
||||||
|
|
@ -2077,7 +2084,9 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node )
|
||||||
VectorCopy( p2->normal, plane2 );
|
VectorCopy( p2->normal, plane2 );
|
||||||
plane2[ 3 ] = p2->dist;
|
plane2[ 3 ] = p2->dist;
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
|
/* div0: this is the plague (inaccurate) */
|
||||||
|
|
||||||
/* invert surface plane */
|
/* invert surface plane */
|
||||||
VectorSubtract( vec3_origin, plane2, reverse );
|
VectorSubtract( vec3_origin, plane2, reverse );
|
||||||
reverse[ 3 ] = -plane2[ 3 ];
|
reverse[ 3 ] = -plane2[ 3 ];
|
||||||
|
|
@ -2088,6 +2097,8 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node )
|
||||||
if( DotProduct( plane1, reverse ) > 0.999f && fabs( plane1[ 3 ] - reverse[ 3 ] ) < 0.001f )
|
if( DotProduct( plane1, reverse ) > 0.999f && fabs( plane1[ 3 ] - reverse[ 3 ] ) < 0.001f )
|
||||||
return FilterWindingIntoTree_r( w, ds, node->children[ 1 ] );
|
return FilterWindingIntoTree_r( w, ds, node->children[ 1 ] );
|
||||||
#else
|
#else
|
||||||
|
/* div0: this is the cholera (doesn't hit enough) */
|
||||||
|
|
||||||
/* the drawsurf might have an associated plane, if so, force a filter here */
|
/* the drawsurf might have an associated plane, if so, force a filter here */
|
||||||
if( ds->planeNum == node->planenum )
|
if( ds->planeNum == node->planenum )
|
||||||
return FilterWindingIntoTree_r( w, ds, node->children[ 0 ] );
|
return FilterWindingIntoTree_r( w, ds, node->children[ 0 ] );
|
||||||
|
|
@ -2097,10 +2108,17 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clip the winding by this plane */
|
/* clip the winding by this plane */
|
||||||
ClipWindingEpsilon( w, plane1, plane1[ 3 ], ON_EPSILON, &front, &back );
|
ClipWindingEpsilonStrict( w, plane1, plane1[ 3 ], ON_EPSILON, &front, &back );
|
||||||
|
|
||||||
/* filter by this plane */
|
/* filter by this plane */
|
||||||
refs = 0;
|
refs = 0;
|
||||||
|
if( front == NULL && back == NULL )
|
||||||
|
{
|
||||||
|
/* same plane, this is an ugly hack */
|
||||||
|
/* but better too many than too few refs */
|
||||||
|
refs += FilterWindingIntoTree_r( CopyWinding(w), ds, node->children[ 0 ] );
|
||||||
|
refs += FilterWindingIntoTree_r( CopyWinding(w), ds, node->children[ 1 ] );
|
||||||
|
}
|
||||||
if( front != NULL )
|
if( front != NULL )
|
||||||
refs += FilterWindingIntoTree_r( front, ds, node->children[ 0 ] );
|
refs += FilterWindingIntoTree_r( front, ds, node->children[ 0 ] );
|
||||||
if( back != NULL )
|
if( back != NULL )
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user