From 31ebe8982eb86e8c17fa140862781de7fc6d9528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Foucault?= Date: Mon, 27 Jun 2022 20:04:50 +0200 Subject: BLI: Math: Add ceil_to_multiple_u() Standalone version of a function added to `BLI_math_vector.hh`. --- source/blender/blenlib/intern/math_base_inline.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/blenlib/intern') diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index 4a213f5fe74..cb7659a7059 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -370,6 +370,14 @@ MINLINE uint divide_ceil_u(uint a, uint b) return (a + b - 1) / b; } +/** + * Returns \a a if it is a multiple of \a b or the next multiple or \a b after \b a . + */ +MINLINE uint ceil_to_multiple_u(uint a, uint b) +{ + return divide_ceil_u(a, b) * b; +} + MINLINE int mod_i(int i, int n) { return (i % n + n) % n; -- cgit v1.2.3