From: Mario Date: Thu, 29 Aug 2019 17:00:11 +0000 (+1000) Subject: Optimize vehicle impact code by only calling vlen() if damage would be taken X-Git-Tag: xonotic-v0.8.5~1351 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3ac61b98c83be079c61cf525491d2028b2a889dc;p=xonotic%2Fxonotic-data.pk3dir.git Optimize vehicle impact code by only calling vlen() if damage would be taken --- diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index c8e47dabc..f0877269c 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -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"); } } }