/* * GS_AddClippingPlane */ static void GS_AddClippingPlane( move_t *move, const vec3_t planeNormal ) { int i; // see if we are already clipping to this plane for( i = 0; i < move->numClipPlanes; i++ ) { if( DotProduct( planeNormal, move->clipPlaneNormals[i] ) >= ( 1.0f - SLIDEMOVE_PLANEINTERACT_EPSILON ) ) { return; } } if( move->numClipPlanes + 1 == MAX_SLIDEMOVE_CLIP_PLANES ) module_Error( "GS_AddTouchPlane: MAX_SLIDEMOVE_CLIP_PLANES reached\n" ); // add the plane VectorCopy( planeNormal, move->clipPlaneNormals[move->numClipPlanes] ); move->numClipPlanes++; }
/* * CG_SetupViewDef */ static void CG_SetupViewDef( cg_viewdef_t *view, int type, bool flipped ) { memset( view, 0, sizeof( cg_viewdef_t ) ); // // VIEW SETTINGS // view->type = type; view->flipped = flipped; if( view->type == VIEWDEF_PLAYERVIEW ) { view->POVent = cg.frame.playerState.POVnum; view->draw2D = true; // set up third-person if( cgs.demoPlaying ) view->thirdperson = CG_DemoCam_GetThirdPerson(); else if( chaseCam.mode == CAM_THIRDPERSON ) view->thirdperson = true; else view->thirdperson = ( cg_thirdPerson->integer != 0 ); if( cg_entities[view->POVent].serverFrame != cg.frame.serverFrame ) view->thirdperson = false; // check for drawing gun if( !view->thirdperson && view->POVent > 0 && view->POVent <= gs.maxclients ) { if( ( cg_entities[view->POVent].serverFrame == cg.frame.serverFrame ) && ( cg_entities[view->POVent].current.weapon != 0 ) ) view->drawWeapon = ( cg_gun->integer != 0 ) && ( cg_gun_alpha->value > 0 ); } // check for chase cams if( !( cg.frame.playerState.pmove.pm_flags & PMF_NO_PREDICTION ) ) { if( (unsigned)view->POVent == cgs.playerNum + 1 ) { if( cg_predict->integer && !cgs.demoPlaying ) { view->playerPrediction = true; } } } } else if( view->type == VIEWDEF_CAMERA ) { CG_DemoCam_GetViewDef( view ); } else { module_Error( "CG_SetupView: Invalid view type %i\n", view->type ); } // // SETUP REFDEF FOR THE VIEW SETTINGS // if( view->type == VIEWDEF_PLAYERVIEW ) { int i; vec3_t viewoffset; if( view->playerPrediction ) { CG_PredictMovement(); // fixme: crouching is predicted now, but it looks very ugly VectorSet( viewoffset, 0.0f, 0.0f, cg.predictedPlayerState.viewheight ); for( i = 0; i < 3; i++ ) { view->origin[i] = cg.predictedPlayerState.pmove.origin[i] + viewoffset[i] - ( 1.0f - cg.lerpfrac ) * cg.predictionError[i]; view->angles[i] = cg.predictedPlayerState.viewangles[i]; } CG_ViewSmoothPredictedSteps( view->origin ); // smooth out stair climbing if( cg_viewBob->integer && !cg_thirdPerson->integer ) { view->origin[2] += CG_ViewSmoothFallKick() * 6.5f; } } else { cg.predictingTimeStamp = cg.time; cg.predictFrom = 0; // we don't run prediction, but we still set cg.predictedPlayerState with the interpolation CG_InterpolatePlayerState( &cg.predictedPlayerState ); VectorSet( viewoffset, 0.0f, 0.0f, cg.predictedPlayerState.viewheight ); VectorAdd( cg.predictedPlayerState.pmove.origin, viewoffset, view->origin ); VectorCopy( cg.predictedPlayerState.viewangles, view->angles ); } view->refdef.fov_x = cg.predictedPlayerState.fov; CG_CalcViewBob(); VectorCopy( cg.predictedPlayerState.pmove.velocity, view->velocity ); } else if( view->type == VIEWDEF_CAMERA ) { view->refdef.fov_x = CG_DemoCam_GetOrientation( view->origin, view->angles, view->velocity ); } Matrix3_FromAngles( view->angles, view->axis ); if( view->flipped ) VectorInverse( &view->axis[AXIS_RIGHT] ); // view rectangle size view->refdef.x = scr_vrect.x; view->refdef.y = scr_vrect.y; view->refdef.width = scr_vrect.width; view->refdef.height = scr_vrect.height; view->refdef.time = cg.time; view->refdef.areabits = cg.frame.areabits; view->refdef.scissor_x = scr_vrect.x; view->refdef.scissor_y = scr_vrect.y; view->refdef.scissor_width = scr_vrect.width; view->refdef.scissor_height = scr_vrect.height; view->refdef.fov_y = CalcFov( view->refdef.fov_x, view->refdef.width, view->refdef.height ); AdjustFov( &view->refdef.fov_x, &view->refdef.fov_y, view->refdef.width, view->refdef.height, false ); view->fracDistFOV = tan( view->refdef.fov_x * ( M_PI/180 ) * 0.5f ); view->refdef.minLight = 0.3f; if( view->thirdperson ) CG_ThirdPersonOffsetView( view ); if( !view->playerPrediction ) cg.predictedWeaponSwitch = 0; VectorCopy( cg.view.origin, view->refdef.vieworg ); Matrix3_Copy( cg.view.axis, view->refdef.viewaxis ); VectorInverse( &view->refdef.viewaxis[AXIS_RIGHT] ); view->refdef.colorCorrection = NULL; if( cg_colorCorrection->integer ) { int colorCorrection = GS_ColorCorrection(); if( ( colorCorrection > 0 ) && ( colorCorrection < MAX_IMAGES ) ) view->refdef.colorCorrection = cgs.imagePrecache[colorCorrection]; } }