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>2012-09-05 07:45:32 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-09-05 07:45:32 +0400
commita512cac545dcb233e9487b327cf18da58bd61218 (patch)
tree795fb3fd90960f602f1eb671e992b6928f907d17 /source/blender/blenkernel/intern/DerivedMesh.c
parent84dc5c2992553270d267ac8c0e06defd1c78238e (diff)
code cleanup: move get_selected_defgroups into object_deform.c and make it behave like similar functions, also when drawing vertex weight colors, only call this function when multi-paint is enabled.
Diffstat (limited to 'source/blender/blenkernel/intern/DerivedMesh.c')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 1aa54307841..a7f8e1bb161 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -59,6 +59,7 @@
#include "BKE_modifier.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
+#include "BKE_object_deform.h"
#include "BKE_paint.h"
#include "BKE_texture.h"
#include "BKE_multires.h"
@@ -1015,14 +1016,14 @@ static void calc_weightpaint_vert_color(
unsigned char r_col[4],
MDeformVert *dv, ColorBand *coba,
const int defbase_tot, const int defbase_act,
- const char *dg_flags,
- const int selected, const int draw_flag)
+ const char *defbase_sel, const int defbase_sel_tot,
+ const int draw_flag)
{
float input = 0.0f;
int make_black = FALSE;
- if ((selected > 1) && (draw_flag & CALC_WP_MULTIPAINT)) {
+ if ((defbase_sel_tot > 1) && (draw_flag & CALC_WP_MULTIPAINT)) {
int was_a_nonzero = FALSE;
unsigned int i;
@@ -1031,7 +1032,7 @@ static void calc_weightpaint_vert_color(
/* in multipaint, get the average if auto normalize is inactive
* get the sum if it is active */
if (dw->def_nr < defbase_tot) {
- if (dg_flags[dw->def_nr]) {
+ if (defbase_sel[dw->def_nr]) {
if (dw->weight) {
input += dw->weight;
was_a_nonzero = TRUE;
@@ -1045,7 +1046,7 @@ static void calc_weightpaint_vert_color(
make_black = TRUE;
}
else if ((draw_flag & CALC_WP_AUTO_NORMALIZE) == FALSE) {
- input /= selected; /* get the average */
+ input /= defbase_sel_tot; /* get the average */
}
}
else {
@@ -1090,14 +1091,21 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, i
/* variables for multipaint */
const int defbase_tot = BLI_countlist(&ob->defbase);
const int defbase_act = ob->actdef - 1;
- char *dg_flags = MEM_mallocN(defbase_tot * sizeof(char), __func__);
- const int selected = get_selected_defgroups(ob, dg_flags, defbase_tot);
+
+ int defbase_sel_tot = 0;
+ char *defbase_sel = NULL;
+
+ if (draw_flag & CALC_WP_MULTIPAINT) {
+ defbase_sel = BKE_objdef_selected_get(ob, defbase_tot, &defbase_sel_tot);
+ }
for (i = numVerts; i != 0; i--, wc += 4, dv++) {
- calc_weightpaint_vert_color(wc, dv, coba, defbase_tot, defbase_act, dg_flags, selected, draw_flag);
+ calc_weightpaint_vert_color(wc, dv, coba, defbase_tot, defbase_act, defbase_sel, defbase_sel_tot, draw_flag);
}
- MEM_freeN(dg_flags);
+ if (defbase_sel) {
+ MEM_freeN(defbase_sel);
+ }
}
else {
int col_i;