Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-25 18:16:22 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-25 18:16:22 +0400
commitc2d5c72245cfebb612ccb11c60777262c9c5994a (patch)
treeb5636494f274c84d9e47d61c32866f222a34c455 /source/blender/blenlib/intern/math_base_inline.c
parent631f2b94efe9d438a6a8027279d9e665f31653b6 (diff)
Fix part of #34640: colors darkening when using the vertex paint blur tool.
The problem was that vertex colors only have 8 bits of precision, and integer division always rounds down, so after some color blending iterations everything gets darker. Instead use integer division that behaves like round() instead of floor() for blending operations.
Diffstat (limited to 'source/blender/blenlib/intern/math_base_inline.c')
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index d7c950f651a..61af5b5079a 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -145,6 +145,13 @@ MINLINE int power_of_2_min_i(int n)
return n;
}
+/* integer division that rounds 0.5 up, particularly useful for color blending
+ * with integers, to avoid gradual darkening when rounding down */
+MINLINE int divide_round_i(int a, int b)
+{
+ return (2*a + b)/(2*b);
+}
+
MINLINE unsigned int highest_order_bit_i(unsigned int n)
{
n |= (n >> 1);