/* * 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; }
/* * 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; }
/* ================= 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 }