2011-05-09 22:00:00 +02:00
|
|
|
/*
|
|
|
|
cl_view.c - player rendering positioning
|
|
|
|
Copyright (C) 2009 Uncle Mike
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
*/
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2008-06-09 22:00:00 +02:00
|
|
|
#include "common.h"
|
2007-06-21 22:00:00 +02:00
|
|
|
#include "client.h"
|
2008-11-25 22:00:00 +01:00
|
|
|
#include "const.h"
|
2010-08-15 22:00:00 +02:00
|
|
|
#include "entity_types.h"
|
2010-12-02 22:00:00 +01:00
|
|
|
#include "gl_local.h"
|
2011-04-08 22:00:00 +02:00
|
|
|
#include "vgui_draw.h"
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
/*
|
2009-01-22 22:00:00 +01:00
|
|
|
===============
|
|
|
|
V_SetupRefDef
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2009-01-22 22:00:00 +01:00
|
|
|
update refdef values each frame
|
|
|
|
===============
|
2007-06-21 22:00:00 +02:00
|
|
|
*/
|
2009-01-22 22:00:00 +01:00
|
|
|
void V_SetupRefDef( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
2010-08-07 22:00:00 +02:00
|
|
|
cl_entity_t *clent;
|
2009-01-22 22:00:00 +01:00
|
|
|
|
2009-11-26 22:00:00 +01:00
|
|
|
clent = CL_GetLocalPlayer ();
|
2009-01-23 22:00:00 +01:00
|
|
|
|
2011-02-26 22:00:00 +01:00
|
|
|
clgame.entities->curstate.scale = clgame.movevars.waveHeight;
|
2010-11-15 22:00:00 +01:00
|
|
|
VectorCopy( cl.frame.local.client.punchangle, cl.refdef.punchangle );
|
|
|
|
clgame.viewent.curstate.modelindex = cl.frame.local.client.viewmodel;
|
2011-02-20 22:00:00 +01:00
|
|
|
clgame.viewent.model = Mod_Handle( clgame.viewent.curstate.modelindex );
|
2011-07-22 22:00:00 +02:00
|
|
|
clgame.viewent.curstate.number = cl.playernum + 1;
|
2010-12-19 22:00:00 +01:00
|
|
|
clgame.viewent.curstate.entityType = ET_NORMAL;
|
|
|
|
clgame.viewent.index = cl.playernum + 1;
|
2010-08-20 22:00:00 +02:00
|
|
|
|
2009-01-22 22:00:00 +01:00
|
|
|
cl.refdef.movevars = &clgame.movevars;
|
2010-11-15 22:00:00 +01:00
|
|
|
cl.refdef.onground = ( cl.frame.local.client.flags & FL_ONGROUND ) ? 1 : 0;
|
|
|
|
cl.refdef.health = cl.frame.local.client.health;
|
|
|
|
cl.refdef.playernum = cl.playernum;
|
2010-08-20 22:00:00 +02:00
|
|
|
cl.refdef.max_entities = clgame.maxEntities;
|
|
|
|
cl.refdef.maxclients = cl.maxclients;
|
2011-04-08 22:00:00 +02:00
|
|
|
cl.refdef.time = cl.time;
|
2010-10-09 22:00:00 +02:00
|
|
|
cl.refdef.frametime = cl.time - cl.oldtime;
|
2009-01-22 22:00:00 +01:00
|
|
|
cl.refdef.demoplayback = cls.demoplayback;
|
2010-06-20 22:00:00 +02:00
|
|
|
cl.refdef.smoothing = cl_smooth->integer;
|
2010-11-15 22:00:00 +01:00
|
|
|
cl.refdef.waterlevel = cl.frame.local.client.waterlevel;
|
2010-12-14 22:00:00 +01:00
|
|
|
cl.refdef.onlyClientDraw = 0; // reset clientdraw
|
2011-04-10 22:00:00 +02:00
|
|
|
cl.refdef.viewsize = scr_viewsize->integer;
|
2010-11-15 22:00:00 +01:00
|
|
|
cl.refdef.hardware = true; // always true
|
2011-02-20 22:00:00 +01:00
|
|
|
cl.refdef.spectator = cl.spectator;
|
2009-01-23 22:00:00 +01:00
|
|
|
cl.refdef.nextView = 0;
|
2009-01-22 22:00:00 +01:00
|
|
|
|
2010-08-20 22:00:00 +02:00
|
|
|
// setup default viewport
|
|
|
|
cl.refdef.viewport[0] = cl.refdef.viewport[1] = 0;
|
|
|
|
cl.refdef.viewport[2] = scr_width->integer;
|
|
|
|
cl.refdef.viewport[3] = scr_height->integer;
|
|
|
|
|
2010-11-15 22:00:00 +01:00
|
|
|
// calc FOV
|
|
|
|
cl.refdef.fov_x = cl.data.fov; // this is a final fov value
|
2010-12-06 22:00:00 +01:00
|
|
|
cl.refdef.fov_y = V_CalcFov( &cl.refdef.fov_x, cl.refdef.viewport[2], cl.refdef.viewport[3] );
|
2010-11-15 22:00:00 +01:00
|
|
|
|
2010-03-14 22:00:00 +01:00
|
|
|
if( CL_IsPredicted( ) && !cl.refdef.demoplayback )
|
2009-01-22 22:00:00 +01:00
|
|
|
{
|
2011-04-09 22:00:00 +02:00
|
|
|
VectorCopy( cl.predicted_origin, cl.refdef.simorg );
|
2009-12-05 22:00:00 +01:00
|
|
|
VectorCopy( cl.predicted_velocity, cl.refdef.simvel );
|
2011-04-09 22:00:00 +02:00
|
|
|
VectorCopy( cl.predicted_viewofs, cl.refdef.viewheight );
|
2009-12-05 22:00:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-30 22:00:00 +02:00
|
|
|
VectorCopy( cl.frame.local.client.origin, cl.refdef.simorg );
|
2010-11-15 22:00:00 +01:00
|
|
|
VectorCopy( cl.frame.local.client.view_ofs, cl.refdef.viewheight );
|
|
|
|
VectorCopy( cl.frame.local.client.velocity, cl.refdef.simvel );
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-01-22 22:00:00 +01:00
|
|
|
===============
|
|
|
|
V_CalcRefDef
|
|
|
|
|
|
|
|
sets cl.refdef view values
|
|
|
|
===============
|
2007-06-21 22:00:00 +02:00
|
|
|
*/
|
2009-01-22 22:00:00 +01:00
|
|
|
void V_CalcRefDef( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
2011-08-14 22:00:00 +02:00
|
|
|
int passcount = 0;
|
|
|
|
|
|
|
|
// g-cont. keep actual frame for all viewpasses
|
|
|
|
tr.framecount++;
|
|
|
|
|
2009-01-23 22:00:00 +01:00
|
|
|
do
|
|
|
|
{
|
2009-06-24 22:00:00 +02:00
|
|
|
clgame.dllFuncs.pfnCalcRefdef( &cl.refdef );
|
2010-12-02 22:00:00 +01:00
|
|
|
R_RenderFrame( &cl.refdef, true );
|
2010-12-14 22:00:00 +01:00
|
|
|
cl.refdef.onlyClientDraw = false;
|
2009-01-23 22:00:00 +01:00
|
|
|
} while( cl.refdef.nextView );
|
2011-08-14 22:00:00 +02:00
|
|
|
|
|
|
|
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
V_RenderView
|
|
|
|
|
|
|
|
==================
|
|
|
|
*/
|
2007-11-05 22:00:00 +01:00
|
|
|
void V_RenderView( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
2011-04-05 22:00:00 +02:00
|
|
|
if( !cl.video_prepped || ( UI_IsVisible() && !cl.background ))
|
|
|
|
return; // still loading
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2010-07-13 22:00:00 +02:00
|
|
|
if( cl.frame.valid && ( cl.force_refdef || !cl.refdef.paused ))
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
2009-09-28 22:00:00 +02:00
|
|
|
cl.force_refdef = false;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2011-04-09 22:00:00 +02:00
|
|
|
R_ClearScene ();
|
2009-09-28 22:00:00 +02:00
|
|
|
CL_AddEntities ();
|
|
|
|
V_SetupRefDef ();
|
|
|
|
}
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2009-01-25 22:00:00 +01:00
|
|
|
V_CalcRefDef ();
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
/*
|
|
|
|
==================
|
|
|
|
V_PreRender
|
|
|
|
|
|
|
|
==================
|
|
|
|
*/
|
2010-10-26 22:00:00 +02:00
|
|
|
qboolean V_PreRender( void )
|
2007-11-06 22:00:00 +01:00
|
|
|
{
|
2008-05-18 22:00:00 +02:00
|
|
|
// too early
|
2010-12-02 22:00:00 +01:00
|
|
|
if( !glw_state.initialized )
|
|
|
|
return false;
|
2009-07-17 22:00:00 +02:00
|
|
|
|
2010-02-07 22:00:00 +01:00
|
|
|
if( host.state == HOST_NOFOCUS )
|
|
|
|
return false;
|
2010-12-09 22:00:00 +01:00
|
|
|
|
2010-02-07 22:00:00 +01:00
|
|
|
if( host.state == HOST_SLEEP )
|
|
|
|
return false;
|
|
|
|
|
2010-12-09 22:00:00 +01:00
|
|
|
// if the screen is disabled (loading plaque is up)
|
|
|
|
if( cls.disable_screen )
|
2010-04-12 22:00:00 +02:00
|
|
|
{
|
2011-04-09 22:00:00 +02:00
|
|
|
if(( host.realtime - cls.disable_screen ) > cl_timeout->value )
|
2010-12-09 22:00:00 +01:00
|
|
|
{
|
|
|
|
MsgDev( D_NOTE, "V_PreRender: loading plaque timed out.\n" );
|
|
|
|
cls.disable_screen = 0.0f;
|
|
|
|
}
|
|
|
|
return false;
|
2010-04-12 22:00:00 +02:00
|
|
|
}
|
2011-02-22 22:00:00 +01:00
|
|
|
|
2010-12-09 22:00:00 +01:00
|
|
|
R_BeginFrame( !cl.refdef.paused );
|
|
|
|
|
2010-07-17 22:00:00 +02:00
|
|
|
return true;
|
2007-11-06 22:00:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
V_PostRender
|
|
|
|
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void V_PostRender( void )
|
|
|
|
{
|
2010-12-12 22:00:00 +01:00
|
|
|
R_Set2DMode( true );
|
|
|
|
|
|
|
|
if( cls.state == ca_active )
|
|
|
|
{
|
|
|
|
CL_DrawHUD( CL_ACTIVE );
|
2011-03-18 22:00:00 +01:00
|
|
|
VGui_Paint();
|
2010-12-12 22:00:00 +01:00
|
|
|
}
|
|
|
|
|
2011-04-09 22:00:00 +02:00
|
|
|
if( cls.scrshot_action == scrshot_inactive || cls.scrshot_action == scrshot_normal )
|
2009-09-23 22:00:00 +02:00
|
|
|
{
|
|
|
|
SCR_RSpeeds();
|
2010-07-26 22:00:00 +02:00
|
|
|
SCR_NetSpeeds();
|
2009-09-23 22:00:00 +02:00
|
|
|
SCR_DrawFPS();
|
2010-12-12 22:00:00 +01:00
|
|
|
CL_DrawDemoRecording();
|
|
|
|
R_ShowTextures();
|
2010-12-09 22:00:00 +01:00
|
|
|
CL_DrawHUD( CL_CHANGELEVEL );
|
2009-09-23 22:00:00 +02:00
|
|
|
Con_DrawConsole();
|
2010-12-27 22:00:00 +01:00
|
|
|
UI_UpdateMenu( host.realtime );
|
2011-07-07 22:00:00 +02:00
|
|
|
Con_DrawVersion();
|
2011-04-08 22:00:00 +02:00
|
|
|
Con_DrawDebug(); // must be last
|
2010-10-09 22:00:00 +02:00
|
|
|
S_ExtraUpdate();
|
2009-09-23 22:00:00 +02:00
|
|
|
}
|
2010-07-23 22:00:00 +02:00
|
|
|
|
2009-12-11 22:00:00 +01:00
|
|
|
SCR_MakeScreenShot();
|
2010-12-02 22:00:00 +01:00
|
|
|
R_EndFrame();
|
2008-07-17 22:00:00 +02:00
|
|
|
}
|