Tutorial *72*

some quick rough info on fixing the incorrect bounding boxes on rotating bmodel objects in the released quake source...

this fixes the problem with rotating bmodels letting the player walk through in most positions during the rotation, by calculating the radius correctly

in SV_LinkEdict (world.c), the rotated bmodel code is like this originally:


float		max, v;

int		i;



max = 0;

for (i=0 ; i<3 ; i++)

	{

	v = fabs(ent->v.mins[i]);

	if (v > max)

	max = v;

	v = fabs(ent->v.maxs[i]);

	if (v > max)

	max = v;

	}

for (i=0 ; i<3 ; i++)

	{

		ent->v.absmin[i] = ent->v.origin[i] - max;

		ent->v.absmax[i] = ent->v.origin[i] + max;

	}

	
change to:


float		max, v;

int		i;



max = DotProduct(ent->v.mins, ent->v.mins);

v = DotProduct(ent->v.maxs, ent->v.maxs);

if (max < v)

	max = v;

	max = sqrt(max);

	for (i=0 ; i<3 ; i++)

		{

		ent->v.absmin[i] = ent->v.origin[i] - max;

		ent->v.absmax[i] = ent->v.origin[i] + max;

		}

the original code had a flawed concept of the corner, it was measuring it in an axis dependent way, it should be measured using the equivilant of the QC vlen (vector length), and to save a duplicate sqrt I calculate both squared distances and pick the greater and then do the sqrt


 
Sign up
Login:
Passwd:
[Remember Me]