Ejemplo n.º 1
0
/*
* R_CullModel
*/
int R_CullModel( entity_t *e, vec3_t mins, vec3_t maxs, float radius )
{
	if( e->flags & RF_WEAPONMODEL )
	{
		if( ri.params & RP_NONVIEWERREF )
			return 1;
		return 0;
	}

	if( e->flags & RF_VIEWERMODEL )
	{
		//if( !(ri.params & RP_NONVIEWERREF) )
		if( !( ri.params & ( RP_MIRRORVIEW|RP_SHADOWMAPVIEW ) ) )
			return 1;
	}

	// account for possible outlines
#ifdef HARDWARE_OUTLINES
	if( e->outlineHeight )
		radius += e->outlineHeight * r_outlines_scale->value * 1.73/*sqrt(3)*/;
#endif

	if( R_CullSphere( e->origin, radius, ri.clipFlags ) )
		return 1;

	if( ri.params & RP_PVSCULL )
	{
		if( R_VisCullSphere( e->origin, radius ) )
			return 2;
	}

	return 0;
}
Ejemplo n.º 2
0
/*
* R_CullModelEntity
*/
int R_CullModelEntity( const entity_t *e, vec3_t mins, vec3_t maxs, float radius, bool sphereCull, bool pvsCull )
{
	if( e->flags & RF_NOSHADOW )
	{
		if( rn.renderFlags & RF_SHADOWMAPVIEW )
			return 3;
	}

	if( e->flags & RF_WEAPONMODEL )
	{
		if( rn.renderFlags & RF_NONVIEWERREF )
			return 1;
		return 0;
	}

	if( e->flags & RF_VIEWERMODEL )
	{
		//if( !(rn.renderFlags & RF_NONVIEWERREF) )
		if( !( rn.renderFlags & ( RF_MIRRORVIEW|RF_SHADOWMAPVIEW ) ) )
			return 1;
	}

	if( e->flags & RF_NODEPTHTEST )
		return 0;

	// account for possible outlines
	if( e->outlineHeight )
		radius += e->outlineHeight * r_outlines_scale->value * 1.73/*sqrt(3)*/;

	if( sphereCull )
	{
		if( R_CullSphere( e->origin, radius, rn.clipFlags ) )
			return 1;
	}
	else
	{
		if( R_CullBox( mins, maxs, rn.clipFlags ) )
			return 1;
	}

	if( pvsCull )
	{
		if( sphereCull )
		{
			if( R_VisCullSphere( e->origin, radius ) )
				return 2;
		}
		else
		{
			if( R_VisCullBox( mins, maxs ) )
				return 2;
		}
	}

	return 0;
}
Ejemplo n.º 3
0
/*
=============
R_CullModel
=============
*/
bool R_CullModel( cl_entity_t *e, const Vector &origin, const Vector &mins, const Vector &maxs, float radius )
{
	if( e == GET_VIEWMODEL( ))
	{
		if( RI.params & RP_NONVIEWERREF )
			return true;
		return false;
	}

	// don't reflect this entity in mirrors
	if( e->curstate.effects & EF_NOREFLECT && RI.params & RP_MIRRORVIEW )
		return true;

	// draw only in mirrors
	if( e->curstate.effects & EF_REFLECTONLY && !( RI.params & RP_MIRRORVIEW ))
		return true;

	// never draw playermodel for himself flashlight while shadowpass is active
	if( RI.params & RP_SHADOWVIEW && RI.currentlight != NULL )
	{
		if( UTIL_IsLocal( e->index ) && UTIL_IsLocal( RI.currentlight->key ))
			return true;
          }

	if( RP_LOCALCLIENT( e ))
	{
		if( RI.params & RP_FORCE_NOPLAYER )
			return true;

		if( !RI.thirdPerson && UTIL_IsLocal( RI.refdef.viewentity ))
		{
			// player can view himself from the portal camera
			if(!( RI.params & ( RP_MIRRORVIEW|RP_PORTALVIEW|RP_SCREENVIEW|RP_SHADOWVIEW )))
				return true;
		}
	}

	if( R_CullSphere( origin, radius, RI.clipFlags ))
		return true;

	if( RI.params & ( RP_SKYPORTALVIEW|RP_PORTALVIEW ))
	{
		if( R_VisCullSphere( e->origin, radius ))
			return true;
	}

	return false;
}
Ejemplo n.º 4
0
/*
* R_CullBrushModel
*/
qboolean R_CullBrushModel( entity_t *e )
{
	qboolean rotated;
	vec3_t mins, maxs;
	float radius;
	model_t	*model = e->model;
	mbrushmodel_t *bmodel = ( mbrushmodel_t * )model->extradata;

	if( bmodel->nummodelsurfaces == 0 )
		return qtrue;

	radius = R_BrushModelBBox( e, mins, maxs, &rotated );
	if( rotated )
	{
		if( R_CullSphere( e->origin, radius, ri.clipFlags ) )
			return qtrue;
	}
	else
	{
		if( R_CullBox( mins, maxs, ri.clipFlags ) )
			return qtrue;
	}

	if( ri.params & RP_PVSCULL )
	{
		if( rotated )
		{
			if( R_VisCullSphere( e->origin, radius ) )
				return qtrue;
		}
		else
		{
			if( R_VisCullBox( mins, maxs ) )
				return qtrue;
		}
	}

	return qfalse;
}
Ejemplo n.º 5
0
/*
=================
R_ShadowPassDrawBrushModel
=================
*/
void R_ShadowPassDrawBrushModel( cl_entity_t *e, const plight_t *pl )
{
	Vector	mins, maxs;
	model_t	*clmodel;
	bool	rotated;

	clmodel = e->model;

	if( e->angles != g_vecZero )
	{
		for( int i = 0; i < 3; i++ )
		{
			mins[i] = e->origin[i] - clmodel->radius;
			maxs[i] = e->origin[i] + clmodel->radius;
		}
		rotated = true;
	}
	else
	{
		mins = e->origin + clmodel->mins;
		maxs = e->origin + clmodel->maxs;
		rotated = false;
	}

	if( R_CullBox( mins, maxs, RI.clipFlags ))
		return;

	if( RI.params & ( RP_SKYPORTALVIEW|RP_PORTALVIEW|RP_SCREENVIEW ))
	{
		if( rotated )
		{
			if( R_VisCullSphere( e->origin, clmodel->radius ))
				return;
		}
		else
		{
			if( R_VisCullBox( mins, maxs ))
				return;
		}
	}

	if( rotated ) R_RotateForEntity( e );
	else R_TranslateForEntity( e );

	if( rotated ) tr.modelorg = RI.objectMatrix.VectorITransform( RI.vieworg );
	else tr.modelorg = RI.vieworg - e->origin;

	// accumulate lit surfaces
	msurface_t *psurf = &clmodel->surfaces[clmodel->firstmodelsurface];
	for( int i = 0; i < clmodel->nummodelsurfaces; i++, psurf++ )
	{
		float *v;
		int k;

		if( psurf->flags & (SURF_DRAWTILED|SURF_PORTAL|SURF_REFLECT))
			continue;

		R_AddToGrassChain( psurf, pl->frustum, pl->clipflags, false );

		if( R_CullSurfaceExt( psurf, pl->frustum, 0 ))
			continue;

		// draw depth-mask on transparent textures
		if( psurf->flags & SURF_TRANSPARENT )
		{
			pglEnable( GL_ALPHA_TEST );
			pglEnable( GL_TEXTURE_2D );
			pglAlphaFunc( GL_GREATER, 0.0f );
			GL_Bind( GL_TEXTURE0, psurf->texinfo->texture->gl_texturenum );
		}

		pglBegin( GL_POLYGON );
		for( k = 0, v = psurf->polys->verts[0]; k < psurf->polys->numverts; k++, v += VERTEXSIZE )
		{
			if( psurf->flags & SURF_TRANSPARENT )
				pglTexCoord2f( v[3], v[4] );
			pglVertex3fv( v );
		}
		pglEnd();

		if( psurf->flags & SURF_TRANSPARENT )
		{
			pglDisable( GL_ALPHA_TEST );
			pglDisable( GL_TEXTURE_2D );
		}
	}

	R_LoadIdentity();	// restore worldmatrix
}