Revision: 58925
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58925
Author:   walid
Date:     2013-08-05 05:27:49 +0000 (Mon, 05 Aug 2013)
Log Message:
-----------
Vertex Groups transfer: registering its operator, other transfer function: 
changes in the description/error reports strings

Modified Paths:
--------------
    
branches/soc-2013-meshdata_transfer/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    
branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c
    
branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.h
    branches/soc-2013-meshdata_transfer/source/blender/editors/mesh/mesh_data.c
    
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_intern.h
    
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_ops.c
    
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_shapekey.c
    
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_vgroup.c

Modified: 
branches/soc-2013-meshdata_transfer/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- 
branches/soc-2013-meshdata_transfer/release/scripts/startup/bl_ui/space_view3d_toolbar.py
   2013-08-05 05:20:09 UTC (rev 58924)
+++ 
branches/soc-2013-meshdata_transfer/release/scripts/startup/bl_ui/space_view3d_toolbar.py
   2013-08-05 05:27:49 UTC (rev 58925)
@@ -117,6 +117,7 @@
         col.operator("object.shape_key_transfer_new", text="Transfer Shapekeys 
(new)")
         col.operator("mesh.uv_transfer_new", text="Transfer UVs (new)")
         col.operator("mesh.vertex_color_transfer_new", text="Transfer Colors 
(new)")
+        col.operator("object.vgroup_transfer_new", text="Transfer Vertex 
Groups (new)")
 
 
 class VIEW3D_PT_tools_rigidbody(View3DPanel, Panel):

Modified: 
branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c
===================================================================
--- 
branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c
        2013-08-05 05:20:09 UTC (rev 58924)
+++ 
branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c
        2013-08-05 05:27:49 UTC (rev 58925)
@@ -2119,8 +2119,7 @@
        int count;
 } float_pool;
 
-bool BM_mesh_vertex_group_copy(BMesh *bm_src, BMesh* 
bm_dst,ST_ShapekeyGroupMode replace_mode, int *act_shapekey_lay,
-                               float tmp_mat[4][4])
+bool BM_mesh_vertex_group_copy(BMesh *bm_src, BMesh* bm_dst, ReplaceGroupMode 
replace_mode, float tmp_mat[4][4])
 {
        //-----algorithm definitions start
        struct BMBVHTree *bmtree_src = NULL;
@@ -2188,27 +2187,25 @@
        }
 
        tmp_weight = MEM_mallocN(sizeof(*tmp_weight) * exp_vert_per_face, 
"tmp_weight bmesh_data_transfer.c");
-       if (replace_mode == ST_APPEND_SHAPEKEY_GROUPS) {
-               //add 1 to skip the basis
+       if (replace_mode == APPEND_GROUPS) {
                src_lay_start = 0;
                src_lay_end = tot_layer_src;
-               dst_lay_start = tot_layer_dst - tot_layer_src + 1;
+               dst_lay_start = tot_layer_dst - tot_layer_src;
                dst_lay_end = tot_layer_dst;
        }
 
-       else if ((replace_mode == ST_REPLACE_ENOUGH_SHAPEKEY_GROUPS) || 
(replace_mode == ST_REPLACE_ALL_SHAPEKEY_GROUPS)) {
+       else if ((replace_mode == REPLACE_ENOUGH_GROUPS) || (replace_mode == 
REPLACE_ALL_GROUPS)) {
                src_lay_start = 0;
                src_lay_end = tot_layer_src;
                dst_lay_start = 0;
                dst_lay_end = tot_layer_src;
        }
 
-       else if (replace_mode == ST_REPLACE_ACTIVE_SHAPEKEY_GROUP) {
-               //passed shapekey reperesents the # of shapekeys (starts from 
one), however lay_start uses it as an index
-               src_lay_start = act_shapekey_lay[0] - 1;
-               src_lay_end = act_shapekey_lay[0];
-               dst_lay_start = act_shapekey_lay[1] - 1;
-               dst_lay_end = act_shapekey_lay[1];
+       else if (replace_mode == REPLACE_ACTIVE_GROUP) {
+               src_lay_start = 
CustomData_get_active_layer_index(&bm_src->ldata, CD_MDEFORMVERT);
+               src_lay_end = src_lay_start + 1;        //stopping condition
+               dst_lay_start = 
CustomData_get_active_layer_index(&bm_dst->ldata, CD_MDEFORMVERT);
+               dst_lay_end = dst_lay_start + 1;
        }
 
        for (src_lay_iter = src_lay_start, dst_lay_iter = dst_lay_start; 
src_lay_iter < src_lay_end;

Modified: 
branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.h
===================================================================
--- 
branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.h
        2013-08-05 05:20:09 UTC (rev 58924)
+++ 
branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.h
        2013-08-05 05:27:49 UTC (rev 58925)
@@ -68,8 +68,7 @@
                            int UNUSED_interp_pow, int UNUSED_no_pow, bool 
UNUSED_USE_NORMALS, ST_ShapekeyGroupMode replace_mode,
                             int *act_shapekey_lay, float tmp_mat[4][4]);
 void BM_mesh_shapekey_copy_index(BMesh *bm_src, BMesh *bm_dst);
-bool BM_mesh_vertex_group_copy(BMesh *bm_src, BMesh* 
bm_dst,ST_ShapekeyGroupMode replace_mode, int *act_shapekey_lay,
-                               float tmp_mat[4][4]);
+bool BM_mesh_vertex_group_copy(BMesh *bm_src, BMesh* bm_dst, ReplaceGroupMode 
replace_mode, float tmp_mat[4][4]);
 bool BM_mesh_vertex_color_copy(BMesh *bm_src, BMesh* bm_dst, ReplaceGroupMode 
replace_mode, float tmp_mat[4][4]);
 
 #endif /* __BMESH_DATA_TRANSFER_H__ */

Modified: 
branches/soc-2013-meshdata_transfer/source/blender/editors/mesh/mesh_data.c
===================================================================
--- branches/soc-2013-meshdata_transfer/source/blender/editors/mesh/mesh_data.c 
2013-08-05 05:20:09 UTC (rev 58924)
+++ branches/soc-2013-meshdata_transfer/source/blender/editors/mesh/mesh_data.c 
2013-08-05 05:27:49 UTC (rev 58925)
@@ -540,7 +540,7 @@
        if (num_src_lay < 1) {
                //the source should have UV layers
                BKE_report(op->reports, RPT_ERROR,
-                          "Transfer failed no UV groups were found (source 
mesh should have -at least- UV group)");
+                          "Transfer failed no UV groups were found (source 
mesh should have -at least- 1 UV group)");
 
                return false;
        }
@@ -783,7 +783,7 @@
        if (num_src_lay < 1) {
                //the source should have UV layers
                BKE_report(op->reports, RPT_ERROR,
-                          "Transfer failed no color groups were found (source 
mesh should have -at least- UV group)");
+                          "Transfer failed no color groups were found (source 
mesh should have -at least- 1 Vertex col group)");
 
                return false;
        }

Modified: 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_intern.h
===================================================================
--- 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_intern.h
   2013-08-05 05:20:09 UTC (rev 58924)
+++ 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_intern.h
   2013-08-05 05:27:49 UTC (rev 58925)
@@ -229,6 +229,7 @@
 void OBJECT_OT_vertex_weight_set_active(struct wmOperatorType *ot);
 void OBJECT_OT_vertex_weight_normalize_active_vertex(struct wmOperatorType 
*ot);
 void OBJECT_OT_vertex_weight_copy(struct wmOperatorType *ot);
+void OBJECT_OT_vgroup_transfer_new(struct wmOperatorType *ot);
 
 /* object_shapekey.c */
 void OBJECT_OT_shape_key_add(struct wmOperatorType *ot);

Modified: 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_ops.c
===================================================================
--- 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_ops.c  
    2013-08-05 05:20:09 UTC (rev 58924)
+++ 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_ops.c  
    2013-08-05 05:27:49 UTC (rev 58925)
@@ -201,6 +201,7 @@
        WM_operatortype_append(OBJECT_OT_vertex_weight_set_active);
        WM_operatortype_append(OBJECT_OT_vertex_weight_normalize_active_vertex);
        WM_operatortype_append(OBJECT_OT_vertex_weight_copy);
+       WM_operatortype_append(OBJECT_OT_vgroup_transfer_new);
 
        WM_operatortype_append(OBJECT_OT_game_property_new);
        WM_operatortype_append(OBJECT_OT_game_property_remove);

Modified: 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_shapekey.c
===================================================================
--- 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_shapekey.c
 2013-08-05 05:20:09 UTC (rev 58924)
+++ 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_shapekey.c
 2013-08-05 05:27:49 UTC (rev 58925)
@@ -844,7 +844,7 @@
        /* identifiers */
        ot->name = "Transfer Shape Key (new)";
        ot->idname = "OBJECT_OT_shape_key_transfer_new";
-       ot->description = "Transfer () shape key to the selected objects";
+       ot->description = "Transfer shapekey groups to the selected objects";
 
        /* api callbacks */
        ot->poll = shape_key_poll;                      //don't know how to 
edit this yet!!

Modified: 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_vgroup.c
===================================================================
--- 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_vgroup.c
   2013-08-05 05:20:09 UTC (rev 58924)
+++ 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_vgroup.c
   2013-08-05 05:27:49 UTC (rev 58925)
@@ -200,6 +200,186 @@
        }
 }
 
+typedef enum TransferMode {
+       SPATIAL_TRANSFER = 1,
+       PROJECTION_TRANSFER = 2
+} TransferMode;
+
+static EnumPropertyItem transfer_mode_item[] = {
+    {SPATIAL_TRANSFER,
+        "SPATIAL_TRANSFER", 0, "Spatial transfer", "Copy by analyzing the 
spatial relations"},
+    {PROJECTION_TRANSFER,
+        "PROJECTION_TRANSFER", 0, "Projection transfer", "Copy by projecting 
the desitnation onto the source"},
+    {0, NULL, 0, NULL, NULL}
+};
+
+static EnumPropertyItem replace_mode_item[] = {
+    {REPLACE_ACTIVE_GROUP,
+        "REPLACE_ACTIVE_GROUP", 0, "Active", "Overwrite active group only"},
+    {REPLACE_ENOUGH_GROUPS,
+        "REPLACE_ENOUGH_GROUPS", 0, "Enough", "Overwrite source groups only as 
needed"},
+    {REPLACE_ALL_GROUPS,
+        "REPLACE_ALL_GROUPS", 0, "All", "Overwrite all groups"},
+    {APPEND_GROUPS,
+        "APPEND_GROUPS", 0, "Append", "Add groups without overwriting"},
+       {0, NULL, 0, NULL, NULL}
+};
+
+typedef enum FromToActive {
+       FROM_ACTIVE = 1,
+       TO_ACTIVE = 2
+} FromToActive;
+
+static EnumPropertyItem from_to_active[] = {
+    {FROM_ACTIVE,
+        "FROM_ACTIVE", 0, "From active", "Transfer to different objects"},
+    {TO_ACTIVE,
+        "TO_ACTIVE", 0, "To active", "Better to faster tweek the output"},
+    {0, NULL, 0, NULL, NULL}
+};
+
+
+static bool ED_mesh_vgroup_transfer(Object *ob_dst, Object *ob_src, bContext 
*UNUSED(C), Scene *UNUSED(scene), wmOperator * op)
+{
+       Mesh *me_dst, *me_src;
+       BMesh *bm_dst, *bm_src;
+
+       ReplaceGroupMode replace_mode = RNA_enum_get(op->ptr, "replace_mode");
+       TransferMode transfer_mode = RNA_enum_get(op->ptr, "transfer_mode");
+       bDeformGroup *dg_dst;   //used to remove the layers
+
+       int num_src_lay, num_dst_lay;
+
+       int i;
+
+       float tmp_mat[4][4];
+
+       int CD_src;
+       int active_dst, active_src;
+       char *src_name;
+
+       invert_m4_m4(ob_src->imat, ob_src->obmat);
+       mul_m4_m4m4(tmp_mat, ob_src->imat, ob_dst->obmat);
+
+       me_dst = ob_dst->data;
+       me_src = ob_src->data;
+
+       //manipulating the layers first as its interface uses the Mesh 
structure not the BMesh
+       num_src_lay = CustomData_number_of_layers(&me_src->vdata, 
CD_MDEFORMVERT);
+       num_dst_lay = CustomData_number_of_layers(&me_dst->vdata, 
CD_MDEFORMVERT);
+
+       if (num_src_lay < 1) {

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to