From 9bb4a3a6b4d0003fa58d090b368f7533cbee99c2 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 19 Jun 2016 17:00:02 +1000 Subject: [PATCH] Vector: add a reflect function with bounce factor --- qcsrc/lib/vector.qh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qcsrc/lib/vector.qh b/qcsrc/lib/vector.qh index def1dae2d..adb6d6a95 100644 --- a/qcsrc/lib/vector.qh +++ b/qcsrc/lib/vector.qh @@ -116,6 +116,14 @@ vector reflect(vector dir, vector norm) return dir - 2 * (dir * norm) * norm; } +/** + * clip vel along the plane defined by norm (assuming 0 distance away), bounciness determined by bounce 0..1 + */ +vector vec_reflect(vector vel, vector norm, float bounce) +{ + return vel - (1 + bounce) * (vel * norm) * norm; +} + #ifndef MENUQC vector get_corner_position(entity box, int corner) { -- 2.39.2