diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-10-16 22:52:50 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-10-16 22:56:42 +0300 |
commit | bfdb42047af02743d694675700c2e50e98b867ec (patch) | |
tree | 28ea4070ed62b338b912a53dea76a7a87cabe000 /source/blender/blenkernel/intern/customdata.c | |
parent | 8172712841975014e28219da91a41c7c5b074d5a (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!
Diffstat (limited to 'source/blender/blenkernel/intern/customdata.c')
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 5 |
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) |