/* =============== R_ShadowPassSetupFrame =============== */ static void R_ShadowPassSetupFrame( const plight_t *pl ) { // build the transformation matrix for the given view angles RI.refdef.viewangles[0] = anglemod( pl->angles[0] ); RI.refdef.viewangles[1] = anglemod( pl->angles[1] ); RI.refdef.viewangles[2] = anglemod( pl->angles[2] ); AngleVectors( RI.refdef.viewangles, RI.vforward, RI.vright, RI.vup ); RI.vieworg = RI.refdef.vieworg = pl->origin; // setup the screen FOV RI.refdef.fov_x = pl->fov; if( pl->flags & CF_ASPECT3X4 ) RI.refdef.fov_y = pl->fov * (5.0f / 4.0f); else if( pl->flags & CF_ASPECT4X3 ) RI.refdef.fov_y = pl->fov * (4.0f / 5.0f); else RI.refdef.fov_y = pl->fov; // setup frustum memcpy( RI.frustum, pl->frustum, sizeof( RI.frustum )); RI.clipFlags = pl->clipflags; if(!( RI.params & RP_OLDVIEWLEAF )) R_FindViewLeaf(); RI.currentlight = pl; }
/* =============== R_SetupFrame =============== */ static void R_SetupFrame( void ) { vec3_t viewOrg, viewAng; if( RP_NORMALPASS() && cl.thirdperson ) { vec3_t cam_ofs, vpn; clgame.dllFuncs.CL_CameraOffset( cam_ofs ); viewAng[PITCH] = cam_ofs[PITCH]; viewAng[YAW] = cam_ofs[YAW]; viewAng[ROLL] = 0; AngleVectors( viewAng, vpn, NULL, NULL ); VectorMA( RI.refdef.vieworg, -cam_ofs[ROLL], vpn, viewOrg ); } else { VectorCopy( RI.refdef.vieworg, viewOrg ); VectorCopy( RI.refdef.viewangles, viewAng ); } // build the transformation matrix for the given view angles VectorCopy( viewOrg, RI.vieworg ); AngleVectors( viewAng, RI.vforward, RI.vright, RI.vup ); // setup viewplane dist RI.viewplanedist = DotProduct( RI.vieworg, RI.vforward ); if( !r_lockcull->integer ) { VectorCopy( RI.vforward, RI.cull_vforward ); VectorCopy( RI.vright, RI.cull_vright ); VectorCopy( RI.vup, RI.cull_vup ); } R_AnimateLight(); R_RunViewmodelEvents(); // sort opaque entities by model type to avoid drawing model shadows under alpha-surfaces qsort( tr.solid_entities, tr.num_solid_entities, sizeof( cl_entity_t* ), R_SolidEntityCompare ); if( !gl_nosort->integer ) { // sort translucents entities by rendermode and distance qsort( tr.trans_entities, tr.num_trans_entities, sizeof( cl_entity_t* ), R_TransEntityCompare ); } // current viewleaf if( RI.drawWorld ) { RI.waveHeight = cl.refdef.movevars->waveHeight * 2.0f; // set global waveheight RI.isSkyVisible = false; // unknown at this moment if(!( RI.params & RP_OLDVIEWLEAF )) R_FindViewLeaf(); } }
/* ================ R_FindMirrors Build mirror chains for this frame ================ */ void R_FindMirrors( const ref_params_t *fd ) { vec3_t viewOrg, viewAng; if( !world.has_mirrors || RI.drawOrtho || !RI.drawWorld || RI.refdef.onlyClientDraw || !cl.worldmodel ) return; RI.refdef = *fd; // build the transformation matrix for the given view angles if( cl.thirdperson ) { vec3_t cam_ofs, vpn; clgame.dllFuncs.CL_CameraOffset( cam_ofs ); viewAng[PITCH] = cam_ofs[PITCH]; viewAng[YAW] = cam_ofs[YAW]; viewAng[ROLL] = 0; AngleVectors( viewAng, vpn, NULL, NULL ); VectorMA( RI.refdef.vieworg, -cam_ofs[ROLL], vpn, viewOrg ); } else { VectorCopy( RI.refdef.vieworg, viewOrg ); VectorCopy( RI.refdef.viewangles, viewAng ); } // build the transformation matrix for the given view angles VectorCopy( viewOrg, RI.vieworg ); AngleVectors( viewAng, RI.vforward, RI.vright, RI.vup ); VectorCopy( RI.vieworg, RI.pvsorigin ); if( !r_lockcull->integer ) { VectorCopy( RI.vieworg, RI.cullorigin ); VectorCopy( RI.vforward, RI.cull_vforward ); VectorCopy( RI.vright, RI.cull_vright ); VectorCopy( RI.vup, RI.cull_vup ); } R_FindViewLeaf(); R_SetupFrustum(); R_MarkLeaves (); VectorCopy( RI.cullorigin, tr.modelorg ); RI.currententity = clgame.entities; RI.currentmodel = RI.currententity->model; R_RecursiveMirrorNode( cl.worldmodel->nodes, RI.clipFlags ); R_CheckEntitiesOnList(); }
/* =============== R_SetupFrame =============== */ static void R_SetupFrame( void ) { vec3_t viewOrg, viewAng; VectorCopy( RI.refdef.vieworg, viewOrg ); VectorCopy( RI.refdef.viewangles, viewAng ); // build the transformation matrix for the given view angles VectorCopy( viewOrg, RI.vieworg ); AngleVectors( viewAng, RI.vforward, RI.vright, RI.vup ); // setup viewplane dist RI.viewplanedist = DotProduct( RI.vieworg, RI.vforward ); VectorCopy( RI.vieworg, RI.pvsorigin ); if( !r_lockcull->integer ) { VectorCopy( RI.vieworg, RI.cullorigin ); VectorCopy( RI.vforward, RI.cull_vforward ); VectorCopy( RI.vright, RI.cull_vright ); VectorCopy( RI.vup, RI.cull_vup ); } R_AnimateLight(); R_RunViewmodelEvents(); // sort opaque entities by model type to avoid drawing model shadows under alpha-surfaces qsort( tr.solid_entities, tr.num_solid_entities, sizeof( cl_entity_t* ), (void*)R_SolidEntityCompare ); if( !gl_nosort->integer ) { // sort translucents entities by rendermode and distance qsort( tr.trans_entities, tr.num_trans_entities, sizeof( cl_entity_t* ), (void*)R_TransEntityCompare ); } // current viewleaf if( RI.drawWorld ) { RI.waveHeight = cl.refdef.movevars->waveHeight * 2.0f; // set global waveheight RI.isSkyVisible = false; // unknown at this moment if(!( RI.params & RP_OLDVIEWLEAF )) R_FindViewLeaf(); } }
/* ================ R_FindMirrors Build mirror chains for this frame ================ */ void R_FindMirrors( const ref_params_t *fd ) { if( !world.has_mirrors || RI.drawOrtho || !RI.drawWorld || RI.refdef.onlyClientDraw || !cl.worldmodel ) return; RI.refdef = *fd; // build the transformation matrix for the given view angles VectorCopy( RI.refdef.vieworg, RI.vieworg ); AngleVectors( RI.refdef.viewangles, RI.vforward, RI.vright, RI.vup ); R_FindViewLeaf(); R_SetupFrustum(); R_MarkLeaves (); VectorCopy( RI.cullorigin, tr.modelorg ); RI.currententity = clgame.entities; RI.currentmodel = RI.currententity->model; R_RecursiveMirrorNode( cl.worldmodel->nodes, RI.clipFlags ); R_CheckEntitiesOnList(); }