From a8e2daa3060cd8838a2a64040e41eea56eb30924 Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 30 Apr 2021 19:28:04 +0200 Subject: [PATCH] Optimize code rotating prejectiles --- qcsrc/client/weapons/projectile.qc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/qcsrc/client/weapons/projectile.qc b/qcsrc/client/weapons/projectile.qc index 4e457dabab..37efbddfad 100644 --- a/qcsrc/client/weapons/projectile.qc +++ b/qcsrc/client/weapons/projectile.qc @@ -115,7 +115,18 @@ void Projectile_Draw(entity this) 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; -- 2.39.2