X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fvector.qh;h=d2d83ff6595dca5a2642017702112745527eef1c;hb=90b21340c6f5678a7b0ea3dda116ec7f4fa4352e;hp=23bfdf05593ff178f4f31c35d4319d4985d6626a;hpb=2131fc86c8a55826aa6a424f3ffe6b2d09f28b7a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/vector.qh b/qcsrc/lib/vector.qh index 23bfdf055..d2d83ff65 100644 --- a/qcsrc/lib/vector.qh +++ b/qcsrc/lib/vector.qh @@ -196,4 +196,17 @@ vector NearestPointOnBoundingBox(vector mi, vector ma, vector org) bound(mi.z, org.z, ma.z) ); } + +// bones_was_here: rounding bbox to nearest perfect floats prevents obscure collision bugs like #2742 +// FIXME: QC shouldn't need to work around tracebox potentially returning a tiny trace_fraction when the move should have been blocked. +// Tiny values are valid in some situations and can't simply be ignored. +#define PFLOAT (1/1024) // 1/32 1/64 etc also work +#define RPFLOAT(a) (a=rint(a/PFLOAT)*PFLOAT) +ERASEABLE +vector RoundPerfectVector(vector v) +{ + RPFLOAT(v.x); RPFLOAT(v.y); RPFLOAT(v.z); + return v; +} + #endif