diff --git a/.clang-tidy b/.clang-tidy index 7d8d4e9c3c0..acfaf05a2da 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,7 +5,6 @@ Checks: > -readability-magic-numbers, -readability-isolate-declaration, -readability-convert-member-functions-to-static, - -readability-implicit-bool-conversion, -readability-avoid-const-params-in-decls, -readability-simplify-boolean-expr, -readability-make-member-function-const, @@ -49,5 +48,8 @@ Checks: > -bugprone-parent-virtual-call, -bugprone-infinite-loop, -bugprone-copy-constructor-init, - -WarningsAsErrors: '*' +CheckOptions: + - key: readability-implicit-bool-conversion.AllowPointerConditions + value: 1 + - key: readability-implicit-bool-conversion.AllowIntegerConditions + value: 1 diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 88c19355960..58f2a6bdfde 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -29,7 +29,7 @@ if(WITH_CLANG_TIDY) find_package(ClangTidy REQUIRED) set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY_EXECUTABLE}) - set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXECUTABLE}) + set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXECUTABLE} "-fix-errors") endif() add_subdirectory(blender) diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index e5dfee7d0cd..fdcf3a69c82 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -43,7 +43,7 @@ ExecutionGroup::ExecutionGroup() { - this->m_isOutput = false; + this->m_isOutput = 0; this->m_complex = false; this->m_chunkExecutionStates = NULL; this->m_bTree = NULL; @@ -104,7 +104,7 @@ bool ExecutionGroup::addOperation(NodeOperation *operation) if (!operation->isReadBufferOperation() && !operation->isWriteBufferOperation()) { m_complex = operation->isComplex(); m_openCL = operation->isOpenCL(); - m_singleThreaded = operation->isSingleThreaded(); + m_singleThreaded = (operation->isSingleThreaded() != 0); m_initialized = true; } diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 34682aae2fd..8b42e778671 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -60,7 +60,7 @@ ExecutionSystem::ExecutionSystem(RenderData *rd, } this->m_context.setRendering(rendering); this->m_context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() && - (editingtree->flag & NTREE_COM_OPENCL)); + ((editingtree->flag & NTREE_COM_OPENCL) != 0)); this->m_context.setRenderData(rd); this->m_context.setViewSettings(viewSettings); @@ -75,7 +75,7 @@ ExecutionSystem::ExecutionSystem(RenderData *rd, unsigned int resolution[2]; rctf *viewer_border = &editingtree->viewer_border; - bool use_viewer_border = (editingtree->flag & NTREE_VIEWER_BORDER) && + bool use_viewer_border = ((editingtree->flag & NTREE_VIEWER_BORDER) != 0) && viewer_border->xmin < viewer_border->xmax && viewer_border->ymin < viewer_border->ymax; diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp index 53a6d115e97..a6cbeace3e0 100644 --- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp +++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp @@ -393,7 +393,7 @@ void NodeOperationBuilder::resolve_proxies() do { /* walk upstream bypassing the proxy operation */ from = from->getOperation().getInputSocket(0)->getLink(); - } while (from && from->getOperation().isProxyOperation()); + } while ((from != nullptr) && from->getOperation().isProxyOperation()); removeInputLink(to); /* we may not have a final proxy input link, @@ -720,7 +720,7 @@ void NodeOperationBuilder::group_operations() if (op->isOutputOperation(m_context->isRendering())) { ExecutionGroup *group = make_group(op); - group->setOutputExecutionGroup(true); + group->setOutputExecutionGroup(1); } /* add new groups for associated memory proxies where needed */ diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index bccdd026ead..8596f079ac4 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -74,7 +74,7 @@ void COM_execute(RenderData *rd, preview_width = (int)(COM_PREVIEW_SIZE / aspect); preview_height = COM_PREVIEW_SIZE; } - BKE_node_preview_init_tree(editingtree, preview_width, preview_height, false); + BKE_node_preview_init_tree(editingtree, preview_width, preview_height, 0); /* initialize workscheduler, will check if already done. TODO deinitialize somewhere */ bool use_opencl = (editingtree->flag & NTREE_COM_OPENCL) != 0; @@ -84,11 +84,11 @@ void COM_execute(RenderData *rd, editingtree->progress(editingtree->prh, 0.0); editingtree->stats_draw(editingtree->sdh, IFACE_("Compositing")); - bool twopass = (editingtree->flag & NTREE_TWO_PASS) && !rendering; + bool twopass = ((editingtree->flag & NTREE_TWO_PASS) != 0) && (rendering == 0); /* initialize execution system */ if (twopass) { ExecutionSystem *system = new ExecutionSystem( - rd, scene, editingtree, rendering, twopass, viewSettings, displaySettings, viewName); + rd, scene, editingtree, rendering != 0, twopass, viewSettings, displaySettings, viewName); system->execute(); delete system; @@ -101,7 +101,7 @@ void COM_execute(RenderData *rd, } ExecutionSystem *system = new ExecutionSystem( - rd, scene, editingtree, rendering, false, viewSettings, displaySettings, viewName); + rd, scene, editingtree, rendering != 0, false, viewSettings, displaySettings, viewName); system->execute(); delete system; diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp index 32ac1fccec9..31ec0ad7618 100644 --- a/source/blender/compositor/nodes/COM_CompositorNode.cpp +++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp @@ -29,7 +29,7 @@ void CompositorNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { bNode *editorNode = this->getbNode(); - bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC) || context.isRendering(); + bool is_active = ((editorNode->flag & NODE_DO_OUTPUT_RECALC) != 0) || context.isRendering(); bool ignore_alpha = (editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0; NodeInput *imageSocket = this->getInputSocket(0); diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp index 907a9f49353..1d4f928826d 100644 --- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp +++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp @@ -32,8 +32,8 @@ void DoubleEdgeMaskNode::convertToOperations(NodeConverter &converter, bNode *bnode = this->getbNode(); operation = new DoubleEdgeMaskOperation(); - operation->setAdjecentOnly(bnode->custom1); - operation->setKeepInside(bnode->custom2); + operation->setAdjecentOnly(bnode->custom1 != 0); + operation->setKeepInside(bnode->custom2 != 0); converter.addOperation(operation); converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_InvertNode.cpp b/source/blender/compositor/nodes/COM_InvertNode.cpp index 913452c42c8..8ef355931a5 100644 --- a/source/blender/compositor/nodes/COM_InvertNode.cpp +++ b/source/blender/compositor/nodes/COM_InvertNode.cpp @@ -31,8 +31,8 @@ void InvertNode::convertToOperations(NodeConverter &converter, { InvertOperation *operation = new InvertOperation(); bNode *node = this->getbNode(); - operation->setColor(node->custom1 & CMP_CHAN_RGB); - operation->setAlpha(node->custom1 & CMP_CHAN_A); + operation->setColor((node->custom1 & CMP_CHAN_RGB) != 0); + operation->setAlpha((node->custom1 & CMP_CHAN_A) != 0); converter.addOperation(operation); converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp index 34d2fba6433..cc3ef543c65 100644 --- a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp +++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp @@ -41,8 +41,8 @@ void LensDistortionNode::convertToOperations(NodeConverter &converter, } else { ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation(); - operation->setFit(data->fit); - operation->setJitter(data->jit); + operation->setFit(data->fit != 0); + operation->setJitter(data->jit != 0); if (!getInputSocket(1)->isLinked()) { operation->setDistortion(getInputSocket(1)->getEditorValueFloat()); diff --git a/source/blender/compositor/nodes/COM_MapRangeNode.cpp b/source/blender/compositor/nodes/COM_MapRangeNode.cpp index 352bc0dd48d..7d4780ad3b8 100644 --- a/source/blender/compositor/nodes/COM_MapRangeNode.cpp +++ b/source/blender/compositor/nodes/COM_MapRangeNode.cpp @@ -37,7 +37,7 @@ void MapRangeNode::convertToOperations(NodeConverter &converter, NodeOutput *outputSocket = this->getOutputSocket(0); MapRangeOperation *operation = new MapRangeOperation(); - operation->setUseClamp(this->getbNode()->custom1); + operation->setUseClamp(this->getbNode()->custom1 != 0); converter.addOperation(operation); converter.mapInputSocket(valueSocket, operation->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_MaskNode.cpp b/source/blender/compositor/nodes/COM_MaskNode.cpp index b28b849521c..127bcf3fba6 100644 --- a/source/blender/compositor/nodes/COM_MaskNode.cpp +++ b/source/blender/compositor/nodes/COM_MaskNode.cpp @@ -56,7 +56,7 @@ void MaskNode::convertToOperations(NodeConverter &converter, operation->setMask(mask); operation->setFramenumber(context.getFramenumber()); - operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); + operation->setFeather(static_cast((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER)) == 0); if ((editorNode->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) && (editorNode->custom2 > 1) && (editorNode->custom3 > FLT_EPSILON)) { diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp index 227e26af2b2..e679aa844c1 100644 --- a/source/blender/compositor/nodes/COM_MathNode.cpp +++ b/source/blender/compositor/nodes/COM_MathNode.cpp @@ -149,7 +149,7 @@ void MathNode::convertToOperations(NodeConverter &converter, } if (operation) { - bool useClamp = getbNode()->custom2; + bool useClamp = getbNode()->custom2 != 0; operation->setUseClamp(useClamp); converter.addOperation(operation); diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp index 75703876d9e..fc85345a21c 100644 --- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp @@ -34,8 +34,8 @@ void SplitViewerNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { bNode *editorNode = this->getbNode(); - bool do_output = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) && - (editorNode->flag & NODE_DO_OUTPUT); + bool do_output = (((editorNode->flag & NODE_DO_OUTPUT_RECALC) != 0) || context.isRendering()) && + ((editorNode->flag & NODE_DO_OUTPUT) != 0); NodeInput *image1Socket = this->getInputSocket(0); NodeInput *image2Socket = this->getInputSocket(1); @@ -44,7 +44,7 @@ void SplitViewerNode::convertToOperations(NodeConverter &converter, SplitOperation *splitViewerOperation = new SplitOperation(); splitViewerOperation->setSplitPercentage(this->getbNode()->custom1); - splitViewerOperation->setXSplit(!this->getbNode()->custom2); + splitViewerOperation->setXSplit(this->getbNode()->custom2 == 0); converter.addOperation(splitViewerOperation); converter.mapInputSocket(image1Socket, splitViewerOperation->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_SwitchNode.cpp b/source/blender/compositor/nodes/COM_SwitchNode.cpp index 947774e98ae..32cf5d2afe0 100644 --- a/source/blender/compositor/nodes/COM_SwitchNode.cpp +++ b/source/blender/compositor/nodes/COM_SwitchNode.cpp @@ -26,7 +26,7 @@ SwitchNode::SwitchNode(bNode *editorNode) : Node(editorNode) void SwitchNode::convertToOperations(NodeConverter &converter, const CompositorContext & /*context*/) const { - bool condition = this->getbNode()->custom1; + bool condition = this->getbNode()->custom1 != 0; NodeOperationOutput *result; if (!condition) { diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp index fa6c1bc3c28..275af410968 100644 --- a/source/blender/compositor/nodes/COM_ViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp @@ -34,8 +34,8 @@ void ViewerNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { bNode *editorNode = this->getbNode(); - bool do_output = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) && - (editorNode->flag & NODE_DO_OUTPUT); + bool do_output = (((editorNode->flag & NODE_DO_OUTPUT_RECALC) != 0) || context.isRendering()) && + ((editorNode->flag & NODE_DO_OUTPUT) != 0); bool ignore_alpha = (editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0; NodeInput *imageSocket = this->getInputSocket(0); diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index 71cef9dc4da..96244fc731c 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -94,7 +94,7 @@ void CompositorOperation::deinitExecution() MEM_freeN(rv->rectz); } rv->rectz = this->m_depthBuffer; - rr->have_combined = true; + rr->have_combined = 1; } else { if (this->m_outputBuffer) { diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cpp b/source/blender/compositor/operations/COM_DespeckleOperation.cpp index 9b8d72da26d..ab7d3f44f90 100644 --- a/source/blender/compositor/operations/COM_DespeckleOperation.cpp +++ b/source/blender/compositor/operations/COM_DespeckleOperation.cpp @@ -45,7 +45,7 @@ void DespeckleOperation::deinitExecution() BLI_INLINE int color_diff(const float a[3], const float b[3], const float threshold) { - return ((fabsf(a[0] - b[0]) > threshold) || (fabsf(a[1] - b[1]) > threshold) || + return static_cast((fabsf(a[0] - b[0]) > threshold) || (fabsf(a[1] - b[1]) > threshold) || (fabsf(a[2] - b[2]) > threshold)); } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index f5cc5963253..ddb37014a3b 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -498,7 +498,7 @@ void DepsgraphNodeBuilder::build_collection(LayerCollection *from_layer_collecti { const int restrict_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ? COLLECTION_RESTRICT_VIEWPORT : COLLECTION_RESTRICT_RENDER; - const bool is_collection_restricted = (collection->flag & restrict_flag); + const bool is_collection_restricted = (collection->flag & restrict_flag) != 0; const bool is_collection_visible = !is_collection_restricted && is_parent_collection_visible_; IDNode *id_node; if (built_map_.checkIsBuiltAndTag(collection)) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc index ee40fa3f5c8..a23c8c2ce77 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc @@ -32,8 +32,8 @@ void DepsgraphNodeBuilder::build_scene_render(Scene *scene, ViewLayer *view_laye { scene_ = scene; view_layer_ = view_layer; - const bool build_compositor = (scene->r.scemode & R_DOCOMP); - const bool build_sequencer = (scene->r.scemode & R_DOSEQ); + const bool build_compositor = (scene->r.scemode & R_DOCOMP) != 0; + const bool build_sequencer = (scene->r.scemode & R_DOSEQ) != 0; IDNode *id_node = add_id_node(&scene->id); id_node->linked_state = DEG_ID_LINKED_DIRECTLY; add_time_source(); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 50c52a519b4..02fa8d769ea 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1230,7 +1230,7 @@ void DepsgraphRelationBuilder::build_constraints(ID *id, } } if (cti->flush_constraint_targets) { - cti->flush_constraint_targets(con, &targets, 1); + cti->flush_constraint_targets(con, &targets, true); } } } @@ -1452,7 +1452,7 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu) * Bone objects, because the armature data doesn't have per-bone components, * and generic add_relation can only add one link. */ ID *id_ptr = property_entry_key.ptr.owner_id; - bool is_bone = id_ptr && property_entry_key.ptr.type == &RNA_Bone; + bool is_bone = (id_ptr != nullptr) && property_entry_key.ptr.type == &RNA_Bone; /* If the Bone property is referenced via obj.pose.bones[].bone, * the RNA pointer refers to the Object ID, so skip to data. */ if (is_bone && GS(id_ptr->name) == ID_OB) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc index 6ebf5210b63..12094fb97ec 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc @@ -31,8 +31,8 @@ namespace deg { void DepsgraphRelationBuilder::build_scene_render(Scene *scene, ViewLayer *view_layer) { scene_ = scene; - const bool build_compositor = (scene->r.scemode & R_DOCOMP); - const bool build_sequencer = (scene->r.scemode & R_DOSEQ); + const bool build_compositor = (scene->r.scemode & R_DOCOMP) != 0; + const bool build_sequencer = (scene->r.scemode & R_DOSEQ) != 0; build_scene_parameters(scene); build_animdata(&scene->id); build_scene_audio(scene); diff --git a/source/blender/depsgraph/intern/depsgraph_update.cc b/source/blender/depsgraph/intern/depsgraph_update.cc index 98ff136f7bc..02711c6fa77 100644 --- a/source/blender/depsgraph/intern/depsgraph_update.cc +++ b/source/blender/depsgraph/intern/depsgraph_update.cc @@ -45,7 +45,7 @@ void deg_editors_id_update(const DEGEditorUpdateContext *update_ctx, ID *id) void deg_editors_scene_update(const DEGEditorUpdateContext *update_ctx, bool updated) { if (deg_editor_update_scene_cb != nullptr) { - deg_editor_update_scene_cb(update_ctx, updated); + deg_editor_update_scene_cb(update_ctx, static_cast(updated)); } } diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index 68b5b4baeca..f0f7fac105b 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -739,7 +739,7 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex) ++polys; // Even and odd loops connect triangles vertices differently - bool is_odd = n % 2; + bool is_odd = (n % 2) != 0; // loops if (is_odd) { loops[0].v = vertex_index - 1; @@ -770,24 +770,24 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex) // Second UV layer (loopsuv[1]) has tips: (texCoord(1)). for (int L = 0; L < 2; L++) { if (is_odd) { - loopsuv[L][0].uv[0] = svRep[2]->texCoord(L).x(); - loopsuv[L][0].uv[1] = svRep[2]->texCoord(L).y(); + loopsuv[L][0].uv[0] = svRep[2]->texCoord(L != 0).x(); + loopsuv[L][0].uv[1] = svRep[2]->texCoord(L != 0).y(); - loopsuv[L][1].uv[0] = svRep[0]->texCoord(L).x(); - loopsuv[L][1].uv[1] = svRep[0]->texCoord(L).y(); + loopsuv[L][1].uv[0] = svRep[0]->texCoord(L != 0).x(); + loopsuv[L][1].uv[1] = svRep[0]->texCoord(L != 0).y(); - loopsuv[L][2].uv[0] = svRep[1]->texCoord(L).x(); - loopsuv[L][2].uv[1] = svRep[1]->texCoord(L).y(); + loopsuv[L][2].uv[0] = svRep[1]->texCoord(L != 0).x(); + loopsuv[L][2].uv[1] = svRep[1]->texCoord(L != 0).y(); } else { - loopsuv[L][0].uv[0] = svRep[2]->texCoord(L).x(); - loopsuv[L][0].uv[1] = svRep[2]->texCoord(L).y(); + loopsuv[L][0].uv[0] = svRep[2]->texCoord(L != 0).x(); + loopsuv[L][0].uv[1] = svRep[2]->texCoord(L != 0).y(); - loopsuv[L][1].uv[0] = svRep[1]->texCoord(L).x(); - loopsuv[L][1].uv[1] = svRep[1]->texCoord(L).y(); + loopsuv[L][1].uv[0] = svRep[1]->texCoord(L != 0).x(); + loopsuv[L][1].uv[1] = svRep[1]->texCoord(L != 0).y(); - loopsuv[L][2].uv[0] = svRep[0]->texCoord(L).x(); - loopsuv[L][2].uv[1] = svRep[0]->texCoord(L).y(); + loopsuv[L][2].uv[0] = svRep[0]->texCoord(L != 0).x(); + loopsuv[L][2].uv[1] = svRep[0]->texCoord(L != 0).y(); } loopsuv[L] += 3; } @@ -873,7 +873,7 @@ Render *BlenderStrokeRenderer::RenderScene(Render * /*re*/, bool render) DEG_graph_relations_update(freestyle_depsgraph, freestyle_bmain, freestyle_scene, view_layer); RE_RenderFreestyleStrokes( - freestyle_render, freestyle_bmain, freestyle_scene, render && get_stroke_count() > 0); + freestyle_render, freestyle_bmain, freestyle_scene, static_cast(render && get_stroke_count() > 0)); return freestyle_render; } diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 26070a88e5d..895cb0c7929 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -116,7 +116,7 @@ void FRS_initialize() BKE_callback_add(&load_post_callback_funcstore, BKE_CB_EVT_LOAD_POST); - freestyle_is_initialized = 1; + freestyle_is_initialized = true; } void FRS_set_context(bContext *C) @@ -614,7 +614,7 @@ static int displayed_layer_count(ViewLayer *view_layer) int FRS_is_freestyle_enabled(ViewLayer *view_layer) { - return ((view_layer->flag & VIEW_LAYER_RENDER) && (view_layer->flag & VIEW_LAYER_FREESTYLE) && + return static_cast(((view_layer->flag & VIEW_LAYER_RENDER) != 0) && ((view_layer->flag & VIEW_LAYER_FREESTYLE) != 0) && displayed_layer_count(view_layer) > 0); } diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.cpp b/source/blender/freestyle/intern/geometry/GeomUtils.cpp index 4c4f12faaba..219d54b3f2b 100644 --- a/source/blender/freestyle/intern/geometry/GeomUtils.cpp +++ b/source/blender/freestyle/intern/geometry/GeomUtils.cpp @@ -541,9 +541,9 @@ bool intersectRayBBox(const Vec3r &orig, float tymin, tymax, tzmin, tzmax; Vec3r inv_direction(1.0 / dir[0], 1.0 / dir[1], 1.0 / dir[2]); int sign[3]; - sign[0] = (inv_direction.x() < 0); - sign[1] = (inv_direction.y() < 0); - sign[2] = (inv_direction.z() < 0); + sign[0] = static_cast(inv_direction.x() < 0); + sign[1] = static_cast(inv_direction.y() < 0); + sign[2] = static_cast(inv_direction.z() < 0); Vec3r bounds[2]; bounds[0] = boxMin; diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp index 427e4198e5c..5635fc9ecd0 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.cpp +++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp @@ -648,10 +648,10 @@ static bool float_array_from_PyList(PyObject *obj, float *v, int n) v[i] = PyFloat_AsDouble(PyList_GET_ITEM(obj, i)); if (v[i] == -1.0f && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "list elements must be a number"); - return 0; + return false; } } - return 1; + return true; } bool Vec2f_ptr_from_PyList(PyObject *obj, Vec2f &vec) @@ -707,10 +707,10 @@ static bool float_array_from_PyTuple(PyObject *obj, float *v, int n) v[i] = PyFloat_AsDouble(PyTuple_GET_ITEM(obj, i)); if (v[i] == -1.0f && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "tuple elements must be a number"); - return 0; + return false; } } - return 1; + return true; } bool Vec2f_ptr_from_PyTuple(PyObject *obj, Vec2f &vec) @@ -766,21 +766,21 @@ bool float_array_from_PyObject(PyObject *obj, float *v, int n) { if (VectorObject_Check(obj) && ((VectorObject *)obj)->size == n) { if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) { - return 0; + return false; } for (int i = 0; i < n; i++) { v[i] = ((VectorObject *)obj)->vec[i]; } - return 1; + return true; } else if (ColorObject_Check(obj) && n == 3) { if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) { - return 0; + return false; } for (int i = 0; i < n; i++) { v[i] = ((ColorObject *)obj)->col[i]; } - return 1; + return true; } else if (PyList_Check(obj) && PyList_GET_SIZE(obj) == n) { return float_array_from_PyList(obj, v, n); @@ -788,7 +788,7 @@ bool float_array_from_PyObject(PyObject *obj, float *v, int n) else if (PyTuple_Check(obj) && PyTuple_GET_SIZE(obj) == n) { return float_array_from_PyTuple(obj, v, n); } - return 0; + return false; } int convert_v4(PyObject *obj, void *v) diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp index 33078e6ba6a..72b75dc1446 100644 --- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp +++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp @@ -268,7 +268,7 @@ static PyObject *Freestyle_evaluateCurveMappingF(PyObject * /*self*/, PyObject * /* disable extrapolation if enabled */ if ((cumap->flag & CUMA_EXTEND_EXTRAPOLATE)) { cumap->flag &= ~CUMA_EXTEND_EXTRAPOLATE; - BKE_curvemapping_changed(cumap, 0); + BKE_curvemapping_changed(cumap, false); } return PyFloat_FromDouble(BKE_curvemapping_evaluateF(cumap, cur, value)); } diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp index 2c226e330d7..8f2a48106d5 100644 --- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp +++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp @@ -502,7 +502,7 @@ static PyObject *BPy_FrsMaterial_richcmpr(PyObject *objectA, int comparison_type) { const BPy_FrsMaterial *matA = NULL, *matB = NULL; - bool result = 0; + bool result = false; if (!BPy_FrsMaterial_Check(objectA) || !BPy_FrsMaterial_Check(objectB)) { if (comparison_type == Py_NE) { diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp index 0769b30ebb7..0c2dc2ceaf6 100644 --- a/source/blender/freestyle/intern/python/Director.cpp +++ b/source/blender/freestyle/intern/python/Director.cpp @@ -83,7 +83,7 @@ int Director_BPy_BinaryPredicate0D___call__(BinaryPredicate0D *bp0D, if (ret < 0) { return -1; } - bp0D->result = ret; + bp0D->result = (ret != 0); return 0; } @@ -114,7 +114,7 @@ int Director_BPy_BinaryPredicate1D___call__(BinaryPredicate1D *bp1D, if (ret < 0) { return -1; } - bp1D->result = ret; + bp1D->result = (ret != 0); return 0; } @@ -139,7 +139,7 @@ int Director_BPy_UnaryPredicate0D___call__(UnaryPredicate0D *up0D, Interface0DIt if (ret < 0) { return -1; } - up0D->result = ret; + up0D->result = (ret != 0); return 0; } @@ -164,7 +164,7 @@ int Director_BPy_UnaryPredicate1D___call__(UnaryPredicate1D *up1D, Interface1D & if (ret < 0) { return -1; } - up1D->result = ret; + up1D->result = (ret != 0); return 0; } diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp index d024c360e3f..25ab97a7b90 100644 --- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp @@ -522,7 +522,7 @@ FEdge *ViewEdgeXBuilder::BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer Vec3r B2(woeb->GetbVertex()->GetVertex()); Vec3r B(B1 + tb * (B2 - B1)); - if (feprevious && (B - va->point3D()).norm() < 1.0e-6) { + if ((feprevious != nullptr) && (B - va->point3D()).norm() < 1.0e-6) { return feprevious; } diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp index b7de3a5b319..74adf9b7a7c 100644 --- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp @@ -1179,7 +1179,7 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap, (*ve)->setIsInImage(true); } fe = fe->nextEdge(); - } while (fe && fe != festart && !(bestOccluderTargetFound && (*ve)->isInImage())); + } while ((fe != nullptr) && fe != festart && !(bestOccluderTargetFound && (*ve)->isInImage())); // Either we have run out of FEdges, or we already have the one edge we need to determine // visibility Cull all remaining edges. @@ -1246,7 +1246,7 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap, fe->setIsInImage(true); } fe = fe->nextEdge(); - } while (fe && fe != festart); + } while ((fe != nullptr) && fe != festart); } } } @@ -1363,7 +1363,7 @@ void ViewMapBuilder::computeCusps(ViewMap *ioViewMap) } } fe = fe->nextEdge(); - } while (fe && fe != fefirst); + } while ((fe != nullptr) && fe != fefirst); } for (ve = newVEdges.begin(), veend = newVEdges.end(); ve != veend; ++ve) { (*ve)->viewShape()->AddEdge(*ve); @@ -1592,7 +1592,7 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo do { qiMajority++; fe = fe->nextEdge(); - } while (fe && fe != festart); + } while ((fe != nullptr) && fe != festart); qiMajority >>= 1; #if LOGGING if (_global.debug & G_DEBUG_FREESTYLE) { @@ -1660,7 +1660,7 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo ++nSamples; fe = fe->nextEdge(); - } while ((maxCard < qiMajority) && (fe) && (fe != festart)); + } while ((maxCard < qiMajority) && ((fe) != nullptr) && (fe != festart)); #if LOGGING if (_global.debug & G_DEBUG_FREESTYLE) { cout << "\tFinished with " << nSamples << " samples, maxCard = " << maxCard << endl; @@ -1746,7 +1746,7 @@ void ViewMapBuilder::ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real ep do { qiMajority++; fe = fe->nextEdge(); - } while (fe && fe != festart); + } while ((fe != nullptr) && fe != festart); if (qiMajority >= 4) { qiMajority >>= 2; } @@ -1796,7 +1796,7 @@ void ViewMapBuilder::ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real ep even_test = true; } fe = fe->nextEdge(); - } while ((maxCard < qiMajority) && (fe) && (fe != festart)); + } while ((maxCard < qiMajority) && ((fe) != nullptr) && (fe != festart)); (*ve)->setQI(maxIndex); diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 66ed0dd0fa5..e86812bd976 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -328,7 +328,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co } else { tree->iterations = MAX2(data->iterations, tree->iterations); - tree->stretch = tree->stretch && !(data->flag & CONSTRAINT_IK_STRETCH); + tree->stretch = static_cast((static_cast(tree->stretch != 0) != 0) && ((data->flag & CONSTRAINT_IK_STRETCH)) == 0); /* skip common pose channels and add remaining*/ size = MIN2(segcount, tree->totchannel); @@ -974,7 +974,7 @@ static int convert_channels(struct Depsgraph *depsgraph, // this is because some of the pose data (e.g. pose head) don't have corresponding // joint angles and can't be applied to the iTaSC armature dynamically if (!(pchan->flag & POSE_DONE)) { - BKE_pose_where_is_bone(depsgraph, ikscene->blscene, ikscene->blArmature, pchan, ctime, 1); + BKE_pose_where_is_bone(depsgraph, ikscene->blscene, ikscene->blArmature, pchan, ctime, true); } // tell blender that this channel was controlled by IK, // it's cleared on each BKE_pose_where_is() @@ -1271,7 +1271,7 @@ static IK_Scene *convert_tree( length = bone->length * ikscene->blScale; parent = (a > 0) ? ikscene->channels[tree->parent[a]].tail : root; // first the fixed segment to the bone head - if (!(ikchan->pchan->bone->flag & BONE_CONNECTED) || head.M.GetRot().Norm() > KDL::epsilon) { + if (((ikchan->pchan->bone->flag & BONE_CONNECTED) == 0) || head.M.GetRot().Norm() > KDL::epsilon) { joint = bone->name; joint += ":H"; ret = arm->addSegment(joint, parent, KDL::Joint::None, 0.0, head); @@ -1477,7 +1477,7 @@ static IK_Scene *convert_tree( // initialize all the fields that we can set at this time iktarget->blenderConstraint = target->con; iktarget->channel = target->tip; - iktarget->simulation = (ikparam->flag & ITASC_SIMULATION); + iktarget->simulation = ((ikparam->flag & ITASC_SIMULATION) != 0); iktarget->rootChannel = ikscene->channels[0].pchan; iktarget->owner = ob; iktarget->targetName = pchan->bone->name; @@ -1738,7 +1738,7 @@ static void execute_scene(struct Depsgraph *depsgraph, // in animation mode, we must get the bone position from action and constraints for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ikchan++) { if (!(ikchan->pchan->flag & POSE_DONE)) { - BKE_pose_where_is_bone(depsgraph, blscene, ikscene->blArmature, ikchan->pchan, ctime, 1); + BKE_pose_where_is_bone(depsgraph, blscene, ikscene->blArmature, ikchan->pchan, ctime, true); } // tell blender that this channel was controlled by IK, // it's cleared on each BKE_pose_where_is() diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp index df51aada5f0..1e62bc6a607 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp +++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp @@ -172,7 +172,7 @@ int imb_is_a_photoshop(const char *filename) NULL, }; - return BLI_path_extension_check_array(filename, photoshop_extension); + return static_cast(BLI_path_extension_check_array(filename, photoshop_extension)); } int imb_save_photoshop(struct ImBuf *ibuf, const char * /*name*/, int flags) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 2a5532a0902..fd06b0f137d 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -333,7 +333,7 @@ extern "C" { */ int imb_is_a_openexr(const unsigned char *mem) { - return Imf::isImfMagic((const char *)mem); + return static_cast(Imf::isImfMagic((const char *)mem)); } static void openexr_header_compression(Header *header, int compression) @@ -408,7 +408,7 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *name, const int flags { const int channels = ibuf->channels; const bool is_alpha = (channels >= 4) && (ibuf->planes == 32); - const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */ + const bool is_zbuf = ((flags & IB_zbuffloat) != 0) && ibuf->zbuf_float != NULL; /* summarize */ const int width = ibuf->x; const int height = ibuf->y; OStream *file_stream = NULL; @@ -515,7 +515,7 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *name, const int flag { const int channels = ibuf->channels; const bool is_alpha = (channels >= 4) && (ibuf->planes == 32); - const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */ + const bool is_zbuf = ((flags & IB_zbuffloat) != 0) && ibuf->zbuf_float != NULL; /* summarize */ const int width = ibuf->x; const int height = ibuf->y; OStream *file_stream = NULL; @@ -890,7 +890,7 @@ int IMB_exr_begin_write(void *handle, data->ofile_stream = NULL; } - return (data->ofile != NULL); + return static_cast(data->ofile != NULL); } /* only used for writing temp. render results (not image files) @@ -1214,7 +1214,7 @@ void IMB_exr_read_channels(void *handle) "BlenderMultiChannel"); /* 'previous multilayer attribute, flipped. */ - short flip = (ta && STREQLEN(ta->value().c_str(), "Blender V2.43", 13)); + short flip = static_cast((ta != nullptr) && STREQLEN(ta->value().c_str(), "Blender V2.43", 13)); exr_printf( "\nIMB_exr_read_channels\n%s %-6s %-22s " @@ -1915,7 +1915,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem, printf("Error: can't process EXR multilayer file\n"); } else { - const int is_alpha = exr_has_alpha(*file); + const int is_alpha = static_cast(exr_has_alpha(*file)); ibuf = IMB_allocImBuf(width, height, is_alpha ? 32 : 24, 0); ibuf->flags |= exr_is_half_float(*file) ? IB_halffloat : 0; diff --git a/source/blender/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc index fbc5b2d5c02..a781a696cc5 100644 --- a/source/blender/io/alembic/exporter/abc_export_capi.cc +++ b/source/blender/io/alembic/exporter/abc_export_capi.cc @@ -83,7 +83,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo G.is_break = false; *progress = 0.0f; - *do_update = true; + *do_update = 1; build_depsgraph(data->depsgraph, data->bmain); SubdivModifierDisabler subdiv_disabler(data->depsgraph); @@ -128,7 +128,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo iter.iterate_and_write(); *progress += progress_per_frame; - *do_update = true; + *do_update = 1; } } else { @@ -147,7 +147,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo data->export_ok = !data->was_canceled; *progress = 1.0f; - *do_update = true; + *do_update = 1; } static void export_endjob(void *customdata) diff --git a/source/blender/io/alembic/exporter/abc_writer_hair.cc b/source/blender/io/alembic/exporter/abc_writer_hair.cc index f9b4619b263..544e5878f13 100644 --- a/source/blender/io/alembic/exporter/abc_writer_hair.cc +++ b/source/blender/io/alembic/exporter/abc_writer_hair.cc @@ -84,7 +84,7 @@ void ABCHairWriter::do_write(HierarchyContext &context) ParticleSystem *psys = context.particle_system; if (psys->pathcache) { ParticleSettings *part = psys->part; - bool export_children = psys->childcache && part->childtype != 0; + bool export_children = (psys->childcache != nullptr) && part->childtype != 0; if (!export_children || part->draw & PART_DRAW_PARENT) { write_hair_sample(context, mesh, verts, norm_values, uv_values, hvertices); diff --git a/source/blender/io/alembic/exporter/abc_writer_mesh.cc b/source/blender/io/alembic/exporter/abc_writer_mesh.cc index 89cb76db9a6..a8cd21c4226 100644 --- a/source/blender/io/alembic/exporter/abc_writer_mesh.cc +++ b/source/blender/io/alembic/exporter/abc_writer_mesh.cc @@ -198,8 +198,8 @@ void ABCGenericMeshWriter::do_write(HierarchyContext &context) const int quad_method = args_.export_params->quad_method; const int ngon_method = args_.export_params->ngon_method; - struct BMeshCreateParams bmcp = {false}; - struct BMeshFromMeshParams bmfmp = {true, false, false, 0}; + struct BMeshCreateParams bmcp = {0u}; + struct BMeshFromMeshParams bmfmp = {1u, 0u, 0u, 0}; BMesh *bm = BKE_mesh_to_bmesh_ex(mesh, &bmcp, &bmfmp); BM_mesh_triangulate(bm, quad_method, ngon_method, 4, tag_only, nullptr, nullptr, nullptr); diff --git a/source/blender/io/alembic/exporter/abc_writer_nurbs.cc b/source/blender/io/alembic/exporter/abc_writer_nurbs.cc index 1fd382214a6..21cab84558d 100644 --- a/source/blender/io/alembic/exporter/abc_writer_nurbs.cc +++ b/source/blender/io/alembic/exporter/abc_writer_nurbs.cc @@ -57,7 +57,7 @@ void ABCNurbsWriter::create_alembic_objects(const HierarchyContext *context) std::stringstream patch_name_stream; patch_name_stream << args_.abc_name << '_' << i; - while (abc_parent.getChildHeader(patch_name_stream.str())) { + while (abc_parent.getChildHeader(patch_name_stream.str()) != nullptr) { patch_name_stream << "_"; } diff --git a/source/blender/io/alembic/intern/abc_reader_camera.cc b/source/blender/io/alembic/intern/abc_reader_camera.cc index 3affb35908d..bb3a93585af 100644 --- a/source/blender/io/alembic/intern/abc_reader_camera.cc +++ b/source/blender/io/alembic/intern/abc_reader_camera.cc @@ -84,8 +84,8 @@ void AbcCameraReader::readObjectData(Main *bmain, const ISampleSelector &sample_ ICompoundProperty customDataContainer = m_schema.getUserProperties(); - if (customDataContainer.valid() && customDataContainer.getPropertyHeader("stereoDistance") && - customDataContainer.getPropertyHeader("eyeSeparation")) { + if (customDataContainer.valid() && (customDataContainer.getPropertyHeader("stereoDistance") != nullptr) && + (customDataContainer.getPropertyHeader("eyeSeparation") != nullptr)) { IFloatProperty convergence_plane(customDataContainer, "stereoDistance"); IFloatProperty eye_separation(customDataContainer, "eyeSeparation"); diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc index 756dde3783c..21f7f609c5f 100644 --- a/source/blender/io/alembic/intern/abc_reader_mesh.cc +++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc @@ -200,7 +200,7 @@ static void read_mpolys(CDStreamConfig &config, const AbcMeshData &mesh_data) const UInt32ArraySamplePtr &uvs_indices = mesh_data.uvs_indices; - const bool do_uvs = (mloopuvs && uvs && uvs_indices) && + const bool do_uvs = ((mloopuvs != nullptr) && uvs && uvs_indices) && (uvs_indices->size() == face_indices->size()); unsigned int loop_index = 0; unsigned int rev_loop_index = 0; diff --git a/source/blender/io/alembic/intern/abc_reader_object.cc b/source/blender/io/alembic/intern/abc_reader_object.cc index 39b9cd4c161..881079eb63a 100644 --- a/source/blender/io/alembic/intern/abc_reader_object.cc +++ b/source/blender/io/alembic/intern/abc_reader_object.cc @@ -98,7 +98,7 @@ void AbcObjectReader::determine_inherits_xform() m_inherits_xform = false; } else { - m_inherits_xform = ixform_parent && m_inherits_xform; + m_inherits_xform = (ixform_parent != nullptr) && m_inherits_xform; } } @@ -237,7 +237,7 @@ Alembic::AbcGeom::IXform AbcObjectReader::xform() IObject abc_parent = m_iobject.getParent(); /* The archive's top object can be recognised by not having a parent. */ - if (abc_parent.getParent() && IXform::matches(abc_parent.getMetaData())) { + if ((abc_parent.getParent() != nullptr) && IXform::matches(abc_parent.getMetaData())) { try { return IXform(abc_parent, Alembic::AbcGeom::kWrapExisting); } diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc index 7cde2d4fe73..0b6b843c0f2 100644 --- a/source/blender/io/alembic/intern/alembic_capi.cc +++ b/source/blender/io/alembic/intern/alembic_capi.cc @@ -372,7 +372,7 @@ static std::pair visit_object( } } } - else if (object.getParent()) { + else if (object.getParent() != nullptr) { if (!claiming_child_readers.empty()) { /* The first claiming child will serve just fine as parent to * our non-claiming children. Since all claiming children share @@ -464,14 +464,14 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa * it is not used by anyone, its use count will off by one. */ id_us_min(&cache_file->id); - cache_file->is_sequence = data->settings.is_sequence; + cache_file->is_sequence = static_cast(data->settings.is_sequence); cache_file->scale = data->settings.scale; STRNCPY(cache_file->filepath, data->filename); data->archive = archive; data->settings.cache_file = cache_file; - *data->do_update = true; + *data->do_update = 1; *data->progress = 0.05f; /* Parse Alembic Archive. */ @@ -486,7 +486,7 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa return; } - *data->do_update = true; + *data->do_update = 1; *data->progress = 0.1f; /* Create objects and set scene frame range. */ @@ -514,7 +514,7 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa } *data->progress = 0.1f + 0.3f * (++i / size); - *data->do_update = true; + *data->do_update = 1; if (G.is_break) { data->was_cancelled = true; @@ -558,7 +558,7 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa reader->setupObjectTransform(0.0f); *data->progress = 0.7f + 0.3f * (++i / size); - *data->do_update = true; + *data->do_update = 1; if (G.is_break) { data->was_cancelled = true; diff --git a/source/blender/io/collada/AnimationExporter.cpp b/source/blender/io/collada/AnimationExporter.cpp index c25b4ea543b..c14b007ee89 100644 --- a/source/blender/io/collada/AnimationExporter.cpp +++ b/source/blender/io/collada/AnimationExporter.cpp @@ -123,7 +123,7 @@ bool AnimationExporter::exportAnimations() } #endif } - return animation_count; + return animation_count != 0; } /* called for each exported object */ diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp index 0e211f08d1f..f44a5e09e78 100644 --- a/source/blender/io/collada/AnimationImporter.cpp +++ b/source/blender/io/collada/AnimationImporter.cpp @@ -355,7 +355,7 @@ void AnimationImporter::read_node_transform(COLLADAFW::Node *node, Object *ob) TransformReader::get_node_mat(mat, node, &uid_animated_map, ob); if (ob) { copy_m4_m4(ob->obmat, mat); - BKE_object_apply_mat4(ob, ob->obmat, 0, 0); + BKE_object_apply_mat4(ob, ob->obmat, false, false); } } diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp index 3755b71f300..d5f08bf5621 100644 --- a/source/blender/io/collada/ArmatureImporter.cpp +++ b/source/blender/io/collada/ArmatureImporter.cpp @@ -343,7 +343,7 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone *parentbone if (pbe && pbe->get_chain_length() >= this->import_settings->min_chain_length) { BoneExtended *cbe = extended_bones[cebone->name]; - cbe->set_use_connect(true); + cbe->set_use_connect(1); cebone->flag |= BONE_CONNECTED; pbe->set_leaf_bone(false); @@ -640,7 +640,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin) for (ri = root_joints.begin(); ri != root_joints.end(); ri++) { COLLADAFW::Node *node = *ri; /* for shared armature check if bone tree is already created */ - if (shared && std::find(skin_root_joints.begin(), skin_root_joints.end(), node) != + if ((shared != nullptr) && std::find(skin_root_joints.begin(), skin_root_joints.end(), node) != skin_root_joints.end()) { continue; } @@ -652,7 +652,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin) &skin, node, NULL, node->getChildNodes().getCount(), NULL, armature, layer_labels); if (joint_parent_map.find(node->getUniqueId()) != joint_parent_map.end() && - !skin.get_parent()) { + (skin.get_parent() == nullptr)) { skin.set_parent(joint_parent_map[node->getUniqueId()]); } } @@ -1104,7 +1104,7 @@ BoneExtended &ArmatureImporter::add_bone_extended(EditBone *bone, if (!has_connect && this->import_settings->auto_connect) { /* auto connect only whyen parent has exactly one child*/ - connect_type = sibcount == 1; + connect_type = static_cast(sibcount == 1); } be->set_use_connect(connect_type); diff --git a/source/blender/io/collada/BCAnimationSampler.cpp b/source/blender/io/collada/BCAnimationSampler.cpp index f44e3e8385d..1cfb7ddab9f 100644 --- a/source/blender/io/collada/BCAnimationSampler.cpp +++ b/source/blender/io/collada/BCAnimationSampler.cpp @@ -558,7 +558,7 @@ const bool BCSampleFrame::has_sample_for(Object *ob) const const bool BCSampleFrame::has_sample_for(Object *ob, Bone *bone) const { const BCMatrix *bc_bone = get_sample_matrix(ob, bone); - return (bc_bone); + return (bc_bone) != nullptr; } /* ==================================================================== */ diff --git a/source/blender/io/collada/BlenderContext.cpp b/source/blender/io/collada/BlenderContext.cpp index a9783a9b9c4..c458ce5c1fe 100644 --- a/source/blender/io/collada/BlenderContext.cpp +++ b/source/blender/io/collada/BlenderContext.cpp @@ -93,7 +93,7 @@ bool bc_is_in_Export_set(LinkNode *export_set, Object *ob, ViewLayer *view_layer int bc_is_marked(Object *ob) { - return ob && (ob->id.tag & LIB_TAG_DOIT); + return (static_cast(ob != nullptr) && ((ob->id.tag & LIB_TAG_DOIT)) != 0); } void bc_remove_mark(Object *ob) diff --git a/source/blender/io/collada/CameraExporter.cpp b/source/blender/io/collada/CameraExporter.cpp index 246a454eb66..aed0cc0e847 100644 --- a/source/blender/io/collada/CameraExporter.cpp +++ b/source/blender/io/collada/CameraExporter.cpp @@ -64,7 +64,7 @@ void CamerasExporter::operator()(Object *ob, Scene *sce) case CAM_PANO: case CAM_PERSP: { COLLADASW::PerspectiveOptic persp(mSW); - persp.setXFov(RAD2DEGF(focallength_to_fov(cam->lens, cam->sensor_x)), "xfov"); + persp.setXFov(RAD2DEGF(focallength_to_fov(cam->lens, cam->sensor_x)), true); persp.setAspectRatio((float)(sce->r.xsch) / (float)(sce->r.ysch), false, "aspect_ratio"); persp.setZFar(cam->clip_end, false, "zfar"); persp.setZNear(cam->clip_start, false, "znear"); @@ -77,7 +77,7 @@ void CamerasExporter::operator()(Object *ob, Scene *sce) case CAM_ORTHO: default: { COLLADASW::OrthographicOptic ortho(mSW); - ortho.setXMag(cam->ortho_scale / 2, "xmag"); + ortho.setXMag(cam->ortho_scale / 2, true); ortho.setAspectRatio((float)(sce->r.xsch) / (float)(sce->r.ysch), false, "aspect_ratio"); ortho.setZFar(cam->clip_end, false, "zfar"); ortho.setZNear(cam->clip_start, false, "znear"); diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp index 0f84db79c28..7ea2f14c4dc 100644 --- a/source/blender/io/collada/DocumentImporter.cpp +++ b/source/blender/io/collada/DocumentImporter.cpp @@ -437,7 +437,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, } /* calc new matrix and apply */ mul_m4_m4m4(obn->obmat, obn->obmat, mat); - BKE_object_apply_mat4(obn, obn->obmat, 0, 0); + BKE_object_apply_mat4(obn, obn->obmat, false, false); } } else { @@ -481,7 +481,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, * current with blender profile. */ void DocumentImporter::create_constraints(ExtraTags *et, Object *ob) { - if (et && et->isProfile("blender")) { + if ((et != nullptr) && et->isProfile("blender")) { std::string name; short type = 0; et->setData("type", &type); @@ -893,7 +893,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) return true; } - if (et && et->isProfile("blender")) { + if ((et != nullptr) && et->isProfile("blender")) { et->setData("shiftx", &(cam->shiftx)); et->setData("shifty", &(cam->shifty)); et->setData("dof_distance", &(cam->dof.focus_distance)); @@ -1056,7 +1056,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) } /* if we find an ExtraTags for this, use that instead. */ - if (et && et->isProfile("blender")) { + if ((et != nullptr) && et->isProfile("blender")) { et->setData("type", &(lamp->type)); et->setData("flag", &(lamp->flag)); et->setData("mode", &(lamp->mode)); diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp index c7fcc51d42f..f5edfb133af 100644 --- a/source/blender/io/collada/GeometryExporter.cpp +++ b/source/blender/io/collada/GeometryExporter.cpp @@ -647,7 +647,7 @@ void GeometryExporter::create_normals(std::vector &normals, for (int poly_index = 0; poly_index < me->totpoly; poly_index++) { MPoly *mpoly = &me->mpoly[poly_index]; - bool use_vertex_normals = use_custom_normals || mpoly->flag & ME_SMOOTH; + bool use_vertex_normals = use_custom_normals || ((mpoly->flag & ME_SMOOTH) != 0); if (!use_vertex_normals) { /* For flat faces use face normal as vertex normal: */ diff --git a/source/blender/io/collada/Materials.cpp b/source/blender/io/collada/Materials.cpp index 06f54884668..4e0a1e693d7 100644 --- a/source/blender/io/collada/Materials.cpp +++ b/source/blender/io/collada/Materials.cpp @@ -100,7 +100,7 @@ bNodeTree *MaterialNode::prepare_material_nodetree() } material->nodetree = ntreeAddTree(NULL, "Shader Nodetree", "ShaderNodeTree"); - material->use_nodes = true; + material->use_nodes = 1u; ntree = material->nodetree; return ntree; } diff --git a/source/blender/io/collada/SceneExporter.cpp b/source/blender/io/collada/SceneExporter.cpp index 1b3bc1b66ea..b8de5bbd91e 100644 --- a/source/blender/io/collada/SceneExporter.cpp +++ b/source/blender/io/collada/SceneExporter.cpp @@ -222,7 +222,7 @@ void SceneExporter::writeNode(Object *ob) } if (cti->flush_constraint_targets) { - cti->flush_constraint_targets(con, &targets, 1); + cti->flush_constraint_targets(con, &targets, true); } } diff --git a/source/blender/io/collada/SkinInfo.cpp b/source/blender/io/collada/SkinInfo.cpp index 5692d11d0c3..33fb893e1d9 100644 --- a/source/blender/io/collada/SkinInfo.cpp +++ b/source/blender/io/collada/SkinInfo.cpp @@ -248,7 +248,7 @@ void SkinInfo::link_armature(bContext *C, DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); #endif copy_m4_m4(ob->obmat, bind_shape_matrix); - BKE_object_apply_mat4(ob, ob->obmat, 0, 0); + BKE_object_apply_mat4(ob, ob->obmat, false, false); amd->deformflag = ARM_DEF_VGROUP; diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index d2e05c7ae5b..1ea164e7f89 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -331,7 +331,7 @@ bool bc_is_root_bone(Bone *aBone, bool deform_bones_only) return (aBone == root); } else { - return !(aBone->parent); + return (aBone->parent) == nullptr; } } @@ -373,7 +373,7 @@ void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene) mul_m4_m4m4(ob->obmat, bc_unit.get_scale(), ob->obmat); } mul_m4_m4m4(ob->obmat, bc_unit.get_rotation(), ob->obmat); - BKE_object_apply_mat4(ob, ob->obmat, 0, 0); + BKE_object_apply_mat4(ob, ob->obmat, false, false); } void bc_match_scale(std::vector *objects_done, @@ -452,7 +452,7 @@ void bc_triangulate_mesh(Mesh *me) BMeshFromMeshParams bm_from_me_params = {0}; bm_from_me_params.calc_face_normal = true; BM_mesh_bm_from_me(bm, me, &bm_from_me_params); - BM_mesh_triangulate(bm, quad_method, use_beauty, 4, tag_only, NULL, NULL, NULL); + BM_mesh_triangulate(bm, quad_method, static_cast(use_beauty), 4, tag_only, NULL, NULL, NULL); BMeshToMeshParams bm_to_me_params = {0}; bm_to_me_params.calc_object_remap = false; @@ -830,8 +830,8 @@ static bool has_custom_props(Bone *bone, bool enabled, std::string key) return false; } - return (bc_get_IDProperty(bone, key + "_x") || bc_get_IDProperty(bone, key + "_y") || - bc_get_IDProperty(bone, key + "_z")); + return ((bc_get_IDProperty(bone, key + "_x") != nullptr) || (bc_get_IDProperty(bone, key + "_y") != nullptr) || + (bc_get_IDProperty(bone, key + "_z") != nullptr)); } void bc_enable_fcurves(bAction *act, char *bone_name) @@ -1065,13 +1065,13 @@ void bc_create_restpose_mat(BCExportSettings &export_settings, } if (export_settings.get_keep_bind_info()) { - if (bc_get_IDProperty(bone, "restpose_rot_x")) { + if (bc_get_IDProperty(bone, "restpose_rot_x") != nullptr) { rot[0] = DEG2RADF(bc_get_property(bone, "restpose_rot_x", 0)); } - if (bc_get_IDProperty(bone, "restpose_rot_y")) { + if (bc_get_IDProperty(bone, "restpose_rot_y") != nullptr) { rot[1] = DEG2RADF(bc_get_property(bone, "restpose_rot_y", 0)); } - if (bc_get_IDProperty(bone, "restpose_rot_z")) { + if (bc_get_IDProperty(bone, "restpose_rot_z") != nullptr) { rot[2] = DEG2RADF(bc_get_property(bone, "restpose_rot_z", 0)); } } @@ -1199,7 +1199,7 @@ static bNodeTree *prepare_material_nodetree(Material *ma) { if (ma->nodetree == NULL) { ma->nodetree = ntreeAddTree(NULL, "Shader Nodetree", "ShaderNodeTree"); - ma->use_nodes = true; + ma->use_nodes = 1u; } return ma->nodetree; } @@ -1406,9 +1406,9 @@ double bc_get_float_from_shader(bNode *shader, double &val, std::string nodeid) if (socket) { bNodeSocketValueFloat *ref = (bNodeSocketValueFloat *)socket->default_value; val = (double)ref->value; - return true; + return 1.0; } - return false; + return 0.0; } COLLADASW::ColorOrTexture bc_get_cot_from_shader(bNode *shader, diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc index dce6b8e178b..1b5422d794a 100644 --- a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc +++ b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc @@ -712,7 +712,7 @@ bool AbstractHierarchyIterator::mark_as_weak_export(const Object * /*object*/) c bool AbstractHierarchyIterator::should_visit_dupli_object(const DupliObject *dupli_object) const { // Removing dupli_object->no_draw hides things like custom bone shapes. - return !dupli_object->no_draw; + return dupli_object->no_draw == 0u; } } // namespace io diff --git a/source/blender/io/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc index 2d3972410a4..89ad363ae0d 100644 --- a/source/blender/io/usd/intern/usd_capi.cc +++ b/source/blender/io/usd/intern/usd_capi.cc @@ -75,7 +75,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo BKE_scene_graph_update_tagged(data->depsgraph, data->bmain); *progress = 0.0f; - *do_update = true; + *do_update = 1; // For restoring the current frame after exporting animation is done. const int orig_frame = CFRA; @@ -123,7 +123,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo iter.iterate_and_write(); *progress += progress_per_frame; - *do_update = true; + *do_update = 1; } } else { @@ -142,7 +142,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo data->export_ok = true; *progress = 1.0f; - *do_update = true; + *do_update = 1; } static void export_endjob(void *customdata) diff --git a/source/blender/modifiers/intern/MOD_mask.cc b/source/blender/modifiers/intern/MOD_mask.cc index 93fb7749392..8288a329570 100644 --- a/source/blender/modifiers/intern/MOD_mask.cc +++ b/source/blender/modifiers/intern/MOD_mask.cc @@ -111,7 +111,7 @@ static void compute_vertex_mask__armature_mode(MDeformVert *dvert, for (bDeformGroup *def : ListBaseWrapper(ob->defbase)) { bPoseChannel *pchan = BKE_pose_channel_find_name(armature_ob->pose, def->name); - bool bone_for_group_exists = pchan && pchan->bone && (pchan->bone->flag & BONE_SELECTED); + bool bone_for_group_exists = (pchan != nullptr) && (pchan->bone != nullptr) && ((pchan->bone->flag & BONE_SELECTED) != 0); selected_bone_uses_group.append(bone_for_group_exists); } @@ -313,7 +313,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * { MaskModifierData *mmd = (MaskModifierData *)md; Object *ob = ctx->object; - const bool invert_mask = mmd->flag & MOD_MASK_INV; + const bool invert_mask = (mmd->flag & MOD_MASK_INV) != 0; /* Return empty or input mesh when there are no vertex groups. */ MDeformVert *dvert = (MDeformVert *)CustomData_get_layer(&mesh->vdata, CD_MDEFORMVERT); @@ -400,7 +400,7 @@ static bool isDisabled(const struct Scene *UNUSED(scene), * * In other cases it should be impossible to have a type mismatch. */ - return mmd->ob_arm && mmd->ob_arm->type != OB_ARMATURE; + return (mmd->ob_arm != nullptr) && mmd->ob_arm->type != OB_ARMATURE; } static void panel_draw(const bContext *C, Panel *panel) diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index b23511c3bdb..b2339b4699e 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -224,7 +224,7 @@ void node_socket_init_default_value(bNodeSocket *sock) case SOCK_BOOLEAN: { bNodeSocketValueBoolean *dval = (bNodeSocketValueBoolean *)MEM_callocN( sizeof(bNodeSocketValueBoolean), "node socket value bool"); - dval->value = false; + dval->value = 0u; sock->default_value = dval; break; diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp index 051f11aa1d9..ce9a3e31b42 100644 --- a/source/blender/physics/intern/BPH_mass_spring.cpp +++ b/source/blender/physics/intern/BPH_mass_spring.cpp @@ -372,7 +372,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) ClothSimSettings *parms = clmd->sim_parms; Implicit_Data *data = cloth->implicit; bool using_angular = parms->bending_model == CLOTH_BENDING_ANGULAR; - bool resist_compress = (parms->flags & CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS) && + bool resist_compress = ((parms->flags & CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS) != 0) && !using_angular; s->flags &= ~CLOTH_SPRING_FLAG_NEEDED; @@ -1267,7 +1267,7 @@ int BPH_cloth_solve( Implicit_Data *id = cloth->implicit; /* Hydrostatic pressure gradient of the fluid inside the object is affected by acceleration. */ - bool use_acceleration = (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE) && + bool use_acceleration = ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE) != 0) && (clmd->sim_parms->fluid_density > 0); BKE_sim_debug_data_clear_category("collision");