From: Mircea Kitsune Date: Tue, 22 May 2012 16:11:22 +0000 (+0300) Subject: Implement inverted cosine movement X-Git-Tag: xonotic-v0.8.0~295^2~34 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=54f85a71cafdf8101c4238602552748a512bf375;p=xonotic%2Fxonotic-data.pk3dir.git Implement inverted cosine movement --- diff --git a/qcsrc/server/g_subs.qc b/qcsrc/server/g_subs.qc index 05e5153f1..f7516d914 100644 --- a/qcsrc/server/g_subs.qc +++ b/qcsrc/server/g_subs.qc @@ -188,12 +188,24 @@ void SUB_CalcMove_controller_think (void) traveltime = self.animstate_endtime - self.animstate_starttime; phasepos = (nexttick - self.animstate_starttime) / traveltime; // range: [0, 1] - if(self.platmovetype != 1) + if(!self.platmovetype) + self.platmovetype = 2; // default + switch(self.platmovetype) { - phasepos = 3.14159265 + (phasepos * 3.14159265); // range: [pi, 2pi] - phasepos = cos(phasepos); // cos [pi, 2pi] is in [-1, 1] - phasepos = phasepos + 1; // correct range to [0, 2] - phasepos = phasepos / 2; // correct range to [0, 1] + case 1: // linear + break; + case 2: // cosine + phasepos = 3.14159265 + (phasepos * 3.14159265); // range: [pi, 2pi] + phasepos = cos(phasepos); // cos [pi, 2pi] is in [-1, 1] + phasepos = phasepos + 1; // correct range to [0, 2] + phasepos = phasepos / 2; // correct range to [0, 1] + break; + case 2: // inverted cosine + phasepos = 3.14159265 + (phasepos * 3.14159265); // range: [pi, 2pi] + phasepos = sin(phasepos); // sin [pi, 2pi] is in [-1, 1] + phasepos = phasepos + 1; // correct range to [0, 2] + phasepos = phasepos / 2; // correct range to [0, 1] + break; } nextpos = self.origin + (delta * phasepos) + (delta2 * phasepos * phasepos); // derivative: delta + 2 * delta2 * phasepos (e.g. for angle positioning) @@ -354,7 +366,7 @@ void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void() func) // of controlled animation, so let's just use linear movement. // Alternatively entities can choose to specify non-controlled movement. // The only currently implemented alternative movement is linear (value 1) - if (traveltime < 0.15 || self.platmovetype == 1) + if (traveltime < 0.15 || self.platmovetype < 2) { self.velocity = delta * (1/traveltime); // QuakeC doesn't allow vector/float division self.nextthink = self.ltime + traveltime;