]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize vehicle impact code by only calling vlen() if damage would be taken
authorMario <mario@smbclan.net>
Thu, 29 Aug 2019 17:00:11 +0000 (03:00 +1000)
committerMario <mario@smbclan.net>
Thu, 29 Aug 2019 17:00:11 +0000 (03:00 +1000)
qcsrc/common/vehicles/sv_vehicles.qc

index c8e47dabc20ea7efdb3b55b6c71ac86fbe49453d..f0877269c12b8ef9653e926004f7b2fb1a1c1c81 100644 (file)
@@ -777,17 +777,12 @@ void vehicles_impact(entity this, float _minspeed, float _speedfac, float _maxpa
 
        if(this.play_time < time)
        {
-               float wc = vlen(this.velocity - this.oldvelocity);
-               //dprint("oldvel: ", vtos(this.oldvelocity), "\n");
-               //dprint("vel: ", vtos(this.velocity), "\n");
-               if(_minspeed < wc)
+               if(vdist(this.velocity - this.oldvelocity, >, _minspeed))
                {
+                       float wc = vlen(this.velocity - this.oldvelocity);
                        float take = min(_speedfac * wc, _maxpain);
-                       Damage (this, NULL, NULL, take, DEATH_FALL.m_id, DMG_NOWEP, this.origin, '0 0 0');
+                       Damage(this, NULL, NULL, take, DEATH_FALL.m_id, DMG_NOWEP, this.origin, '0 0 0');
                        this.play_time = time + 0.25;
-
-                       //dprint("wc: ", ftos(wc), "\n");
-                       //dprint("take: ", ftos(take), "\n");
                }
        }
 }