]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/math.qh
Cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / math.qh
index 24d004166cfd4bec600b102eb50a9198757e5e58..ea968e84c7763c35477c4674e0ce7f68e341609c 100644 (file)
@@ -184,6 +184,13 @@ float almost_in_bounds(float a, float b, float c)
        return b == median(a - eps, b, c + eps);
 }
 
+float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d)
+{
+       if (halflifedist > 0) return pow(0.5, (bound(mindist, d, maxdist) - mindist) / halflifedist);
+       else if (halflifedist < 0) return pow(0.5, (bound(mindist, d, maxdist) - maxdist) / halflifedist);
+       else return 1;
+}
+
 float power2of(float e)
 {
        return pow(2, e);