HERE's the fix fix fix!
Code:
void UTIL_ClampAngle (float *fAngle)
{
// Whistler, TEST your bugfixes before submitting them!!! :D
if (*fAngle >= 180)
*fAngle -= 360 * ((int) (*fAngle / 360) + 1); // and not 0.5
if (*fAngle < -180)
*fAngle += 360 * ((int) (-*fAngle / 360) + 1); // and not 0.5
if ((*fAngle >= 180) || (*fAngle < -180))
*fAngle = 0; // heck, if we're still above the limit then something's REALLY fuckedup!
}
void UTIL_ClampVector (Vector *vecAngles)
{
// Whistler, TEST your bugfixes before submitting them!!! :D
if (vecAngles->x >= 180)
vecAngles->x -= 360 * ((int) (vecAngles->x / 360) + 1); // and not 0.5
if (vecAngles->x < -180)
vecAngles->x += 360 * ((int) (-vecAngles->x / 360) + 1); // and not 0.5
if (vecAngles->y >= 180)
vecAngles->y -= 360 * ((int) (vecAngles->y / 360) + 1); // and not 0.5
if (vecAngles->y < -180)
vecAngles->y += 360 * ((int) (-vecAngles->y / 360) + 1); // and not 0.5
vecAngles->z = 0.0;
if (vecAngles->x > 89)
vecAngles->x = 89;
else if (vecAngles->x < -89)
vecAngles->x = -89;
if ((vecAngles->x >= 180) || (vecAngles->x < -180))
vecAngles->x = 0; // heck, if we're still above the limit then something's REALLY fuckedup!
if ((vecAngles->y >= 180) || (vecAngles->y < -180))
vecAngles->y = 0; // heck, if we're still above the limit then something's REALLY fuckedup!
}
I'm compiling a nunux library and then I'll wrap all this up together in a .zip file.