From 5f3f3a7e1da6bfe651afa13546700d1a610f89c8 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sun, 17 Aug 2025 08:48:04 +0200 Subject: [PATCH] Address feedback --- components/fx/lexer.cpp | 2 +- components/fx/technique.cpp | 10 +++++----- components/fx/types.hpp | 20 ++++++++------------ 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/components/fx/lexer.cpp b/components/fx/lexer.cpp index 9844a6de6e..e2759e7af0 100644 --- a/components/fx/lexer.cpp +++ b/components/fx/lexer.cpp @@ -205,7 +205,7 @@ namespace Fx advance(); return { Comma{} }; default: - error(std::format("unexpected token <{}>", head())); + error(std::format("unexpected token <{:c}>", head())); } } diff --git a/components/fx/technique.cpp b/components/fx/technique.cpp index 38db49bc7a..ac55a16b6f 100644 --- a/components/fx/technique.cpp +++ b/components/fx/technique.cpp @@ -98,7 +98,7 @@ namespace Fx Technique::UniformMap::iterator Technique::findUniform(std::string_view name) { return std::find_if(mDefinedUniforms.begin(), mDefinedUniforms.end(), - [=](const auto& uniform) { return uniform->mName == name; }); + [name](const auto& uniform) { return uniform->mName == name; }); } bool Technique::compile() @@ -372,7 +372,7 @@ namespace Fx else if (!pass->mFragment) pass->mFragment = new osg::Shader(osg::Shader::FRAGMENT, getBlockWithLineDirective()); else - error(std::format("duplicate vertex shader for block '{}'", mBlockName)); + error(std::format("duplicate fragment shader for block '{}'", mBlockName)); pass->mType = Pass::Type::Pixel; } @@ -397,7 +397,7 @@ namespace Fx else if (!pass->mFragment) pass->mCompute = new osg::Shader(osg::Shader::COMPUTE, getBlockWithLineDirective()); else - error(std::format("duplicate vertex shader for block '{}'", mBlockName)); + error(std::format("duplicate compute shader for block '{}'", mBlockName)); pass->mType = Pass::Type::Compute; } @@ -690,9 +690,9 @@ namespace Fx if (!std::holds_alternative(mToken) && !std::holds_alternative(mToken)) { if (err.empty()) - error(std::format("{}. Expected {} or {}", err, T::repr, T2::repr)); - else error(std::format("Expected {} or {}", T::repr, T2::repr)); + else + error(std::format("{}. Expected {} or {}", err, T::repr, T2::repr)); } } diff --git a/components/fx/types.hpp b/components/fx/types.hpp index 7897156d7f..bdb46a76c1 100644 --- a/components/fx/types.hpp +++ b/components/fx/types.hpp @@ -112,12 +112,7 @@ namespace Fx size_t getNumElements() const { - return std::visit( - [&](auto&& arg) { - ; - return arg.isArray() ? arg.getArray().size() : 1; - }, - mData); + return std::visit([](auto&& arg) { return arg.isArray() ? arg.getArray().size() : 1; }, mData); } template @@ -261,29 +256,30 @@ namespace Fx if (useUniform) return std::format("uniform vec2 {};", uname); - return std::format("const vec2 {}=vec2({},{});", mName, value[0], value[1]); + return std::format("const vec2 {}=vec2({:f},{:f});", mName, value[0], value[1]); } else if constexpr (std::is_same_v) { if (useUniform) return std::format("uniform vec3 {};", uname); - return std::format("const vec3 {}=vec3({},{},{});", mName, value[0], value[1], value[2]); + return std::format( + "const vec3 {}=vec3({:f},{:f},{:f});", mName, value[0], value[1], value[2]); } else if constexpr (std::is_same_v) { if (useUniform) return std::format("uniform vec4 {};", uname); - return std::format( - "const vec4 {}=vec4({},{},{},{});", mName, value[0], value[1], value[2], value[3]); + return std::format("const vec4 {}=vec4({:f},{:f},{:f},{:f});", mName, value[0], value[1], + value[2], value[3]); } else if constexpr (std::is_same_v) { if (useUniform) return std::format("uniform float {};", uname); - return std::format("const float {}={};", mName, value); + return std::format("const float {}={:f};", mName, value); } else if constexpr (std::is_same_v) { @@ -298,7 +294,7 @@ namespace Fx if (useUniform) return std::format("uniform bool {};", uname); - return std::format("const bool {}={};", mName, value ? "true" : "false"); + return std::format("const bool {}={};", mName, value); } }, mData);