From 1b9c19fd788e6116984c2466bad0b75047012a6a Mon Sep 17 00:00:00 2001 From: SirLynix Date: Thu, 31 Aug 2023 18:01:59 +0200 Subject: [PATCH] Minor fixes --- include/Nazara/Math/BoundingVolume.inl | 4 +-- include/Nazara/Math/Matrix4.inl | 8 ++--- include/Nazara/Renderer/DebugDrawer.hpp | 2 +- src/Nazara/Graphics/PointLightShadowData.cpp | 12 ++++--- xmake.lua | 33 +++++++++++++------- 5 files changed, 35 insertions(+), 24 deletions(-) diff --git a/include/Nazara/Math/BoundingVolume.inl b/include/Nazara/Math/BoundingVolume.inl index 3d5cea6f8..5b4f3c015 100644 --- a/include/Nazara/Math/BoundingVolume.inl +++ b/include/Nazara/Math/BoundingVolume.inl @@ -363,7 +363,7 @@ namespace Nz } // If we arrive here, the extent is invalid - NazaraError("Invalid extent type (From) ({0:#x})", UnderlyingCast(from.extent)); + NazaraError("invalid extent type (From) ({0:#x})", UnderlyingCast(from.extent)); return Null(); } @@ -390,7 +390,7 @@ namespace Nz } // If we arrive here, the extent is invalid - NazaraError("Invalid extent type (From) ({0:#x})", UnderlyingCast(from.extent)); + NazaraError("invalid extent type (From) ({0:#x})", UnderlyingCast(from.extent)); return Null(); } } diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index 11a100756..1931268c5 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -1226,10 +1226,10 @@ namespace Nz { // http://msdn.microsoft.com/en-us/library/windows/desktop/bb204942(v=vs.85).aspx return Matrix4( - T(2.0) / (right - left), T(0.0), T(0.0), T(0.0), - T(0.0), T(2.0) / (top - bottom), T(0.0), T(0.0), - T(0.0), T(0.0), T(1.0) / (zNear - zFar), T(0.0), - (left + right) / (left - right), (top + bottom) / (bottom - top), zNear / (zNear - zFar), T(1.0) + T(2.0) / (right - left), T(0.0), T(0.0), T(0.0), + T(0.0), T(2.0) / (top - bottom), T(0.0), T(0.0), + T(0.0), T(0.0), T(1.0) / (zNear - zFar), T(0.0), + (left + right) / (left - right), (top + bottom) / (bottom - top), zNear / (zNear - zFar), T(1.0) ); } diff --git a/include/Nazara/Renderer/DebugDrawer.hpp b/include/Nazara/Renderer/DebugDrawer.hpp index 1d916daa3..795d56076 100644 --- a/include/Nazara/Renderer/DebugDrawer.hpp +++ b/include/Nazara/Renderer/DebugDrawer.hpp @@ -44,7 +44,7 @@ namespace Nz inline void DrawFrustum(const Frustumf& frustum, const Color& color); inline void DrawLine(const Vector3f& start, const Vector3f& end, const Color& color); inline void DrawLine(const Vector3f& start, const Vector3f& end, const Color& startColor, const Color& endColor); - inline void DrawPoint(const Vector3f& point, const Color& color, float boxSize = 0.1f); + inline void DrawPoint(const Vector3f& point, const Color& color, float boxSize = 0.01f); void DrawSkeleton(const Skeleton& skeleton, const Color& color); void Prepare(RenderFrame& renderFrame); diff --git a/src/Nazara/Graphics/PointLightShadowData.cpp b/src/Nazara/Graphics/PointLightShadowData.cpp index a8d4e36b2..b0c5c6944 100644 --- a/src/Nazara/Graphics/PointLightShadowData.cpp +++ b/src/Nazara/Graphics/PointLightShadowData.cpp @@ -21,8 +21,8 @@ namespace Nz Quaternionf::RotationBetween(Vector3f::Forward(), -Vector3f::UnitX()), Quaternionf::RotationBetween(Vector3f::Forward(), Vector3f::UnitY()), Quaternionf::RotationBetween(Vector3f::Forward(), -Vector3f::UnitY()), - Quaternionf::Identity(), - Quaternionf(0.f, 0.f, 1.f, 0.f) + Quaternionf::RotationBetween(Vector3f::Forward(), -Vector3f::UnitZ()), //< FIXME: Find out why Z is reversed + Quaternionf::RotationBetween(Vector3f::Forward(), Vector3f::UnitZ()), }; constexpr std::array s_dirNames = { @@ -30,8 +30,8 @@ namespace Nz "Point-light shadow mapping -X", "Point-light shadow mapping +Y", "Point-light shadow mapping -Y", - "Point-light shadow mapping +Z", - "Point-light shadow mapping -Z" + "Point-light shadow mapping -Z", + "Point-light shadow mapping +Z" }; } @@ -63,6 +63,8 @@ namespace Nz std::size_t shadowPassIndex = Graphics::Instance()->GetMaterialPassRegistry().GetPassIndex("ShadowPass"); + Matrix4f projectionMatrix = Matrix4f::Perspective(RadianAnglef(HalfPi), 1.f, 0.01f, m_light.GetRadius()); + UInt32 shadowMapSize = light.GetShadowMapSize(); for (std::size_t i = 0; i < m_directions.size(); ++i) { @@ -72,8 +74,8 @@ namespace Nz viewer.UpdateViewport(Recti(0, 0, SafeCast(shadowMapSize), SafeCast(shadowMapSize))); ViewerInstance& viewerInstance = viewer.GetViewerInstance(); - viewerInstance.UpdateProjectionMatrix(Matrix4f::Perspective(RadianAnglef(HalfPi), 1.f, 0.01f, m_light.GetRadius())); viewerInstance.UpdateEyePosition(m_light.GetPosition()); + viewerInstance.UpdateProjectionMatrix(projectionMatrix); viewerInstance.UpdateViewMatrix(Matrix4f::TransformInverse(m_light.GetPosition(), s_dirRotations[i])); m_pipeline.QueueTransfer(&viewerInstance); diff --git a/xmake.lua b/xmake.lua index 5c225fdbe..96ea4e5ab 100644 --- a/xmake.lua +++ b/xmake.lua @@ -207,7 +207,7 @@ if is_plat("wasm") then end if not has_config("embed_rendererbackends", "static") then - -- Register backends as separate modules + -- Register renderer backends as separate modules for name, module in pairs(rendererBackends) do if (modules[name] ~= nil) then os.raise("overriding module " .. name) @@ -219,6 +219,13 @@ end NazaraModules = modules +-- add_extrafiles was added in xmake 2.8.2 but was broken for wildcard +if xmake.version():lt("2.8.3") then + add_extrafiles = function (...) + add_headerfiles(..., { install = false }) + end +end + set_project("NazaraEngine") set_xmakever("2.7.3") @@ -234,8 +241,8 @@ option("link_curl", { description = "Link libcurl in the executable instead of d option("link_openal", { description = "Link OpenAL in the executable instead of dynamically loading it", default = is_plat("wasm") or false }) option("static", { description = "Build the engine statically (implies embed_rendererbackends and embed_plugins)", default = is_plat("wasm") or false }) option("override_runtime", { description = "Override vs runtime to MD in release and MDd in debug", default = true }) -option("usepch", { description = "Use precompiled headers to speedup compilation", default = false }) option("unitybuild", { description = "Build the engine using unity build", default = false }) +option("usepch", { description = "Use precompiled headers to speedup compilation", default = false }) -- Allow to disable some modules for name, module in pairs(modules) do @@ -443,16 +450,21 @@ function ModuleTargetConfig(name, module) end -- Add header and source files - local headerExts = {".h", ".hpp", ".inl", ".natvis"} - for _, ext in ipairs(headerExts) do + for _, ext in ipairs({".h", ".hpp", ".inl"}) do add_headerfiles("include/(Nazara/" .. name .. "/**" .. ext .. ")") add_headerfiles("src/Nazara/" .. name .. "/**" .. ext, { prefixdir = "private", install = false }) add_headerfiles("src/Nazara/" .. name .. "/Resources/**.nzsl", { prefixdir = "private", install = false }) end - remove_headerfiles("src/Nazara/" .. name .. "/Resources/**.h") + -- Add extra files for projects + for _, ext in ipairs({".natvis", ".nzsl"}) do + add_extrafiles("include/Nazara/" .. name .. "/**" .. ext) + add_extrafiles("src/Nazara/" .. name .. "/**" .. ext) + end + add_files("src/Nazara/" .. name .. "/**.cpp") + if has_config("embed_resources") then local embedResourceRule = false for _, filepath in pairs(os.files("src/Nazara/" .. name .. "/Resources/**|**.h|**.nzsl|**.nzslb")) do @@ -512,16 +524,16 @@ for name, module in pairs(modules) do else set_kind("shared") end - + + add_defines("NAZARA_BUILD") + add_includedirs("src") + add_packages("fmt") -- fmt is a special package that is not public but required by all Nazara modules add_rpathdirs("$ORIGIN") if module.Deps then add_deps(table.unpack(module.Deps)) end - -- fmt is a special package that is not public but required by all Nazara modules - add_packages("fmt") - if module.Packages then add_packages(table.unpack(module.Packages)) end @@ -540,13 +552,10 @@ for name, module in pairs(modules) do add_rules("c++.unity_build", {uniqueid = "NAZARA_UNITY_ID", batchsize = 12}) end - add_defines("NAZARA_BUILD") if is_plat("windows", "mingw") then add_defines("NAZARA_UTILS_WINDOWS_NT6=1") end - add_includedirs("src") - ModuleTargetConfig(name, module) end)