Commit: ae6f74e84165be13a0875549f020860a22516ece
Author: Campbell Barton
Date:   Sat Jul 12 20:43:20 2014 +1000
https://developer.blender.org/rBae6f74e84165be13a0875549f020860a22516ece

Misc code cleanup

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

M       source/blender/editors/sculpt_paint/paint_image_proj.c
M       source/blender/editors/sculpt_paint/paint_stroke.c
M       source/blender/editors/sculpt_paint/paint_utils.c
M       source/blender/gpu/intern/gpu_buffers.c
M       source/blender/makesdna/DNA_scene_types.h
M       source/blender/makesrna/intern/rna_brush.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c 
b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 5e68875..7442bce 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -517,8 +517,8 @@ static int project_paint_PickFace(const ProjPaintState *ps, 
const float pt[2], f
 static void uvco_to_wrapped_pxco(const float uv[2], int ibuf_x, int ibuf_y, 
float *x, float *y)
 {
        /* use */
-       *x = (float)fmodf(uv[0], 1.0f);
-       *y = (float)fmodf(uv[1], 1.0f);
+       *x = fmodf(uv[0], 1.0f);
+       *y = fmodf(uv[1], 1.0f);
 
        if (*x < 0.0f) *x += 1.0f;
        if (*y < 0.0f) *y += 1.0f;
@@ -803,11 +803,11 @@ static int line_isect_x(const float p1[2], const float 
p2[2], const float x_leve
 static bool cmp_uv(const float vec2a[2], const float vec2b[2])
 {
        /* if the UV's are not between 0.0 and 1.0 */
-       float xa = (float)fmodf(vec2a[0], 1.0f);
-       float ya = (float)fmodf(vec2a[1], 1.0f);
+       float xa = fmodf(vec2a[0], 1.0f);
+       float ya = fmodf(vec2a[1], 1.0f);
 
-       float xb = (float)fmodf(vec2b[0], 1.0f);
-       float yb = (float)fmodf(vec2b[1], 1.0f);
+       float xb = fmodf(vec2b[0], 1.0f);
+       float yb = fmodf(vec2b[1], 1.0f);
 
        if (xa < 0.0f) xa += 1.0f;
        if (ya < 0.0f) ya += 1.0f;
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c 
b/source/blender/editors/sculpt_paint/paint_stroke.c
index 1041144..773b428 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -678,9 +678,7 @@ PaintStroke *paint_stroke_new(bContext *C,
 void paint_stroke_data_free(struct wmOperator *op)
 {
        BKE_paint_set_overlay_override(0);
-       if (op->customdata)
-               MEM_freeN(op->customdata);
-       op->customdata = NULL;
+       MEM_SAFE_FREE(op->customdata);
 }
 
 static void stroke_done(struct bContext *C, struct wmOperator *op)
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c 
b/source/blender/editors/sculpt_paint/paint_utils.c
index 03c5c76..eaa4885 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -239,8 +239,8 @@ static void imapaint_tri_weights(float matrix[4][4], GLint 
view[4],
        imapaint_project(matrix, v3, pv3);
 
        /* do inverse view mapping, see gluProject man page */
-       h[0] = (co[0] - view[0]) * 2.0f / view[2] - 1;
-       h[1] = (co[1] - view[1]) * 2.0f / view[3] - 1;
+       h[0] = (co[0] - view[0]) * 2.0f / view[2] - 1.0f;
+       h[1] = (co[1] - view[1]) * 2.0f / view[3] - 1.0f;
        h[2] = 1.0f;
 
        /* solve for (w1,w2,w3)/perspdiv in:
@@ -355,19 +355,19 @@ static void imapaint_pick_uv(Scene *scene, Object *ob, 
unsigned int faceindex, c
 }
 
 /* returns 0 if not found, otherwise 1 */
-static int imapaint_pick_face(ViewContext *vc, const int mval[2], unsigned int 
*index, unsigned int totface)
+static int imapaint_pick_face(ViewContext *vc, const int mval[2], unsigned int 
*r_index, unsigned int totface)
 {
        if (totface == 0)
                return 0;
 
        /* sample only on the exact position */
-       *index = view3d_sample_backbuf(vc, mval[0], mval[1]);
+       *r_index = view3d_sample_backbuf(vc, mval[0], mval[1]);
 
-       if ((*index) == 0 || (*index) > (unsigned int)totface) {
+       if ((*r_index) == 0 || (*r_index) > (unsigned int)totface) {
                return 0;
        }
 
-       (*index)--;
+       (*r_index)--;
 
        return 1;
 }
@@ -455,8 +455,8 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, 
int y, bool texpaint_pr
                                                imapaint_pick_uv(scene, ob, 
faceindex, mval, uv);
                                                sample_success = true;
 
-                                               u = (float)fmodf(uv[0], 1.0f);
-                                               v = (float)fmodf(uv[1], 1.0f);
+                                               u = fmodf(uv[0], 1.0f);
+                                               v = fmodf(uv[1], 1.0f);
 
                                                if (u < 0.0f) u += 1.0f;
                                                if (v < 0.0f) v += 1.0f;
@@ -468,8 +468,9 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, 
int y, bool texpaint_pr
                                                        float rgba_f[4];
                                                        
bilinear_interpolation_color_wrap(ibuf, NULL, rgba_f, u, v);
                                                        
straight_to_premul_v4(rgba_f);
-                                                       if (use_palette)
+                                                       if (use_palette) {
                                                                
linearrgb_to_srgb_v3_v3(color->rgb, rgba_f);
+                                                       }
                                                        else {
                                                                
linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);
                                                                
BKE_brush_color_set(scene, br, rgba_f);
@@ -478,8 +479,9 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, 
int y, bool texpaint_pr
                                                else {
                                                        unsigned char rgba[4];
                                                        
bilinear_interpolation_color_wrap(ibuf, rgba, NULL, u, v);
-                                                       if (use_palette)
+                                                       if (use_palette) {
                                                                
rgb_uchar_to_float(color->rgb, rgba);
+                                                       }
                                                        else {
                                                                float rgba_f[3];
                                                                
rgb_uchar_to_float(rgba_f, rgba);
@@ -509,8 +511,9 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, 
int y, bool texpaint_pr
        }
        cp = (unsigned char *)&col;
        
-       if (use_palette)
+       if (use_palette) {
                rgb_uchar_to_float(color->rgb, cp);
+       }
        else {
                float rgba_f[3];
                rgb_uchar_to_float(rgba_f, cp);
diff --git a/source/blender/gpu/intern/gpu_buffers.c 
b/source/blender/gpu/intern/gpu_buffers.c
index ea25324..0cd4635 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -851,11 +851,11 @@ static void GPU_buffer_copy_uv_texpaint(DerivedMesh *dm, 
float *varray, int *ind
        MTFace **mtface_base;
        MTFace *stencil_base;
        int stencil;
-       MFace *f;
+       MFace *mf;
 
        /* should have been checked for before, reassert */
        BLI_assert(DM_get_tessface_data_layer(dm, CD_MTFACE));
-       f = dm->getTessFaceArray(dm);
+       mf = dm->getTessFaceArray(dm);
        mtface_base = MEM_mallocN(totmaterial * sizeof(*mtface_base), 
"texslots");
 
        for (i = 0; i < totmaterial; i++) {
@@ -867,8 +867,8 @@ static void GPU_buffer_copy_uv_texpaint(DerivedMesh *dm, 
float *varray, int *ind
 
        totface = dm->getNumTessFaces(dm);
 
-       for (i = 0; i < totface; i++, f++) {
-               int mat_i = f->mat_nr;
+       for (i = 0; i < totface; i++, mf++) {
+               int mat_i = mf->mat_nr;
                start = index[mat_orig_to_new[mat_i]];
 
                /* v1 v2 v3 */
@@ -880,7 +880,7 @@ static void GPU_buffer_copy_uv_texpaint(DerivedMesh *dm, 
float *varray, int *ind
                copy_v2_v2(&varray[start + 10], stencil_base[i].uv[2]);
                index[mat_orig_to_new[mat_i]] += 12;
 
-               if (f->v4) {
+               if (mf->v4) {
                        /* v3 v4 v1 */
                        copy_v2_v2(&varray[start + 12], 
mtface_base[mat_i][i].uv[2]);
                        copy_v2_v2(&varray[start + 14], stencil_base[i].uv[2]);
diff --git a/source/blender/makesdna/DNA_scene_types.h 
b/source/blender/makesdna/DNA_scene_types.h
index 7489230..a6cb5b6 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -996,8 +996,8 @@ typedef struct UnifiedPaintSettings {
        int draw_anchored;
        int anchored_size;
 
-       int draw_inverted;
-       int pad3;
+       char draw_inverted;
+       char pad3[7];
 
        float overlap_factor; /* normalization factor due to accumulated value 
of curve along spacing.
                               * Calculated when brush spacing changes to 
dampen strength of stroke
diff --git a/source/blender/makesrna/intern/rna_brush.c 
b/source/blender/makesrna/intern/rna_brush.c
index c4156c3..d8ec695 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -731,12 +731,12 @@ static void rna_def_image_paint_capabilities(BlenderRNA 
*brna)
                               "Read-only indications of which brush operations 
"
                               "are supported by the current image paint 
brush");
 
-#define IMAPAINT_TOOL_CAPABILITY(prop_name_, ui_name_)                         
 \
-       prop = RNA_def_property(srna, #prop_name_,                          \
-                               PROP_BOOLEAN, PROP_NONE);                   \
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);                   \
-       RNA_def_property_boolean_funcs(prop, "rna_ImapaintToolCapabilities_"    
  \
-                                      #prop_name_ "_get", NULL);           \
+#define IMAPAINT_TOOL_CAPABILITY(prop_name_, ui_name_)                       \
+       prop = RNA_def_property(srna, #prop_name_,                              
 \
+                               PROP_BOOLEAN, PROP_NONE);                       
 \
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);                       
 \
+       RNA_def_property_boolean_funcs(prop, "rna_ImapaintToolCapabilities_"    
 \
+                                      #prop_name_ "_get", NULL);               
 \
        RNA_def_property_ui_text(prop, ui_name_, NULL)
 
        IMAPAINT_TOOL_CAPABILITY(has_accumulate, "Has Accumulate");

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

Reply via email to