diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-05-21 11:28:02 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-05-21 11:28:02 +0400 |
commit | 3f584de8ecf76ad084b15eb4fb1e78e827ab1328 (patch) | |
tree | 536fdca56884843fa9fd25abf60653d5d5e7d1b2 | |
parent | 3daa8bd4ef5a52c40b01827b55df3807a1917eea (diff) |
[#18795] Subdivide Smooth can give wrong vcol
weights given by subdivide are not normalized, if that was fixed could avoid clamping.
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 6d5b86fa874..4038ccb1ea7 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -33,7 +33,7 @@ */ #include "BKE_customdata.h" - +#include "BKE_utildefines.h" // CLAMP #include "BLI_blenlib.h" #include "BLI_linklist.h" #include "BLI_mempool.h" @@ -421,6 +421,14 @@ static void layerInterp_mloopcol(void **sources, float *weights, col.b += src->b * weight; } } + + /* Subdivide smooth or fractal can cause problems without clamping + * although weights should also not cause this situation */ + CLAMP(col.a, 0.0f, 255.0f); + CLAMP(col.r, 0.0f, 255.0f); + CLAMP(col.g, 0.0f, 255.0f); + CLAMP(col.b, 0.0f, 255.0f); + mc->a = (int)col.a; mc->r = (int)col.r; mc->g = (int)col.g; @@ -496,6 +504,14 @@ static void layerInterp_mcol(void **sources, float *weights, } for(j = 0; j < 4; ++j) { + + /* Subdivide smooth or fractal can cause problems without clamping + * although weights should also not cause this situation */ + CLAMP(col[j].a, 0.0f, 255.0f); + CLAMP(col[j].r, 0.0f, 255.0f); + CLAMP(col[j].g, 0.0f, 255.0f); + CLAMP(col[j].b, 0.0f, 255.0f); + mc[j].a = (int)col[j].a; mc[j].r = (int)col[j].r; mc[j].g = (int)col[j].g; |