diff options
| author | Karl Zylinski <karl@zylinski.se> | 2024-09-01 16:30:48 +0200 |
|---|---|---|
| committer | Karl Zylinski <karl@zylinski.se> | 2024-09-01 16:30:48 +0200 |
| commit | 6e150d1d584b26407d56b368ef61a3ca8351e214 (patch) | |
| tree | 44ddb5191fcbf28972f35a868b651f71ea45557c | |
| parent | 722b638e2cbefcc1735256ef712cf2b28078a7fb (diff) | |
Make math.remap clamp the result in range [new_min, new_max].
| -rw-r--r-- | core/math/math.odin | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/math/math.odin b/core/math/math.odin index 957e1672b..cf6630ef2 100644 --- a/core/math/math.odin +++ b/core/math/math.odin @@ -402,7 +402,8 @@ remap :: proc "contextless" (old_value, old_min, old_max, new_min, new_max: $T) if old_range == 0 { return new_range / 2 } - return ((old_value - old_min) / old_range) * new_range + new_min + remapped := ((old_value - old_min) / old_range) * new_range + new_min + return clamp(remapped, new_min, new_max) } @(require_results) |