Commit: 8469a6985e1fcb8140ef0e8193caa062ee7c4568
Author: Bastien Montagne
Date:   Mon Oct 27 17:10:42 2014 +0100
Branches: mesh-transfer-data
https://developer.blender.org/rB8469a6985e1fcb8140ef0e8193caa062ee7c4568

WIP

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

M       source/blender/blenkernel/BKE_customdata.h
M       source/blender/blenkernel/intern/customdata.c
M       source/blender/editors/object/object_transfer_data.c

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

diff --git a/source/blender/blenkernel/BKE_customdata.h 
b/source/blender/blenkernel/BKE_customdata.h
index dbac8d1..ab13f82 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -411,14 +411,11 @@ enum {
        CDT_MIX_REPLACE_ALL             = 0,
        CDT_MIX_REPLACE_ABOVE_THRESHOLD = 1,
        CDT_MIX_REPLACE_BELOW_THRESHOLD = 2,
-#if 0
        CDT_MIX_MIX                     = 16,
        CDT_MIX_ADD                     = 17,
        CDT_MIX_SUB                     = 18,
        CDT_MIX_MUL                     = 19,
-       CDT_MIX_DIV                     = 20,
        /* etc. etc. */
-#endif
 };
 
 typedef struct DataTransferLayerMapping {
diff --git a/source/blender/blenkernel/intern/customdata.c 
b/source/blender/blenkernel/intern/customdata.c
index 93c794d..9ecf9fe 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -48,6 +48,7 @@
 #include "BLI_string.h"
 #include "BLI_path_util.h"
 #include "BLI_math.h"
+#include "BLI_math_color_blend.h"
 #include "BLI_mempool.h"
 
 #include "BLF_translation.h"
@@ -664,26 +665,36 @@ static void layerCopyValue_mloopcol(const void *source, 
void *dest, const int mi
 {
        const MLoopCol *m1 = source;
        MLoopCol *m2 = dest;
+       unsigned char tmp_col[4];
 
        switch (mixmode) {
-#if 0
                case CDT_MIX_MIX:
+                       blend_color_interpolate_byte((unsigned char *)&m2->r, 
(unsigned char *)&m2->r,
+                                                    (unsigned char *)&m1->r, 
mixfactor);
+                       break;
                case CDT_MIX_ADD:
+                       blend_color_add_byte(tmp_col, (unsigned char *)&m2->r, 
(unsigned char *)&m1->r);
+                       blend_color_interpolate_byte((unsigned char *)&m2->r, 
(unsigned char *)&m2->r, tmp_col, mixfactor);
+                       break;
                case CDT_MIX_SUB:
+                       blend_color_sub_byte(tmp_col, (unsigned char *)&m2->r, 
(unsigned char *)&m1->r);
+                       blend_color_interpolate_byte((unsigned char *)&m2->r, 
(unsigned char *)&m2->r, tmp_col, mixfactor);
+                       break;
                case CDT_MIX_MUL:
-               case CDT_MIX_DIV:
+                       blend_color_mul_byte(tmp_col, (unsigned char *)&m2->r, 
(unsigned char *)&m1->r);
+                       blend_color_interpolate_byte((unsigned char *)&m2->r, 
(unsigned char *)&m2->r, tmp_col, mixfactor);
+                       break;
                /* etc. etc. */
-#endif
                case CDT_MIX_REPLACE_ABOVE_THRESHOLD:
                case CDT_MIX_REPLACE_BELOW_THRESHOLD:
                        {
                                /* TODO: Check for a real valid way to get 
'factor' value of our dest color? */
                                const float f = ((float)m2->r + (float)m2->g + 
(float)m2->b) / 3.0f;
                                if (mixmode == CDT_MIX_REPLACE_ABOVE_THRESHOLD 
&& f < mixfactor) {
-                                       return;
+                                       break;
                                }
                                else if (mixmode == 
CDT_MIX_REPLACE_BELOW_THRESHOLD && f > mixfactor) {
-                                       return;
+                                       break;
                                }
                        }
                        /* Fall through. */
@@ -3624,6 +3635,7 @@ static void customdata_data_transfer_interp_generic(const 
DataTransferLayerMappi
        cd_copy copy_cd = NULL;
 
        void *tmp_dst = data_dst;
+       bool free_tmp_dst = false;
 
        if (data_type & CD_FAKE) {
                data_size = laymap->data_size;
@@ -3638,6 +3650,7 @@ static void customdata_data_transfer_interp_generic(const 
DataTransferLayerMappi
 
        if (laymap->mix_mode != CDT_MIX_REPLACE_ALL) {
                tmp_dst = MEM_mallocN(data_size, __func__);
+               free_tmp_dst = true;
        }
 
        if (count > 1 && !interp_cd) {
@@ -3703,6 +3716,10 @@ static void 
customdata_data_transfer_interp_generic(const DataTransferLayerMappi
                }
                /* Else we can do nothing by default, needs custom interp func! 
*/
        }
+
+       if (free_tmp_dst) {
+               MEM_freeN(tmp_dst);
+       }
 }
 
 void CustomData_data_transfer(const Mesh2MeshMapping *m2mmap, const 
DataTransferLayerMapping *laymap)
diff --git a/source/blender/editors/object/object_transfer_data.c 
b/source/blender/editors/object/object_transfer_data.c
index 120844c..cd5b5cc 100644
--- a/source/blender/editors/object/object_transfer_data.c
+++ b/source/blender/editors/object/object_transfer_data.c
@@ -154,7 +154,6 @@ static EnumPropertyItem MDT_mix_mode_items[] = {
                        "Only replace dest elements where data is above given 
threshold (exact behavior depends on data type)"},
        {CDT_MIX_REPLACE_BELOW_THRESHOLD, "BELOW_THRESHOLD", 0, "Below 
Threshold",
                        "Only replace dest elements where data is below given 
threshold (exact behavior depends on data type)"},
-#if 0
        {CDT_MIX_MIX, "MIX", 0, "Mix",
                        "Mix source value into destination one, using given 
threshold as factor"},
        {CDT_MIX_ADD, "ADD", 0, "Add",
@@ -163,10 +162,7 @@ static EnumPropertyItem MDT_mix_mode_items[] = {
                        "Subtract source value to destination one, using given 
threshold as factor"},
        {CDT_MIX_MUL, "MUL", 0, "Multiply",
                        "Multiply source value to destination one, using given 
threshold as factor"},
-       {CDT_MIX_DIV, "DIV", 0, "Divide",
-                       "Divide destination value by source one, using given 
threshold as factor"},
        /* etc. etc. */
-#endif
        {0, NULL, 0, NULL, NULL}
 };

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to