diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-05-31 15:51:19 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-05-31 15:55:15 +0300 |
commit | d8dbd49a2f23b7637f05fc058f39bdf6ab706624 (patch) | |
tree | 0805b9372c82ae6505d87e879824efe1d3e32f8e /source/blender/freestyle/intern/blender_interface | |
parent | 8987f7987d8160e1f6e79e8c85d6ce65b885ab25 (diff) |
Cleanup: style, use braces in source/
Automated using clang-tidy.
Diffstat (limited to 'source/blender/freestyle/intern/blender_interface')
3 files changed, 114 insertions, 57 deletions
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp index e9d81ef479b..a770251c1fe 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp @@ -156,16 +156,20 @@ int BlenderFileLoader::countClippedFaces(float v1[3], float v2[3], float v3[3], numTris = 2; // tetragon break; case 2: - if (sum == 0) + if (sum == 0) { numTris = 3; // pentagon - else + } + else { numTris = 1; // triangle + } break; case 3: - if (sum == 3 || sum == -3) + if (sum == 3 || sum == -3) { numTris = 0; - else + } + else { numTris = 2; // tetragon + } break; } return numTris; @@ -188,8 +192,9 @@ void BlenderFileLoader::clipLine(float v1[3], float v2[3], float c[3], float z) q = v1; } double d[3]; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { d[i] = q[i] - p[i]; + } double t = (z - p[2]) / d[2]; c[0] = p[0] + t * d[0]; c[1] = p[1] + t * d[1]; @@ -303,11 +308,13 @@ void BlenderFileLoader::addTriangle(struct LoaderState *ls, // update the bounding box for (j = 0; j < 3; j++) { - if (ls->minBBox[j] > ls->pv[j]) + if (ls->minBBox[j] > ls->pv[j]) { ls->minBBox[j] = ls->pv[j]; + } - if (ls->maxBBox[j] < ls->pv[j]) + if (ls->maxBBox[j] < ls->pv[j]) { ls->maxBBox[j] = ls->pv[j]; + } } #if 0 @@ -329,14 +336,18 @@ void BlenderFileLoader::addTriangle(struct LoaderState *ls, ls->pmi++; } - if (fm) + if (fm) { marks |= IndexedFaceSet::FACE_MARK; - if (em1) + } + if (em1) { marks |= IndexedFaceSet::EDGE_MARK_V1V2; - if (em2) + } + if (em2) { marks |= IndexedFaceSet::EDGE_MARK_V2V3; - if (em3) + } + if (em3) { marks |= IndexedFaceSet::EDGE_MARK_V3V1; + } *(ls->pm++) = marks; } @@ -543,8 +554,9 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id) } unsigned int numTris = countClippedFaces(v1, v2, v3, clip); - if (numTris == 0) + if (numTris == 0) { continue; + } bool fm = (ffa) ? (ffa[lt->poly].flag & FREESTYLE_FACE_MARK) != 0 : false; bool em1 = false, em2 = false, em3 = false; @@ -688,8 +700,9 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id) detri.v = zero; detri.n = 0; for (unsigned int j = 0; j < viSize; j += 3) { - if (i == j) + if (i == j) { continue; + } vi0 = cleanVIndices[j]; vi1 = cleanVIndices[j + 1]; vi2 = cleanVIndices[j + 2]; diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index 8a3cdd575fe..72a5e1fa273 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -219,8 +219,9 @@ float BlenderStrokeRenderer::get_stroke_vertex_z(void) const { float z = _z; BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this); - if (!(_z < _z_delta * 100000.0f)) + if (!(_z < _z_delta * 100000.0f)) { self->_z_delta *= 10.0f; + } self->_z += _z_delta; return -z; } @@ -472,8 +473,9 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const // count visible faces and strip segments test_strip_visibility(strip_vertices, &visible_faces, &visible_segments); - if (visible_faces == 0) + if (visible_faces == 0) { continue; + } totvert += visible_faces + visible_segments * 2; totedge += visible_faces * 2 + visible_segments; @@ -509,14 +511,18 @@ bool BlenderStrokeRenderer::test_triangle_visibility(StrokeVertexRep *svRep[3]) xl = xu = yl = yu = 0; for (int i = 0; i < 3; i++) { p = svRep[i]->point2d(); - if (p[0] < 0.0) + if (p[0] < 0.0) { xl++; - else if (p[0] > _width) + } + else if (p[0] > _width) { xu++; - if (p[1] < 0.0) + } + if (p[1] < 0.0) { yl++; - else if (p[1] > _height) + } + else if (p[1] > _height) { yu++; + } } return !(xl == 3 || xu == 3 || yl == 3 || yu == 3); } @@ -545,8 +551,9 @@ void BlenderStrokeRenderer::test_strip_visibility(Strip::vertex_container &strip svRep[2] = *(v[2]); if (test_triangle_visibility(svRep)) { (*visible_faces)++; - if (!visible) + if (!visible) { (*visible_segments)++; + } visible = true; } else { @@ -671,8 +678,9 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex) // count visible faces and strip segments test_strip_visibility(strip_vertices, &visible_faces, &visible_segments); - if (visible_faces == 0) + if (visible_faces == 0) { continue; + } v[0] = strip_vertices.begin(); v[1] = v[0] + 1; @@ -869,8 +877,9 @@ Object *BlenderStrokeRenderer::NewMesh() const Render *BlenderStrokeRenderer::RenderScene(Render * /*re*/, bool render) { Camera *camera = (Camera *)freestyle_scene->camera->data; - if (camera->clip_end < _z) + if (camera->clip_end < _z) { camera->clip_end = _z + _z_delta * 100.0f; + } #if 0 if (G.debug & G_DEBUG_FREESTYLE) { cout << "clip_start " << camera->clip_start << ", clip_end " << camera->clip_end << endl; diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 7ef3e23d379..bcf87f81c71 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -99,8 +99,9 @@ static bCallbackFuncStore load_post_callback_funcstore = { void FRS_initialize() { - if (freestyle_is_initialized) + if (freestyle_is_initialized) { return; + } pathconfig = new Config::Path; controller = new Controller(); @@ -166,9 +167,10 @@ static void init_view(Render *re) cout << "\n=== Dimensions of the 2D image coordinate system ===" << endl; cout << "Width : " << width << endl; cout << "Height : " << height << endl; - if (re->r.mode & R_BORDER) + if (re->r.mode & R_BORDER) { cout << "Border : (" << xmin << ", " << ymin << ") - (" << xmax << ", " << ymax << ")" << endl; + } cout << "Unit line thickness : " << thickness << " pixel(s)" << endl; } } @@ -196,8 +198,9 @@ static char *escape_quotes(char *name) char *s = (char *)MEM_mallocN(strlen(name) * 2 + 1, "escape_quotes"); char *p = s; while (*name) { - if (*name == '\'') + if (*name == '\'') { *(p++) = '\\'; + } *(p++) = *(name++); } *p = '\0'; @@ -231,54 +234,71 @@ static bool test_edge_type_conditions(struct edge_type_condition *conditions, int num_non_target_negative_conditions = 0; for (int i = 0; i < num_edge_types; i++) { - if (conditions[i].edge_type == target) + if (conditions[i].edge_type == target) { target_condition = conditions[i].value; - else if (conditions[i].value > 0) + } + else if (conditions[i].value > 0) { ++num_non_target_positive_conditions; - else if (conditions[i].value < 0) + } + else if (conditions[i].value < 0) { ++num_non_target_negative_conditions; + } } if (distinct) { // In this case, the 'target' edge type is assumed to appear on distinct edge // of its own and never together with other edge types. if (logical_and) { - if (num_non_target_positive_conditions > 0) + if (num_non_target_positive_conditions > 0) { return false; - if (target_condition > 0) + } + if (target_condition > 0) { return true; - if (target_condition < 0) + } + if (target_condition < 0) { return false; - if (num_non_target_negative_conditions > 0) + } + if (num_non_target_negative_conditions > 0) { return true; + } } else { - if (target_condition > 0) + if (target_condition > 0) { return true; - if (num_non_target_negative_conditions > 0) + } + if (num_non_target_negative_conditions > 0) { return true; - if (target_condition < 0) + } + if (target_condition < 0) { return false; - if (num_non_target_positive_conditions > 0) + } + if (num_non_target_positive_conditions > 0) { return false; + } } } else { // In this case, the 'target' edge type may appear together with other edge types. - if (target_condition > 0) + if (target_condition > 0) { return true; - if (target_condition < 0) + } + if (target_condition < 0) { return true; + } if (logical_and) { - if (num_non_target_positive_conditions > 0) + if (num_non_target_positive_conditions > 0) { return false; - if (num_non_target_negative_conditions > 0) + } + if (num_non_target_negative_conditions > 0) { return true; + } } else { - if (num_non_target_negative_conditions > 0) + if (num_non_target_negative_conditions > 0) { return true; - if (num_non_target_positive_conditions > 0) + } + if (num_non_target_positive_conditions > 0) { return false; + } } } return true; @@ -291,10 +311,12 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) re->stats_draw(re->sdh, &re->i); re->i.infostr = NULL; if (controller->LoadMesh( - re, view_layer, depsgraph)) // returns if scene cannot be loaded or if empty + re, view_layer, depsgraph)) { // returns if scene cannot be loaded or if empty return; - if (re->test_break(re->tbh)) + } + if (re->test_break(re->tbh)) { return; + } // add style modules FreestyleConfig *config = &view_layer->freestyle_config; @@ -316,8 +338,9 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) const char *id_name = module_conf->script->id.name + 2; if (G.debug & G_DEBUG_FREESTYLE) { cout << " " << layer_count + 1 << ": " << id_name; - if (module_conf->script->name) + if (module_conf->script->name) { cout << " (" << module_conf->script->name << ")"; + } cout << endl; } controller->InsertStyleModule(layer_count, id_name, module_conf->script); @@ -373,12 +396,15 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) else { // conditions for feature edge selection by edge types for (int i = 0; i < num_edge_types; i++) { - if (!(lineset->edge_types & conditions[i].edge_type)) + if (!(lineset->edge_types & conditions[i].edge_type)) { conditions[i].value = 0; // no condition specified - else if (!(lineset->exclude_edge_types & conditions[i].edge_type)) + } + else if (!(lineset->exclude_edge_types & conditions[i].edge_type)) { conditions[i].value = 1; // condition: X - else + } + else { conditions[i].value = -1; // condition: NOT X + } } // logical operator for the selection conditions bool logical_and = ((lineset->flags & FREESTYLE_LINESET_FE_AND) != 0); @@ -388,8 +414,9 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) // Inclusive equivalent using De Morgan's laws: // - NOT (X OR Y) --> (NOT X) AND (NOT Y) // - NOT (X AND Y) --> (NOT X) OR (NOT Y) - for (int i = 0; i < num_edge_types; i++) + for (int i = 0; i < num_edge_types; i++) { conditions[i].value *= -1; + } logical_and = !logical_and; } if (test_edge_type_conditions( @@ -470,8 +497,9 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) cout << " Z = " << (z ? "enabled" : "disabled") << endl; } - if (controller->hitViewMapCache()) + if (controller->hitViewMapCache()) { return; + } // compute view map re->i.infostr = IFACE_("Freestyle: View map creation"); @@ -486,8 +514,9 @@ void FRS_composite_result(Render *re, ViewLayer *view_layer, Render *freestyle_r float *src, *dest, *pixSrc, *pixDest; int x, y, rectx, recty; - if (freestyle_render == NULL || freestyle_render->result == NULL) + if (freestyle_render == NULL || freestyle_render->result == NULL) { return; + } rl = render_get_active_layer(freestyle_render, freestyle_render->result); if (!rl) { @@ -553,8 +582,9 @@ static int displayed_layer_count(ViewLayer *view_layer) (FreestyleModuleConfig *)view_layer->freestyle_config.modules.first; module; module = module->next) { - if (module->script && module->is_displayed) + if (module->script && module->is_displayed) { count++; + } } break; case FREESTYLE_CONTROL_EDITOR_MODE: @@ -562,8 +592,9 @@ static int displayed_layer_count(ViewLayer *view_layer) (FreestyleLineSet *)view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) { - if (lineset->flags & FREESTYLE_LINESET_ENABLED) + if (lineset->flags & FREESTYLE_LINESET_ENABLED) { count++; + } } break; } @@ -599,8 +630,9 @@ Render *FRS_do_stroke_rendering(Render *re, ViewLayer *view_layer, int render) { Render *freestyle_render = NULL; - if (!render) + if (!render) { return controller->RenderStrokes(re, false); + } RenderMonitor monitor(re); controller->setRenderMonitor(&monitor); @@ -704,17 +736,20 @@ void FRS_copy_active_lineset(FreestyleConfig *config) void FRS_paste_active_lineset(FreestyleConfig *config) { - if (!lineset_copied) + if (!lineset_copied) { return; + } FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(config); if (lineset) { - if (lineset->linestyle) + if (lineset->linestyle) { id_us_min(&lineset->linestyle->id); + } lineset->linestyle = lineset_buffer.linestyle; - if (lineset->linestyle) + if (lineset->linestyle) { id_us_plus(&lineset->linestyle->id); + } lineset->flags = lineset_buffer.flags; lineset->selection = lineset_buffer.selection; lineset->qi = lineset_buffer.qi; |