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:
authorOve Murberg Henriksen <sorayasilvermoon@hotmail.com>2012-03-16 01:49:40 +0400
committerOve Murberg Henriksen <sorayasilvermoon@hotmail.com>2012-03-16 01:49:40 +0400
commit0b8ae86e591955214bb78b684be57430d119f9ab (patch)
tree4a6da8852ea26b84919e972d9a3bd64d2030082b /source/blender/editors/object
parent5087c5a6184522f6f25848a367b29374e471c7d9 (diff)
Added functionality: copy vertex group from source to targets.
Changed some comments to represent the code more accuratly.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_intern.h1
-rw-r--r--source/blender/editors/object/object_ops.c1
-rw-r--r--source/blender/editors/object/object_vgroup.c77
3 files changed, 66 insertions, 13 deletions
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index bb87bd5de2e..8f24a9638ab 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -197,6 +197,7 @@ void OBJECT_OT_vertex_group_select(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_deselect(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_copy_to_linked(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_copy_to_selected(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_copy_to_selected_single(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_copy(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_normalize(struct wmOperatorType *ot);
void OBJECT_OT_vertex_group_normalize_all(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 08df069fbf1..c704e165ca2 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -170,6 +170,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_vertex_group_deselect);
WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_linked);
WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_selected);
+ WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_selected_single);
WM_operatortype_append(OBJECT_OT_vertex_group_copy);
WM_operatortype_append(OBJECT_OT_vertex_group_normalize);
WM_operatortype_append(OBJECT_OT_vertex_group_normalize_all);
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 8855b7c08c1..2983ea6c65f 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -75,7 +75,7 @@
#include "UI_resources.h"
#include "object_intern.h"
-#include <stdio.h>
+#include <stdio.h> /*only for development purposes, remove*/
/************************ Exported Functions **********************/
static void vgroup_remap_update_users(Object *ob, int *map);
@@ -2250,7 +2250,7 @@ void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-/*Adds a copy of selected vertex group on source object to source object*/
+/*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);
@@ -2628,6 +2628,7 @@ void OBJECT_OT_vertex_group_copy_to_linked(wmOperatorType *ot)
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);
@@ -2652,6 +2653,7 @@ static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+/*Copy vertex groups from source to target*/ /*warning! overwrites list*/
void OBJECT_OT_vertex_group_copy_to_selected(wmOperatorType *ot)
{
/* identifiers */
@@ -2667,31 +2669,77 @@ void OBJECT_OT_vertex_group_copy_to_selected(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-/* Transfers all vertex groups and weight from active object to targets*/
+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;
+
+ bDeformGroup *dg;
+ dg = BLI_findlink(&obact->defbase, (obact->actdef-1));
+
+ CTX_DATA_BEGIN(C, Object*, obslc, selected_editable_objects)
+ {
+ if(obact != obslc) {
+ if(ED_vgroup_add_name(obslc, dg->name)) change++;
+ else fail++;
+ }
+ }
+ CTX_DATA_END;
+
+ if((change == 0 && fail == 0) || fail) {
+ BKE_reportf(op->reports, RPT_ERROR,
+ "Copy to VGroups to Selected warning done %d, failed %d, object data must have matching indicies",
+ change, fail);
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+/*Copy a vertex group from source to targets*/
+void OBJECT_OT_vertex_group_copy_to_selected_single(wmOperatorType *ot) /*Todo: add gui in python*/
+{
+ /* 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_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
static void vgroup_copy_weight_all(const bContext *C, wmOperator *op)
{
- /* for each vertex group {vgroup_copy_weight(sourceGroup, targetGroup)} */
+ /* for each vertex group {defvert_copy(sourceGroup, targetGroup)} */
printf("Not implemented yet! \n");
}
static int vertex_group_transfer_weight_all_exec(const bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_active_object(C);
- vertex_group_copy_to_selected_exec(C, op);
+ Object *ob = CTX_data_active_object(C);
+
+ vertex_group_copy_to_selected_exec(C, op); /*!!!This causes all vertex groups to be copied, weight or not.*/
vgroup_copy_weight_all(C, op);
+ /*is the right stuff being updated?*/
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
+ WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
return OPERATOR_FINISHED;
}
+/* Transfers all vertex groups with weight from source to targets*/
void OBJECT_OT_vertex_group_transfer_weight_all(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Transfer Weight All";
ot->idname= "OBJECT_OT_vertex_group_transfer_weight_all";
+ ot->description= "Copy all vertex groups including weights to targets";
/* api callbacks */
ot->poll= vertex_group_poll;
@@ -2701,30 +2749,33 @@ void OBJECT_OT_vertex_group_transfer_weight_all(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-/* Transfers one vertex group with weight from active object to target*/
-static void vgroup_copy_weight(/*source vertex group*/ /*target vertex group*/)
+static void vgroup_copy_weight(const bContext *C, wmOperator *op)
{
printf("Not implemented yet! \n");
}
static int vertex_group_transfer_weight_exec(const bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_active_object(C);
- /*vertex_group_copy_to_selected_exec(C,op); ----- must be implemented!*/
- vgroup_copy_weight();
+ Object *ob = CTX_data_active_object(C);
+
+ vertex_group_copy_to_selected_single_exec(C,op); /*!!!This will copy vertex grop, weight or not.*/
+ vgroup_copy_weight(C, op);
+ /*is the right stuff being updated?*/
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
+ WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
return OPERATOR_FINISHED;
}
+/* Transfers one vertex group with weight from source to targets*/
void OBJECT_OT_vertex_group_transfer_weight(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Transfer Weight";
ot->idname= "OBJECT_OT_vertex_group_transfer_weight";
+ ot->description= "Copy a vertex group including weights to targets";
/* api callbacks */
ot->poll= vertex_group_poll;