/* * R_AddSurfaceToDrawList */ static void R_AddSurfaceToDrawList( const entity_t *e, const msurface_t *surf, const mfog_t *fog, unsigned int clipFlags, unsigned int dlightBits, unsigned shadowBits, float dist ) { shader_t *shader; drawSurfaceBSP_t *drawSurf = surf->drawSurf; portalSurface_t *portalSurface = NULL; if( R_CullSurface( e, surf, clipFlags ) ) { return; } if( r_drawworld->integer == 2 ) { shader = rsh.envShader; } else { shader = surf->shader; if( shader->flags & SHADER_SKY ) { bool addSurf = true, addSlice = false; if( R_FASTSKY() ) { return; } if( R_ClipSkySurface( surf ) ) { if( rn.refdef.rdflags & RDF_SKYPORTALINVIEW ) { // for skyportals, generate portal surface and // also add BSP surface to skybox if it's fogged to render // the fog hull later portalSurface = R_AddSkyportalSurface( e, shader, drawSurf ); addSurf = portalSurface != NULL && surf->fog != NULL; addSlice = portalSurface != NULL; } if( addSurf ) { addSlice = R_AddSkySurfToDrawList( surf, portalSurface ); } if( addSlice ) { R_AddSurfaceVBOSlice( surf, 0 ); } } rn.numVisSurfaces++; return; } } if( drawSurf->visFrame != rf.frameCount ) { if( shader->flags & SHADER_PORTAL ) { // draw portals in front-to-back order dist = 1024 - dist / 100.0f; if( dist < 1 ) dist = 1; portalSurface = R_AddPortalSurface( e, surf->mesh, surf->mins, surf->maxs, shader, drawSurf ); } else { // just ignore the distance since we're drawing batched geometry anyway dist = 0; } drawSurf->visFrame = rf.frameCount; if( !R_AddSurfToDrawList( rn.meshlist, e, fog, shader, dist, 0, portalSurface, drawSurf ) ) { return; } if( portalSurface && !( shader->flags & (SHADER_PORTAL_CAPTURE|SHADER_PORTAL_CAPTURE2) ) ) { R_AddSurfToDrawList( rn.portalmasklist, e, NULL, rsh.skyShader, 0, 0, NULL, drawSurf ); } } // keep track of the actual vbo chunk we need to render R_AddSurfaceVBOSlice( surf, 0 ); // dynamic lights that affect the surface if( dlightBits ) { // ignore dlights that have already been marked as affectors if( drawSurf->dlightFrame == rsc.frameCount ) { drawSurf->dlightBits |= dlightBits; } else { drawSurf->dlightBits = dlightBits; drawSurf->dlightFrame = rsc.frameCount; } } // shadows that are projected onto the surface if( shadowBits ) { R_AddSurfaceVBOSlice( surf, rsh.worldBrushModel->numDrawSurfaces ); // ignore shadows that have already been marked as affectors if( drawSurf->shadowFrame == rsc.frameCount ) { drawSurf->shadowBits |= shadowBits; } else { drawSurf->shadowBits = shadowBits; drawSurf->shadowFrame = rsc.frameCount; } } rf.stats.c_brush_polys++; rn.numVisSurfaces++; }
/* * R_AddSurfaceToDrawList */ static void R_AddSurfaceToDrawList( const entity_t *e, const msurface_t *surf, const mfog_t *fog, unsigned int clipFlags, unsigned int dlightBits, unsigned shadowBits, float dist ) { int order = 0; shader_t *shader; drawSurfaceBSP_t *drawSurf; if( R_CullSurface( e, surf, clipFlags ) ) { return; } if( r_drawworld->integer == 2 ) { shader = rsh.envShader; } else { shader = surf->shader; if( shader->flags & SHADER_SKY ) { if( !R_FASTSKY() ) { R_AddSkyToDrawList( surf ); rn.numVisSurfaces++; } return; } } drawSurf = surf->drawSurf; if( drawSurf->visFrame != rf.frameCount ) { portalSurface_t *portalSurface = NULL; if( shader->flags & SHADER_PORTAL ) { // draw portals in front-to-back order dist = 1024 - dist / 100.0f; if( dist < 1 ) dist = 1; portalSurface = R_AddPortalSurface( e, surf->mesh, surf->mins, surf->maxs, shader ); } drawSurf->visFrame = rf.frameCount; if( !R_AddDSurfToDrawList( e, fog, shader, dist, order, portalSurface, drawSurf ) ) { return; } } // keep track of the actual vbo chunk we need to render R_AddVBOSlice( drawSurf - rsh.worldBrushModel->drawSurfaces, surf->mesh->numVerts, surf->mesh->numElems, surf->firstDrawSurfVert, surf->firstDrawSurfElem ); // dynamic lights that affect the surface if( dlightBits && R_SurfPotentiallyLit( surf ) ) { // ignore dlights that have already been marked as affectors if( drawSurf->dlightFrame == rsc.frameCount ) { drawSurf->dlightBits |= dlightBits; } else { drawSurf->dlightBits = dlightBits; drawSurf->dlightFrame = rsc.frameCount; } } // shadows that are projected onto the surface if( shadowBits && R_SurfPotentiallyShadowed( surf ) ) { // ignore shadows that have already been marked as affectors if( drawSurf->shadowFrame == rsc.frameCount ) { drawSurf->shadowBits |= shadowBits; } else { drawSurf->shadowBits = shadowBits; drawSurf->shadowFrame = rsc.frameCount; } } rf.stats.c_brush_polys++; rn.numVisSurfaces++; }
/* * R_AddSurfaceToDrawList */ static void R_AddSurfaceToDrawList( const entity_t *e, const msurface_t *surf, const mfog_t *fog, unsigned int clipFlags, unsigned int dlightBits, unsigned shadowBits, float dist ) { int order = 0; shader_t *shader; drawSurfaceBSP_t *drawSurf; if( R_CullSurface( e, surf, clipFlags ) ) { return; } if( r_drawworld->integer == 2 ) { shader = rf.envShader; } else { shader = surf->shader; if( shader->flags & SHADER_SKY ) { if( !R_FASTSKY() ) { R_AddSkyToDrawList( surf ); } // fallthrough, but add with skyclip shader, writing to depthbuffer // that will mask our skydome and prevent world geometry from // bleeding through it fog = NULL; shader = rf.skyclipShader; order = 1000; } } drawSurf = surf->drawSurf; if( drawSurf->visFrame != r_framecount ) { portalSurface_t *portalSurface = NULL; if( shader->flags & SHADER_PORTAL ) { portalSurface = R_AddPortalSurface( e, surf->mesh, surf->mins, surf->maxs, shader ); } drawSurf->visFrame = r_framecount; if( !R_AddDSurfToDrawList( e, fog, shader, dist, order, portalSurface, drawSurf ) ) { return; } } // keep track of the actual vbo chunk we need to render R_AddVBOSlice( drawSurf - r_worldbrushmodel->drawSurfaces, surf->mesh->numVerts, surf->mesh->numElems, surf->firstDrawSurfVert, surf->firstDrawSurfElem ); // dynamic lights that affect the surface if( dlightBits && R_SurfPotentiallyLit( surf ) ) { // ignore dlights that have already been marked as affectors if( drawSurf->dlightFrame == rf.sceneFrameCount ) { drawSurf->dlightBits |= dlightBits; } else { drawSurf->dlightBits = dlightBits; drawSurf->dlightFrame = rf.sceneFrameCount; } } // shadows that are projected onto the surface if( shadowBits && R_SurfPotentiallyShadowed( surf ) ) { // ignore shadows that have already been marked as affectors if( drawSurf->shadowFrame == rf.sceneFrameCount ) { drawSurf->shadowBits |= shadowBits; } else { drawSurf->shadowBits = shadowBits; drawSurf->shadowFrame = rf.sceneFrameCount; } } c_brush_polys++; rn.numVisSurfaces++; }