From 3ac61b98c83be079c61cf525491d2028b2a889dc Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 30 Aug 2019 03:00:11 +1000 Subject: [PATCH] Optimize vehicle impact code by only calling vlen() if damage would be taken --- qcsrc/common/vehicles/sv_vehicles.qc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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"); } } } -- 2.39.2