Permalink
Browse files

mod: use tau instead of 2pi

  • Loading branch information...
IR4T4 committed Jan 10, 2019
1 parent c9046e1 commit 044ba7a2d776c52b697000f5386e3b6cb0150e20
@@ -241,7 +241,7 @@ static qboolean CG_SetParticleActive(cg_atmosphericParticle_t *particle, active_
*/
static qboolean CG_ParticleGenerate(cg_atmosphericParticle_t *particle, vec3_t currvec, float currweight, atmFXType_t atmFX)
{
float angle = random() * 2 * M_PI;
float angle = random() * M_TAU_F;
float distance = 20 + MAX_ATMOSPHERIC_DISTANCE * random();
float groundHeight, skyHeight;

@@ -670,7 +670,7 @@ void CG_DrawMapEntity(mapEntityData_t *mEnt, float x, float y, float w, float h,
msec = 0;
}

reviveClr[3] = .5f + .5f * (float)((sin(sqrt((double)msec) * 25 * 2 * M_PI) + 1) * 0.5);
reviveClr[3] = .5f + .5f * (float)((sin(sqrt((double)msec) * 25 * M_TAU_F) + 1) * 0.5);

trap_R_SetColor(reviveClr);
CG_DrawPic(icon_pos[0] + 3, icon_pos[1] + 3, icon_extends[0] - 3, icon_extends[1] - 3, cgs.media.medicIcon);
@@ -884,7 +884,7 @@ static void CG_DrawStaminaBar(rectDef_t *rect)

if (msec >= 0)
{
Vector4Average(colour, colorMdRed, (float)(.5 + sin(.2 * sqrt((double)msec) * 2 * M_PI) * .5), colour);
Vector4Average(colour, colorMdRed, (float)(.5 + sin(.2 * sqrt((double)msec) * M_TAU_F) * .5), colour);
}
}
}
@@ -1400,7 +1400,7 @@ void CG_StatsDebugAddText(const char *text)
*/
void CG_DrawCompassIcon(float x, float y, float w, float h, vec3_t origin, vec3_t dest, qhandle_t shader)
{
float angle, pi2 = (float)(M_PI * 2);
float angle;
vec3_t v1, angles;
float len;

@@ -1417,7 +1417,7 @@ void CG_DrawCompassIcon(float x, float y, float w, float h, vec3_t origin, vec3_

angles[YAW] = AngleSubtract(cg.predictedPlayerState.viewangles[YAW], angles[YAW]);

angle = ((angles[YAW] + 180.f) / 360.f - (0.50f / 2.f)) * pi2;
angle = ((angles[YAW] + 180.f) / 360.f - (0.50f / 2.f)) * M_TAU_F;

w /= 2;
h /= 2;
@@ -561,10 +561,10 @@ static void CG_ZoomSway(void)

spreadfrac = cg.snap->ps.aimSpreadScale / 255.0f;

phase = cg.time / 1000.0 * ZOOM_PITCH_FREQUENCY * M_PI * 2;
phase = cg.time / 1000.0 * ZOOM_PITCH_FREQUENCY * M_TAU_F;
cg.refdefViewAngles[PITCH] += ZOOM_PITCH_AMPLITUDE * sin(phase) * (spreadfrac + ZOOM_PITCH_MIN_AMPLITUDE);

phase = cg.time / 1000.0 * ZOOM_YAW_FREQUENCY * M_PI * 2;
phase = cg.time / 1000.0 * ZOOM_YAW_FREQUENCY * M_TAU_F;
cg.refdefViewAngles[YAW] += ZOOM_YAW_AMPLITUDE * sin(phase) * (spreadfrac + ZOOM_YAW_MIN_AMPLITUDE);
}

@@ -1091,7 +1091,7 @@ static int CG_CalcFov(void)
contents = CG_PointContents(cg.refdef.vieworg, -1);
if (contents & (CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA))
{
float phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2;
float phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_TAU_F;
float v = WAVE_AMPLITUDE * sin(phase);

fov_x += v;
@@ -3320,8 +3320,8 @@ void BG_EvaluateTrajectoryDelta(const trajectory_t *tr, int atTime, vec3_t resul
break;
case TR_SINE:
deltaTime = (atTime - tr->trTime) / (float) tr->trDuration;
phase = cos(deltaTime * M_PI * 2); // derivative of sin = cos
phase *= M_PI * 2 * 1000 / (float)tr->trDuration;
phase = cos(deltaTime * M_TAU_F); // derivative of sin = cos
phase *= M_TAU_F * 2 * 1000 / (float)tr->trDuration;
VectorScale(tr->trDelta, phase, result);
break;
case TR_LINEAR_STOP:
@@ -4004,7 +4004,7 @@ void SP_func_pendulum(gentity_t *ent)
length = 8;
}

freq = 1 / (M_PI * 2) * sqrt(g_gravity.value / (3 * length));
freq = 1 / M_TAU_F * sqrt(g_gravity.value / (3 * length));

ent->s.pos.trDuration = (int)(1000 / freq);

@@ -99,7 +99,7 @@ void moveit(gentity_t *ent, float yaw, float dist)
trace_t tr;
vec3_t mins, maxs;

yaw = (float)(yaw * M_PI * 2 / 360);
yaw = (float)(yaw * M_TAU_F / 360);

move[0] = (float)cos((double)yaw) * dist;
move[1] = (float)sin((double)yaw) * dist;
@@ -1015,7 +1015,7 @@ void G_CalculateSkillRatings(void)
*/
float pdf(float x)
{
return exp(-0.5f * pow(x, 2)) / sqrt(2 * M_PI);
return exp(-0.5f * pow(x, 2)) / sqrt(M_TAU_F);
}

/**
@@ -3973,10 +3973,10 @@ void CalcMuzzlePoints(gentity_t *ent, int weapon)
}

// rotate 'forward' vector by the sway
phase = level.time / 1000.0f * ZOOM_PITCH_FREQUENCY * (float)M_PI * 2;
phase = level.time / 1000.0f * ZOOM_PITCH_FREQUENCY * M_TAU_F;
viewang[PITCH] += ZOOM_PITCH_AMPLITUDE * (float)sin((double)phase) * (ent->client->currentAimSpreadScale + pitchMinAmp);

phase = level.time / 1000.0f * ZOOM_YAW_FREQUENCY * (float)M_PI * 2;
phase = level.time / 1000.0f * ZOOM_YAW_FREQUENCY * M_TAU_F;
viewang[YAW] += ZOOM_YAW_AMPLITUDE * (float)sin((double)phase) * (ent->client->currentAimSpreadScale + yawMinAmp);
}

0 comments on commit 044ba7a

Please sign in to comment.