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:
authorAlexander Gavrilov <angavrilov@gmail.com>2016-01-21 00:03:15 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-01-21 00:03:47 +0300
commit5ef2ed23e1238e88db899f9d96a9463e6f725e35 (patch)
treebe650ab88c4acc28416b091b23b2b4a77fa1986c /source/blender/blenkernel/intern/object_deform.c
parent3c74968aa461ec986190d3197cb3517851ac98be (diff)
Weight Paint: Make multi-paint & mirror work as if bone selection was symmetric
The simplest way of handling mirroring in multi-paint is creating a uniform symmetric selection and relying on existing symmetric weights to direct changes to the appropriate vertex groups. This already works if mirror bones are selected manually, and can be made easier to use by doing it implicitly.
Diffstat (limited to 'source/blender/blenkernel/intern/object_deform.c')
-rw-r--r--source/blender/blenkernel/intern/object_deform.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c
index e823f87468d..38391c84d29 100644
--- a/source/blender/blenkernel/intern/object_deform.c
+++ b/source/blender/blenkernel/intern/object_deform.c
@@ -596,6 +596,30 @@ bool *BKE_object_defgroup_selected_get(Object *ob, int defbase_tot, int *r_dg_fl
return dg_selection;
}
+/* Marks mirror vgroups in output and counts them. Output and counter assumed to be already initialized.
+ * Designed to be usable after BKE_object_defgroup_selected_get to extend selection to mirror.
+ */
+void BKE_object_defgroup_mirror_selection(
+ struct Object *ob, int defbase_tot, const bool *dg_selection,
+ bool *dg_flags_sel, int *r_dg_flags_sel_tot)
+{
+ bDeformGroup *defgroup;
+ unsigned int i, i_mirr;
+
+ for (i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) {
+ if (dg_selection[i]) {
+ char name_flip[MAXBONENAME];
+
+ BKE_deform_flip_side_name(name_flip, defgroup->name, false);
+ i_mirr = STREQ(name_flip, defgroup->name) ? i : defgroup_name_index(ob, name_flip);
+
+ if ((i_mirr >= 0 && i_mirr < defbase_tot) && (dg_flags_sel[i_mirr] == false)) {
+ dg_flags_sel[i_mirr] = true;
+ (*r_dg_flags_sel_tot) += 1;
+ }
+ }
+ }
+}
/**
* Return the subset type of the Vertex Group Selection