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:28:22 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-10-16 22:56:42 +0300
commit8172712841975014e28219da91a41c7c5b074d5a (patch)
tree876c6683bab9c6d2759293baf317dd41805d0733 /source/blender/blenkernel/intern/customdata.c
parenta88ae6fa708ff099410c035e022eacbc62d87bea (diff)
Fix T46508: data_transfer of normals fails in case objects are transformed.
The final stage of the process (copying/interpolating new dst cddata from src cddata) was simply broken in normal case, where we need to convert from source to destination object space. This patch is a bit verbose, but I cannot see how to avoid it really. To think this code is in master since over 6 months and it only gets reported now... :/
Diffstat (limited to 'source/blender/blenkernel/intern/customdata.c')
-rw-r--r--source/blender/blenkernel/intern/customdata.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index f14feee0b2a..7149b24161f 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -61,6 +61,8 @@
#include "BKE_mesh_remap.h"
#include "BKE_multires.h"
+#include "data_transfer_intern.h"
+
#include "bmesh.h"
#include <math.h>
@@ -3913,6 +3915,38 @@ static void customdata_data_transfer_interp_generic(
MEM_freeN(tmp_dst);
}
+/* Normals are special, we need to take care of source & destination spaces... */
+void customdata_data_transfer_interp_normal_normals(
+ const CustomDataTransferLayerMap *laymap, void *data_dst,
+ const void **sources, const float *weights, const int count,
+ const float mix_factor)
+{
+ const int data_type = laymap->data_type;
+ const int mix_mode = laymap->mix_mode;
+
+ SpaceTransform *space_transform = laymap->interp_data;
+
+ const LayerTypeInfo *type_info = layerType_getInfo(data_type);
+ cd_interp interp_cd = type_info->interp;
+
+ float tmp_dst[3];
+
+ BLI_assert(data_type == CD_NORMAL);
+
+ if (!sources) {
+ /* Not supported here, abort. */
+ return;
+ }
+
+ interp_cd(sources, weights, NULL, count, tmp_dst);
+ if (space_transform) {
+ /* tmp_dst is in source space so far, bring it back in destination space. */
+ BLI_space_transform_invert_normal(space_transform, tmp_dst);
+ }
+
+ CustomData_data_mix_value(data_type, tmp_dst, data_dst, mix_mode, mix_factor);
+}
+
void CustomData_data_transfer(const MeshPairRemap *me_remap, const CustomDataTransferLayerMap *laymap)
{
MeshPairRemapItem *mapit = me_remap->items;