cl_dll/view.cpp
// Quakeworld bob code, this fixes jitters in the mutliplayer since the clock (pparams->time) isn't quite linear
Quakeworld bob code, this fixes jitters in the mutliplayer since the clock (pparams->time) isn't quite linear
Quakeworld bob code this fixes jitters in the mutliplayer since the clock ( pparams - > time ) isn ' t quite linear
void V_CalcBob(struct ref_params_s* pparams, float freqmod, calcBobMode_t mode, double& bobtime, float& bob, float& lasttime)
{
	float cycle;
	Vector vel;
	float bobcycle = cl_bobcycle->value;
	extern kbutton_s in_run;
	if (!pparams->onground || pparams->waterlevel ||
		pparams->time == lasttime)
	{
		return; 
	}
	lasttime = pparams->time;
	if ((in_run.state & 1)!=0)
	{
		bobcycle -= 0.40f; 
	}
	bobtime += pparams->frametime * freqmod;
	cycle = bobtime - (int)(bobtime / bobcycle) * bobcycle;
	cycle /= bobcycle;
	if (cycle < cl_bobup->value)
	{
		cycle = M_PI * cycle / cl_bobup->value;
	}
	else
	{
		cycle = M_PI + M_PI * (cycle - cl_bobup->value) / (1.0 - cl_bobup->value);
	}
	VectorCopy(pparams->simvel, vel);
	vel[2] = 0;
    bob = sqrt(vel[0] * vel[0] + vel[1] * vel[1]) * cl_bob->value;
	if (mode == VB_SIN)
		bob = bob * 0.3 + bob * 0.7 * sin(cycle);
	else if (mode == VB_COS)
		bob = bob * 0.3 + bob * 0.7 * cos(cycle);
	else if (mode == VB_SIN2)
		bob = bob * 0.3 + bob * 0.7 * sin(cycle) * sin(cycle);
	else if (mode == VB_COS2)
		bob = bob * 0.3 + bob * 0.7 * cos(cycle) * cos(cycle);
	bob = V_min(bob, 4);
	bob = V_max(bob, -7);
}
void V_CalcBob ( struct ref_params_s * pparams , float freqmod , calcBobMode_t mode , double & bobtime , float & bob , float & lasttime ) { float cycle ; Vector vel ; float bobcycle = cl_bobcycle -> value ; extern kbutton_s in_run ; if ( ! pparams -> onground || pparams -> waterlevel || pparams -> time == lasttime ) { return ; } lasttime = pparams -> time ; if ( ( in_run . state & 1 ) != 0 ) { bobcycle -= 0.40f ; } bobtime += pparams -> frametime * freqmod ; cycle = bobtime - ( int ) ( bobtime / bobcycle ) * bobcycle ; cycle /= bobcycle ; if ( cycle < cl_bobup -> value ) { cycle = M_PI * cycle / cl_bobup -> value ; } else { cycle = M_PI + M_PI * ( cycle - cl_bobup -> value ) / ( 1.0 - cl_bobup -> value ) ; } VectorCopy ( pparams -> simvel , vel ) ; vel [ 2 ] = 0 ; bob = sqrt ( vel [ 0 ] * vel [ 0 ] + vel [ 1 ] * vel [ 1 ] ) * cl_bob -> value ; if ( mode == VB_SIN ) bob = bob * 0.3 + bob * 0.7 * sin ( cycle ) ; else if ( mode == VB_COS ) bob = bob * 0.3 + bob * 0.7 * cos ( cycle ) ; else if ( mode == VB_SIN2 ) bob = bob * 0.3 + bob * 0.7 * sin ( cycle ) * sin ( cycle ) ; else if ( mode == VB_COS2 ) bob = bob * 0.3 + bob * 0.7 * cos ( cycle ) * cos ( cycle ) ; bob = V_min ( bob , 4 ) ; bob = V_max ( bob , -7 ) ; }
Quakeworld bob code, this fixes jitters in the mutliplayer since the clock (pparams->time) isn't quite linear
Quakeworld bob code this fixes jitters in the mutliplayer since the clock ( pparams - > time ) isn ' t quite linear
// just use old value // bob; // bob is proportional to simulated velocity in the xy plane // (don't count Z, or jumping messes it up) // return bob;