From: terencehill Date: Fri, 18 Mar 2022 13:50:33 +0000 (+0100) Subject: Add NearestPointOnBoundingBox (copy of WarpZoneLib_NearestPointOnBox) as shared funct... X-Git-Tag: xonotic-v0.8.5~145^2~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=996290b3f53a1ee66fca3933e900e116690462d9;p=xonotic%2Fxonotic-data.pk3dir.git Add NearestPointOnBoundingBox (copy of WarpZoneLib_NearestPointOnBox) as shared function to be used outside the warpzone lib code --- diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index 6b357968a..2429a3017 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -479,7 +479,7 @@ void W_Shockwave_Attack(Weapon thiswep, entity actor, .entity weaponentity) // WEAPONTODO: replace with simpler method vector nearest_on_line = (w_shotorg + a * w_shotdir); - vector nearest_to_attacker = WarpZoneLib_NearestPointOnBox(center + head.mins, center + head.maxs, nearest_on_line); + vector nearest_to_attacker = NearestPointOnBoundingBox(center + head.mins, center + head.maxs, nearest_on_line); if((vdist(head.WarpZone_findradius_dist, <=, WEP_CVAR(shockwave, blast_distance))) && (W_Shockwave_Attack_IsVisible(actor, head, nearest_on_line, w_shotorg, attack_endpos))) diff --git a/qcsrc/lib/vector.qh b/qcsrc/lib/vector.qh index 13869b016..23bfdf055 100644 --- a/qcsrc/lib/vector.qh +++ b/qcsrc/lib/vector.qh @@ -177,13 +177,23 @@ vector vec_epsilon(vector this, float eps) ERASEABLE vector NearestPointOnBox(entity box, vector org) { - vector m1 = box.mins + box.origin; - vector m2 = box.maxs + box.origin; + vector mi = box.mins + box.origin; + vector ma = box.maxs + box.origin; return vec3( - bound(m1.x, org.x, m2.x), - bound(m1.y, org.y, m2.y), - bound(m1.z, org.z, m2.z) + bound(mi.x, org.x, ma.x), + bound(mi.y, org.y, ma.y), + bound(mi.z, org.z, ma.z) ); } + +ERASEABLE +vector NearestPointOnBoundingBox(vector mi, vector ma, vector org) +{ + return vec3( + bound(mi.x, org.x, ma.x), + bound(mi.y, org.y, ma.y), + bound(mi.z, org.z, ma.z) + ); +} #endif diff --git a/qcsrc/server/damage.qc b/qcsrc/server/damage.qc index 32620218b..ce2dd04b3 100644 --- a/qcsrc/server/damage.qc +++ b/qcsrc/server/damage.qc @@ -919,7 +919,7 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in // measure distance from nearest point on target (not origin) // to nearest point on inflictor (not origin) nearest = targ.WarpZone_findradius_nearest; - vector inflictornearest = WarpZoneLib_NearestPointOnBox( + vector inflictornearest = NearestPointOnBoundingBox( inflictororigin - (inflictor.maxs - inflictor.mins) * 0.5, inflictororigin + (inflictor.maxs - inflictor.mins) * 0.5, nearest);