Revision: 58893 http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58893 Author: walid Date: 2013-08-04 03:51:24 +0000 (Sun, 04 Aug 2013) Log Message: ----------- UV transfer Operator: Adding support for bidirectional transfer (from or to active object)
Modified Paths: -------------- branches/soc-2013-meshdata_transfer/source/blender/editors/mesh/mesh_data.c 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-04 03:47:43 UTC (rev 58892) +++ branches/soc-2013-meshdata_transfer/source/blender/editors/mesh/mesh_data.c 2013-08-04 03:51:24 UTC (rev 58893) @@ -491,6 +491,19 @@ {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_uv_transfer(Object *ob_dst, Object *ob_src, bContext *UNUSED(C), Scene *UNUSED(scene), wmOperator * op) { Mesh *me_dst, *me_src; @@ -896,17 +909,36 @@ Object *ob_act = CTX_data_active_object(C); int fail = 0; + bool transfer_first_to_act = true; + + FromToActive from_active = RNA_enum_get(op->ptr, "from_to_active"); + /* Macro to loop through selected objects.*/ CTX_DATA_BEGIN (C, Object *, ob_slc, selected_editable_objects) { //if the selected isn't the active object if (ob_act != ob_slc) { - if (!ED_mesh_uv_transfer(ob_act, ob_slc, C, scene, op)) { - fail++; + if (from_active == TO_ACTIVE) { + + //if many objects were selected within this mode ... we should copy only from the first + //notice that ob_slc priority isn't set by order of selection! + if (transfer_first_to_act == true) { + transfer_first_to_act = false; + + if (!ED_mesh_uv_transfer(ob_act, ob_slc, C, scene, op)) { + fail++; + } + } } + + else { //copy from the active to all the other selected + if (!ED_mesh_uv_transfer(ob_slc, ob_act, C, scene, op)) { + fail++; + } + } } - } +} ////ported from transfer weights /* Event notifiers for correct display of data.*/ @@ -953,6 +985,8 @@ "Replace/Append", "define which groups to move"); RNA_def_enum(ot->srna, "transfer_mode", transfer_mode_item, 2, "Transfer Mode", "Choose between different algorithms"); + RNA_def_enum(ot->srna, "from_to_active", from_to_active, 2, "From/To active object", + "Choose the transfer direction"); } /*********************** vertex color operators ************************/ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs