From f59e5bf51f1b071973cce0603255452e1c52f17a Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Wed, 3 Apr 2024 18:17:08 -0500 Subject: [PATCH] Hush various clang-tidy warnings --- .clang-tidy | 2 ++ src/adera/drawing_gl/visualizer_shader.cpp | 4 ++-- src/osp/activescene/active_ent.h | 4 +++- src/osp/activescene/basic_fn.cpp | 4 ++-- src/osp/activescene/prefab_fn.cpp | 2 +- src/osp/core/global_id.h | 22 ++++++++++++++++------ src/osp/core/strong_id.h | 16 ++++++++++------ src/osp/drawing/draw_ent.h | 6 ++++-- src/osp/drawing/prefab_draw.cpp | 4 ++-- src/osp/drawing_gl/rendergl.cpp | 6 +++--- src/osp/tasks/execute.cpp | 6 ++++++ src/osp/tasks/tasks.cpp | 2 ++ src/osp/tasks/top_execute.cpp | 19 +++++++++---------- src/planet-a/SubdivTriangleMesh.cpp | 12 ++++++------ src/planet-a/icosahedron.cpp | 16 +++++++++------- src/testapp/enginetest.cpp | 2 +- src/testapp/sessions/newton.cpp | 10 +++++----- src/testapp/sessions/shapes.cpp | 4 ++-- src/testapp/sessions/universe.cpp | 8 ++++---- src/testapp/sessions/vehicles.cpp | 4 ++-- src/testapp/sessions/vehicles_prebuilt.cpp | 14 +++++++------- test/resources/main.cpp | 2 +- test/tasks/main.cpp | 2 +- 23 files changed, 100 insertions(+), 71 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index a13949b6..e597a2fe 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -11,6 +11,8 @@ Checks: 'clang-diagnostic-*, ,-readability-else-after-return, ,-readability-magic-numbers, ,-readability-identifier-length, + ,-readability-function-cognitive-complexity, + ,-readability-qualified-auto, ,-clang-analyzer-cplusplus.InnerPointer, ,-cplusplus.InnerPointer, ,-clang-diagnostic-ignored-optimization-argument, diff --git a/src/adera/drawing_gl/visualizer_shader.cpp b/src/adera/drawing_gl/visualizer_shader.cpp index 114099bc..7141c43b 100644 --- a/src/adera/drawing_gl/visualizer_shader.cpp +++ b/src/adera/drawing_gl/visualizer_shader.cpp @@ -58,7 +58,7 @@ void adera::shader::draw_ent_visualizer( if (rData.m_wireframeOnly) { rShader.setColor(0x00000000_rgbaf); - Magnum::GL::Renderer::setDepthMask(false); + Magnum::GL::Renderer::setDepthMask(GL_FALSE); } MeshGlId const meshId = (*rData.m_pMeshId)[ent].m_glId; @@ -72,6 +72,6 @@ void adera::shader::draw_ent_visualizer( if (rData.m_wireframeOnly) { - Magnum::GL::Renderer::setDepthMask(true); + Magnum::GL::Renderer::setDepthMask(GL_TRUE); } } diff --git a/src/osp/activescene/active_ent.h b/src/osp/activescene/active_ent.h index 9d65eaf6..c9750092 100644 --- a/src/osp/activescene/active_ent.h +++ b/src/osp/activescene/active_ent.h @@ -26,9 +26,11 @@ #include "../core/strong_id.h" +#include // for std::uint32_t + namespace osp::active { -using ActiveEnt = StrongId; +using ActiveEnt = StrongId; } // namespace osp::active diff --git a/src/osp/activescene/basic_fn.cpp b/src/osp/activescene/basic_fn.cpp index e7a3f26c..1ad4de72 100644 --- a/src/osp/activescene/basic_fn.cpp +++ b/src/osp/activescene/basic_fn.cpp @@ -46,7 +46,7 @@ SubtreeBuilder SubtreeBuilder::add_child(ActiveEnt ent, uint32_t descendantCount m_first = childLast; - return SubtreeBuilder(m_rScnGraph, ent, childFirst, childLast); + return {m_rScnGraph, ent, childFirst, childLast}; } SubtreeBuilder SysSceneGraph::add_descendants(ACtxSceneGraph& rScnGraph, uint32_t descendantCount, ActiveEnt root) @@ -169,7 +169,7 @@ void SysSceneGraph::do_delete(ACtxSceneGraph& rScnGraph) TreePos_t const keepLast = (notLast) ? (*itDelNext) : (treeLast); assert(keepFirst <= keepLast); - std::size_t const shift = keepFirst - done; + std::ptrdiff_t const shift = keepFirst - done; // Update descendant count of ancestors ActiveEnt parent = rScnGraph.m_treeToEnt[*itDel]; diff --git a/src/osp/activescene/prefab_fn.cpp b/src/osp/activescene/prefab_fn.cpp index daf181b1..5b4df0fe 100644 --- a/src/osp/activescene/prefab_fn.cpp +++ b/src/osp/activescene/prefab_fn.cpp @@ -167,7 +167,7 @@ void SysPrefabInit::init_info( PrefabInstanceInfo &rInfo = rPrefabs.instanceInfo[ent]; rInfo.importer = rPfBasic.m_importerRes; rInfo.prefab = rPfBasic.m_prefabId; - rInfo.obj = i; + rInfo.obj = static_cast(i); if (parents[i] == -1) { diff --git a/src/osp/core/global_id.h b/src/osp/core/global_id.h index 991f3188..01f54721 100644 --- a/src/osp/core/global_id.h +++ b/src/osp/core/global_id.h @@ -24,7 +24,9 @@ */ #pragma once -#include +#include // for lgrn::underlying_int_type_t + +#include // for std::is_integral_v namespace osp { @@ -32,18 +34,26 @@ namespace osp template struct GlobalIdReg { - [[nodiscard]] static inline ID_T create() noexcept + using underlying_t = lgrn::underlying_int_type_t; + static_assert(std::is_integral_v); + + [[nodiscard]] static constexpr ID_T create() noexcept + { + return ID_T{sm_count++}; + } + + [[nodiscard]] static constexpr std::size_t size() noexcept { - return ID_T(sm_count++); + return std::size_t{sm_count}; } - [[nodiscard]] static inline std::size_t size() noexcept + [[nodiscard]] static constexpr underlying_t largest() noexcept { - return sm_count; + return sm_count; } private: - static inline std::size_t sm_count{0}; + static inline constinit underlying_t sm_count{0}; }; } // namespace osp diff --git a/src/osp/core/strong_id.h b/src/osp/core/strong_id.h index b9d2cbc7..17621f2a 100644 --- a/src/osp/core/strong_id.h +++ b/src/osp/core/strong_id.h @@ -24,10 +24,12 @@ */ #pragma once -#include -#include // light-ish header that happens to include std::hash +#include // for lgrn::id_null +#include // for lgrn::underlying_int_type -#include +#include // for std::integral +#include // for std::size_t +#include // IWYU pragma: keep, light-ish header that happens to include std::hash namespace osp { @@ -58,9 +60,10 @@ struct StrongId : value{value} { }; - constexpr explicit operator std::size_t() const noexcept + template + constexpr explicit operator T() const noexcept { - return value; + return static_cast(value); } constexpr explicit operator INT_T() const noexcept @@ -77,7 +80,8 @@ struct StrongId // std::hash support for unordered containers template -struct std::hash> { +struct std::hash> +{ constexpr auto operator() (osp::StrongId const& key) const { return key.value; diff --git a/src/osp/drawing/draw_ent.h b/src/osp/drawing/draw_ent.h index 1b9e8b01..84ef4f3e 100644 --- a/src/osp/drawing/draw_ent.h +++ b/src/osp/drawing/draw_ent.h @@ -26,11 +26,13 @@ #include "../core/strong_id.h" +#include // for std::uint32_t + namespace osp::draw { -using DrawEnt = StrongId; +using DrawEnt = StrongId; -using MaterialId = StrongId; +using MaterialId = StrongId; } // namespace osp::draw diff --git a/src/osp/drawing/prefab_draw.cpp b/src/osp/drawing/prefab_draw.cpp index 085429fd..2e0b8ba9 100644 --- a/src/osp/drawing/prefab_draw.cpp +++ b/src/osp/drawing/prefab_draw.cpp @@ -166,7 +166,7 @@ void SysPrefabDraw::init_mesh_and_material( mat.types() & Magnum::Trade::MaterialType::PbrMetallicRoughness) { auto const& matPbr = mat.as(); - if (int const baseColor = matPbr.baseColorTexture(); + if (auto const baseColor = matPbr.baseColorTexture(); baseColor != -1) { osp::ResId const texRes = rImportData.m_textures[baseColor]; @@ -238,7 +238,7 @@ void SysPrefabDraw::resync_mesh_and_material( mat.types() & Magnum::Trade::MaterialType::PbrMetallicRoughness) { auto const& matPbr = mat.as(); - if (int const baseColor = matPbr.baseColorTexture(); + if (auto const baseColor = matPbr.baseColorTexture(); baseColor != -1) { osp::ResId const texRes = rImportData.m_textures[baseColor]; diff --git a/src/osp/drawing_gl/rendergl.cpp b/src/osp/drawing_gl/rendergl.cpp index b1cd6c2d..aed39c00 100644 --- a/src/osp/drawing_gl/rendergl.cpp +++ b/src/osp/drawing_gl/rendergl.cpp @@ -320,7 +320,7 @@ void SysRenderGL::display_texture( Renderer::disable(Renderer::Feature::DepthTest); Renderer::disable(Renderer::Feature::FaceCulling); Renderer::disable(Renderer::Feature::Blending); - Renderer::setDepthMask(true); + Renderer::setDepthMask(GL_TRUE); rRenderGl.m_fullscreenTriShader.display_texure( rRenderGl.m_meshGl.get(rRenderGl.m_fullscreenTri), @@ -352,7 +352,7 @@ void SysRenderGL::render_opaque( Renderer::enable(Renderer::Feature::DepthTest); Renderer::enable(Renderer::Feature::FaceCulling); Renderer::disable(Renderer::Feature::Blending); - Renderer::setDepthMask(true); + Renderer::setDepthMask(GL_TRUE); draw_group(group, visible, viewProj); } @@ -373,7 +373,7 @@ void SysRenderGL::render_transparent( // temporary: disabled depth writing makes the plumes look nice, but // can mess up other transparent objects once added - //Renderer::setDepthMask(false); + //Renderer::setDepthMask(GL_FALSE); draw_group(group, visible, viewProj); } diff --git a/src/osp/tasks/execute.cpp b/src/osp/tasks/execute.cpp index 2b5fadb9..250bb62b 100644 --- a/src/osp/tasks/execute.cpp +++ b/src/osp/tasks/execute.cpp @@ -493,6 +493,7 @@ static void pipeline_advance_reqs(Tasks const& tasks, TaskGraph const& graph, Ex { ExecPipeline &rReqTaskExecPl = rExec.plData[stgreqtask.reqPipeline]; + // NOLINTBEGIN(bugprone-branch-clone) bool const reqTaskDone = [&tasks, &rReqTaskExecPl, &stgreqtask, &rExec] () noexcept -> bool { if ( ! rReqTaskExecPl.running ) @@ -525,6 +526,7 @@ static void pipeline_advance_reqs(Tasks const& tasks, TaskGraph const& graph, Ex return true; // On the right stage and task not running. This means it's done } }(); + // NOLINTEND(bugprone-branch-clone) if (reqTaskDone) { @@ -828,6 +830,7 @@ static bool is_pipeline_in_loop(Tasks const& tasks, TaskGraph const& graph, Exec if (exec.plData[args.insideLoop].canceled) { + // NOLINTBEGIN(readability-simplify-boolean-expr) if (exec.plData[graph.pltreeToPipeline[insideLoopScopePos]].canceled) { return false; // insideLoop is canceled and will not loop again @@ -837,6 +840,7 @@ static bool is_pipeline_in_loop(Tasks const& tasks, TaskGraph const& graph, Exec return true; // insideLoop itself is canceled, but is parented to a non-canceled // loop scope. It will loop more times. } + // NOLINTEND(readability-simplify-boolean-expr) } else // insideLoop is canceled { @@ -856,6 +860,7 @@ static bool is_pipeline_in_loop(Tasks const& tasks, TaskGraph const& graph, Exec { if (exec.plData[args.insideLoop].canceled) { + // NOLINTBEGIN(readability-simplify-boolean-expr) if (exec.plData[graph.pltreeToPipeline[insideLoopScopePos]].canceled) { return false; // insideLoop is canceled and will not loop again @@ -865,6 +870,7 @@ static bool is_pipeline_in_loop(Tasks const& tasks, TaskGraph const& graph, Exec return true; // insideLoop is in a nested loop and is canceled, but is parented // to a non-canceled loop scope. It will loop more times. } + // NOLINTEND(readability-simplify-boolean-expr) } else { diff --git a/src/osp/tasks/tasks.cpp b/src/osp/tasks/tasks.cpp index e0933010..aa0b80ad 100644 --- a/src/osp/tasks/tasks.cpp +++ b/src/osp/tasks/tasks.cpp @@ -302,6 +302,7 @@ TaskGraph make_exec_graph(Tasks const& tasks, ArrayView } } + // NOLINTBEGIN(readability-use-anyofallof) [[maybe_unused]] auto const all_counts_zero = [&] () { if ( totalStageReqTasks != 0 @@ -331,6 +332,7 @@ TaskGraph make_exec_graph(Tasks const& tasks, ArrayView return true; }; + // NOLINTEND(readability-use-anyofallof) LGRN_ASSERTM(all_counts_zero(), "Counts repurposed as items remaining, and must all be zero by the end here"); diff --git a/src/osp/tasks/top_execute.cpp b/src/osp/tasks/top_execute.cpp index ebcc4e7b..b12d0ed8 100644 --- a/src/osp/tasks/top_execute.cpp +++ b/src/osp/tasks/top_execute.cpp @@ -32,7 +32,6 @@ #include #include -#include #include namespace osp @@ -50,7 +49,7 @@ void top_run_blocking(Tasks const& tasks, TaskGraph const& graph, TopTaskDataVec if (runTasksLeft != 0) { - TaskId const task = rExec.tasksQueuedRun.at(0); + TaskId const task = rExec.tasksQueuedRun[0]; TopTask &rTopTask = rTaskData[task]; topDataRefs.clear(); @@ -99,17 +98,17 @@ std::ostream& operator<<(std::ostream& rStream, TopExecWriteState const& write) { auto const& [tasks, taskData, graph, exec] = write; - static constexpr int nameMinColumns = 50; - static constexpr int maxDepth = 4; + static constexpr std::size_t nameMinColumns = 50; + static constexpr std::size_t maxDepth = 4; rStream << "Pipeline/Tree | Status | Stages | Pipeline Names\n" << "_________________________________________________________________________________________\n"; - auto const write_pipeline = [&rStream, &tasks=tasks, &exec=exec, &graph=graph] (PipelineId const pipeline, int const depth) + auto const write_pipeline = [&rStream, &tasks=tasks, &exec=exec, &graph=graph] (PipelineId const pipeline, std::size_t const depth) { ExecPipeline const &plExec = exec.plData[pipeline]; - for (int i = 0; i < depth; ++i) + for (std::size_t i = 0; i < depth; ++i) { rStream << "- "; } @@ -139,19 +138,19 @@ std::ostream& operator<<(std::ostream& rStream, TopExecWriteState const& write) rStream << " | "; - int const stageCount = fanout_size(graph.pipelineToFirstAnystg, pipeline); + uint32_t const stageCount = fanout_size(graph.pipelineToFirstAnystg, pipeline); PipelineInfo const& info = tasks.m_pipelineInfo[pipeline]; - int charsUsed = 7; // "PL###" + ": " + std::size_t charsUsed = 7; // "PL###" + ": " if (info.stageType != lgrn::id_null()) { auto const stageNames = ArrayView{PipelineInfo::sm_stageNames[info.stageType]}; - for (int stage = 0; stage < std::min(stageNames.size(), stageCount); ++stage) + for (uint32_t stage = 0; stage < std::min(uint32_t(stageNames.size()), stageCount); ++stage) { - bool const sel = int(plExec.stage) == stage; + bool const sel = uint32_t(plExec.stage) == stage; rStream << (sel ? '[' : ' ') << stageNames[stage] << (sel ? ']' : ' '); diff --git a/src/planet-a/SubdivTriangleMesh.cpp b/src/planet-a/SubdivTriangleMesh.cpp index 6639207d..baf4d774 100644 --- a/src/planet-a/SubdivTriangleMesh.cpp +++ b/src/planet-a/SubdivTriangleMesh.cpp @@ -40,8 +40,8 @@ ChunkedTriangleMeshInfo planeta::make_subdivtrimesh_general( using std::ceil; using std::pow; - float const C = chunkMax; - float const L = subdivLevels; + float const C = static_cast(chunkMax); + float const L = static_cast(subdivLevels); // Calculate a fair number of shared vertices, based on a triangular // tiling pattern. @@ -72,7 +72,7 @@ ChunkId ChunkedTriangleMeshInfo::chunk_create( // Create a new chunk ID ChunkId const chunkId = m_chunkIds.create(); - Chunk &rChunk = m_chunkData[size_t(chunkId)]; + Chunk &rChunk = m_chunkData[std::size_t(chunkId)]; rChunk.m_skeletonTri = rSkel.tri_store(skTri); @@ -84,8 +84,8 @@ ChunkId ChunkedTriangleMeshInfo::chunk_create( for (int i = 0; i < 3; i ++) { - size_t const cornerOffset = m_chunkWidth * i; - size_t const edgeOffset = m_chunkWidth * i + 1; + std::size_t const cornerOffset = static_cast(m_chunkWidth) * i; + std::size_t const edgeOffset = static_cast(m_chunkWidth) * i + 1; ArrayView_t const edge = edges[i]; { @@ -93,7 +93,7 @@ ChunkId ChunkedTriangleMeshInfo::chunk_create( tri.m_vertices[i], rSkel); sharedSpace[cornerOffset] = shared_store(sharedId); } - for (unsigned int j = 0; j < m_chunkWidth - 1; j ++) + for (std::size_t j = 0; j < m_chunkWidth - 1; j ++) { SharedVrtxId const sharedId = shared_get_or_create(edge[j], rSkel); sharedSpace[edgeOffset + j] = shared_store(sharedId); diff --git a/src/planet-a/icosahedron.cpp b/src/planet-a/icosahedron.cpp index aad9652f..bd5fff75 100644 --- a/src/planet-a/icosahedron.cpp +++ b/src/planet-a/icosahedron.cpp @@ -26,6 +26,8 @@ #include "icosahedron.h" +#include // for std::pow + using namespace planeta; SubdivTriangleSkeleton planeta::create_skeleton_icosahedron( @@ -165,8 +167,8 @@ void subdiv_curvature( { osp::Vector3l const avg = (a + b) / 2; osp::Vector3d const avgDouble = osp::Vector3d(avg) / scale; - float const avgLen = avgDouble.length(); - float const roundness = radius - avgLen; + double const avgLen = avgDouble.length(); + double const roundness = radius - avgLen; rNorm = osp::Vector3(avgDouble / avgLen); rPos = avg + osp::Vector3l(rNorm * roundness * scale); @@ -182,15 +184,15 @@ void planeta::ico_calc_middles( auto const pos = [&rPositions] (SkVrtxId const id) -> osp::Vector3l& { return rPositions[size_t(id)]; }; auto const nrm = [&rNormals] (SkVrtxId const id) -> osp::Vector3& { return rNormals[size_t(id)]; }; - float const scale = std::pow(2.0f, pow2scale); + auto const scale = std::pow(2.0, pow2scale); - subdiv_curvature(radius, scale, pos(vrtxCorner[0]), pos(vrtxCorner[1]), + subdiv_curvature(radius, float(scale), pos(vrtxCorner[0]), pos(vrtxCorner[1]), pos(vrtxMid[0]), nrm(vrtxMid[0])); - subdiv_curvature(radius, scale, pos(vrtxCorner[1]), pos(vrtxCorner[2]), + subdiv_curvature(radius, float(scale), pos(vrtxCorner[1]), pos(vrtxCorner[2]), pos(vrtxMid[1]), nrm(vrtxMid[1])); - subdiv_curvature(radius, scale, pos(vrtxCorner[2]), pos(vrtxCorner[0]), + subdiv_curvature(radius, float(scale), pos(vrtxCorner[2]), pos(vrtxCorner[0]), pos(vrtxMid[2]), nrm(vrtxMid[2])); } @@ -213,7 +215,7 @@ void planeta::ico_calc_chunk_edge_recurse( size_t const halfSize = vrtxs.size() / 2; SkVrtxId const mid = vrtxs[halfSize]; - subdiv_curvature(radius, std::pow(2.0f, pow2scale), pos(a), pos(b), + subdiv_curvature(radius, float(std::pow(2.0f, pow2scale)), pos(a), pos(b), pos(mid), nrm(mid)); ico_calc_chunk_edge_recurse(radius, pow2scale, level - 1, a, mid, diff --git a/src/testapp/enginetest.cpp b/src/testapp/enginetest.cpp index aaecceca..115d6401 100644 --- a/src/testapp/enginetest.cpp +++ b/src/testapp/enginetest.cpp @@ -415,7 +415,7 @@ MagnumApplication::AppPtr_t generate_osp_magnum_app(EngineTestScene& rScene, Mag for (std::size_t const entInt : rScene.m_matPhong.ones()) { - rScene.m_matPhongDirty.push_back(DrawEnt(entInt)); + rScene.m_matPhongDirty.emplace_back(entInt); } sync_test_scene(rRenderGl, rScene, rRenderer); diff --git a/src/testapp/sessions/newton.cpp b/src/testapp/sessions/newton.cpp index a6f62cd9..22d59317 100644 --- a/src/testapp/sessions/newton.cpp +++ b/src/testapp/sessions/newton.cpp @@ -357,8 +357,8 @@ Session setup_vehicle_spawn_newton( ? (*itWeldOffsetsNext) : SpWeldId(uint32_t(rVehicleSpawn.spawnedWelds.size())); - std::for_each(itWeldsFirst + std::size_t{*itWeldOffsets}, - itWeldsFirst + std::size_t{weldOffsetNext}, + std::for_each(itWeldsFirst + std::ptrdiff_t{*itWeldOffsets}, + itWeldsFirst + std::ptrdiff_t{weldOffsetNext}, [&rBasic, &rScnParts, &rVehicleSpawn, &rPrefabs, &rResources, &toInit] (WeldId const weld) { // Count parts in this weld first @@ -415,8 +415,8 @@ Session setup_vehicle_spawn_newton( ? (*itWeldOffsetsNext) : SpWeldId(uint32_t(rVehicleSpawn.spawnedWelds.size())); - std::for_each(itWeldsFirst + std::size_t{*itWeldOffsets}, - itWeldsFirst + std::size_t{weldOffsetNext}, + std::for_each(itWeldsFirst + std::ptrdiff_t{*itWeldOffsets}, + itWeldsFirst + std::ptrdiff_t{weldOffsetNext}, [&rBasic, &rScnParts, &rVehicleSpawn, &toInit, &rPhys, &rNwt] (WeldId const weld) { ActiveEnt const weldEnt = rScnParts.weldToActive[weld]; @@ -599,7 +599,7 @@ static void rocket_thrust_force(NewtonBody const* pBody, BodyId const body, ACtx auto &rBodyRockets = rRocketsNwt.m_bodyRockets[body]; - if (rBodyRockets.size() == 0) + if (rBodyRockets.empty()) { return; } diff --git a/src/testapp/sessions/shapes.cpp b/src/testapp/sessions/shapes.cpp index e12a0d67..118602da 100644 --- a/src/testapp/sessions/shapes.cpp +++ b/src/testapp/sessions/shapes.cpp @@ -68,7 +68,7 @@ void add_floor( { float const heightZ = distHeight(randGen); rPhysShapes.m_spawnRequest.emplace_back(SpawnShape{ - .m_position = Vector3{x*spread, y*spread, heightZ}, + .m_position = Vector3{float(x)*spread, float(y)*spread, heightZ}, .m_velocity = {0.0f, 0.0f, 0.0f}, .m_size = Vector3{distSizeX(randGen), distSizeY(randGen), heightZ}, .m_mass = 0.0f, @@ -398,7 +398,7 @@ Session setup_thrower( for (int y = -2; y < 3; ++y) { rPhysShapes.m_spawnRequest.push_back({ - .m_position = camTf.translation() - camTf.backward()*dist + camTf.up()*y*5.5f + camTf.right()*x*5.5f, + .m_position = camTf.translation() - camTf.backward()*dist + camTf.up()*float(y)*5.5f + camTf.right()*float(x)*5.5f, .m_velocity = -camTf.backward()*speed, .m_size = Vector3{1.0f}, .m_mass = 1.0f, diff --git a/src/testapp/sessions/universe.cpp b/src/testapp/sessions/universe.cpp index 73f2ab70..2a60c26c 100644 --- a/src/testapp/sessions/universe.cpp +++ b/src/testapp/sessions/universe.cpp @@ -203,8 +203,8 @@ Session setup_uni_testplanets( { CoSpaceCommon &rMainSpaceCommon = rUniverse.m_coordCommon[planetMainSpace]; - float const scale = osp::math::mul_2pow(1.0f, -rMainSpaceCommon.m_precision); - float const scaleDelta = uniDeltaTimeIn / scale; + auto const scale = osp::math::mul_2pow(1.0, -rMainSpaceCommon.m_precision); + double const scaleDelta = uniDeltaTimeIn / scale; auto const [x, y, z] = sat_views(rMainSpaceCommon.m_satPositions, rMainSpaceCommon.m_data, rMainSpaceCommon.m_satCount); auto const [vx, vy, vz] = sat_views(rMainSpaceCommon.m_satVelocities, rMainSpaceCommon.m_data, rMainSpaceCommon.m_satCount); @@ -220,8 +220,8 @@ Session setup_uni_testplanets( // Apply arbitrary inverse-square gravity towards origin Vector3d const pos = Vector3d( Vector3g( x[i], y[i], z[i] ) ) * scale; - float const r = pos.length(); - float const c_gm = 10000000000.0f; + double const r = pos.length(); + double const c_gm = 10000000000.0; Vector3d const accel = -pos * uniDeltaTimeIn * c_gm / (r * r * r); vx[i] += accel.x(); diff --git a/src/testapp/sessions/vehicles.cpp b/src/testapp/sessions/vehicles.cpp index 13419f7c..df29bf15 100644 --- a/src/testapp/sessions/vehicles.cpp +++ b/src/testapp/sessions/vehicles.cpp @@ -283,7 +283,7 @@ Session setup_vehicle_spawn_vb( remapMachTotal += bounds; machTotal += srcMachines.ids.size(); - for (MachTypeId type = 0; type < MachTypeReg_t::size(); ++type) + for (MachTypeId type = 0; type < MachTypeReg_t::largest(); ++type) { rVSVB.machtypeCount[type] += srcMachines.perType[type].localIds.size(); } @@ -442,7 +442,7 @@ Session setup_vehicle_spawn_vb( auto machRemap = arrayView(std::as_const(rVSVB.remapMachs)).exceptPrefix(rVSVB.remapMachOffsets[vhId]); - for (NodeTypeId nodeType = 0; nodeType < NodeTypeReg_t::size(); ++nodeType) + for (NodeTypeId nodeType = 0; nodeType < NodeTypeReg_t::largest(); ++nodeType) { PerNodeType const &rSrcNodeType = pVData->m_nodePerType[nodeType]; diff --git a/src/testapp/sessions/vehicles_prebuilt.cpp b/src/testapp/sessions/vehicles_prebuilt.cpp index 1d8ecc57..08f1d0f5 100644 --- a/src/testapp/sessions/vehicles_prebuilt.cpp +++ b/src/testapp/sessions/vehicles_prebuilt.cpp @@ -176,16 +176,16 @@ Session setup_prebuilt_vehicles( RCSInputs rcsInputs{pitch, yaw, roll}; - int const rcsRingBlocks = 4; - int const rcsRingCount = 2; - float const rcsRingZ = -2.0f; - float const rcsZStep = 4.0f; - float const rcsRadius = 1.1f; - float const rcsThrust = 3000.0f; + static constexpr int const rcsRingBlocks = 4; + static constexpr int const rcsRingCount = 2; + static constexpr float const rcsRingZ = -2.0f; + static constexpr float const rcsZStep = 4.0f; + static constexpr float const rcsRadius = 1.1f; + static constexpr float const rcsThrust = 3000.0f; for (int ring = 0; ring < rcsRingCount; ++ring) { - Vector3 const rcsOset{rcsRadius, 0.0f, rcsRingZ + ring*rcsZStep }; + Vector3 const rcsOset{rcsRadius, 0.0f, rcsRingZ + float(ring)*rcsZStep }; for (Rad ang = 0.0_degf; ang < Rad(360.0_degf); ang += Rad(360.0_degf)/rcsRingBlocks) { diff --git a/test/resources/main.cpp b/test/resources/main.cpp index 0b52674c..879b0b4e 100644 --- a/test/resources/main.cpp +++ b/test/resources/main.cpp @@ -109,7 +109,7 @@ TEST(Resources, RefCounting) storage = res.owner_create(restypes::gc_image, id); EXPECT_TRUE(storage.has_value()); res.owner_destroy(restypes::gc_image, std::move(storage)); - EXPECT_FALSE(storage.has_value()); + EXPECT_FALSE(storage.has_value()); // NOLINT(bugprone-use-after-move) } #ifdef NDEBUG diff --git a/test/tasks/main.cpp b/test/tasks/main.cpp index 4d4328db..75f145cb 100644 --- a/test/tasks/main.cpp +++ b/test/tasks/main.cpp @@ -63,7 +63,7 @@ void randomized_singlethreaded_execute(Tasks const& tasks, TaskGraph const& grap if (runTasksLeft != 0) { - TaskId const randomTask = rExec.tasksQueuedRun.at(rRand() % runTasksLeft); + TaskId const randomTask = rExec.tasksQueuedRun[rRand() % runTasksLeft]; TaskActions const status = runTask(randomTask); complete_task(tasks, graph, rExec, randomTask, status); }