Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

surface.c File Reference

#include "qbsp.h"

Include dependency graph for surface.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  sideRef_t

Defines

#define COLINEAR_AREA   10
#define MAX_INDICES   1024
#define MAX_SIDE_REFS   MAX_MAP_PLANES
#define SNAP_FLOAT_TO_INT   8
#define SNAP_INT_TO_FLOAT   (1.0/SNAP_FLOAT_TO_INT)
#define SUBDIVISION_LIMIT   8.0

Functions

void AddSideRef (side_t *side)
mapDrawSurface_tAllocDrawSurf (void)
void ClipSideIntoTree_r (winding_t *w, side_t *side, node_t *node)
void ClipSidesIntoTree (entity_t *e, tree_t *tree)
void CreateFlareSurface (mapDrawSurface_t *faceDs)
mapDrawSurface_tDrawSurfaceForSide (bspbrush_t *b, side_t *s, winding_t *w)
void EmitFlareSurf (mapDrawSurface_t *ds)
void EmitModelSurf (mapDrawSurface_t *ds)
void EmitPatchSurf (mapDrawSurface_t *ds)
void EmitPlanarSurf (mapDrawSurface_t *ds)
void FilterDrawsurfsIntoTree (entity_t *e, tree_t *tree)
int FilterFaceIntoTree (mapDrawSurface_t *ds, tree_t *tree)
int FilterFlareSurfIntoTree (mapDrawSurface_t *ds, tree_t *tree)
int FilterMapDrawSurfIntoTree (vec3_t point, mapDrawSurface_t *ds, node_t *node)
int FilterMapDrawSurfIntoTree_r (winding_t *w, mapDrawSurface_t *ds, node_t *node)
int FilterMiscModelSurfIntoTree (mapDrawSurface_t *ds, tree_t *tree)
int FilterPatchSurfIntoTree (mapDrawSurface_t *ds, tree_t *tree)
int FilterSideIntoTree_r (winding_t *w, side_t *side, mapDrawSurface_t *ds, node_t *node)
qboolean IsTriangleDegenerate (drawVert_t *points, int a, int b, int c)
void MergeSides (entity_t *e, tree_t *tree)
void SubdivideDrawSurf (mapDrawSurface_t *ds, winding_t *w, float subdivisions)
void SubdivideDrawSurfs (entity_t *e, tree_t *tree)
void SurfaceAsTriFan (dsurface_t *ds)
void SurfaceAsTristrip (dsurface_t *ds)

Variables

int c_fanSurfaces
int c_stripSurfaces
mapDrawSurface_t mapDrawSurfs [MAX_MAP_DRAW_SURFS]
int numMapDrawSurfs
int numSideRefs
sideRef_t sideRefs [MAX_SIDE_REFS]


Define Documentation

#define COLINEAR_AREA   10
 

Definition at line 709 of file surface.c.

#define MAX_INDICES   1024
 

Definition at line 809 of file surface.c.

#define MAX_SIDE_REFS   MAX_MAP_PLANES
 

Definition at line 161 of file surface.c.

#define SNAP_FLOAT_TO_INT   8
 

Definition at line 59 of file surface.c.

Referenced by DrawSurfaceForSide().

#define SNAP_INT_TO_FLOAT   (1.0/SNAP_FLOAT_TO_INT)
 

Definition at line 60 of file surface.c.

Referenced by DrawSurfaceForSide().

#define SUBDIVISION_LIMIT   8.0
 

Definition at line 619 of file surface.c.

Referenced by FilterPatchSurfIntoTree().


Function Documentation

void AddSideRef side_t side  ) 
 

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:

mapDrawSurface_t* AllocDrawSurf void   ) 
 

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:

void ClipSideIntoTree_r winding_t w,
side_t side,
node_t node
 

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:

void ClipSidesIntoTree entity_t e,
tree_t tree
 

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:

void CreateFlareSurface mapDrawSurface_t faceDs  ) 
 

Definition at line 1076 of file surface.c.

References AllocDrawSurf(), shaderInfo_s::color, shaderInfo_s::flareShader, drawsurf_s::flareSurface, i, drawsurf_s::lightmapOrigin, drawsurf_s::lightmapVecs, mapDrawSurface_t, drawsurf_s::numVerts, drawsurf_s::shaderInfo, ShaderInfoForShader(), VectorAdd, VectorClear, VectorCopy, VectorMA, VectorScale, drawsurf_s::verts, and drawVert_t::xyz.

Referenced by FilterDrawsurfsIntoTree().

01076                                                     {
01077     mapDrawSurface_t    *ds;
01078     int                 i;
01079 
01080     ds = AllocDrawSurf();
01081 
01082     if ( faceDs->shaderInfo->flareShader[0] ) {
01083         ds->shaderInfo = ShaderInfoForShader( faceDs->shaderInfo->flareShader );
01084     } else {
01085         ds->shaderInfo = ShaderInfoForShader( "flareshader" );
01086     }
01087     ds->flareSurface = qtrue;
01088     VectorCopy( faceDs->lightmapVecs[2], ds->lightmapVecs[2] );
01089 
01090     // find midpoint
01091     VectorClear( ds->lightmapOrigin );
01092     for ( i = 0 ; i < faceDs->numVerts ; i++ ) {
01093         VectorAdd( ds->lightmapOrigin, faceDs->verts[i].xyz, ds->lightmapOrigin );
01094     }
01095     VectorScale( ds->lightmapOrigin, 1.0/faceDs->numVerts, ds->lightmapOrigin );
01096 
01097     VectorMA( ds->lightmapOrigin, 2,  ds->lightmapVecs[2], ds->lightmapOrigin );
01098 
01099     VectorCopy( faceDs->shaderInfo->color, ds->lightmapVecs[0] );
01100 
01101     // FIXME: fog
01102 }

Here is the call graph for this function:

mapDrawSurface_t* DrawSurfaceForSide bspbrush_t b,
side_t s,
winding_t w
 

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:

void EmitFlareSurf mapDrawSurface_t ds  ) 
 

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:

void EmitModelSurf mapDrawSurface_t ds  ) 
 

Definition at line 1015 of file surface.c.

References drawVert_t::color, drawIndexes, drawSurfaces, drawVerts, EmitShader(), Error(), dsurface_t::firstIndex, dsurface_t::firstVert, drawsurf_s::fogNum, dsurface_t::fogNum, drawsurf_s::indexes, j, drawsurf_s::lightmapHeight, dsurface_t::lightmapHeight, drawsurf_s::lightmapNum, dsurface_t::lightmapNum, dsurface_t::lightmapOrigin, drawsurf_s::lightmapOrigin, dsurface_t::lightmapVecs, drawsurf_s::lightmapVecs, drawsurf_s::lightmapWidth, dsurface_t::lightmapWidth, drawsurf_s::lightmapX, dsurface_t::lightmapX, drawsurf_s::lightmapY, dsurface_t::lightmapY, mapDrawSurface_t, memcpy(), numDrawIndexes, numDrawSurfaces, numDrawVerts, drawsurf_s::numIndexes, dsurface_t::numIndexes, drawsurf_s::numVerts, dsurface_t::numVerts, drawsurf_s::patchHeight, dsurface_t::patchHeight, drawsurf_s::patchWidth, dsurface_t::patchWidth, shaderInfo_s::shader, drawsurf_s::shaderInfo, dsurface_t::shaderNum, dsurface_t::surfaceType, VectorCopy, and drawsurf_s::verts.

Referenced by FilterDrawsurfsIntoTree().

01015                                            {
01016     int             j;
01017     dsurface_t      *out;
01018     drawVert_t      *outv;
01019 
01020     if ( numDrawSurfaces == MAX_MAP_DRAW_SURFS ) {
01021         Error( "MAX_MAP_DRAW_SURFS" );
01022     }
01023     out = &drawSurfaces[ numDrawSurfaces ];
01024     numDrawSurfaces++;
01025 
01026     out->surfaceType = MST_TRIANGLE_SOUP;
01027     out->shaderNum = EmitShader( ds->shaderInfo->shader );
01028     out->firstVert = numDrawVerts;
01029     out->numVerts = ds->numVerts;
01030     out->firstIndex = numDrawIndexes;
01031     out->numIndexes = ds->numIndexes;
01032     out->patchWidth = ds->patchWidth;
01033     out->patchHeight = ds->patchHeight;
01034     out->fogNum = ds->fogNum;
01035     out->lightmapNum = ds->lightmapNum;
01036     out->lightmapX = ds->lightmapX;
01037     out->lightmapY = ds->lightmapY;
01038     out->lightmapWidth = ds->lightmapWidth;
01039     out->lightmapHeight = ds->lightmapHeight;
01040 
01041     VectorCopy( ds->lightmapOrigin, out->lightmapOrigin );
01042     VectorCopy( ds->lightmapVecs[0], out->lightmapVecs[0] );
01043     VectorCopy( ds->lightmapVecs[1], out->lightmapVecs[1] );
01044     VectorCopy( ds->lightmapVecs[2], out->lightmapVecs[2] );
01045 
01046     for ( j = 0 ; j < ds->numVerts ; j++ ) {
01047         if ( numDrawVerts == MAX_MAP_DRAW_VERTS ) {
01048             Error( "MAX_MAP_DRAW_VERTS" );
01049         }
01050         outv = &drawVerts[ numDrawVerts ];
01051         numDrawVerts++;
01052         memcpy( outv, &ds->verts[ j ], sizeof( *outv ) );
01053         outv->color[0] = 255;
01054         outv->color[1] = 255;
01055         outv->color[2] = 255;
01056     }
01057 
01058     for ( j = 0 ; j < ds->numIndexes ; j++ ) {
01059         if ( numDrawIndexes == MAX_MAP_DRAW_INDEXES ) {
01060             Error( "MAX_MAP_DRAW_INDEXES" );
01061         }
01062         drawIndexes[ numDrawIndexes ] = ds->indexes[ j ];
01063         numDrawIndexes++;
01064     }
01065 }

Here is the call graph for this function:

void EmitPatchSurf mapDrawSurface_t ds  ) 
 

Definition at line 933 of file surface.c.

References drawVert_t::color, drawIndexes, drawSurfaces, drawVerts, EmitShader(), Error(), dsurface_t::firstIndex, dsurface_t::firstVert, drawsurf_s::fogNum, dsurface_t::fogNum, drawsurf_s::indexes, j, drawsurf_s::lightmapHeight, dsurface_t::lightmapHeight, drawsurf_s::lightmapNum, dsurface_t::lightmapNum, dsurface_t::lightmapOrigin, drawsurf_s::lightmapOrigin, dsurface_t::lightmapVecs, drawsurf_s::lightmapVecs, drawsurf_s::lightmapWidth, dsurface_t::lightmapWidth, drawsurf_s::lightmapX, dsurface_t::lightmapX, drawsurf_s::lightmapY, dsurface_t::lightmapY, mapDrawSurface_t, memcpy(), numDrawIndexes, numDrawSurfaces, numDrawVerts, drawsurf_s::numIndexes, dsurface_t::numIndexes, drawsurf_s::numVerts, dsurface_t::numVerts, drawsurf_s::patchHeight, dsurface_t::patchHeight, drawsurf_s::patchWidth, dsurface_t::patchWidth, shaderInfo_s::shader, drawsurf_s::shaderInfo, dsurface_t::shaderNum, dsurface_t::surfaceType, VectorCopy, and drawsurf_s::verts.

Referenced by FilterDrawsurfsIntoTree().

00933                                            {
00934     int             j;
00935     dsurface_t      *out;
00936     drawVert_t      *outv;
00937 
00938     if ( numDrawSurfaces == MAX_MAP_DRAW_SURFS ) {
00939         Error( "MAX_MAP_DRAW_SURFS" );
00940     }
00941     out = &drawSurfaces[ numDrawSurfaces ];
00942     numDrawSurfaces++;
00943 
00944     out->surfaceType = MST_PATCH;
00945     out->shaderNum = EmitShader( ds->shaderInfo->shader );
00946     out->firstVert = numDrawVerts;
00947     out->numVerts = ds->numVerts;
00948     out->firstIndex = numDrawIndexes;
00949     out->numIndexes = ds->numIndexes;
00950     out->patchWidth = ds->patchWidth;
00951     out->patchHeight = ds->patchHeight;
00952     out->fogNum = ds->fogNum;
00953     out->lightmapNum = ds->lightmapNum;
00954     out->lightmapX = ds->lightmapX;
00955     out->lightmapY = ds->lightmapY;
00956     out->lightmapWidth = ds->lightmapWidth;
00957     out->lightmapHeight = ds->lightmapHeight;
00958 
00959     VectorCopy( ds->lightmapOrigin, out->lightmapOrigin );
00960     VectorCopy( ds->lightmapVecs[0], out->lightmapVecs[0] );
00961     VectorCopy( ds->lightmapVecs[1], out->lightmapVecs[1] );
00962     VectorCopy( ds->lightmapVecs[2], out->lightmapVecs[2] );
00963 
00964     for ( j = 0 ; j < ds->numVerts ; j++ ) {
00965         if ( numDrawVerts == MAX_MAP_DRAW_VERTS ) {
00966             Error( "MAX_MAP_DRAW_VERTS" );
00967         }
00968         outv = &drawVerts[ numDrawVerts ];
00969         numDrawVerts++;
00970         memcpy( outv, &ds->verts[ j ], sizeof( *outv ) );
00971         outv->color[0] = 255;
00972         outv->color[1] = 255;
00973         outv->color[2] = 255;
00974         outv->color[3] = 255;
00975     }
00976 
00977     for ( j = 0 ; j < ds->numIndexes ; j++ ) {
00978         if ( numDrawIndexes == MAX_MAP_DRAW_INDEXES ) {
00979             Error( "MAX_MAP_DRAW_INDEXES" );
00980         }
00981         drawIndexes[ numDrawIndexes ] = ds->indexes[ j ];
00982         numDrawIndexes++;
00983     }
00984 }

Here is the call graph for this function:

void EmitPlanarSurf mapDrawSurface_t ds  ) 
 

Definition at line 883 of file surface.c.

References drawVert_t::color, drawSurfaces, drawVerts, EmitShader(), Error(), dsurface_t::firstVert, drawsurf_s::fogNum, dsurface_t::fogNum, j, drawsurf_s::lightmapHeight, dsurface_t::lightmapHeight, drawsurf_s::lightmapNum, dsurface_t::lightmapNum, dsurface_t::lightmapOrigin, drawsurf_s::lightmapOrigin, dsurface_t::lightmapVecs, drawsurf_s::lightmapVecs, drawsurf_s::lightmapWidth, dsurface_t::lightmapWidth, drawsurf_s::lightmapX, dsurface_t::lightmapX, drawsurf_s::lightmapY, dsurface_t::lightmapY, mapDrawSurface_t, memcpy(), numDrawSurfaces, numDrawVerts, drawsurf_s::numVerts, dsurface_t::numVerts, shaderInfo_s::shader, drawsurf_s::shaderInfo, dsurface_t::shaderNum, SurfaceAsTristrip(), dsurface_t::surfaceType, VectorCopy, and drawsurf_s::verts.

Referenced by FilterDrawsurfsIntoTree().

00883                                             {
00884     int             j;
00885     dsurface_t      *out;
00886     drawVert_t      *outv;
00887 
00888     if ( numDrawSurfaces == MAX_MAP_DRAW_SURFS ) {
00889         Error( "MAX_MAP_DRAW_SURFS" );
00890     }
00891     out = &drawSurfaces[ numDrawSurfaces ];
00892     numDrawSurfaces++;
00893 
00894     out->surfaceType = MST_PLANAR;
00895     out->shaderNum = EmitShader( ds->shaderInfo->shader );
00896     out->firstVert = numDrawVerts;
00897     out->numVerts = ds->numVerts;
00898     out->fogNum = ds->fogNum;
00899     out->lightmapNum = ds->lightmapNum;
00900     out->lightmapX = ds->lightmapX;
00901     out->lightmapY = ds->lightmapY;
00902     out->lightmapWidth = ds->lightmapWidth;
00903     out->lightmapHeight = ds->lightmapHeight;
00904 
00905     VectorCopy( ds->lightmapOrigin, out->lightmapOrigin );
00906     VectorCopy( ds->lightmapVecs[0], out->lightmapVecs[0] );
00907     VectorCopy( ds->lightmapVecs[1], out->lightmapVecs[1] );
00908     VectorCopy( ds->lightmapVecs[2], out->lightmapVecs[2] );
00909 
00910     for ( j = 0 ; j < ds->numVerts ; j++ ) {
00911         if ( numDrawVerts == MAX_MAP_DRAW_VERTS ) {
00912             Error( "MAX_MAP_DRAW_VERTS" );
00913         }
00914         outv = &drawVerts[ numDrawVerts ];
00915         numDrawVerts++;
00916         memcpy( outv, &ds->verts[ j ], sizeof( *outv ) );
00917         outv->color[0] = 255;
00918         outv->color[1] = 255;
00919         outv->color[2] = 255;
00920         outv->color[3] = 255;
00921     }
00922 
00923     // create the indexes
00924     SurfaceAsTristrip( out );
00925 }

Here is the call graph for this function:

void FilterDrawsurfsIntoTree entity_t e,
tree_t tree
 

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:

int FilterFaceIntoTree mapDrawSurface_t ds,
tree_t tree
 

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:

int FilterFlareSurfIntoTree mapDrawSurface_t ds,
tree_t tree
 

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:

int FilterMapDrawSurfIntoTree vec3_t  point,
mapDrawSurface_t ds,
node_t node
 

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