Commit: 6daa6acdf16e25bd6cda8b8cd32fe221455f1881
Author: Campbell Barton
Date:   Mon Apr 10 13:57:26 2017 +1000
Branches: soc-2016-pbvh-painting
https://developer.blender.org/rB6daa6acdf16e25bd6cda8b8cd32fe221455f1881

Cleanup: move WPaintData, VPaintData, WeightPaintInfo back into paint_vertex.c

There is no reason to make these public
Revert allocated ViewContext, its no longer needed.

===================================================================

M       source/blender/editors/sculpt_paint/paint_intern.h
M       source/blender/editors/sculpt_paint/paint_vertex.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_intern.h 
b/source/blender/editors/sculpt_paint/paint_intern.h
index 56f7b3db48e..f91a6baf6a9 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -91,104 +91,7 @@ void paint_cursor_start(struct bContext *C, int 
(*poll)(struct bContext *C));
 void paint_cursor_start_explicit(struct Paint *p, struct wmWindowManager *wm, 
int (*poll)(struct bContext *C));
 void paint_cursor_delete_textures(void);
 
-/**
-* Variables stored both for 'active' and 'mirror' sides.
-*/
-struct WeightPaintGroupData {
-       /** index of active group or its mirror
-        *
-        * - 'active' is always `ob->actdef`.
-        * - 'mirror' is -1 when 'ME_EDIT_MIRROR_X' flag id disabled,
-        *   otherwise this will be set to the mirror or the active group (if 
the group isn't mirrored).
-        */
-       int index;
-       /** lock that includes the 'index' as locked too
-        *
-        * - 'active' is set of locked or active/selected groups
-        * - 'mirror' is set of locked or mirror groups
-        */
-       const bool *lock;
-};
-
-/* struct to avoid passing many args each call to do_weight_paint_vertex()
- * this _could_ be made a part of the operators 'WPaintData' struct, or at
- * least a member, but for now keep its own struct, initialized on every
- * paint stroke update - campbell */
-typedef struct WeightPaintInfo {
-
-       int defbase_tot;
-
-       /* both must add up to 'defbase_tot' */
-       int defbase_tot_sel;
-       int defbase_tot_unsel;
-
-       struct WeightPaintGroupData active, mirror;
-
-       const bool *lock_flags;  /* boolean array for locked bones,
-                                 * length of defbase_tot */
-       const bool *defbase_sel; /* boolean array for selected bones,
-                                 * length of defbase_tot, cant be const 
because of how its passed */
-
-       const bool *vgroup_validmap; /* same as WeightPaintData.vgroup_validmap,
-                                     * only added here for convenience */
-
-       bool do_flip;
-       bool do_multipaint;
-       bool do_auto_normalize;
-
-       float brush_alpha_value;  /* result of BKE_brush_alpha_get() */
-} WeightPaintInfo;
-
 /* paint_vertex.c */
-typedef struct VPaintData {
-       struct ViewContext *vc;
-       unsigned int paintcol;
-
-       struct VertProjHandle *vp_handle;
-       struct DMCoNo *vertexcosnos;
-
-       float vpimat[3][3];
-
-       /* modify 'me->mcol' directly, since the derived mesh is drawing from 
this
-        * array, otherwise we need to refresh the modifier stack */
-       bool use_fast_update;
-
-       /* loops tagged as having been painted, to apply shared vertex color
-        * blending only to modified loops */
-       bool *mlooptag;
-
-       bool is_texbrush;
-} VPaintData;
-
-typedef struct WPaintData {
-       struct ViewContext *vc;
-
-       struct WeightPaintGroupData active, mirror;
-
-       void *vp_handle;
-       struct DMCoNo *vertexcosnos;
-
-       float wpimat[3][3];
-
-       /* variables for auto normalize */
-       const bool *vgroup_validmap; /* stores if vgroups tie to deforming 
bones or not */
-       const bool *lock_flags;
-
-       /* variables for multipaint */
-       const bool *defbase_sel;      /* set of selected groups */
-       int defbase_tot_sel;          /* number of selected groups */
-       bool do_multipaint;           /* true if multipaint enabled and 
multiple groups selected */
-
-       /* variables for blur */
-       struct {
-               struct MeshElemMap *vmap;
-               int *vmap_mem;
-       } blur_data;
-
-       int defbase_tot;
-} WPaintData;
-
-
 int weight_paint_poll(struct bContext *C);
 int weight_paint_mode_poll(struct bContext *C);
 int vertex_paint_poll(struct bContext *C);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c 
b/source/blender/editors/sculpt_paint/paint_vertex.c
index bcf1c15da06..c78f4f9fea7 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -802,8 +802,9 @@ static unsigned int vpaint_blend(VPaint *vp, unsigned int 
col, unsigned int colo
 
 
 /* whats _dl mean? */
-static float calc_vp_strength_col_dl(VPaint *vp, ViewContext *vc, const float 
co[3],
-                                 const float mval[2], const float 
brush_size_pressure, float rgba[4])
+static float calc_vp_strength_col_dl(
+        VPaint *vp, const ViewContext *vc, const float co[3],
+        const float mval[2], const float brush_size_pressure, float rgba[4])
 {
        float co_ss[2];  /* screenspace */
 
@@ -839,10 +840,11 @@ static float calc_vp_strength_col_dl(VPaint *vp, 
ViewContext *vc, const float co
        return 0.0f;
 }
 
-static float calc_vp_alpha_col_dl(VPaint *vp, ViewContext *vc,
-                              float vpimat[3][3], const DMCoNo *v_co_no,
-                              const float mval[2],
-                              const float brush_size_pressure, const float 
brush_alpha_pressure, float rgba[4])
+static float calc_vp_alpha_col_dl(
+        VPaint *vp, const ViewContext *vc,
+        float vpimat[3][3], const DMCoNo *v_co_no,
+        const float mval[2],
+        const float brush_size_pressure, const float brush_alpha_pressure, 
float rgba[4])
 {
        float strength = calc_vp_strength_col_dl(vp, vc, v_co_no->co, mval, 
brush_size_pressure, rgba);
 
@@ -1407,6 +1409,54 @@ static void multipaint_apply_change(MDeformVert *dvert, 
const int defbase_tot, f
        }
 }
 
+/**
+ * Variables stored both for 'active' and 'mirror' sides.
+ */
+struct WeightPaintGroupData {
+       /** index of active group or its mirror
+        *
+        * - 'active' is always `ob->actdef`.
+        * - 'mirror' is -1 when 'ME_EDIT_MIRROR_X' flag id disabled,
+        *   otherwise this will be set to the mirror or the active group (if 
the group isn't mirrored).
+        */
+       int index;
+       /** lock that includes the 'index' as locked too
+        *
+        * - 'active' is set of locked or active/selected groups
+        * - 'mirror' is set of locked or mirror groups
+        */
+       const bool *lock;
+};
+
+/* struct to avoid passing many args each call to do_weight_paint_vertex()
+ * this _could_ be made a part of the operators 'WPaintData' struct, or at
+ * least a member, but for now keep its own struct, initialized on every
+ * paint stroke update - campbell */
+typedef struct WeightPaintInfo {
+
+       int defbase_tot;
+
+       /* both must add up to 'defbase_tot' */
+       int defbase_tot_sel;
+       int defbase_tot_unsel;
+
+       struct WeightPaintGroupData active, mirror;
+
+       const bool *lock_flags;  /* boolean array for locked bones,
+                                 * length of defbase_tot */
+       const bool *defbase_sel; /* boolean array for selected bones,
+                                 * length of defbase_tot, cant be const 
because of how its passed */
+
+       const bool *vgroup_validmap; /* same as WeightPaintData.vgroup_validmap,
+                                     * only added here for convenience */
+
+       bool do_flip;
+       bool do_multipaint;
+       bool do_auto_normalize;
+
+       float brush_alpha_value;  /* result of BKE_brush_alpha_get() */
+} WeightPaintInfo;
+
 static void do_weight_paint_vertex_single(
         /* vars which remain the same for every vert */
         VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
@@ -1822,6 +1872,34 @@ struct WPaintVGroupIndex {
        int mirror;
 };
 
+struct WPaintData {
+       ViewContext vc;
+
+       struct WeightPaintGroupData active, mirror;
+
+       void *vp_handle;
+       struct DMCoNo *vertexcosnos;
+
+       float wpimat[3][3];
+
+       /* variables for auto normalize */
+       const bool *vgroup_validmap; /* stores if vgroups tie to deforming 
bones or not */
+       const bool *lock_flags;
+
+       /* variables for multipaint */
+       const bool *defbase_sel;      /* set of selected groups */
+       int defbase_tot_sel;          /* number of selected groups */
+       bool do_multipaint;           /* true if multipaint enabled and 
multiple groups selected */
+
+       /* variables for blur */
+       struct {
+               struct MeshElemMap *vmap;
+               int *vmap_mem;
+       } blur_data;
+
+       int defbase_tot;
+};
+
 /* ensure we have data on wpaint start, add if needed */
 static bool wpaint_ensure_data(
         bContext *C, wmOperator *op,
@@ -2074,10 +2152,9 @@ static bool wpaint_stroke_test_start(bContext *C, 
wmOperator *op, const float mo
 
        /* ALLOCATIONS! no return after this line */
        /* make mode data storage */
-       wpd = MEM_callocN(sizeof(WPaintData), "WPaintData");
-       wpd->vc = MEM_callocN(sizeof(*wpd->vc), __func__);
+       wpd = MEM_callocN(sizeof(struct WPaintData), "WPaintData");
        paint_stroke_set_mode_data(stroke, wpd);
-       view3d_set_viewcontext(C, wpd->vc);
+       view3d_set_viewcontext(C, &wpd->vc);
 
        wpd->active.index = vgroup_index.active;
        wpd->mirror.index = vgroup_index.mirror;
@@ -2128,7 +2205,7 @@ static bool wpaint_stroke_test_start(bContext *C, 
wmOperator *op, const float mo
        ob->sculpt->modes.vwpaint.building_vp_handle = false;
 
        /* imat for normals */
-       mul_m4_m4m4(mat, wpd->vc->rv3d->viewmat, ob->obmat);
+       mul_m4_m4m4(mat, wpd->vc.rv3d->viewmat, ob->obmat);
        invert_m4_m4(imat, mat);
        copy_m3_m4(wpd->wpimat, imat);
 
@@ -2400,7 +2477,8 @@ static void do_wpaint_brush_smudge_task_cb_ex(
                                }
                                if (shouldColor && dot > 0.0) {
                                        const float fade = 
BKE_brush_curve_strength(brush, test.dist, cache->radius);
-                                       do_weight_paint_vertex(data->vp, 
data->ob, data->wpi, vertexIndex, dot * fade * bstrength, (float)finalWeight);
+                                       do_weight_paint_vertex(
+                                               data->vp, data->ob, data->wpi, 
vertexIndex, dot * fade * bstrength, (float)finalWeight);
                                }
                        }
                BKE_pbvh_vertex_iter_end;
@@ -2445,8 +2523,9 @@ static void do_wpaint_brush_draw_task_cb_ex(
                                if (!(data->vp->flag & VP_SPRAY)) {
                                        MDeformVert *dv = 
&data->me->dvert[vertexIndex];
                                        MDeformWeight *dw;
-                                       dw = (data->vp->flag & VP_ONLYVGROUP) ? 
defvert_find_index(dv, data->wpi->active.index) :
-                                                                               
                                                                                
                                        defvert_verify_index(dv, 
data->wpi->active.index);
+                                       dw = (data->vp->flag & VP_ONLYVGROUP) ?
+                                               defvert_find_index(dv, 
data->wpi->active.index) :
+                                               defvert_verify_index(dv, 
data->wpi->active.index);
                                        currentWeight = dw->weight;
                                        if 
(ss->modes.vwpaint.max_weight[vertexIndex] < 0) {
                                                
ss->modes.vwpaint.max_weight[vertexIndex] = min_ff(bstrength + dw->weight, 
1.0f);
@@ -2473,7 +2552,7 @@ static void do_wpaint_brush_draw_task_cb_ex(
 }
 
 static void do_wpaint_brush_calc_ave_weight_cb_ex(
-               void *userdata, void *UNUSED(userdata_chunk), const int n, 
const int UNUSED(thread_id))
+        void *userdata, void *UNUSED(userdata_chunk), const int n, const 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to