[Bf-blender-cvs] [9ef8bee82a8] soc-2016-pbvh-painting: Cleanup: variable names, const correctness, formatting
Campbell Barton
noreply at git.blender.org
Mon Apr 10 07:19:21 CEST 2017
Commit: 9ef8bee82a859e75312d38a9f41f9b071026894e
Author: Campbell Barton
Date: Mon Apr 10 15:17:22 2017 +1000
Branches: soc-2016-pbvh-painting
https://developer.blender.org/rB9ef8bee82a859e75312d38a9f41f9b071026894e
Cleanup: variable names, const correctness, formatting
This makes the code match more closely with BKE_mesh conventions.
Also remove unused WPaintDefer struct.
===================================================================
M source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index c78f4f9fea7..28e5081d06d 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -82,12 +82,6 @@
#include "sculpt_intern.h"
#include "paint_intern.h" /* own include */
-/* small structure to defer applying weight-paint results */
-struct WPaintDefer {
- int index;
- float alpha, weight;
-};
-
/* check if we can do partial updates and have them draw realtime
* (without rebuilding the 'derivedFinal') */
static bool vertex_paint_use_fast_update_check(Object *ob)
@@ -190,7 +184,7 @@ unsigned int vpaint_get_current_col(Scene *scene, VPaint *vp)
static void do_shared_vertexcol(Mesh *me, bool *mlooptag)
{
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
- MPoly *mp;
+ const MPoly *mp;
int (*scol)[4];
int i, j;
bool has_shared = false;
@@ -204,7 +198,7 @@ static void do_shared_vertexcol(Mesh *me, bool *mlooptag)
for (i = 0, mp = me->mpoly; i < me->totpoly; i++, mp++) {
if ((use_face_sel == false) || (mp->flag & ME_FACE_SEL)) {
- MLoop *ml = me->mloop + mp->loopstart;
+ const MLoop *ml = me->mloop + mp->loopstart;
MLoopCol *lcol = me->mloopcol + mp->loopstart;
for (j = 0; j < mp->totloop; j++, ml++, lcol++) {
scol[ml->v][0] += lcol->r;
@@ -227,7 +221,7 @@ static void do_shared_vertexcol(Mesh *me, bool *mlooptag)
for (i = 0, mp = me->mpoly; i < me->totpoly; i++, mp++) {
if ((use_face_sel == false) || (mp->flag & ME_FACE_SEL)) {
- MLoop *ml = me->mloop + mp->loopstart;
+ const MLoop *ml = me->mloop + mp->loopstart;
MLoopCol *lcol = me->mloopcol + mp->loopstart;
for (j = 0; j < mp->totloop; j++, ml++, lcol++) {
if (mlooptag[mp->loopstart + j]) {
@@ -315,9 +309,8 @@ static void copy_wpaint_prev(VPaint *wp, MDeformVert *dverts, int dcount)
bool ED_vpaint_fill(Object *ob, unsigned int paintcol)
{
Mesh *me;
- MPoly *mp;
+ const MPoly *mp;
int i, j;
- bool selected;
if (((me = BKE_mesh_from_object(ob)) == NULL) ||
(me->mloopcol == NULL && (make_vertexcol(ob) == false)))
@@ -325,13 +318,13 @@ bool ED_vpaint_fill(Object *ob, unsigned int paintcol)
return false;
}
- selected = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
mp = me->mpoly;
for (i = 0; i < me->totpoly; i++, mp++) {
MLoopCol *lcol = me->mloopcol + mp->loopstart;
- if (selected && !(mp->flag & ME_FACE_SEL))
+ if (use_face_sel && !(mp->flag & ME_FACE_SEL))
continue;
for (j = 0; j < mp->totloop; j++, lcol++) {
@@ -352,7 +345,7 @@ bool ED_vpaint_fill(Object *ob, unsigned int paintcol)
bool ED_wpaint_fill(VPaint *wp, Object *ob, float paintweight)
{
Mesh *me = ob->data;
- MPoly *mp;
+ const MPoly *mp;
MDeformWeight *dw, *dw_prev;
int vgroup_active, vgroup_mirror = -1;
unsigned int index;
@@ -435,12 +428,11 @@ bool ED_wpaint_fill(VPaint *wp, Object *ob, float paintweight)
bool ED_vpaint_smooth(Object *ob)
{
Mesh *me;
- MPoly *mp;
+ const MPoly *mp;
int i, j;
bool *mlooptag;
- bool selected;
if (((me = BKE_mesh_from_object(ob)) == NULL) ||
(me->mloopcol == NULL && (make_vertexcol(ob) == false)))
@@ -448,17 +440,17 @@ bool ED_vpaint_smooth(Object *ob)
return false;
}
- selected = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
mlooptag = MEM_callocN(sizeof(bool) * me->totloop, "VPaintData mlooptag");
/* simply tag loops of selected faces */
mp = me->mpoly;
for (i = 0; i < me->totpoly; i++, mp++) {
- MLoop *ml = me->mloop + mp->loopstart;
+ const MLoop *ml = me->mloop + mp->loopstart;
int ml_index = mp->loopstart;
- if (selected && !(mp->flag & ME_FACE_SEL))
+ if (use_face_sel && !(mp->flag & ME_FACE_SEL))
continue;
for (j = 0; j < mp->totloop; j++, ml_index++, ml++) {
@@ -495,13 +487,13 @@ bool ED_vpaint_color_transform(
return false;
}
- const bool do_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
mp = me->mpoly;
for (int i = 0; i < me->totpoly; i++, mp++) {
MLoopCol *lcol = &me->mloopcol[mp->loopstart];
- if (do_face_sel && !(mp->flag & ME_FACE_SEL)) {
+ if (use_face_sel && !(mp->flag & ME_FACE_SEL)) {
continue;
}
@@ -587,17 +579,17 @@ BLI_INLINE unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac
cp = (unsigned char *)&col;
/* Updated to use the rgb squared color model which blends nicer. */
- int red1 = cp1[0] * cp1[0];
- int green1 = cp1[1] * cp1[1];
- int blue1 = cp1[2] * cp1[2];
+ int r1 = cp1[0] * cp1[0];
+ int g1 = cp1[1] * cp1[1];
+ int b1 = cp1[2] * cp1[2];
- int red2 = cp2[0] * cp2[0];
- int green2 = cp2[1] * cp2[1];
- int blue2 = cp2[2] * cp2[2];
+ int r2 = cp2[0] * cp2[0];
+ int g2 = cp2[1] * cp2[1];
+ int b2 = cp2[2] * cp2[2];
- cp[0] = (unsigned char)round(sqrt(divide_round_i((mfac * red1 + fac * red2), 255)));
- cp[1] = (unsigned char)round(sqrt(divide_round_i((mfac * green1 + fac * green2), 255)));
- cp[2] = (unsigned char)round(sqrt(divide_round_i((mfac * blue1 + fac * blue2), 255)));
+ cp[0] = (unsigned char)round(sqrt(divide_round_i((mfac * r1 + fac * r2), 255)));
+ cp[1] = (unsigned char)round(sqrt(divide_round_i((mfac * g1 + fac * g2), 255)));
+ cp[2] = (unsigned char)round(sqrt(divide_round_i((mfac * b1 + fac * b2), 255)));
cp[3] = 255;
return col;
@@ -764,8 +756,8 @@ static unsigned int vpaint_blend_tool(const int tool, const unsigned int col,
}
/* wpaint has 'wpaint_blend' */
-static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colorig, const
- unsigned int paintcol, const int alpha_i,
+static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colorig,
+ const unsigned int paintcol, const int alpha_i,
/* pre scaled from [0-1] --> [0-255] */
const int brush_alpha_value_i)
{
@@ -1101,7 +1093,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(
}
else {
if (ED_mesh_pick_face(C, vc.obact, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
- MPoly *mp = &me->mpoly[index];
+ const MPoly *mp = &me->mpoly[index];
unsigned int fidx = mp->totloop - 1;
do {
@@ -1706,13 +1698,14 @@ static void do_weight_paint_vertex(
/ copied from sculpt.c ****/
static void vertex_paint_init_session(Scene *scene, Object *ob)
{
- if (!ob->sculpt) {
+ if (ob->sculpt == NULL) {
ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, 0, false);
}
}
-static void vertex_paint_init_session_maps(Object *ob) {
+static void vertex_paint_init_session_maps(Object *ob)
+{
/* Create maps */
if (ob->sculpt->modes.vwpaint.vert_to_loop == NULL) {
Mesh *me = ob->data;
@@ -1731,7 +1724,8 @@ static void vertex_paint_init_session_maps(Object *ob) {
}
}
-static void vertex_paint_init_session_average_arrays(Object *ob){
+static void vertex_paint_init_session_average_arrays(Object *ob)
+{
/* Create average brush arrays */
if (!ob->sculpt->modes.vwpaint.tot_loops_hit) {
int totNode = 0;
@@ -1789,7 +1783,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
ED_mesh_mirror_topo_table(NULL, NULL, 'e');
/* If the cache is not released by a cancel or a done, free it now. */
- if (ob->sculpt->cache){
+ if (ob->sculpt->cache) {
sculpt_cache_free(ob->sculpt->cache);
ob->sculpt->cache = NULL;
}
@@ -1878,7 +1872,7 @@ struct WPaintData {
struct WeightPaintGroupData active, mirror;
void *vp_handle;
- struct DMCoNo *vertexcosnos;
+ DMCoNo *vertexcosnos;
float wpimat[3][3];
@@ -1893,7 +1887,7 @@ struct WPaintData {
/* variables for blur */
struct {
- struct MeshElemMap *vmap;
+ MeshElemMap *vmap;
int *vmap_mem;
} blur_data;
@@ -1977,7 +1971,8 @@ static bool wpaint_ensure_data(
}
/* Initialize the stroke cache invariants from operator properties */
-static void vwpaint_update_cache_invariants(bContext *C, VPaint *vd, SculptSession *ss, wmOperator *op, const float mouse[2])
+static void vwpaint_update_cache_invariants(
+ bContext *C, VPaint *vd, SculptSession *ss, wmOperator *op, const float mouse[2])
{
StrokeCache *cache;
Scene *scene = CTX_data_scene(C);
@@ -1986,7 +1981,7 @@ static void vwpaint_update_cache_invariants(bContext *C, VPaint *vd, SculptSessi
ViewContext *vc = paint_stroke_view_context(op->customdata);
Object *ob = CTX_data_active_object(C);
float mat[3][3];
- float viewDir[3] = { 0.0f, 0.0f, 1.0f };
+ float view_dir[3] = {0.0f, 0.0f, 1.0f};
int mode;
/* VW paint needs to allocate stroke cache before update is called. */
@@ -2023,10 +2018,10 @@ static void vwpaint_update_cache_invariants(bContext *C, VPaint *vd, SculptSessi
invert_m4_m4(ob->imat, ob->obmat);
copy_m3_m4(mat, cache->vc->rv3d->viewinv);
- mul_m3_v3(mat, viewDir);
+ mul_m3_v3(mat, view_dir);
copy_m3_m4(mat, ob->imat);
- mul_m3_v3(mat, viewDir);
- normalize_v3_v3(cache->true_view_normal, viewDir);
+ mul_m3_v3(mat, view_dir);
+ normalize_v3_v3(cache->true_view_normal, view_dir);
copy_v3_v3(cache->view_normal, cache->true_view_normal);
cache->bstrength = BKE_brush_alpha_get(scene, brush);
@@ -2043,8 +2038,7 @@ static void vwpaint_update_cache_variants(bContext *C, VPaint *vd, Object *ob, P
/* This effects the actual brush radius, so things farther away */
/* are compared with a larger radius and vise versa. */
- if (cache->first_time)
- {
+ if (cache->first_time) {
RNA_float_get_array(ptr, "location", cache->true_location);
}
@@ -2062,10 +2056,8 @@ static void vwpaint_update_cache_variants(bContext *C, VPaint *vd, Object *ob, P
/* Truly temporary data that isn't stored in properties */
if (cache->first_time) {
if (!BKE_brush_use_locked_size(scene, brush)) {
- cache->initial_radius = paint_calc_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list