]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize code rotating prejectiles
authorterencehill <piuntn@gmail.com>
Fri, 30 Apr 2021 17:28:04 +0000 (19:28 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 30 Apr 2021 17:28:04 +0000 (19:28 +0200)
qcsrc/client/weapons/projectile.qc

index 4e457dabab9bcf24f2dbe4338b29d9e8c0e5e6bc..37efbddfadcb092310048f54bc538c17e9417a8a 100644 (file)
@@ -115,7 +115,18 @@ void Projectile_Draw(entity this)
                if (Projectile_isnade(this.cnt))
                        rot = this.avelocity;
 
                if (Projectile_isnade(this.cnt))
                        rot = this.avelocity;
 
-               this.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(this.angles), rot * (t - this.spawntime)));
+               if (rot)
+               {
+                       if (!rot.x && !rot.y)
+                       {
+                               // cheaper z-only rotation formula
+                               this.angles.z = (rot.z * (t - this.spawntime)) % 360;
+                               if (this.angles.z < 0)
+                                       this.angles.z += 360;
+                       }
+                       else
+                               this.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(this.angles), rot * (t - this.spawntime)));
+               }
        }
 
        vector ang;
        }
 
        vector ang;