Source/ThunderBeast/QuakeToonProto1/client/cl_ents.c
void CL_CalcViewValues (void)
{
	int			i;
	float		lerp, backlerp;
	centity_t	*ent;
	frame_t		*oldframe;
	player_state_t	*ps, *ops;

	// find the previous frame to interpolate from
	ps = &cl.frame.playerstate;
	i = (cl.frame.serverframe - 1) & UPDATE_MASK;
	oldframe = &cl.frames[i];
	if (oldframe->serverframe != cl.frame.serverframe-1 || !oldframe->valid)
		oldframe = &cl.frame;		// previous frame was dropped or involid
	ops = &oldframe->playerstate;

	// see if the player entity was teleported this frame
	if ( fabs(ops->pmove.origin[0] - ps->pmove.origin[0]) > 256*8
		|| abs(ops->pmove.origin[1] - ps->pmove.origin[1]) > 256*8
		|| abs(ops->pmove.origin[2] - ps->pmove.origin[2]) > 256*8)
		ops = ps;		// don't interpolate

	ent = &cl_entities[cl.playernum+1];
	lerp = cl.lerpfrac;

	// calculate the origin
	if ((cl_predict->value) && !(cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION))
	{	// use predicted values
		unsigned	delta;

		backlerp = 1.0 - lerp;
		for (i=0 ; i<3 ; i++)
		{
			cl.refdef.vieworg[i] = cl.predicted_origin[i] + ops->viewoffset[i] 
				+ cl.lerpfrac * (ps->viewoffset[i] - ops->viewoffset[i])
				- backlerp * cl.prediction_error[i];
		}

		// smooth out stair climbing
		delta = cls.realtime - cl.predicted_step_time;
		if (delta < 100)
			cl.refdef.vieworg[2] -= cl.predicted_step * (100 - delta) * 0.01;
	}
	else
	{	// just use interpolated values
		for (i=0 ; i<3 ; i++)
			cl.refdef.vieworg[i] = ops->pmove.origin[i]*0.125 + ops->viewoffset[i] 
				+ lerp * (ps->pmove.origin[i]*0.125 + ps->viewoffset[i] 
				- (ops->pmove.origin[i]*0.125 + ops->viewoffset[i]) );
	}

	// if not running a demo or on a locked frame, add the local angle movement
	if ( cl.frame.playerstate.pmove.pm_type < PM_DEAD )
	{	// use predicted values
		for (i=0 ; i<3 ; i++)
			cl.refdef.viewangles[i] = cl.predicted_angles[i];
	}
	else
	{	// just use interpolated values
		for (i=0 ; i<3 ; i++)
			cl.refdef.viewangles[i] = LerpAngle (ops->viewangles[i], ps->viewangles[i], lerp);
	}

	for (i=0 ; i<3 ; i++)
		cl.refdef.viewangles[i] += LerpAngle (ops->kick_angles[i], ps->kick_angles[i], lerp);

	AngleVectors (cl.refdef.viewangles, cl.v_forward, cl.v_right, cl.v_up);

	// interpolate field of view
	cl.refdef.fov_x = ops->fov + lerp * (ps->fov - ops->fov);

	// don't interpolate blend color
	for (i=0 ; i<4 ; i++)
		cl.refdef.blend[i] = ps->blend[i];

	// add the weapon
	CL_AddViewWeapon (ps, ops);
}
/*
===============
CL_CalcViewValues

Sets cl.refdef view values
===============
*/
CL_CalcViewValues
Sets cl.refdef view values
CL_CalcViewValues Sets cl . refdef view values
void CL_CalcViewValues (void)
{
	int			i;
	float		lerp, backlerp;
	centity_t	*ent;
	frame_t		*oldframe;
	player_state_t	*ps, *ops;
	ps = &cl.frame.playerstate;
	i = (cl.frame.serverframe - 1) & UPDATE_MASK;
	oldframe = &cl.frames[i];
	if (oldframe->serverframe != cl.frame.serverframe-1 || !oldframe->valid)
		oldframe = &cl.frame;		
	ops = &oldframe->playerstate;
	if ( fabs(ops->pmove.origin[0] - ps->pmove.origin[0]) > 256*8
		|| abs(ops->pmove.origin[1] - ps->pmove.origin[1]) > 256*8
		|| abs(ops->pmove.origin[2] - ps->pmove.origin[2]) > 256*8)
		ops = ps;		
	ent = &cl_entities[cl.playernum+1];
	lerp = cl.lerpfrac;
	if ((cl_predict->value) && !(cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION))
	{	
		unsigned	delta;
		backlerp = 1.0 - lerp;
		for (i=0 ; i<3 ; i++)
		{
			cl.refdef.vieworg[i] = cl.predicted_origin[i] + ops->viewoffset[i] 
				+ cl.lerpfrac * (ps->viewoffset[i] - ops->viewoffset[i])
				- backlerp * cl.prediction_error[i];
		}
		delta = cls.realtime - cl.predicted_step_time;
		if (delta < 100)
			cl.refdef.vieworg[2] -= cl.predicted_step * (100 - delta) * 0.01;
	}
	else
	{	
		for (i=0 ; i<3 ; i++)
			cl.refdef.vieworg[i] = ops->pmove.origin[i]*0.125 + ops->viewoffset[i] 
				+ lerp * (ps->pmove.origin[i]*0.125 + ps->viewoffset[i] 
				- (ops->pmove.origin[i]*0.125 + ops->viewoffset[i]) );
	}
	if ( cl.frame.playerstate.pmove.pm_type < PM_DEAD )
	{	
		for (i=0 ; i<3 ; i++)
			cl.refdef.viewangles[i] = cl.predicted_angles[i];
	}
	else
	{	
		for (i=0 ; i<3 ; i++)
			cl.refdef.viewangles[i] = LerpAngle (ops->viewangles[i], ps->viewangles[i], lerp);
	}
	for (i=0 ; i<3 ; i++)
		cl.refdef.viewangles[i] += LerpAngle (ops->kick_angles[i], ps->kick_angles[i], lerp);
	AngleVectors (cl.refdef.viewangles, cl.v_forward, cl.v_right, cl.v_up);
	cl.refdef.fov_x = ops->fov + lerp * (ps->fov - ops->fov);
	 blend color
	for (i=0 ; i<4 ; i++)
		cl.refdef.blend[i] = ps->blend[i];
	CL_AddViewWeapon (ps, ops);
}
void CL_CalcViewValues ( void ) { int i ; float lerp , backlerp ; centity_t * ent ; frame_t * oldframe ; player_state_t * ps , * ops ; ps = & cl . frame . playerstate ; i = ( cl . frame . serverframe - 1 ) & UPDATE_MASK ; oldframe = & cl . frames [ i ] ; if ( oldframe -> serverframe != cl . frame . serverframe - 1 || ! oldframe -> valid ) oldframe = & cl . frame ; ops = & oldframe -> playerstate ; if ( fabs ( ops -> pmove . origin [ 0 ] - ps -> pmove . origin [ 0 ] ) > 256 * 8 || abs ( ops -> pmove . origin [ 1 ] - ps -> pmove . origin [ 1 ] ) > 256 * 8 || abs ( ops -> pmove . origin [ 2 ] - ps -> pmove . origin [ 2 ] ) > 256 * 8 ) ops = ps ; ent = & cl_entities [ cl . playernum + 1 ] ; lerp = cl . lerpfrac ; if ( ( cl_predict -> value ) && ! ( cl . frame . playerstate . pmove . pm_flags & PMF_NO_PREDICTION ) ) { unsigned delta ; backlerp = 1.0 - lerp ; for ( i = 0 ; i < 3 ; i ++ ) { cl . refdef . vieworg [ i ] = cl . predicted_origin [ i ] + ops -> viewoffset [ i ] + cl . lerpfrac * ( ps -> viewoffset [ i ] - ops -> viewoffset [ i ] ) - backlerp * cl . prediction_error [ i ] ; } delta = cls . realtime - cl . predicted_step_time ; if ( delta < 100 ) cl . refdef . vieworg [ 2 ] -= cl . predicted_step * ( 100 - delta ) * 0.01 ; } else { for ( i = 0 ; i < 3 ; i ++ ) cl . refdef . vieworg [ i ] = ops -> pmove . origin [ i ] * 0.125 + ops -> viewoffset [ i ] + lerp * ( ps -> pmove . origin [ i ] * 0.125 + ps -> viewoffset [ i ] - ( ops -> pmove . origin [ i ] * 0.125 + ops -> viewoffset [ i ] ) ) ; } if ( cl . frame . playerstate . pmove . pm_type < PM_DEAD ) { for ( i = 0 ; i < 3 ; i ++ ) cl . refdef . viewangles [ i ] = cl . predicted_angles [ i ] ; } else { for ( i = 0 ; i < 3 ; i ++ ) cl . refdef . viewangles [ i ] = LerpAngle ( ops -> viewangles [ i ] , ps -> viewangles [ i ] , lerp ) ; } for ( i = 0 ; i < 3 ; i ++ ) cl . refdef . viewangles [ i ] += LerpAngle ( ops -> kick_angles [ i ] , ps -> kick_angles [ i ] , lerp ) ; AngleVectors ( cl . refdef . viewangles , cl . v_forward , cl . v_right , cl . v_up ) ; cl . refdef . fov_x = ops -> fov + lerp * ( ps -> fov - ops -> fov ) ; for ( i = 0 ; i < 4 ; i ++ ) cl . refdef . blend [ i ] = ps -> blend [ i ] ; CL_AddViewWeapon ( ps , ops ) ; }
CL_CalcViewValues
Sets cl.refdef view values
CL_CalcViewValues Sets cl . refdef view values
// find the previous frame to interpolate from // previous frame was dropped or involid // see if the player entity was teleported this frame // don't interpolate // calculate the origin // use predicted values // smooth out stair climbing // just use interpolated values // if not running a demo or on a locked frame, add the local angle movement // use predicted values // just use interpolated values // interpolate field of view // don't interpolate blend color // add the weapon