#include "qbsp.h"
Include dependency graph for surface.c:

Go to the source code of this file.
|
|
|
|
|
|
|
|
|
|
|
Definition at line 59 of file surface.c. Referenced by DrawSurfaceForSide(). |
|
|
Definition at line 60 of file surface.c. Referenced by DrawSurfaceForSide(). |
|
|
Definition at line 619 of file surface.c. Referenced by FilterPatchSurfIntoTree(). |
|
|
Definition at line 166 of file surface.c. References sideRef_t::count, Error(), i, numSideRefs, sideRef_t::planenum, side_s::planenum, sideRef_t::shaderInfo, side_s::shaderInfo, side_t, and sideRefs. 00166 {
00167 int i;
00168
00169 for ( i = 0 ; i < numSideRefs ; i++ ) {
00170 if ( side->planenum == sideRefs[i].planenum
00171 && side->shaderInfo == sideRefs[i].shaderInfo ) {
00172 sideRefs[i].count++;
00173 return;
00174 }
00175 }
00176
00177 if ( numSideRefs == MAX_SIDE_REFS ) {
00178 Error( "MAX_SIDE_REFS" );
00179 }
00180
00181 sideRefs[i].planenum = side->planenum;
00182 sideRefs[i].shaderInfo = side->shaderInfo;
00183 sideRefs[i].count++;
00184 numSideRefs++;
00185 }
|
Here is the call graph for this function:

|
|
Definition at line 42 of file surface.c. References Error(), mapDrawSurface_t, mapDrawSurfs, and numMapDrawSurfs. Referenced by CreateFlareSurface(), CreateTerrainSurface(), DrawSurfaceForMesh(), DrawSurfaceForSide(), InsertASEModel(), and InsertMD3Model(). 00042 {
00043 mapDrawSurface_t *ds;
00044
00045 if ( numMapDrawSurfs >= MAX_MAP_DRAW_SURFS ) {
00046 Error( "MAX_MAP_DRAW_SURFS");
00047 }
00048 ds = &mapDrawSurfs[ numMapDrawSurfs ];
00049 numMapDrawSurfs++;
00050
00051 return ds;
00052 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 329 of file surface.c. References AddWindingToConvexHull(), node_s::children, ClipWindingEpsilon(), plane_t::dist, FreeWinding(), mapplanes, node_t, plane_t::normal, ON_EPSILON, node_s::opaque, side_s::planenum, node_s::planenum, side_t, side_s::visibleHull, and w. Referenced by ClipSidesIntoTree(). 00329 {
00330 plane_t *plane;
00331 winding_t *front, *back;
00332
00333 if ( !w ) {
00334 return;
00335 }
00336
00337 if ( node->planenum != PLANENUM_LEAF ) {
00338 if ( side->planenum == node->planenum ) {
00339 ClipSideIntoTree_r( w, side, node->children[0] );
00340 return;
00341 }
00342 if ( side->planenum == ( node->planenum ^ 1) ) {
00343 ClipSideIntoTree_r( w, side, node->children[1] );
00344 return;
00345 }
00346
00347 plane = &mapplanes[ node->planenum ];
00348 ClipWindingEpsilon ( w, plane->normal, plane->dist,
00349 ON_EPSILON, &front, &back );
00350 FreeWinding( w );
00351
00352 ClipSideIntoTree_r( front, side, node->children[0] );
00353 ClipSideIntoTree_r( back, side, node->children[1] );
00354
00355 return;
00356 }
00357
00358 // if opaque leaf, don't add
00359 if ( !node->opaque ) {
00360 AddWindingToConvexHull( w, &side->visibleHull, mapplanes[ side->planenum ].normal );
00361 }
00362
00363 FreeWinding( w );
00364 return;
00365 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 379 of file surface.c. References shaderInfo_s::autosprite, b, side_s::bevel, entity_t::brushes, bspbrush_t, ClipSideIntoTree_r(), shaderInfo_s::contents, CopyWinding(), DrawSurfaceForSide(), e, Error(), i, malloc(), bspbrush_s::next, bspbrush_s::numsides, side_s::planenum, qprintf(), ReverseWinding(), side_s::shaderInfo, shaderInfo_t, side_t, bspbrush_s::sides, shaderInfo_s::surfaceFlags, tree(), side_s::visibleHull, w, and side_s::winding. Referenced by ProcessSubModel(), and ProcessWorldModel(). 00379 {
00380 bspbrush_t *b;
00381 int i;
00382 winding_t *w;
00383 side_t *side, *newSide;
00384 shaderInfo_t *si;
00385
00386 qprintf( "----- ClipSidesIntoTree -----\n");
00387
00388 for ( b = e->brushes ; b ; b = b->next ) {
00389 for ( i = 0 ; i < b->numsides ; i++ ) {
00390 side = &b->sides[i];
00391 if ( !side->winding) {
00392 continue;
00393 }
00394 w = CopyWinding( side->winding );
00395 side->visibleHull = NULL;
00396 ClipSideIntoTree_r( w, side, tree->headnode );
00397
00398 w = side->visibleHull;
00399 if ( !w ) {
00400 continue;
00401 }
00402 si = side->shaderInfo;
00403 if ( !si ) {
00404 continue;
00405 }
00406 // don't create faces for non-visible sides
00407 if ( si->surfaceFlags & SURF_NODRAW ) {
00408 continue;
00409 }
00410
00411 // always use the original quad winding for auto sprites
00412 if ( side->shaderInfo->autosprite ) {
00413 w = side->winding;
00414 }
00415 //
00416 if ( side->bevel ) {
00417 Error( "monkey tried to create draw surface for brush bevel" );
00418 }
00419 // save this winding as a visible surface
00420 DrawSurfaceForSide( b, side, w );
00421
00422 // make a back side for it if needed
00423 if ( !(si->contents & CONTENTS_FOG) ) {
00424 continue;
00425 }
00426
00427 // duplicate the up-facing side
00428 w = ReverseWinding( w );
00429
00430 newSide = malloc( sizeof( *side ) );
00431 *newSide = *side;
00432 newSide->visibleHull = w;
00433 newSide->planenum ^= 1;
00434
00435 // save this winding as a visible surface
00436 DrawSurfaceForSide( b, newSide, w );
00437
00438 }
00439 }
00440 }
|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 62 of file surface.c. References AllocDrawSurf(), bspbrush_t, ComputeAxisBase(), DotProduct, Error(), floor(), drawsurf_s::fogNum, g_bBrushPrimit, shaderInfo_s::globalTexture, shaderInfo_s::height, i, j, malloc(), drawsurf_s::mapBrush, mapDrawSurface_t, mapplanes, memset(), drawVert_t::normal, winding_t::numpoints, drawsurf_s::numVerts, winding_t::p, side_s::planenum, s, drawsurf_s::shaderInfo, side_s::shaderInfo, shaderInfo_t, drawsurf_s::side, side_t, SNAP_FLOAT_TO_INT, SNAP_INT_TO_FLOAT, drawVert_t::st, side_s::texMat, vec3_t, vec_t, side_s::vecs, VectorCopy, drawsurf_s::verts, w, shaderInfo_s::width, x, drawVert_t::xyz, and y. Referenced by ChopFaceByBrush(), ClipSidesIntoTree(), and SubdivideDrawSurf(). 00062 {
00063 mapDrawSurface_t *ds;
00064 int i, j;
00065 shaderInfo_t *si;
00066 drawVert_t *dv;
00067 float mins[2], maxs[2];
00068
00069 // brush primitive :
00070 // axis base
00071 vec3_t texX,texY;
00072 vec_t x,y;
00073
00074 if ( w->numpoints > 64 ) {
00075 Error( "DrawSurfaceForSide: w->numpoints = %i", w->numpoints );
00076 }
00077
00078 si = s->shaderInfo;
00079
00080 ds = AllocDrawSurf();
00081
00082 ds->shaderInfo = si;
00083 ds->mapBrush = b;
00084 ds->side = s;
00085 ds->fogNum = -1;
00086 ds->numVerts = w->numpoints;
00087 ds->verts = malloc( ds->numVerts * sizeof( *ds->verts ) );
00088 memset( ds->verts, 0, ds->numVerts * sizeof( *ds->verts ) );
00089
00090 mins[0] = mins[1] = 99999;
00091 maxs[0] = maxs[1] = -99999;
00092
00093 // compute s/t coordinates from brush primitive texture matrix
00094 // compute axis base
00095 ComputeAxisBase( mapplanes[s->planenum].normal, texX, texY );
00096
00097 for ( j = 0 ; j < w->numpoints ; j++ ) {
00098 dv = ds->verts + j;
00099
00100 // round the xyz to a given precision
00101 for ( i = 0 ; i < 3 ; i++ ) {
00102 dv->xyz[i] = SNAP_INT_TO_FLOAT * floor( w->p[j][i] * SNAP_FLOAT_TO_INT + 0.5 );
00103 }
00104
00105 if (g_bBrushPrimit==BPRIMIT_OLDBRUSHES)
00106 {
00107 // calculate texture s/t
00108 dv->st[0] = s->vecs[0][3] + DotProduct( s->vecs[0], dv->xyz );
00109 dv->st[1] = s->vecs[1][3] + DotProduct( s->vecs[1], dv->xyz );
00110 dv->st[0] /= si->width;
00111 dv->st[1] /= si->height;
00112 }
00113 else
00114 {
00115 // calculate texture s/t from brush primitive texture matrix
00116 x = DotProduct( dv->xyz, texX );
00117 y = DotProduct( dv->xyz, texY );
00118 dv->st[0]=s->texMat[0][0]*x+s->texMat[0][1]*y+s->texMat[0][2];
00119 dv->st[1]=s->texMat[1][0]*x+s->texMat[1][1]*y+s->texMat[1][2];
00120 }
00121
00122 for ( i = 0 ; i < 2 ; i++ ) {
00123 if ( dv->st[i] < mins[i] ) {
00124 mins[i] = dv->st[i];
00125 }
00126 if ( dv->st[i] > maxs[i] ) {
00127 maxs[i] = dv->st[i];
00128 }
00129 }
00130
00131 // copy normal
00132 VectorCopy ( mapplanes[s->planenum].normal, dv->normal );
00133 }
00134
00135 // adjust the texture coordinates to be as close to 0 as possible
00136 if ( !si->globalTexture ) {
00137 mins[0] = floor( mins[0] );
00138 mins[1] = floor( mins[1] );
00139 for ( i = 0 ; i < w->numpoints ; i++ ) {
00140 dv = ds->verts + i;
00141 dv->st[0] -= mins[0];
00142 dv->st[1] -= mins[1];
00143 }
00144 }
00145
00146 return ds;
00147 }
|
Here is the call graph for this function:

|
|
Definition at line 991 of file surface.c. References drawSurfaces, EmitShader(), Error(), drawsurf_s::fogNum, dsurface_t::fogNum, dsurface_t::lightmapOrigin, drawsurf_s::lightmapOrigin, dsurface_t::lightmapVecs, drawsurf_s::lightmapVecs, mapDrawSurface_t, numDrawSurfaces, shaderInfo_s::shader, drawsurf_s::shaderInfo, dsurface_t::shaderNum, dsurface_t::surfaceType, and VectorCopy. Referenced by FilterDrawsurfsIntoTree(). 00991 {
00992 dsurface_t *out;
00993
00994 if ( numDrawSurfaces == MAX_MAP_DRAW_SURFS ) {
00995 Error( "MAX_MAP_DRAW_SURFS" );
00996 }
00997 out = &drawSurfaces[ numDrawSurfaces ];
00998 numDrawSurfaces++;
00999
01000 out->surfaceType = MST_FLARE;
01001 out->shaderNum = EmitShader( ds->shaderInfo->shader );
01002 out->fogNum = ds->fogNum;
01003
01004 VectorCopy( ds->lightmapOrigin, out->lightmapOrigin );
01005 VectorCopy( ds->lightmapVecs[0], out->lightmapVecs[0] ); // color
01006 VectorCopy( ds->lightmapVecs[2], out->lightmapVecs[2] );
01007 }
|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1113 of file surface.c. References c_fanSurfaces, c_stripSurfaces, CreateFlareSurface(), e, EmitFlareSurf(), EmitModelSurf(), EmitPatchSurf(), EmitPlanarSurf(), FilterFaceIntoTree(), FilterFlareSurfIntoTree(), FilterMiscModelSurfIntoTree(), FilterPatchSurfIntoTree(), entity_t::firstDrawSurf, shaderInfo_s::flareShader, drawsurf_s::flareSurface, i, mapDrawSurface_t, mapDrawSurfs, drawsurf_s::miscModel, drawsurf_s::numVerts, drawsurf_s::patch, qprintf(), drawsurf_s::shaderInfo, and tree(). Referenced by ProcessSubModel(), and ProcessWorldModel(). 01113 {
01114 int i;
01115 mapDrawSurface_t *ds;
01116 int refs;
01117 int c_surfs, c_refs;
01118
01119 qprintf( "----- FilterDrawsurfsIntoTree -----\n");
01120
01121 c_surfs = 0;
01122 c_refs = 0;
01123 for ( i = e->firstDrawSurf ; i < numMapDrawSurfs ; i++ ) {
01124 ds = &mapDrawSurfs[i];
01125
01126 if ( !ds->numVerts && !ds->flareSurface ) {
01127 continue;
01128 }
01129 if ( ds->miscModel ) {
01130 refs = FilterMiscModelSurfIntoTree( ds, tree );
01131 EmitModelSurf( ds );
01132 } else if ( ds->patch ) {
01133 refs = FilterPatchSurfIntoTree( ds, tree );
01134 EmitPatchSurf( ds );
01135 } else if ( ds->flareSurface ) {
01136 refs = FilterFlareSurfIntoTree( ds, tree );
01137 EmitFlareSurf( ds );
01138 } else {
01139 refs = FilterFaceIntoTree( ds, tree );
01140 // if ( ds->shaderInfo->value >= 1000 ) { // ds->shaderInfo->flareShader[0] ) {
01141 if ( ds->shaderInfo->flareShader[0] ) {
01142 CreateFlareSurface( ds );
01143 }
01144 EmitPlanarSurf( ds );
01145 }
01146 if ( refs > 0 ) {
01147 c_surfs++;
01148 c_refs += refs;
01149 }
01150 }
01151 qprintf( "%5i emited drawsurfs\n", c_surfs );
01152 qprintf( "%5i references\n", c_refs );
01153 qprintf( "%5i stripfaces\n", c_stripSurfaces );
01154 qprintf( "%5i fanfaces\n", c_fanSurfaces );
01155 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 602 of file surface.c. References FilterSideIntoTree_r(), l, mapDrawSurface_t, drawsurf_s::side, tree(), w, and WindingFromDrawSurf(). Referenced by FilterDrawsurfsIntoTree(). 00602 {
00603 int l;
00604 winding_t *w;
00605
00606 w = WindingFromDrawSurf( ds );
00607 l = FilterSideIntoTree_r( w, ds->side, ds, tree->headnode );
00608
00609 return l;
00610 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 693 of file surface.c. References FilterMapDrawSurfIntoTree(), drawsurf_s::lightmapOrigin, mapDrawSurface_t, and tree(). Referenced by FilterDrawsurfsIntoTree(). 00693 {
00694 return FilterMapDrawSurfIntoTree( ds->lightmapOrigin, ds, tree->headnode );
00695 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 459 of file surface.c. References c, node_s::children, d, plane_t::dist, DotProduct, drawSurfRef_t, node_s::drawSurfReferences, malloc(), mapDrawSurface_t, mapplanes, drawSurfRef_s::nextRef, node_t, plane_t::normal, node_s::opaque, drawSurfRef_s::outputNumber, node_s::planenum, and point. Referenced by FilterFlareSurfIntoTree(), FilterMiscModelSurfIntoTree(), and FilterPatchSurfIntoTree(). 00459 {
00460 drawSurfRef_t *dsr;
00461 float d;
00462 plane_t *plane;
00463 int c;
00464
00465 if ( node->planenum != PLANENUM_LEAF ) {
00466 plane = &mapplanes[ node->planenum ];
00467 d = DotProduct( point, plane->normal ) - plane->dist;
00468 c |