svn merge ^/trunk/blender -r46000:46100
authorOve Murberg Henriksen <sorayasilvermoon@hotmail.com>
Sun, 6 May 2012 22:19:13 +0000 (22:19 +0000)
committerOve Murberg Henriksen <sorayasilvermoon@hotmail.com>
Sun, 6 May 2012 22:19:13 +0000 (22:19 +0000)
some conflicts. had to backup my code, accept with "tc" and introduce my own code again.
Hope I didnt leave anything out.

1  2 
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c
source/blender/editors/object/object_vgroup.c

@@@ -317,12 -316,13 +317,12 @@@ int ED_vgroup_copy_array(Object *ob, Ob
  {
        MDeformVert **dvert_array_from, **dvf;
        MDeformVert **dvert_array, **dv;
 -      int dvert_tot_from;
 -      int dvert_tot;
 -      int i;
 +      int dvert_tot_from, dvert_tot, i;
-       int defbase_tot_from= BLI_countlist(&ob_from->defbase);
-       int defbase_tot= BLI_countlist(&ob->defbase);
-       short new_vgroup= FALSE;
+       int defbase_tot_from = BLI_countlist(&ob_from->defbase);
+       int defbase_tot = BLI_countlist(&ob->defbase);
+       short new_vgroup = FALSE;
  
 +      /*get vertex groups arrays*/
        ED_vgroup_give_parray(ob_from->data, &dvert_array_from, &dvert_tot_from, FALSE);
        ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE);
  
@@@ -2493,13 -2292,12 +2494,13 @@@ void OBJECT_OT_vertex_group_deselect(wm
        ot->exec = vertex_group_deselect_exec;
  
        /* flags */
-       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
  }
  
 +/*Adds a copy of selected vertex group from source object to source object*/
  static int vertex_group_copy_exec(bContext *C, wmOperator *UNUSED(op))
  {
-       Object *ob= ED_object_context(C);
+       Object *ob = ED_object_context(C);
  
        vgroup_duplicate(ob);
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@@ -2906,21 -2704,19 +2907,20 @@@ void OBJECT_OT_vertex_group_copy_to_lin
        ot->exec = vertex_group_copy_to_linked_exec;
  
        /* flags */
-       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
  }
  
 +/*Copy vertex groups from source to target*/ /*warning! overwrites list*/
  static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op)
  {
-       Object *obact= ED_object_context(C);
-       int change= 0;
-       int fail= 0;
+       Object *obact = ED_object_context(C);
+       int change = 0;
+       int fail = 0;
  
-       CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
-       {
+       CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
                if (obact != ob) {
                        if (ED_vgroup_copy_array(ob, obact)) change++;
-                       else                                fail++;
+                       else fail++;
                }
        }
        CTX_DATA_END;
  void OBJECT_OT_vertex_group_copy_to_selected(wmOperatorType *ot)
  {
        /* identifiers */
 -      ot->name = "Copy Vertex Group to Selected";
 -      ot->idname = "OBJECT_OT_vertex_group_copy_to_selected";
 -      ot->description = "Copy Vertex Groups to other selected objects with matching indices";
 +      ot->name= "Copy Vertex Group to Selected";
 +      ot->idname= "OBJECT_OT_vertex_group_copy_to_selected";
 +      ot->description= "Copy Vertex Groups to other selected objects with matching indices";
  
        /* api callbacks */
 -      ot->poll = vertex_group_poll;
 -      ot->exec = vertex_group_copy_to_selected_exec;
 +      ot->poll= vertex_group_poll;
 +      ot->exec= vertex_group_copy_to_selected_exec;
  
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
  }
  
- static EnumPropertyItem vgroup_items[]= {
-       {0, NULL, 0, NULL, NULL}};
 +static int vertex_group_copy_to_selected_single_exec(bContext *C, wmOperator *op)
 +{
 +      Object *obact= CTX_data_active_object(C);
 +      int change= 0;
 +      int fail= 0;
 +
 +      /*Macro to loop through selected objects and perform operation*/
 +      CTX_DATA_BEGIN(C, Object*, obslc, selected_editable_objects)
 +      {
 +              if(obact != obslc) {
 +                      /*Try function for matching number of vertices*/
 +                      if(ED_vgroup_copy_single(obslc, obact)) change++;
 +                      /*Try function for get weight from closest vertex*/
 +                      /*TODO: try this function*/
 +                      /*Try function for get weight from closest face*/
 +                      else if(ED_vgroup_copy_by_nearest_face_single(obslc, obact)) change++;
 +                      /*Trigger error message*/
 +                      else fail++;
 +                      /*Event notifiers for correct display of data*/
 +                      DAG_id_tag_update(&obslc->id, OB_RECALC_DATA);
 +                      WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obslc);
 +                      WM_event_add_notifier(C, NC_GEOM|ND_DATA, obslc->data);
 +              }
 +      }
 +      CTX_DATA_END;
 +
 +      /*Report error when task can not be completed with available functions.*/
 +      if((change == 0 && fail == 0) || fail) {
 +              BKE_reportf(op->reports, RPT_ERROR,
 +                          "Copy to VGroups to Selected warning done %d, failed %d, All functions failed!",
 +                          change, fail);
 +      }
 +
 +      return OPERATOR_FINISHED;
 +}
 +
 +/*Transfer vertex group with weight to selected*/
 +void OBJECT_OT_vertex_group_copy_to_selected_single(wmOperatorType *ot)
 +{
 +      /* identifiers */
 +      ot->name= "Copy a Vertex Group to Selected";
 +      ot->idname= "OBJECT_OT_vertex_group_copy_to_selected_single";
 +      ot->description= "Copy a vertex group to other selected objects with matching indices";
 +
 +      /* api callbacks */
 +      ot->poll= vertex_group_poll;
 +      ot->exec= vertex_group_copy_to_selected_single_exec;
 +
 +      /* flags */
 +      ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 +}
 +
+ static EnumPropertyItem vgroup_items[] = {
+       {0, NULL, 0, NULL, NULL}
+ };
  
  static int set_active_group_exec(bContext *C, wmOperator *op)
  {