]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Implement inverted cosine movement
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Tue, 22 May 2012 16:11:22 +0000 (19:11 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Tue, 22 May 2012 16:11:22 +0000 (19:11 +0300)
qcsrc/server/g_subs.qc

index 05e5153f1ecf20d0f1e509c81c700e12ef73aa1f..f7516d914185c2c35dbac7fa06b24ea55881727a 100644 (file)
@@ -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;