From 6b0d1ef7e118f679fb5dacac184a7e72fef6142e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 13 Sep 2019 16:18:18 +0200 Subject: Cleanup: compiler warnings --- source/blender/blenfont/intern/blf_font.c | 7 +++++-- source/blender/editors/sculpt_paint/paint_stroke.c | 23 +++++++++++++--------- source/blender/gpu/intern/gpu_buffers.c | 14 +++++++++---- 3 files changed, 29 insertions(+), 15 deletions(-) (limited to 'source') diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 1369240f0e2..d75da6a126f 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -312,6 +312,9 @@ static void blf_font_ensure_ascii_kerning(FontBLF *font, const FT_UInt kern_mode _g = blf_glyph_add(_font, FT_Get_Char_Index((_font)->face, _c), _c); \ } \ } \ + else { \ + _g = NULL; \ + } \ (void)0 #define BLF_KERNING_VARS(_font, _has_kerning, _kern_mode) \ @@ -677,7 +680,7 @@ static bool blf_font_width_to_strlen_glyph_process(FontBLF *font, size_t blf_font_width_to_strlen( FontBLF *font, const char *str, size_t len, float width, float *r_width) { - unsigned int c, c_prev; + unsigned int c, c_prev = BLI_UTF8_ERR; GlyphBLF *g, *g_prev; int pen_x, width_new; size_t i, i_prev; @@ -711,7 +714,7 @@ size_t blf_font_width_to_strlen( size_t blf_font_width_to_rstrlen( FontBLF *font, const char *str, size_t len, float width, float *r_width) { - unsigned int c, c_prev; + unsigned int c, c_prev = BLI_UTF8_ERR; GlyphBLF *g, *g_prev; int pen_x, width_new; size_t i, i_prev, i_tmp; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index d2173ed0d96..c764933fcf0 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -775,17 +775,19 @@ static int paint_space_stroke(bContext *C, Brush *brush = BKE_paint_brush(paint); int cnt = 0; - float pressure, dpressure; - float mouse[2], dmouse[2]; - float world_space_position[3], d_world_space_position[3], final_world_space_position[3]; - float length; + const bool use_scene_spacing = paint_stroke_use_scene_spacing(brush, mode); + float d_world_space_position[3] = {0.0f}; + float no_pressure_spacing = paint_space_stroke_spacing(C, scene, stroke, 1.0f, 1.0f); - pressure = stroke->last_pressure; - dpressure = final_pressure - stroke->last_pressure; + float pressure = stroke->last_pressure; + float dpressure = final_pressure - stroke->last_pressure; + + float dmouse[2]; sub_v2_v2v2(dmouse, final_mouse, stroke->last_mouse_position); - length = normalize_v2(dmouse); + float length = normalize_v2(dmouse); - if (paint_stroke_use_scene_spacing(brush, mode)) { + if (use_scene_spacing) { + float world_space_position[3]; bool hit = sculpt_stroke_get_location(C, world_space_position, final_mouse); mul_m4_v3(stroke->vc.obact->obmat, world_space_position); if (hit && stroke->stroke_over_mesh) { @@ -795,6 +797,7 @@ static int paint_space_stroke(bContext *C, } else { length = 0.0f; + zero_v3(d_world_space_position); stroke->stroke_over_mesh = hit; if (stroke->stroke_over_mesh) { copy_v3_v3(stroke->last_world_space_position, world_space_position); @@ -805,9 +808,11 @@ static int paint_space_stroke(bContext *C, while (length > 0.0f) { float spacing = paint_space_stroke_spacing_variable( C, scene, stroke, pressure, dpressure, length); + float mouse[2]; if (length >= spacing) { - if (paint_stroke_use_scene_spacing(brush, mode)) { + if (use_scene_spacing) { + float final_world_space_position[3]; normalize_v3(d_world_space_position); mul_v3_v3fl(final_world_space_position, d_world_space_position, spacing); add_v3_v3v3(final_world_space_position, diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index add3a154c93..12ed8d4de70 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -452,7 +452,10 @@ static void gpu_pbvh_grid_fill_index_buffers( } grid_visible = true; } - GPU_indexbuf_add_line_verts(&elb_lines, v1, v2); + + if (grid_visible) { + GPU_indexbuf_add_line_verts(&elb_lines, v1, v2); + } } if (grid_visible) { @@ -504,7 +507,10 @@ static void gpu_pbvh_grid_fill_index_buffers( } grid_visible = true; } - GPU_indexbuf_add_line_verts(&elb_lines, v1, v2); + + if (grid_visible) { + GPU_indexbuf_add_line_verts(&elb_lines, v1, v2); + } } if (grid_visible) { @@ -803,7 +809,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers, const bool show_vcol = (update_flags & GPU_PBVH_BUFFERS_SHOW_VCOL) != 0; int tottri, totvert, maxvert = 0; bool empty_mask = true; - BMFace *f; + BMFace *f = NULL; /* Count visible triangles */ tottri = gpu_bmesh_face_visible_count(bm_faces); @@ -972,7 +978,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers, } /* Get material index from the last face we iterated on. */ - buffers->material_index = f->mat_nr; + buffers->material_index = (f) ? f->mat_nr : 0; buffers->show_mask = !empty_mask; -- cgit v1.2.3