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:
authorCampbell Barton <ideasman42@gmail.com>2013-05-15 19:52:48 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-05-15 19:52:48 +0400
commit65dcc6ad4f11097eeb601fcd70b3db52ed482f6f (patch)
tree672b5f02870b1141821d083359154c3c8e72887a
parente1229b2978c37a043f3932657ac5cfa156093866 (diff)
use bool arrays rather then char for weight paint lock/select arrays
-rw-r--r--source/blender/blenkernel/BKE_deform.h2
-rw-r--r--source/blender/blenkernel/BKE_object_deform.h6
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c4
-rw-r--r--source/blender/blenkernel/intern/deform.c2
-rw-r--r--source/blender/blenkernel/intern/object_deform.c14
-rw-r--r--source/blender/editors/object/object_vgroup.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c41
7 files changed, 37 insertions, 36 deletions
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h
index b18bb5a87b6..5e8cd8d90fa 100644
--- a/source/blender/blenkernel/BKE_deform.h
+++ b/source/blender/blenkernel/BKE_deform.h
@@ -74,7 +74,7 @@ void defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip
void defvert_flip_merged(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len);
void defvert_normalize(struct MDeformVert *dvert);
void defvert_normalize_lock_single(struct MDeformVert *dvert, const int def_nr_lock);
-void defvert_normalize_lock_map(struct MDeformVert *dvert, const char *lock_flags, const int defbase_tot);
+void defvert_normalize_lock_map(struct MDeformVert *dvert, const bool *lock_flags, const int defbase_tot);
/* utility function, note that MAX_VGROUP_NAME chars is the maximum string length since its only
* used with defgroups currently */
diff --git a/source/blender/blenkernel/BKE_object_deform.h b/source/blender/blenkernel/BKE_object_deform.h
index ecc521a77fb..6de7ff9bc1c 100644
--- a/source/blender/blenkernel/BKE_object_deform.h
+++ b/source/blender/blenkernel/BKE_object_deform.h
@@ -31,8 +31,8 @@
struct Object;
-char *BKE_objdef_lock_flags_get(struct Object *ob, const int defbase_tot);
-char *BKE_objdef_validmap_get(struct Object *ob, const int defbase_tot);
-char *BKE_objdef_selected_get(struct Object *ob, int defbase_tot, int *r_dg_flags_sel_tot);
+bool *BKE_objdef_lock_flags_get(struct Object *ob, const int defbase_tot);
+bool *BKE_objdef_validmap_get(struct Object *ob, const int defbase_tot);
+bool *BKE_objdef_selected_get(struct Object *ob, int defbase_tot, int *r_dg_flags_sel_tot);
#endif /* __BKE_OBJECT_DEFORM_H__ */
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 6e332559e29..3dda6933eab 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1066,7 +1066,7 @@ static void calc_weightpaint_vert_color(
MDeformVert *dv,
DMWeightColorInfo *dm_wcinfo,
const int defbase_tot, const int defbase_act,
- const char *defbase_sel, const int defbase_sel_tot,
+ const bool *defbase_sel, const int defbase_sel_tot,
const int draw_flag)
{
float input = 0.0f;
@@ -1154,7 +1154,7 @@ static void calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, int const d
const int defbase_act = ob->actdef - 1;
int defbase_sel_tot = 0;
- char *defbase_sel = NULL;
+ bool *defbase_sel = NULL;
if (draw_flag & CALC_WP_MULTIPAINT) {
defbase_sel = BKE_objdef_selected_get(ob, defbase_tot, &defbase_sel_tot);
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index ed665d44431..371f64fd468 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -254,7 +254,7 @@ void defvert_normalize_lock_single(MDeformVert *dvert, const int def_nr_lock)
}
}
-void defvert_normalize_lock_map(MDeformVert *dvert, const char *lock_flags, const int defbase_tot)
+void defvert_normalize_lock_map(MDeformVert *dvert, const bool *lock_flags, const int defbase_tot)
{
if (dvert->totweight <= 0) {
/* nothing */
diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c
index 7f9578250f2..03e331436f9 100644
--- a/source/blender/blenkernel/intern/object_deform.c
+++ b/source/blender/blenkernel/intern/object_deform.c
@@ -45,12 +45,12 @@
* gets the status of "flag" for each bDeformGroup
* in ob->defbase and returns an array containing them
*/
-char *BKE_objdef_lock_flags_get(Object *ob, const int defbase_tot)
+bool *BKE_objdef_lock_flags_get(Object *ob, const int defbase_tot)
{
- char is_locked = FALSE;
+ bool is_locked = false;
int i;
//int defbase_tot = BLI_countlist(&ob->defbase);
- char *lock_flags = MEM_mallocN(defbase_tot * sizeof(char), "defflags");
+ bool *lock_flags = MEM_mallocN(defbase_tot * sizeof(bool), "defflags");
bDeformGroup *defgroup;
for (i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) {
@@ -65,11 +65,11 @@ char *BKE_objdef_lock_flags_get(Object *ob, const int defbase_tot)
return NULL;
}
-char *BKE_objdef_validmap_get(Object *ob, const int defbase_tot)
+bool *BKE_objdef_validmap_get(Object *ob, const int defbase_tot)
{
bDeformGroup *dg;
ModifierData *md;
- char *vgroup_validmap;
+ bool *vgroup_validmap;
GHash *gh;
int i, step1 = 1;
//int defbase_tot = BLI_countlist(&ob->defbase);
@@ -127,9 +127,9 @@ char *BKE_objdef_validmap_get(Object *ob, const int defbase_tot)
/* Returns total selected vgroups,
* wpi.defbase_sel is assumed malloc'd, all values are set */
-char *BKE_objdef_selected_get(Object *ob, int defbase_tot, int *r_dg_flags_sel_tot)
+bool *BKE_objdef_selected_get(Object *ob, int defbase_tot, int *r_dg_flags_sel_tot)
{
- char *dg_selection = MEM_mallocN(defbase_tot * sizeof(char), __func__);
+ bool *dg_selection = MEM_mallocN(defbase_tot * sizeof(bool), __func__);
bDeformGroup *defgroup;
unsigned int i;
Object *armob = BKE_object_pose_armature_get(ob);
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 38a26447cb0..7b17523185f 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -1528,7 +1528,7 @@ static void vgroup_normalize_all(Object *ob, const bool lock_active)
if (dvert_array) {
const int defbase_tot = BLI_countlist(&ob->defbase);
- char *lock_flags = BKE_objdef_lock_flags_get(ob, defbase_tot);
+ bool *lock_flags = BKE_objdef_lock_flags_get(ob, defbase_tot);
if ((lock_active == true) &&
(lock_flags != NULL) &&
@@ -1809,7 +1809,7 @@ static bool vertex_group_limit_total(Object *ob,
if (dvert_array) {
int defbase_tot = BLI_countlist(&ob->defbase);
- const char *vgroup_validmap = (all_deform_weights == false) ?
+ const bool *vgroup_validmap = (all_deform_weights == false) ?
BKE_objdef_validmap_get(ob, defbase_tot) :
NULL;
int num_to_drop = 0;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 3a24fcd652f..388b0e769e8 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1288,7 +1288,7 @@ void PAINT_OT_weight_sample_group(wmOperatorType *ot)
ot->prop = prop;
}
-static void do_weight_paint_normalize_all(MDeformVert *dvert, const int defbase_tot, const char *vgroup_validmap)
+static void do_weight_paint_normalize_all(MDeformVert *dvert, const int defbase_tot, const bool *vgroup_validmap)
{
float sum = 0.0f, fac;
unsigned int i, tot = 0;
@@ -1330,7 +1330,7 @@ static void do_weight_paint_normalize_all(MDeformVert *dvert, const int defbase_
*
* note that the active is just the group which is unchanged, it can be any,
* can also be -1 to normalize all but in that case call 'do_weight_paint_normalize_all' */
-static void do_weight_paint_normalize_all_active(MDeformVert *dvert, const int defbase_tot, const char *vgroup_validmap,
+static void do_weight_paint_normalize_all_active(MDeformVert *dvert, const int defbase_tot, const bool *vgroup_validmap,
const int vgroup_active)
{
float sum = 0.0f, fac;
@@ -1391,7 +1391,7 @@ static void do_weight_paint_normalize_all_active(MDeformVert *dvert, const int d
* See if the current deform vertex has a locked group
*/
static char has_locked_group(MDeformVert *dvert, const int defbase_tot,
- const char *bone_groups, const char *lock_flags)
+ const bool *bone_groups, const bool *lock_flags)
{
int i;
MDeformWeight *dw;
@@ -1406,20 +1406,21 @@ static char has_locked_group(MDeformVert *dvert, const int defbase_tot,
return FALSE;
}
-static int has_locked_group_selected(int defbase_tot, const char *defbase_sel, const char *lock_flags)
+static bool has_locked_group_selected(int defbase_tot, const bool *defbase_sel, const bool *lock_flags)
{
int i;
for (i = 0; i < defbase_tot; i++) {
if (defbase_sel[i] && lock_flags[i]) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
#if 0 /* UNUSED */
-static int has_unselected_unlocked_bone_group(int defbase_tot, char *defbase_sel, int selected, char *lock_flags, char *vgroup_validmap)
+static int has_unselected_unlocked_bone_group(int defbase_tot, bool *defbase_sel, int selected,
+ const bool *lock_flags, const bool *vgroup_validmap)
{
int i;
if (defbase_tot == selected) {
@@ -1435,7 +1436,7 @@ static int has_unselected_unlocked_bone_group(int defbase_tot, char *defbase_sel
#endif
-static void multipaint_selection(MDeformVert *dvert, const int defbase_tot, float change, const char *defbase_sel)
+static void multipaint_selection(MDeformVert *dvert, const int defbase_tot, float change, const bool *defbase_sel)
{
int i;
MDeformWeight *dw;
@@ -1529,13 +1530,13 @@ static float redistribute_change(MDeformVert *ndv, const int defbase_tot,
/* left overs */
return totchange;
}
-static float get_mp_change(MDeformVert *odv, const int defbase_tot, const char *defbase_sel, float brush_change);
+static float get_mp_change(MDeformVert *odv, const int defbase_tot, const bool *defbase_sel, float brush_change);
/* observe the changes made to the weights of groups.
* make sure all locked groups on the vertex have the same deformation
* by moving the changes made to groups onto other unlocked groups */
static void enforce_locks(MDeformVert *odv, MDeformVert *ndv,
- const int defbase_tot, const char *defbase_sel,
- const char *lock_flags, const char *vgroup_validmap,
+ const int defbase_tot, const bool *defbase_sel,
+ const bool *lock_flags, const bool *vgroup_validmap,
char do_auto_normalize, char do_multipaint)
{
float totchange = 0.0f;
@@ -1645,7 +1646,7 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv,
}
/* multi-paint's initial, potential change is computed here based on the user's stroke */
-static float get_mp_change(MDeformVert *odv, const int defbase_tot, const char *defbase_sel, float brush_change)
+static float get_mp_change(MDeformVert *odv, const int defbase_tot, const bool *defbase_sel, float brush_change)
{
float selwsum = 0.0f;
unsigned int i;
@@ -1702,12 +1703,12 @@ typedef struct WeightPaintInfo {
int vgroup_active; /* (ob->actdef - 1) */
int vgroup_mirror; /* mirror group or -1 */
- const char *lock_flags; /* boolean array for locked bones,
+ const bool *lock_flags; /* boolean array for locked bones,
* length of defbase_tot */
- const char *defbase_sel; /* boolean array for selected bones,
+ const bool *defbase_sel; /* boolean array for selected bones,
* length of defbase_tot, cant be const because of how its passed */
- const char *vgroup_validmap; /* same as WeightPaintData.vgroup_validmap,
+ const bool *vgroup_validmap; /* same as WeightPaintData.vgroup_validmap,
* only added here for convenience */
char do_flip;
@@ -1738,8 +1739,8 @@ static int apply_mp_locks_normalize(Mesh *me, const WeightPaintInfo *wpi,
/* do not multi-paint if a locked group is selected or the active group is locked
* !lock_flags[dw->def_nr] helps if nothing is selected, but active group is locked */
if ((wpi->lock_flags == NULL) ||
- ((wpi->lock_flags[dw->def_nr] == FALSE) && /* def_nr range has to be checked for by caller */
- has_locked_group_selected(wpi->defbase_tot, wpi->defbase_sel, wpi->lock_flags) == FALSE))
+ ((wpi->lock_flags[dw->def_nr] == false) && /* def_nr range has to be checked for by caller */
+ has_locked_group_selected(wpi->defbase_tot, wpi->defbase_sel, wpi->lock_flags) == false))
{
if (wpi->do_multipaint && wpi->defbase_tot_sel > 1) {
if (change && change != 1) {
@@ -1781,7 +1782,7 @@ static int apply_mp_locks_normalize(Mesh *me, const WeightPaintInfo *wpi,
/* within the current dvert index, get the dw that is selected and has a weight
* above 0, this helps multi-paint */
-static int get_first_selected_nonzero_weight(MDeformVert *dvert, const int defbase_tot, const char *defbase_sel)
+static int get_first_selected_nonzero_weight(MDeformVert *dvert, const int defbase_tot, const bool *defbase_sel)
{
int i;
MDeformWeight *dw = dvert->dw;
@@ -2138,8 +2139,8 @@ struct WPaintData {
float wpimat[3][3];
/* variables for auto normalize */
- const char *vgroup_validmap; /* stores if vgroups tie to deforming bones or not */
- const char *lock_flags;
+ const bool *vgroup_validmap; /* stores if vgroups tie to deforming bones or not */
+ const bool *lock_flags;
int defbase_tot;
};