Ejemplo n.º 1
0
/*
* 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++;
}
Ejemplo n.º 2
0
/*
* 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++;
}