Пример #1
0
/*
================
PM_InitialSnapPosition

================
*/
void PM_InitialSnapPosition (void)
{
	int		x, y, z;
	short	base[3];

	VectorCopy (pm->s.origin, base);

	for (z=1 ; z>=-1 ; z--)
	{
		pm->s.origin[2] = base[2] + z;
		for (y=1 ; y>=-1 ; y--)
		{
			pm->s.origin[1] = base[1] + y;
			for (x=1 ; x>=-1 ; x--)
			{
				pm->s.origin[0] = base[0] + x;
				if (PM_GoodPosition ())
				{
					pml.origin[0] = pm->s.origin[0]*0.125;
					pml.origin[1] = pm->s.origin[1]*0.125;
					pml.origin[2] = pm->s.origin[2]*0.125;
					VectorCopy (pm->s.origin, pml.previous_origin);
					return;
				}
			}
		}
	}

	Com_DPrintf ("Bad InitialSnapPosition\n");
}
Пример #2
0
void PM_InitialSnapPosition(void)
{
	int        x, y, z;
	short      base[3];
	static int offset[3] = { 0, -1, 1 };

	VectorCopy (pm->s.origin, base);

	for ( z = 0; z < 3; z++ )
	{
		pm->s.origin[2] = base[2] + offset[ z ];

		for ( y = 0; y < 3; y++ )
		{
			pm->s.origin[1] = base[1] + offset[ y ];

			for ( x = 0; x < 3; x++ )
			{
				pm->s.origin[0] = base[0] + offset[ x ];

				if (PM_GoodPosition ())
				{
					pml.origin[0] = pm->s.origin[0]*0.125f;
					pml.origin[1] = pm->s.origin[1]*0.125f;
					pml.origin[2] = pm->s.origin[2]*0.125f;
					VectorCopy (pm->s.origin, pml.previous_origin);
					return;
				}
			}
		}
	}

	Com_DPrintf ("Bad InitialSnapPosition\n");
}
Пример #3
0
/*
 * On exit, the origin will have a value that is pre-quantized to the 0.125
 * precision of the network channel and in a valid position.
 */
void PM_SnapPosition (void)
{
	int		sign[3];
	int		i, j, bits;
	short	base[3];
	/* try all single bits first */
	static int jitterbits[8] = {0,4,1,2,3,5,6,7};

	/* snap velocity to eigths */
	for (i=0 ; i<3 ; i++)
		pm->s.velocity[i] = (int)(pml.velocity[i]*8);

	for (i=0 ; i<3 ; i++)
	{
		if (pml.origin[i] >= 0)
			sign[i] = 1;

		else
			sign[i] = -1;

		pm->s.origin[i] = (int)(pml.origin[i]*8);

		if (pm->s.origin[i]*0.125f == pml.origin[i])
			sign[i] = 0;
	}

	VectorCopy (pm->s.origin, base);

	/* try all combinations */
	for (j=0 ; j<8 ; j++)
	{
		bits = jitterbits[j];
		VectorCopy (base, pm->s.origin);

		for (i=0 ; i<3 ; i++)
			if (bits & (1<<i) )
				pm->s.origin[i] += sign[i];

		if (PM_GoodPosition ())
			return;
	}

	/* go back to the last position */
	VectorCopy (pml.previous_origin, pm->s.origin);
}
Пример #4
0
/*
================
PM_SnapPosition

On exit, the origin will have a value that is pre-quantized to the 0.125
precision of the network channel and in a valid position.
================
*/
static void PM_SnapPosition (void)
{
	int		sign[3];
	int		i, j, bits;
	int16	base[3];
	// try all single bits first
	static const int jitterbits[8] = {0,4,1,2,3,5,6,7};

	// snap velocity to eigths
	pm->s.velocity[0] = (int)(pml.velocity[0]*8);
	pm->s.velocity[1] = (int)(pml.velocity[1]*8);
	pm->s.velocity[2] = (int)(pml.velocity[2]*8);

	for (i=0 ; i<3 ; i++)
	{
		if (pml.origin[i] >= 0)
			sign[i] = 1;
		else 
			sign[i] = -1;
		pm->s.origin[i] = (int)(pml.origin[i]*8);
		if (pm->s.origin[i]*0.125f == pml.origin[i])
			sign[i] = 0;
	}
	VectorCopy (pm->s.origin, base);

	// try all combinations
	for (j=0 ; j<8 ; j++)
	{
		bits = jitterbits[j];
		VectorCopy (base, pm->s.origin);
		for (i=0 ; i<3 ; i++) {
			if (bits & (1<<i) )
				pm->s.origin[i] += sign[i];
		}

		if (PM_GoodPosition ())
			return;
	}

	// go back to the last position
	VectorCopy (pml.previous_origin, pm->s.origin);
//	Com_DPrintf ("using previous_origin\n");
}