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:
authorBastien Montagne <montagne29@wanadoo.fr>2015-10-16 22:52:50 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-10-16 22:56:42 +0300
commitbfdb42047af02743d694675700c2e50e98b867ec (patch)
tree28ea4070ed62b338b912a53dea76a7a87cabe000
parent8172712841975014e28219da91a41c7c5b074d5a (diff)
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!
-rw-r--r--source/blender/blenkernel/intern/customdata.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 7149b24161f..88ab6340184 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)