[Bf-blender-cvs] [f81ecf1] blender-v2.76a-release: Fix broken CD_NORMAL interpolation callback (would generate non-unit vectors).

Bastien Montagne noreply at git.blender.org
Thu Oct 29 11:39:48 CET 2015


Commit: f81ecf117f57a2bb713ade6e4cb59e13b8a382c9
Author: Bastien Montagne
Date:   Fri Oct 16 21:52:50 2015 +0200
Branches: blender-v2.76a-release
https://developer.blender.org/rBf81ecf117f57a2bb713ade6e4cb59e13b8a382c9

Fix broken CD_NORMAL interpolation callback (would generate non-unit vectors).

Even if the weights are normalized, the weighted sum of normalized vectors
usually does **not** give a normalized vector (unless all source vectors
are aligned).

This probably was not a big issue in most cases, since we usually interpolate
similar vectors here - but still!

===================================================================

M	source/blender/blenkernel/intern/customdata.c

===================================================================

diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 7149b24..88ab634 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -307,13 +307,16 @@ static void layerInterp_normal(
         const void **sources, const float *weights,
         const float *UNUSED(sub_weights), int count, void *dest)
 {
+	/* Note: This is linear interpolation, which is not optimal for vectors.
+	 *       Unfortunately, spherical interpolation of more than two values is hairy, so for now it will do... */
 	float no[3] = {0.0f};
 
 	while (count--) {
 		madd_v3_v3fl(no, (const float *)sources[count], weights[count]);
 	}
 
-	copy_v3_v3((float *)dest, no);
+	/* Weighted sum of normalized vectors will **not** be normalized, even if weights are. */
+	normalize_v3_v3((float *)dest, no);
 }
 
 static void layerCopyValue_normal(const void *source, void *dest, const int mixmode, const float mixfactor)




More information about the Bf-blender-cvs mailing list