13 Sep 2008

This commit is contained in:
g-cont 2008-09-13 00:00:00 +04:00 committed by Alibek Omarov
parent 0843ead0ae
commit 4242e2adcd
11 changed files with 310 additions and 404 deletions

View File

@ -240,7 +240,7 @@ bool LoadBSPFile( void )
{ {
byte *buffer; byte *buffer;
buffer = (byte *)FS_LoadFile( va("maps/%.bsp", gs_filename ), NULL ); buffer = (byte *)FS_LoadFile( va("maps/%s.bsp", gs_filename ), NULL );
if( !buffer ) return false; if( !buffer ) return false;
header = (dheader_t *)buffer; // load the file header header = (dheader_t *)buffer; // load the file header

View File

@ -419,7 +419,6 @@ bool LoadBSPFile ( void );
void WriteBSPFile ( void ); void WriteBSPFile ( void );
//============================================================================= //=============================================================================
// //
// terrain.c // terrain.c
// //
@ -665,8 +664,6 @@ typedef struct
vec3_t origin; vec3_t origin;
float radius; float radius;
bool patch;
int numFacets; int numFacets;
cFacet_t *facets; cFacet_t *facets;
bsp_shader_t *shader; // for translucency bsp_shader_t *shader; // for translucency
@ -710,4 +707,6 @@ typedef struct
} lightmap_t; } lightmap_t;
bool PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c );
#endif//BSPLIB_H #endif//BSPLIB_H

View File

@ -4,6 +4,7 @@
//======================================================================= //=======================================================================
#include "bsplib.h" #include "bsplib.h"
#include "const.h"
#define CURVE_FACET_ERROR 8 #define CURVE_FACET_ERROR 8
@ -13,6 +14,31 @@ int c_testFacets;
surfaceTest_t *surfaceTest[MAX_MAP_SURFACES]; surfaceTest_t *surfaceTest[MAX_MAP_SURFACES];
/*
=====================
PlaneFromPoints
Returns false if the triangle is degenrate.
The normal will point out of the clock for clockwise ordered points
=====================
*/
bool PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c )
{
vec3_t d1, d2;
VectorSubtract( b, a, d1 );
VectorSubtract( c, a, d2 );
CrossProduct( d2, d1, plane );
if( VectorNormalizeLength( plane ) == 0 )
{
return false;
}
plane[3] = DotProduct( a, plane );
return true;
}
/* /*
===================== =====================
CM_GenerateBoundaryForPoints CM_GenerateBoundaryForPoints
@ -59,14 +85,19 @@ void TextureMatrixFromPoints( cFacet_t *f, dvertex_t *a, dvertex_t *b, dvertex_t
m[2][2] = c->point[2]; m[2][2] = c->point[2];
m[2][3] = c->st[i]; m[2][3] = c->st[i];
if ( fabs(m[1][0]) > fabs(m[0][0]) && fabs(m[1][0]) > fabs(m[2][0]) ) { if( fabs(m[1][0]) > fabs(m[0][0]) && fabs(m[1][0]) > fabs(m[2][0]))
for ( j = 0 ; j < 4 ; j ++ ) { {
for( j = 0; j < 4; j++ )
{
t = m[0][j]; t = m[0][j];
m[0][j] = m[1][j]; m[0][j] = m[1][j];
m[1][j] = t; m[1][j] = t;
} }
} else if ( fabs(m[2][0]) > fabs(m[0][0]) && fabs(m[2][0]) > fabs(m[1][0]) ) { }
for ( j = 0 ; j < 4 ; j ++ ) { else if( fabs(m[2][0]) > fabs(m[0][0]) && fabs(m[2][0]) > fabs(m[1][0]))
{
for( j = 0; j < 4; j++ )
{
t = m[0][j]; t = m[0][j];
m[0][j] = m[2][j]; m[0][j] = m[2][j];
m[2][j] = t; m[2][j] = t;
@ -91,8 +122,10 @@ void TextureMatrixFromPoints( cFacet_t *f, dvertex_t *a, dvertex_t *b, dvertex_t
m[2][2] -= m[0][2] * s; m[2][2] -= m[0][2] * s;
m[2][3] -= m[0][3] * s; m[2][3] -= m[0][3] * s;
if ( fabs(m[2][1]) > fabs(m[1][1]) ) { if( fabs(m[2][1]) > fabs(m[1][1]))
for ( j = 0 ; j < 4 ; j ++ ) { {
for( j = 0; j < 4; j++ )
{
t = m[1][j]; t = m[1][j];
m[1][j] = m[2][j]; m[1][j] = m[2][j];
m[2][j] = t; m[2][j] = t;
@ -124,16 +157,19 @@ void TextureMatrixFromPoints( cFacet_t *f, dvertex_t *a, dvertex_t *b, dvertex_t
f->textureMatrix[i][3] = 0; f->textureMatrix[i][3] = 0;
/* /*
s = fabs( DotProduct( a->point, f->textureMatrix[i] ) - a->st[i] ); s = fabs( DotProduct( a->point, f->textureMatrix[i] ) - a->st[i] );
if ( s > 0.01 ) { if( s > 0.01 )
Error( "Bad textureMatrix" ); {
Sys_Error( "Bad textureMatrix\n" );
} }
s = fabs( DotProduct( b->point, f->textureMatrix[i] ) - b->st[i] ); s = fabs( DotProduct( b->point, f->textureMatrix[i] ) - b->st[i] );
if ( s > 0.01 ) { if( s > 0.01 )
Error( "Bad textureMatrix" ); {
Sys_Error( "Bad textureMatrix\n" );
} }
s = fabs( DotProduct( c->point, f->textureMatrix[i] ) - c->st[i] ); s = fabs( DotProduct( c->point, f->textureMatrix[i] ) - c->st[i] );
if ( s > 0.01 ) { if ( s > 0.01 )
Error( "Bad textureMatrix" ); {
Sys_Error( "Bad textureMatrix\n" );
} }
*/ */
} }
@ -144,11 +180,13 @@ void TextureMatrixFromPoints( cFacet_t *f, dvertex_t *a, dvertex_t *b, dvertex_t
CM_GenerateFacetFor3Points CM_GenerateFacetFor3Points
===================== =====================
*/ */
bool CM_GenerateFacetFor3Points( cFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c ) { bool CM_GenerateFacetFor3Points( cFacet_t *f, dvertex_t *a, dvertex_t *b, dvertex_t *c )
{
// if we can't generate a valid plane for the points, ignore the facet // if we can't generate a valid plane for the points, ignore the facet
if ( !PlaneFromPoints( f->surface, a->point, b->point, c->point ) ) { if( !PlaneFromPoints( f->surface, a->point, b->point, c->point ))
{
f->numBoundaries = 0; f->numBoundaries = 0;
return qfalse; return false;
} }
// make boundaries // make boundaries
@ -164,7 +202,7 @@ bool CM_GenerateFacetFor3Points( cFacet_t *f, drawVert_t *a, drawVert_t *b, draw
TextureMatrixFromPoints( f, a, b, c ); TextureMatrixFromPoints( f, a, b, c );
return qtrue; return true;
} }
/* /*
@ -174,23 +212,25 @@ CM_GenerateFacetFor4Points
Attempts to use four points as a planar quad Attempts to use four points as a planar quad
===================== =====================
*/ */
#define PLANAR_EPSILON 0.1 bool CM_GenerateFacetFor4Points( cFacet_t *f, dvertex_t *a, dvertex_t *b, dvertex_t *c, dvertex_t *d )
qboolean CM_GenerateFacetFor4Points( cFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c, drawVert_t *d ) { {
float dist; float dist;
int i; int i;
vec4_t plane; vec4_t plane;
// if we can't generate a valid plane for the points, ignore the facet // if we can't generate a valid plane for the points, ignore the facet
if ( !PlaneFromPoints( f->surface, a->point, b->point, c->point ) ) { if( !PlaneFromPoints( f->surface, a->point, b->point, c->point ))
{
f->numBoundaries = 0; f->numBoundaries = 0;
return qfalse; return false;
} }
// if the fourth point is also on the plane, we can make a quad facet // if the fourth point is also on the plane, we can make a quad facet
dist = DotProduct( d->point, f->surface ) - f->surface[3]; dist = DotProduct( d->point, f->surface ) - f->surface[3];
if ( fabs( dist ) > PLANAR_EPSILON ) { if( fabs( dist ) > ON_EPSILON )
{
f->numBoundaries = 0; f->numBoundaries = 0;
return qfalse; return false;
} }
// make boundaries // make boundaries
@ -208,20 +248,22 @@ qboolean CM_GenerateFacetFor4Points( cFacet_t *f, drawVert_t *a, drawVert_t *b,
for( i = 1; i < 4; i++ ) for( i = 1; i < 4; i++ )
{ {
if ( !PlaneFromPoints( plane, f->points[i], f->points[(i+1) % 4], f->points[(i+2) % 4]) ) { if( !PlaneFromPoints( plane, f->points[i], f->points[(i+1) % 4], f->points[(i+2) % 4]))
{
f->numBoundaries = 0; f->numBoundaries = 0;
return qfalse; return false;
} }
if (DotProduct(f->surface, plane) < 0.9) { if( DotProduct( f->surface, plane ) < 0.9 )
{
f->numBoundaries = 0; f->numBoundaries = 0;
return qfalse; return false;
} }
} }
TextureMatrixFromPoints( f, a, b, c ); TextureMatrixFromPoints( f, a, b, c );
return qtrue; return true;
} }
@ -232,7 +274,8 @@ qboolean CM_GenerateFacetFor4Points( cFacet_t *f, drawVert_t *a, drawVert_t *b,
SphereFromBounds SphereFromBounds
=============== ===============
*/ */
void SphereFromBounds( vec3_t mins, vec3_t maxs, vec3_t origin, float *radius ) { void SphereFromBounds( vec3_t mins, vec3_t maxs, vec3_t origin, float *radius )
{
vec3_t temp; vec3_t temp;
VectorAdd( mins, maxs, origin ); VectorAdd( mins, maxs, origin );
@ -247,35 +290,39 @@ void SphereFromBounds( vec3_t mins, vec3_t maxs, vec3_t origin, float *radius )
FacetsForTriangleSurface FacetsForTriangleSurface
==================== ====================
*/ */
void FacetsForTriangleSurface( dsurface_t *dsurf, shaderInfo_t *si, surfaceTest_t *test ) { void FacetsForTriangleSurface( dsurface_t *dsurf, bsp_shader_t *si, surfaceTest_t *test )
{
int i; int i;
drawVert_t *v1, *v2, *v3, *v4; dvertex_t *v1, *v2, *v3, *v4;
int count; int count;
int i1, i2, i3, i4, i5, i6; int i1, i2, i3, i4, i5, i6;
test->patch = qfalse; test->numFacets = dsurf->numindices / 3;
test->numFacets = dsurf->numIndexes / 3; test->facets = BSP_Malloc( sizeof( test->facets[0] ) * test->numFacets );
test->facets = malloc( sizeof( test->facets[0] ) * test->numFacets );
test->shader = si; test->shader = si;
count = 0; count = 0;
for ( i = 0 ; i < test->numFacets ; i++ ) { for( i = 0; i < test->numFacets; i++ )
i1 = drawIndexes[ dsurf->firstIndex + i*3 ]; {
i2 = drawIndexes[ dsurf->firstIndex + i*3 + 1 ]; i1 = dindexes[dsurf->firstindex+i*3+0];
i3 = drawIndexes[ dsurf->firstIndex + i*3 + 2 ]; i2 = dindexes[dsurf->firstindex+i*3+1];
i3 = dindexes[dsurf->firstindex+i*3+2];
v1 = &drawVerts[ dsurf->firstVert + i1 ]; v1 = &dvertexes[dsurf->firstvertex+i1];
v2 = &drawVerts[ dsurf->firstVert + i2 ]; v2 = &dvertexes[dsurf->firstvertex+i2];
v3 = &drawVerts[ dsurf->firstVert + i3 ]; v3 = &dvertexes[dsurf->firstvertex+i3];
// try and make a quad out of two triangles // try and make a quad out of two triangles
if ( i != test->numFacets - 1 ) { if( i != test->numFacets - 1 )
i4 = drawIndexes[ dsurf->firstIndex + i*3 + 3 ]; {
i5 = drawIndexes[ dsurf->firstIndex + i*3 + 4 ]; i4 = dindexes[dsurf->firstindex+i*3+3];
i6 = drawIndexes[ dsurf->firstIndex + i*3 + 5 ]; i5 = dindexes[dsurf->firstindex+i*3+4];
if ( i4 == i3 && i5 == i2 ) { i6 = dindexes[dsurf->firstindex+i*3+5];
v4 = &drawVerts[ dsurf->firstVert + i6 ]; if( i4 == i3 && i5 == i2 )
if ( CM_GenerateFacetFor4Points( &test->facets[count], v1, v2, v4, v3 ) ) { {
v4 = &dvertexes[ dsurf->firstvertex + i6 ];
if( CM_GenerateFacetFor4Points( &test->facets[count], v1, v2, v4, v3 ))
{
count++; count++;
i++; // skip next tri i++; // skip next tri
continue; continue;
@ -291,58 +338,6 @@ void FacetsForTriangleSurface( dsurface_t *dsurf, shaderInfo_t *si, surfaceTest_
test->numFacets = count; test->numFacets = count;
} }
/*
====================
FacetsForPatch
====================
*/
void FacetsForPatch( dsurface_t *dsurf, shaderInfo_t *si, surfaceTest_t *test ) {
int i, j;
drawVert_t *v1, *v2, *v3, *v4;
int count;
mesh_t srcMesh, *subdivided, *mesh;
srcMesh.width = dsurf->patchWidth;
srcMesh.height = dsurf->patchHeight;
srcMesh.verts = &drawVerts[ dsurf->firstVert ];
//subdivided = SubdivideMesh( mesh, CURVE_FACET_ERROR, 9999 );
mesh = SubdivideMesh( srcMesh, 8, 999 );
PutMeshOnCurve( *mesh );
MakeMeshNormals( *mesh );
subdivided = RemoveLinearMeshColumnsRows( mesh );
FreeMesh(mesh);
test->patch = qtrue;
test->numFacets = ( subdivided->width - 1 ) * ( subdivided->height - 1 ) * 2;
test->facets = malloc( sizeof( test->facets[0] ) * test->numFacets );
test->shader = si;
count = 0;
for ( i = 0 ; i < subdivided->width - 1 ; i++ ) {
for ( j = 0 ; j < subdivided->height - 1 ; j++ ) {
v1 = subdivided->verts + j * subdivided->width + i;
v2 = v1 + 1;
v3 = v1 + subdivided->width + 1;
v4 = v1 + subdivided->width;
if ( CM_GenerateFacetFor4Points( &test->facets[count], v1, v4, v3, v2 ) ) {
count++;
} else {
if (CM_GenerateFacetFor3Points( &test->facets[count], v1, v4, v3 ))
count++;
if (CM_GenerateFacetFor3Points( &test->facets[count], v1, v3, v2 ))
count++;
}
}
}
test->numFacets = count;
FreeMesh(subdivided);
}
/* /*
===================== =====================
InitSurfacesForTesting InitSurfacesForTesting
@ -350,43 +345,43 @@ InitSurfacesForTesting
Builds structures to speed the ray tracing against surfaces Builds structures to speed the ray tracing against surfaces
===================== =====================
*/ */
void InitSurfacesForTesting( void ) { void InitSurfacesForTesting( void )
{
int i, j; int i, j;
dsurface_t *dsurf; dsurface_t *dsurf;
surfaceTest_t *test; surfaceTest_t *test;
drawVert_t *dvert; dvertex_t *dvert;
shaderInfo_t *si; bsp_shader_t *si;
for ( i = 0 ; i < numDrawSurfaces ; i++ ) { for( i = 0; i < numsurfaces; i++ )
dsurf = &drawSurfaces[ i ]; {
if ( !dsurf->numIndexes && !dsurf->patchWidth ) { dsurf = &dsurfaces[i];
if( !dsurf->numindices )
{
continue; continue;
} }
// don't make surfaces for transparent objects // don't make surfaces for transparent objects
// because we want light to pass through them // because we want light to pass through them
si = ShaderInfoForShader( dshaders[ dsurf->shaderNum].shader ); si = FindShader( dshaders[dsurf->shadernum].name );
if ( (si->contents & CONTENTS_TRANSLUCENT) && !(si->surfaceFlags & SURF_ALPHASHADOW) ) { if(( si->contents & CONTENTS_TRANSLUCENT) && !(si->surfaceFlags & SURF_ALPHASHADOW))
{
continue; continue;
} }
test = malloc( sizeof( *test ) ); test = BSP_Malloc( sizeof( *test ));
surfaceTest[i] = test; surfaceTest[i] = test;
ClearBounds( test->mins, test->maxs ); ClearBounds( test->mins, test->maxs );
dvert = &drawVerts[ dsurf->firstVert ]; dvert = &dvertexes[ dsurf->firstvertex ];
for ( j = 0 ; j < dsurf->numVerts ; j++, dvert++ ) { for( j = 0; j < dsurf->numvertices; j++, dvert++ )
{
AddPointToBounds( dvert->point, test->mins, test->maxs ); AddPointToBounds( dvert->point, test->mins, test->maxs );
} }
SphereFromBounds( test->mins, test->maxs, test->origin, &test->radius ); SphereFromBounds( test->mins, test->maxs, test->origin, &test->radius );
if ( dsurf->surfaceType == MST_TRIANGLE_SOUP || dsurf->surfaceType == MST_PLANAR ) {
FacetsForTriangleSurface( dsurf, si, test ); FacetsForTriangleSurface( dsurf, si, test );
} else if ( dsurf->surfaceType == MST_PATCH ) {
FacetsForPatch( dsurf, si, test );
}
} }
} }
@ -396,13 +391,14 @@ void InitSurfacesForTesting( void ) {
GenerateBoundaryForPoints GenerateBoundaryForPoints
===================== =====================
*/ */
void GenerateBoundaryForPoints( float boundary[4], float plane[4], vec3_t a, vec3_t b ) { void GenerateBoundaryForPoints( float boundary[4], float plane[4], vec3_t a, vec3_t b )
{
vec3_t d1; vec3_t d1;
// amke a perpendicular vector to the edge and the surface // amke a perpendicular vector to the edge and the surface
VectorSubtract( b, a, d1 ); VectorSubtract( b, a, d1 );
CrossProduct( plane, d1, boundary ); CrossProduct( plane, d1, boundary );
VectorNormalize( boundary, boundary ); VectorNormalize( boundary );
boundary[3] = DotProduct( a, boundary ); boundary[3] = DotProduct( a, boundary );
} }
@ -415,14 +411,16 @@ Given a point on a facet, determine the color filter
for light passing through for light passing through
================= =================
*/ */
void SetFacetFilter( traceWork_t *tr, shaderInfo_t *shader, cFacet_t *facet, vec3_t point ) { void SetFacetFilter( traceWork_t *tr, bsp_shader_t *shader, cFacet_t *facet, vec3_t point )
{
float s, t; float s, t;
int is, it; int is, it;
byte *image; byte *image;
int b; int b;
// most surfaces are completely opaque // most surfaces are completely opaque
if ( !(shader->surfaceFlags & SURF_ALPHASHADOW) ) { if( !(shader->surfaceFlags & SURF_ALPHASHADOW ))
{
VectorClear( tr->trace->filter ); VectorClear( tr->trace->filter );
return; return;
} }
@ -430,7 +428,8 @@ void SetFacetFilter( traceWork_t *tr, shaderInfo_t *shader, cFacet_t *facet, vec
s = DotProduct( point, facet->textureMatrix[0] ) + facet->textureMatrix[0][3]; s = DotProduct( point, facet->textureMatrix[0] ) + facet->textureMatrix[0][3];
t = DotProduct( point, facet->textureMatrix[1] ) + facet->textureMatrix[1][3]; t = DotProduct( point, facet->textureMatrix[1] ) + facet->textureMatrix[1][3];
if ( !shader->pixels ) { if( !shader->pixels )
{
// assume completely solid // assume completely solid
VectorClear( point ); VectorClear( point );
return; return;
@ -463,14 +462,16 @@ TraceAgainstFacet
Shader is needed for translucent surfaces Shader is needed for translucent surfaces
==================== ====================
*/ */
void TraceAgainstFacet( traceWork_t *tr, shaderInfo_t *shader, cFacet_t *facet ) { void TraceAgainstFacet( traceWork_t *tr, bsp_shader_t *shader, cFacet_t *facet )
{
int j; int j;
float d1, d2, d, f; float d1, d2, d, f;
vec3_t point; vec3_t point;
float dist; float dist;
// ignore degenerate facets // ignore degenerate facets
if ( facet->numBoundaries < 3 ) { if( facet->numBoundaries < 3 )
{
return; return;
} }
@ -478,49 +479,60 @@ void TraceAgainstFacet( traceWork_t *tr, shaderInfo_t *shader, cFacet_t *facet )
// compare the trace endpoints against the facet plane // compare the trace endpoints against the facet plane
d1 = DotProduct( tr->start, facet->surface ) - dist; d1 = DotProduct( tr->start, facet->surface ) - dist;
if ( d1 > -1 && d1 < 1 ) { if( d1 > -1 && d1 < 1 )
{
return; // don't self intersect return; // don't self intersect
} }
d2 = DotProduct( tr->end, facet->surface ) - dist; d2 = DotProduct( tr->end, facet->surface ) - dist;
if ( d2 > -1 && d2 < 1 ) { if( d2 > -1 && d2 < 1 )
{
return; // don't self intersect return; // don't self intersect
} }
// calculate the intersection fraction // calculate the intersection fraction
f = ( d1 - ON_EPSILON ) / ( d1 - d2 ); f = ( d1 - ON_EPSILON ) / ( d1 - d2 );
if ( f <= 0 ) { if( f <= 0 )
{
return; return;
} }
if ( f >= tr->trace->hitFraction ) { if( f >= tr->trace->hitFraction )
{
return; // we have hit something earlier return; // we have hit something earlier
} }
// calculate the intersection point // calculate the intersection point
for ( j = 0 ; j < 3 ; j++ ) { for( j = 0; j < 3; j++ )
{
point[j] = tr->start[j] + f * ( tr->end[j] - tr->start[j] ); point[j] = tr->start[j] + f * ( tr->end[j] - tr->start[j] );
} }
// check the point against the facet boundaries // check the point against the facet boundaries
for ( j = 0 ; j < facet->numBoundaries ; j++ ) { for( j = 0; j < facet->numBoundaries; j++ )
{
// adjust the plane distance apropriately for mins/maxs // adjust the plane distance apropriately for mins/maxs
dist = facet->boundaries[j][3]; dist = facet->boundaries[j][3];
d = DotProduct( point, facet->boundaries[j] ); d = DotProduct( point, facet->boundaries[j] );
if ( d > dist + ON_EPSILON ) { if( d > dist + ON_EPSILON )
{
break; // outside the bounds break; // outside the bounds
} }
} }
if ( j != facet->numBoundaries ) { if( j != facet->numBoundaries )
{
return; // we are outside the bounds of the facet return; // we are outside the bounds of the facet
} }
// we hit this facet // we hit this facet
// if this is a transparent surface, calculate filter value // if this is a transparent surface, calculate filter value
if ( shader->surfaceFlags & SURF_ALPHASHADOW ) { if( shader->surfaceFlags & SURF_ALPHASHADOW )
{
SetFacetFilter( tr, shader, facet, point ); SetFacetFilter( tr, shader, facet, point );
} else { }
else
{
// completely opaque // completely opaque
VectorClear( tr->trace->filter ); VectorClear( tr->trace->filter );
tr->trace->hitFraction = f; tr->trace->hitFraction = f;
@ -538,10 +550,6 @@ void TraceAgainstFacet( traceWork_t *tr, shaderInfo_t *shader, cFacet_t *facet )
=============================================================== ===============================================================
*/ */
#define TRACE_ON_EPSILON 0.1
typedef struct tnode_s typedef struct tnode_s
{ {
int type; int type;
@ -572,24 +580,30 @@ void MakeTnode (int nodenum)
t = tnode_p++; t = tnode_p++;
node = dnodes + nodenum; node = dnodes + nodenum;
plane = dplanes + node->planeNum; plane = dplanes + node->planenum;
t->planeNum = node->planeNum; t->planeNum = node->planenum;
t->type = PlaneTypeForNormal( plane->normal ); t->type = PlaneTypeForNormal( plane->normal );
VectorCopy (plane->normal, t->normal); VectorCopy (plane->normal, t->normal);
t->dist = plane->dist; t->dist = plane->dist;
for( i = 0; i < 2; i++ ) for( i = 0; i < 2; i++ )
{ {
if (node->children[i] < 0) { if( node->children[i] < 0 )
{
leafNum = -node->children[i] - 1; leafNum = -node->children[i] - 1;
if ( dleafs[leafNum].cluster == -1 ) { if( dleafs[leafNum].cluster == -1 )
{
// solid // solid
t->children[i] = leafNum | ( 1 << 31 ) | ( 1 << 30 ); t->children[i] = leafNum | ( 1 << 31 ) | ( 1 << 30 );
} else { }
else
{
t->children[i] = leafNum | ( 1 << 31 ); t->children[i] = leafNum | ( 1 << 31 );
} }
} else { }
else
{
t->children[i] = tnode_p - tnodes; t->children[i] = tnode_p - tnodes;
MakeTnode (node->children[i]); MakeTnode (node->children[i]);
} }
@ -604,9 +618,10 @@ InitTrace
Loads the node structure out of a .bsp file to be used for light occlusion Loads the node structure out of a .bsp file to be used for light occlusion
============= =============
*/ */
void InitTrace( void ) { void InitTrace( void )
{
// 32 byte align the structs // 32 byte align the structs
tnodes = malloc( (MAX_TNODES+1) * sizeof(tnode_t)); tnodes = BSP_Malloc((MAX_TNODES+1) * sizeof(tnode_t));
tnodes = (tnode_t *)(((int)tnodes + 31)&~31); tnodes = (tnode_t *)(((int)tnodes + 31)&~31);
tnode_p = tnodes; tnode_p = tnodes;
@ -621,13 +636,16 @@ void InitTrace( void ) {
PointInSolid PointInSolid
=================== ===================
*/ */
qboolean PointInSolid_r( vec3_t start, int node ) { bool PointInSolid_r( vec3_t start, int node )
{
tnode_t *tnode; tnode_t *tnode;
float front; float front;
while ( !(node & (1<<31) ) ) { while(!(node & ( 1<<31 )))
{
tnode = &tnodes[node]; tnode = &tnodes[node];
switch (tnode->type) { switch( tnode->type )
{
case PLANE_X: case PLANE_X:
front = start[0] - tnode->dist; front = start[0] - tnode->dist;
break; break;
@ -642,23 +660,27 @@ qboolean PointInSolid_r( vec3_t start, int node ) {
break; break;
} }
if ( front == 0 ) { if( front == 0 )
{
// exactly on node, must check both sides // exactly on node, must check both sides
return (qboolean) ( PointInSolid_r( start, tnode->children[0] ) return (bool)(PointInSolid_r( start, tnode->children[0] )|PointInSolid_r( start, tnode->children[1]));
| PointInSolid_r( start, tnode->children[1] ) );
} }
if ( front > 0 ) { if( front > 0 )
{
node = tnode->children[0]; node = tnode->children[0];
} else { }
else
{
node = tnode->children[1]; node = tnode->children[1];
} }
} }
if ( node & ( 1 << 30 ) ) { if( node & ( 1 << 30 ))
return qtrue; {
return true;
} }
return qfalse; return false;
} }
/* /*
@ -667,7 +689,8 @@ PointInSolid
============= =============
*/ */
qboolean PointInSolid( vec3_t start ) { bool PointInSolid( vec3_t start )
{
return PointInSolid_r( start, 0 ); return PointInSolid_r( start, 0 );
} }
@ -679,7 +702,8 @@ TraceLine_r
Returns qtrue if something is hit and tracing can stop Returns qtrue if something is hit and tracing can stop
============= =============
*/ */
int TraceLine_r( int node, const vec3_t start, const vec3_t stop, traceWork_t *tw ) { int TraceLine_r( int node, const vec3_t start, const vec3_t stop, traceWork_t *tw )
{
tnode_t *tnode; tnode_t *tnode;
float front, back; float front, back;
vec3_t mid; vec3_t mid;
@ -687,24 +711,30 @@ int TraceLine_r( int node, const vec3_t start, const vec3_t stop, traceWork_t *t
int side; int side;
int r; int r;
if (node & (1<<31)) { if( node & (1<<31))
if (node & ( 1 << 30 ) ) { {
if( node & ( 1 << 30 ))
{
VectorCopy (start, tw->trace->hit); VectorCopy (start, tw->trace->hit);
tw->trace->passSolid = qtrue; tw->trace->passSolid = true;
return qtrue; return true;
} else { }
else
{
// save the node off for more exact testing // save the node off for more exact testing
if ( tw->numOpenLeafs == MAX_MAP_LEAFS ) { if( tw->numOpenLeafs == MAX_MAP_LEAFS )
return qfalse; {
return false;
} }
tw->openLeafNumbers[ tw->numOpenLeafs ] = node & ~(3 << 30); tw->openLeafNumbers[ tw->numOpenLeafs ] = node & ~(3 << 30);
tw->numOpenLeafs++; tw->numOpenLeafs++;
return qfalse; return false;
} }
} }
tnode = &tnodes[node]; tnode = &tnodes[node];
switch (tnode->type) { switch( tnode->type )
{
case PLANE_X: case PLANE_X:
front = start[0] - tnode->dist; front = start[0] - tnode->dist;
back = stop[0] - tnode->dist; back = stop[0] - tnode->dist;
@ -723,11 +753,13 @@ int TraceLine_r( int node, const vec3_t start, const vec3_t stop, traceWork_t *t
break; break;
} }
if (front >= -TRACE_ON_EPSILON && back >= -TRACE_ON_EPSILON) { if( front >= -ON_EPSILON && back >= -ON_EPSILON )
{
return TraceLine_r( tnode->children[0], start, stop, tw ); return TraceLine_r( tnode->children[0], start, stop, tw );
} }
if (front < TRACE_ON_EPSILON && back < TRACE_ON_EPSILON) { if( front < ON_EPSILON && back < ON_EPSILON )
{
return TraceLine_r( tnode->children[1], start, stop, tw ); return TraceLine_r( tnode->children[1], start, stop, tw );
} }
@ -741,7 +773,8 @@ int TraceLine_r( int node, const vec3_t start, const vec3_t stop, traceWork_t *t
r = TraceLine_r( tnode->children[side], start, mid, tw ); r = TraceLine_r( tnode->children[side], start, mid, tw );
if (r) { if( r )
{
return r; return r;
} }
@ -757,7 +790,8 @@ int TraceLine_r( int node, const vec3_t start, const vec3_t stop, traceWork_t *t
SphereCull SphereCull
================ ================
*/ */
qboolean SphereCull( vec3_t start, vec3_t stop, vec3_t origin, float radius ) { bool SphereCull( vec3_t start, vec3_t stop, vec3_t origin, float radius )
{
vec3_t v; vec3_t v;
float d; float d;
vec3_t dir; vec3_t dir;
@ -765,15 +799,17 @@ qboolean SphereCull( vec3_t start, vec3_t stop, vec3_t origin, float radius ) {
vec3_t on; vec3_t on;
VectorSubtract( stop, start, dir ); VectorSubtract( stop, start, dir );
len = VectorNormalize( dir, dir ); len = VectorNormalizeLength( dir );
VectorSubtract( origin, start, v ); VectorSubtract( origin, start, v );
d = DotProduct( v, dir ); d = DotProduct( v, dir );
if ( d > len + radius ) { if( d > len + radius )
return qtrue; // too far ahead {
return true; // too far ahead
} }
if ( d < -radius ) { if( d < -radius )
return qtrue; // too far behind {
return true; // too far behind
} }
VectorMA( start, d, dir, on ); VectorMA( start, d, dir, on );
@ -781,11 +817,11 @@ qboolean SphereCull( vec3_t start, vec3_t stop, vec3_t origin, float radius ) {
len = VectorLength( v ); len = VectorLength( v );
if ( len > radius ) { if( len > radius )
return qtrue; // too far to the side {
return true; // too far to the side
} }
return false; // must be traced against
return qfalse; // must be traced against
} }
/* /*
@ -793,27 +829,33 @@ qboolean SphereCull( vec3_t start, vec3_t stop, vec3_t origin, float radius ) {
TraceAgainstSurface TraceAgainstSurface
================ ================
*/ */
void TraceAgainstSurface( traceWork_t *tw, surfaceTest_t *surf ) { void TraceAgainstSurface( traceWork_t *tw, surfaceTest_t *surf )
{
int i; int i;
// if surfaces are trans // if surfaces are trans
if ( SphereCull( tw->start, tw->end, surf->origin, surf->radius ) ) { if( SphereCull( tw->start, tw->end, surf->origin, surf->radius ))
if ( numthreads == 1 ) { {
if( GetNumThreads() == 1 )
{
c_cullTrace++; c_cullTrace++;
} }
return; return;
} }
if ( numthreads == 1 ) { if( GetNumThreads() == 1 )
{
c_testTrace++; c_testTrace++;
c_testFacets += surf->numFacets; c_testFacets += surf->numFacets;
} }
/* /*
// MrE: backface culling // MrE: backface culling
if (!surf->patch && surf->numFacets) { if( surf->numFacets )
{
// if the surface does not cast an alpha shadow // if the surface does not cast an alpha shadow
if ( !(surf->shader->surfaceFlags & SURF_ALPHASHADOW) ) { if(!(surf->shader->surfaceFlags & SURF_ALPHASHADOW ))
{
vec3_t vec; vec3_t vec;
VectorSubtract( tw->end, tw->start, vec ); VectorSubtract( tw->end, tw->start, vec );
if( DotProduct(vec, surf->facets->surface) > 0 ) if( DotProduct(vec, surf->facets->surface) > 0 )
@ -845,19 +887,18 @@ if you need to know the exact first point of impact (for a sun trace), set
testAll to true testAll to true
============= =============
*/ */
extern qboolean patchshadows; void TraceLine( const vec3_t start, const vec3_t stop, lighttrace_t *trace, bool testAll, traceWork_t *tw )
{
void TraceLine( const vec3_t start, const vec3_t stop, trace_t *trace, qboolean testAll, traceWork_t *tw ) {
int r; int r;
int i, j; int i, j;
dleaf_t *leaf; dleaf_t *leaf;
float oldHitFrac; float oldHitFrac;
surfaceTest_t *test; surfaceTest_t *test;
int surfaceNum; int surfaceNum;
byte surfaceTested[MAX_MAP_DRAW_SURFS/8]; byte surfaceTested[MAX_MAP_SURFACES/8];
;
if ( numthreads == 1 ) { if( GetNumThreads() == 1 )
{
c_totalTrace++; c_totalTrace++;
} }
@ -873,7 +914,7 @@ void TraceLine( const vec3_t start, const vec3_t stop, trace_t *trace, qboolean
tw->numOpenLeafs = 0; tw->numOpenLeafs = 0;
trace->passSolid = qfalse; trace->passSolid = false;
trace->hitFraction = 1.0; trace->hitFraction = 1.0;
r = TraceLine_r( 0, start, stop, tw ); r = TraceLine_r( 0, start, stop, tw );
@ -881,47 +922,51 @@ void TraceLine( const vec3_t start, const vec3_t stop, trace_t *trace, qboolean
// if we hit a solid leaf, stop without testing the leaf // if we hit a solid leaf, stop without testing the leaf
// surfaces. Note that the plane and endpoint might not // surfaces. Note that the plane and endpoint might not
// be the first solid intersection along the ray. // be the first solid intersection along the ray.
if ( r && !testAll ) { if( r && !testAll )
{
return; return;
} }
if ( noSurfaces ) { if( noSurfaces )
{
return; return;
} }
memset( surfaceTested, 0, (numDrawSurfaces+7)/8 ); memset( surfaceTested, 0, (numsurfaces + 7)/8 );
oldHitFrac = trace->hitFraction; oldHitFrac = trace->hitFraction;
for ( i = 0 ; i < tw->numOpenLeafs ; i++ ) { for( i = 0; i < tw->numOpenLeafs; i++ )
{
leaf = &dleafs[tw->openLeafNumbers[i]]; leaf = &dleafs[tw->openLeafNumbers[i]];
for ( j = 0 ; j < leaf->numLeafSurfaces ; j++ ) { for( j = 0 ; j < leaf->numleaffaces; j++ )
surfaceNum = dleafsurfaces[ leaf->firstLeafSurface + j ]; {
surfaceNum = dleaffaces[leaf->firstleafface+j];
// make sure we don't test the same ray against a surface more than once // make sure we don't test the same ray against a surface more than once
if ( surfaceTested[ surfaceNum>>3 ] & ( 1 << ( surfaceNum & 7) ) ) { if( surfaceTested[surfaceNum>>3] & ( 1 << ( surfaceNum & 7) ))
{
continue; continue;
} }
surfaceTested[surfaceNum>>3] |= ( 1 << ( surfaceNum & 7 )); surfaceTested[surfaceNum>>3] |= ( 1 << ( surfaceNum & 7 ));
test = surfaceTest[surfaceNum]; test = surfaceTest[surfaceNum];
if ( !test ) { if( !test )
continue; {
}
//
if ( !tw->patchshadows && test->patch ) {
continue; continue;
} }
TraceAgainstSurface( tw, test ); TraceAgainstSurface( tw, test );
} }
// if the trace is now solid, we can't possibly hit anything closer // if the trace is now solid, we can't possibly hit anything closer
if ( trace->hitFraction < oldHitFrac ) { if( trace->hitFraction < oldHitFrac )
trace->passSolid = qtrue; {
trace->passSolid = true;
break; break;
} }
} }
for ( i = 0 ; i < 3 ; i++ ) { for( i = 0; i < 3; i++ )
{
trace->hit[i] = start[i] + ( stop[i] - start[i] ) * trace->hitFraction; trace->hit[i] = start[i] + ( stop[i] - start[i] ) * trace->hitFraction;
} }
} }

View File

@ -209,10 +209,10 @@ int FindFloatPlane( vec3_t normal, vec_t dist )
/* /*
================ ================
PlaneFromPoints MapPlaneFromPoints
================ ================
*/ */
int PlaneFromPoints (vec_t *p0, vec_t *p1, vec_t *p2) int MapPlaneFromPoints (vec_t *p0, vec_t *p1, vec_t *p2)
{ {
vec3_t t1, t2, normal; vec3_t t1, t2, normal;
vec_t dist; vec_t dist;
@ -632,7 +632,7 @@ void ParseRawBrush( void )
} }
// find the plane number // find the plane number
planenum = PlaneFromPoints( planepts[0], planepts[1], planepts[2] ); planenum = MapPlaneFromPoints( planepts[0], planepts[1], planepts[2] );
side->planenum = planenum; side->planenum = planenum;
if( g_brushtype == BRUSH_QUARK ) if( g_brushtype == BRUSH_QUARK )

View File

@ -85,7 +85,6 @@ void EmitLeaf( node_t *node )
leaf_p = &dleafs[numleafs]; leaf_p = &dleafs[numleafs];
numleafs++; numleafs++;
leaf_p->contents = node->contents;
leaf_p->cluster = node->cluster; leaf_p->cluster = node->cluster;
leaf_p->area = node->area; leaf_p->area = node->area;
@ -314,7 +313,6 @@ void BeginBSPFile( void )
numleafbrushes = 0; numleafbrushes = 0;
numleafs = 1; // leave leaf 0 as an error numleafs = 1; // leave leaf 0 as an error
dleafs[0].contents = CONTENTS_SOLID; // assume error
} }

View File

@ -60,6 +60,10 @@ int entitySurface[MAX_MAP_SURFACES];
vec3_t sunDirection = { 0.45, 0.3, 0.9 }; vec3_t sunDirection = { 0.45, 0.3, 0.9 };
vec3_t sunLight = { 100, 100, 50 }; vec3_t sunLight = { 100, 100, 50 };
// g-cont. moved it here to avoid stack overflow problems
byte occluded[LIGHTMAP_WIDTH*EXTRASCALE][LIGHTMAP_HEIGHT*EXTRASCALE];
vec3_t color[LIGHTMAP_WIDTH*EXTRASCALE][LIGHTMAP_HEIGHT*EXTRASCALE];
typedef struct typedef struct
{ {
dbrush_t *b; dbrush_t *b;
@ -1107,8 +1111,6 @@ void TraceLtm( int num )
int x, y; int x, y;
int position, numPositions; int position, numPositions;
vec3_t base, origin, normal; vec3_t base, origin, normal;
byte occluded[LIGHTMAP_WIDTH*EXTRASCALE][LIGHTMAP_HEIGHT*EXTRASCALE];
vec3_t color[LIGHTMAP_WIDTH*EXTRASCALE][LIGHTMAP_HEIGHT*EXTRASCALE];
traceWork_t tw; traceWork_t tw;
vec3_t average; vec3_t average;
int count; int count;
@ -1121,6 +1123,9 @@ void TraceLtm( int num )
int sampleWidth, sampleHeight, ssize; int sampleWidth, sampleHeight, ssize;
vec3_t lightmapOrigin, lightmapVecs[2]; vec3_t lightmapOrigin, lightmapVecs[2];
memset( occluded, 0, LIGHTMAP_WIDTH*EXTRASCALE*LIGHTMAP_HEIGHT*EXTRASCALE );
memset( color, 0, LIGHTMAP_WIDTH*EXTRASCALE*LIGHTMAP_HEIGHT*EXTRASCALE );
ds = &dsurfaces[num]; ds = &dsurfaces[num];
si = FindShader( dshaders[ds->shadernum].name ); si = FindShader( dshaders[ds->shadernum].name );
@ -1742,7 +1747,6 @@ void WradMain ( bool option )
pointScale *= com.atof( cmdparm ); pointScale *= com.atof( cmdparm );
if( FS_CheckParm( "-notrace" )) notrace = true; if( FS_CheckParm( "-notrace" )) notrace = true;
if( FS_CheckParm( "-patchshadows" )) patchshadows = true; if( FS_CheckParm( "-patchshadows" )) patchshadows = true;
if( FS_CheckParm( "-notrace" )) notrace = true;
if( FS_CheckParm( "-extrawide" )) extra = extraWide = true; if( FS_CheckParm( "-extrawide" )) extra = extraWide = true;
samplesize = bsp_lightmap_size->integer; samplesize = bsp_lightmap_size->integer;

View File

@ -133,6 +133,10 @@ SOURCE=.\bsplib\leakfile.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\bsplib\light_trace.c
# End Source File
# Begin Source File
SOURCE=.\bsplib\lightmaps.c SOURCE=.\bsplib\lightmaps.c
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -1,125 +0,0 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: common - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP245F.tmp" with contents
[
/nologo /MDd /W3 /Gm /Gi /GX /ZI /I "./" /I "../public" /I "./bsplib/" /I "./ripper" /I "./common" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR"..\temp\common\!debug/" /Fo"..\temp\common\!debug/" /Fd"..\temp\common\!debug/" /FD /GZ /c
"D:\Xash3D\src_main\common\bsplib\brush.c"
"D:\Xash3D\src_main\common\bsplib\bspfile.c"
"D:\Xash3D\src_main\common\bsplib\bsplib.c"
"D:\Xash3D\src_main\common\bsplib\facebsp.c"
"D:\Xash3D\src_main\common\bsplib\leakfile.c"
"D:\Xash3D\src_main\common\bsplib\lightmap.c"
"D:\Xash3D\src_main\common\bsplib\lightmaps.c"
"D:\Xash3D\src_main\common\bsplib\map.c"
"D:\Xash3D\src_main\common\bsplib\patches.c"
"D:\Xash3D\src_main\common\platform.c"
"D:\Xash3D\src_main\common\bsplib\portals.c"
"D:\Xash3D\src_main\common\bsplib\prtfile.c"
"D:\Xash3D\src_main\common\bsplib\qbsp3.c"
"D:\Xash3D\src_main\common\bsplib\qrad3.c"
"D:\Xash3D\src_main\common\bsplib\qvis3.c"
"D:\Xash3D\src_main\common\bsplib\shaders.c"
"D:\Xash3D\src_main\common\spritegen.c"
"D:\Xash3D\src_main\common\studio.c"
"D:\Xash3D\src_main\common\studio_utils.c"
"D:\Xash3D\src_main\common\bsplib\surface.c"
"D:\Xash3D\src_main\common\bsplib\terrain.c"
"D:\Xash3D\src_main\common\bsplib\tjunc.c"
"D:\Xash3D\src_main\common\bsplib\trace.c"
"D:\Xash3D\src_main\common\bsplib\tree.c"
"D:\Xash3D\src_main\common\utils.c"
"D:\Xash3D\src_main\common\bsplib\visflow.c"
"D:\Xash3D\src_main\common\wadlib.c"
"D:\Xash3D\src_main\common\bsplib\winding.c"
]
Creating command line "cl.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP245F.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP2460.tmp" with contents
[
msvcrt.lib user32.lib /nologo /dll /incremental:yes /pdb:"..\temp\common\!debug/common.pdb" /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /out:"..\temp\common\!debug/common.dll" /implib:"..\temp\common\!debug/common.lib" /pdbtype:sept
"\Xash3D\src_main\temp\common\!debug\brush.obj"
"\Xash3D\src_main\temp\common\!debug\bspfile.obj"
"\Xash3D\src_main\temp\common\!debug\bsplib.obj"
"\Xash3D\src_main\temp\common\!debug\facebsp.obj"
"\Xash3D\src_main\temp\common\!debug\leakfile.obj"
"\Xash3D\src_main\temp\common\!debug\lightmap.obj"
"\Xash3D\src_main\temp\common\!debug\lightmaps.obj"
"\Xash3D\src_main\temp\common\!debug\map.obj"
"\Xash3D\src_main\temp\common\!debug\patches.obj"
"\Xash3D\src_main\temp\common\!debug\platform.obj"
"\Xash3D\src_main\temp\common\!debug\portals.obj"
"\Xash3D\src_main\temp\common\!debug\prtfile.obj"
"\Xash3D\src_main\temp\common\!debug\qbsp3.obj"
"\Xash3D\src_main\temp\common\!debug\qrad3.obj"
"\Xash3D\src_main\temp\common\!debug\qvis3.obj"
"\Xash3D\src_main\temp\common\!debug\shaders.obj"
"\Xash3D\src_main\temp\common\!debug\spritegen.obj"
"\Xash3D\src_main\temp\common\!debug\studio.obj"
"\Xash3D\src_main\temp\common\!debug\studio_utils.obj"
"\Xash3D\src_main\temp\common\!debug\surface.obj"
"\Xash3D\src_main\temp\common\!debug\terrain.obj"
"\Xash3D\src_main\temp\common\!debug\tjunc.obj"
"\Xash3D\src_main\temp\common\!debug\trace.obj"
"\Xash3D\src_main\temp\common\!debug\tree.obj"
"\Xash3D\src_main\temp\common\!debug\utils.obj"
"\Xash3D\src_main\temp\common\!debug\visflow.obj"
"\Xash3D\src_main\temp\common\!debug\wadlib.obj"
"\Xash3D\src_main\temp\common\!debug\winding.obj"
]
Creating command line "link.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP2460.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP2461.bat" with contents
[
@echo off
copy \Xash3D\src_main\temp\common\!debug\common.dll "D:\Xash3D\bin\common.dll"
]
Creating command line ""C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP2461.bat""
Compiling...
brush.c
bspfile.c
bsplib.c
facebsp.c
leakfile.c
lightmap.c
lightmaps.c
map.c
patches.c
platform.c
portals.c
prtfile.c
qbsp3.c
qrad3.c
qvis3.c
shaders.c
spritegen.c
studio.c
studio_utils.c
surface.c
Generating Code...
Compiling...
terrain.c
tjunc.c
trace.c
tree.c
utils.c
visflow.c
wadlib.c
winding.c
Generating Code...
Linking...
Creating library ..\temp\common\!debug/common.lib and object ..\temp\common\!debug/common.exp
<h3>Output Window</h3>
Performing Custom Build Step on \Xash3D\src_main\temp\common\!debug\common.dll
‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
<h3>Results</h3>
common.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@ -356,7 +356,6 @@ void BSP_LoadLeafs( lump_t *l )
dleaf_t *in; dleaf_t *in;
cleaf_t *out; cleaf_t *out;
int i, j, n, c, count; int i, j, n, c, count;
int emptyleaf = -1;
in = (void *)(cm.mod_base + l->fileofs); in = (void *)(cm.mod_base + l->fileofs);
if (l->filelen % sizeof(*in)) Host_Error("BSP_LoadLeafs: funny lump size\n"); if (l->filelen % sizeof(*in)) Host_Error("BSP_LoadLeafs: funny lump size\n");
@ -370,7 +369,6 @@ void BSP_LoadLeafs( lump_t *l )
{ {
out->parent = NULL; out->parent = NULL;
out->plane = NULL; out->plane = NULL;
out->contents = LittleLong( in->contents );
out->cluster = LittleLong( in->cluster ); out->cluster = LittleLong( in->cluster );
out->area = LittleLong( in->area ); out->area = LittleLong( in->area );
@ -401,22 +399,6 @@ void BSP_LoadLeafs( lump_t *l )
cm.areaportals_size = cm.numareas * cm.numareas * sizeof( *cm.areaportals ); cm.areaportals_size = cm.numareas * cm.numareas * sizeof( *cm.areaportals );
cm.areas = Mem_Alloc( cmappool, cm.numareas * sizeof( *cm.areas )); cm.areas = Mem_Alloc( cmappool, cm.numareas * sizeof( *cm.areas ));
cm.areaportals = Mem_Alloc( cmappool, cm.areaportals_size ); cm.areaportals = Mem_Alloc( cmappool, cm.areaportals_size );
// probably any wall it's liquid ?
if( cm.leafs[0].contents != CONTENTS_SOLID )
Host_Error("Map %s with leaf 0 is not CONTENTS_SOLID\n", cm.name );
for( i = 1; i < count; i++ )
{
if(!cm.leafs[i].contents)
{
emptyleaf = i;
break;
}
}
// stuck into brushes
if( emptyleaf == -1 ) Host_Error("Map %s does not have an empty leaf\n", cm.name );
} }
/* /*

View File

@ -249,7 +249,6 @@ typedef struct
int cluster; int cluster;
int mins[3]; // for frustum culling int mins[3]; // for frustum culling
int maxs[3]; int maxs[3];
int contents;
int firstleafface; int firstleafface;
int numleaffaces; int numleaffaces;
int firstleafbrush; int firstleafbrush;