From 271bf6d52d5fc506affb60edc495f4a0815b2328 Mon Sep 17 00:00:00 2001 From: Ramses Tech User <94632088+ramses-tech-user@users.noreply.github.com> Date: Fri, 15 Mar 2024 09:03:15 +0000 Subject: [PATCH] Oss release v1.4.4 created 2024-03-15-09-03 see CHANGELOG.md for details Original commit sha: 576b2faef6d27741ca838855d90a415b903a5b5f Co-authored-by: Askanaz Torosyan <46795157+nVxx@users.noreply.github.com> Co-authored-by: Daniel Haas <25718295+bojackHaasman@users.noreply.github.com> Co-authored-by: Mohamed Sharaf-El-Deen <769940+mohhsharaf@users.noreply.github.com> Co-authored-by: Mirko Sova <64351017+smirko-dev@users.noreply.github.com> Co-authored-by: Tobias Hammer Co-authored-by: Violin Yanev --- CHANGELOG.md | 19 +++++- CMakeLists.txt | 2 +- README.md | 2 + .../check-build-with-install-shared-lib.bat | 2 +- doc/sphinx/requirements.txt | 2 +- doc/sphinx/viewer.rst | 23 ++++++++ external/ramses | 2 +- lib/impl/SkinBindingImpl.cpp | 2 +- tools/ramses-logic-viewer/LogicViewer.cpp | 11 +++- tools/ramses-logic-viewer/LogicViewer.h | 1 + .../ramses-logic-viewer/LogicViewerGuiApp.cpp | 1 - .../test/LogicViewerLuaTest.cpp | 58 +++++++++++++++---- unittests/api/SkinBindingTest.cpp | 45 ++++++++++++++ 13 files changed, 151 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49b1705..09c87b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,21 @@ -# master +# v1.4.4 -# Unreleased +**FIXED** + +* SkinBinding serializing inverse binding matrices in wrong order + +**CHANGED** + +* Upgrade ramses from 27.0.130 to 27.0.139 +* ramses-logic-viewer script improvements: + * scene is flushed when `rlogic.update()` is called from script + * added optional sleep parameter (milliseconds) to `rlogic.update()` + +# v1.4.3 + +**FIXED** + +* Patched missing include in sol v3.2.2 # v1.4.2 diff --git a/CMakeLists.txt b/CMakeLists.txt index af3c4e8..bd09615 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ cmake_minimum_required(VERSION 3.13) set(RLOGIC_VERSION_MAJOR 1) set(RLOGIC_VERSION_MINOR 4) -set(RLOGIC_VERSION_PATCH 2) +set(RLOGIC_VERSION_PATCH 4) set(RLOGIC_VERSION ${RLOGIC_VERSION_MAJOR}.${RLOGIC_VERSION_MINOR}.${RLOGIC_VERSION_PATCH}) set(ramses-logic_VERSION "${RLOGIC_VERSION}" CACHE STRING "Ramses Logic version" FORCE) diff --git a/README.md b/README.md index 9aceef6..fb94211 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ existing files exported with Logic Engine version **W** or newer (Binary file co |Logic | Included Ramses version | Minimum required Ramses version | Binary file compatibility | |----------|-------------------------------|------------------------------------|------------------------------| +|v1.4.4 | 27.0.139 | 27.0.102 | >= 1.0.0, F-Levels 01 - 05 | +|v1.4.3 | 27.0.130 | 27.0.102 | >= 1.0.0, F-Levels 01 - 05 | |v1.4.2 | 27.0.130 | 27.0.102 | >= 1.0.0, F-Levels 01 - 05 | |v1.4.1 | 27.0.128 | 27.0.102 | >= 1.0.0, F-Levels 01 - 05 | |v1.4.0 | 27.0.126 | 27.0.102 | >= 1.0.0, F-Levels 01 - 05 | diff --git a/ci/scripts/installation-check/check-build-with-install-shared-lib.bat b/ci/scripts/installation-check/check-build-with-install-shared-lib.bat index 7c9088d..84dfd22 100644 --- a/ci/scripts/installation-check/check-build-with-install-shared-lib.bat +++ b/ci/scripts/installation-check/check-build-with-install-shared-lib.bat @@ -42,7 +42,7 @@ cd test-cmake.config SET PATH=%INSTALL_DIR%/bin;%PATH% -cmake -G%CMAKE_GENERATOR% -DCMAKE_PREFIX_PATH="%INSTALL_DIR%" --build test-cmake.config %SCRIPT_DIR%/shared-lib-check/ +cmake -G%CMAKE_GENERATOR% -DCMAKE_PREFIX_PATH="%INSTALL_DIR%" %SCRIPT_DIR%/shared-lib-check/ cmake --build . --config %BUILD_CONFIG% --target run-all ::check for errors diff --git a/doc/sphinx/requirements.txt b/doc/sphinx/requirements.txt index 9922d1c..7198157 100644 --- a/doc/sphinx/requirements.txt +++ b/doc/sphinx/requirements.txt @@ -10,7 +10,7 @@ alabaster==0.7.12 attrs==21.2.0 Babel==2.9.1 breathe==4.18.1 -certifi==2020.12.5 +certifi==2022.12.7 chardet==4.0.0 docutils==0.16 idna==2.10 diff --git a/doc/sphinx/viewer.rst b/doc/sphinx/viewer.rst index 2d9bd77..3d9cf3f 100644 --- a/doc/sphinx/viewer.rst +++ b/doc/sphinx/viewer.rst @@ -83,6 +83,10 @@ Options Instructs the renderer to apply multisampling (Valid values: 1, 2, 4, 8) +.. option:: --clear-color R G B A + + Sets the display clear color to other than the default black (e.g.: :code:`ramses-logic-viewer --clear-color 0 0.5 0.8 1`) + .. option:: --write-config [filename] Writes the default lua configuration to the given filename. If the filename is omitted, the viewer will use @@ -108,11 +112,18 @@ Logic Nodes The module ``rlogic`` provides members to access all Logic Node types: +* ``rlogic.interfaces`` (:cpp:class:`rlogic::LuaInterface`) * ``rlogic.scripts`` (:cpp:class:`rlogic::LuaScript`) * ``rlogic.animationNodes`` (:cpp:class:`rlogic::AnimationNode`) +* ``rlogic.timerNodes`` (:cpp:class:`rlogic::TimerNode`) * ``rlogic.nodeBindings`` (:cpp:class:`rlogic::RamsesNodeBinding`) * ``rlogic.appearanceBindings`` (:cpp:class:`rlogic::RamsesAppearanceBinding`) * ``rlogic.cameraBindings`` (:cpp:class:`rlogic::RamsesCameraBinding`) +* ``rlogic.renderPassBindings`` (:cpp:class:`rlogic::RamsesRenderPassBinding`) +* ``rlogic.renderGroupBindings`` (:cpp:class:`rlogic::RamsesRenderGroupBinding`) +* ``rlogic.meshNodeBindings`` (:cpp:class:`rlogic::RamsesMeshNodeBinding`) +* ``rlogic.anchorPoints`` (:cpp:class:`rlogic::AnchorPoint`) +* ``rlogic.skinBindings`` (:cpp:class:`rlogic::SkinBinding`) The Logic Node instances can be either found by name or by object id. Alternatively the node list can be iterated. @@ -258,3 +269,15 @@ the logic engine state by calling ``rlogic.update()``: if not rlogic.scripts.foo.OUT.color.value == {255, 0, 0} then error("unexpected value") end + +``rlogic.update()`` has an optional integer parameter that takes a time value in milliseconds. +If the parameter is set to a non-zero value, ``rlogic.update()`` will sleep for the given amount of time. +This can be useful to avoid high CPU load, if the batch script needs to wait for an expected value change. + +.. code-block:: lua + + rlogic.scripts.foo.IN.color.value = "red" + + while not rlogic.scripts.foo.OUT.color.value == {255, 0, 0} do + rlogic.update(16) + end diff --git a/external/ramses b/external/ramses index 5963bf6..3b3dc95 160000 --- a/external/ramses +++ b/external/ramses @@ -1 +1 @@ -Subproject commit 5963bf68238e1b03b7746b45b0b5ea99337d41af +Subproject commit 3b3dc95ca9b63a167b36dfe00b74c41275aab0e1 diff --git a/lib/impl/SkinBindingImpl.cpp b/lib/impl/SkinBindingImpl.cpp index 30bf451..255dfab 100644 --- a/lib/impl/SkinBindingImpl.cpp +++ b/lib/impl/SkinBindingImpl.cpp @@ -73,7 +73,7 @@ namespace rlogic::internal for (const auto& mat : skinBinding.m_inverseBindMatrices) { const auto matData = mat.toStdArray(); - inverseBindMatData.insert(inverseBindMatData.begin(), matData.cbegin(), matData.cend()); + inverseBindMatData.insert(inverseBindMatData.end(), matData.cbegin(), matData.cend()); } const auto fbInverseBindMatData = builder.CreateVector(inverseBindMatData); diff --git a/tools/ramses-logic-viewer/LogicViewer.cpp b/tools/ramses-logic-viewer/LogicViewer.cpp index d655f44..390f83b 100644 --- a/tools/ramses-logic-viewer/LogicViewer.cpp +++ b/tools/ramses-logic-viewer/LogicViewer.cpp @@ -9,6 +9,7 @@ #include "LogicViewer.h" #include "LogicViewerLuaTypes.h" #include "LogicViewerLog.h" +#include "ramses-client-api/Scene.h" #include "ramses-logic/LogicEngine.h" #include "ramses-logic/AnimationNode.h" #include "ramses-logic/TimerNode.h" @@ -27,6 +28,7 @@ #include "internals/SolHelper.h" #include #include +#include namespace rlogic { @@ -129,6 +131,7 @@ namespace rlogic bool LogicViewer::loadRamsesLogic(const std::string& filename, ramses::Scene* scene) { + m_scene = scene; m_logicFilename = filename; return m_logicEngine.loadFromFile(filename, scene); } @@ -205,7 +208,11 @@ namespace rlogic return m_screenshotFunc(screenshotFile); }, ltnUpdate, - [&]() { updateEngine(); }, + [&](uint32_t sleepMs = 0) { + updateEngine(); + if (sleepMs != 0) + std::this_thread::sleep_for(std::chrono::milliseconds(sleepMs)); + }, ltnLink, [&](const ConstPropertyWrapper& src, const PropertyWrapper& target) { return m_logicEngine.link(src.m_property, target.m_property); }, ltnUnlink, @@ -312,6 +319,8 @@ namespace rlogic void LogicViewer::updateEngine() { m_logicEngine.update(); + if (m_scene) + m_scene->flush(); if (m_updateReportEnabled) { m_updateReportSummary.add(m_logicEngine.getLastUpdateReport()); diff --git a/tools/ramses-logic-viewer/LogicViewer.h b/tools/ramses-logic-viewer/LogicViewer.h index d4aaf3c..f04893b 100644 --- a/tools/ramses-logic-viewer/LogicViewer.h +++ b/tools/ramses-logic-viewer/LogicViewer.h @@ -158,6 +158,7 @@ namespace rlogic void load(sol::load_result&& loadResult); rlogic::LogicEngine m_logicEngine; + ramses::Scene* m_scene = nullptr; ScreenshotFunc m_screenshotFunc; std::string m_logicFilename; std::string m_luaFilename; diff --git a/tools/ramses-logic-viewer/LogicViewerGuiApp.cpp b/tools/ramses-logic-viewer/LogicViewerGuiApp.cpp index 48bc63a..093a3f7 100644 --- a/tools/ramses-logic-viewer/LogicViewerGuiApp.cpp +++ b/tools/ramses-logic-viewer/LogicViewerGuiApp.cpp @@ -198,7 +198,6 @@ namespace rlogic if (isRunning) { const auto updateStatus = m_viewer->update(); - m_scene->flush(); m_imguiHelper->dispatchEvents(); ImGui::NewFrame(); m_gui->draw(); diff --git a/tools/ramses-logic-viewer/test/LogicViewerLuaTest.cpp b/tools/ramses-logic-viewer/test/LogicViewerLuaTest.cpp index 1976c01..94a3ab9 100644 --- a/tools/ramses-logic-viewer/test/LogicViewerLuaTest.cpp +++ b/tools/ramses-logic-viewer/test/LogicViewerLuaTest.cpp @@ -44,7 +44,6 @@ namespace rlogic::internal IN.paramInt64_2 = Type:Int64() IN.paramFloat = Type:Float() IN.paramFloat_2 = Type:Float() - IN.paramFloat_3 = Type:Float() IN.paramString = Type:String() IN.paramVec2f = Type:Vec2f() IN.paramVec3f = Type:Vec3f() @@ -59,6 +58,9 @@ namespace rlogic::internal data2 = Type:Int32() } } + IN.anchorData1 = Type:Vec2f() + IN.anchorData2 = Type:Float() + OUT.paramBool = Type:Bool() OUT.paramInt32 = Type:Int32() OUT.paramInt64 = Type:Int64() @@ -77,6 +79,8 @@ namespace rlogic::internal data2 = Type:Int32() } } + OUT.anchorData1 = Type:Vec2f() + OUT.anchorData2 = Type:Float() end function run(IN,OUT) OUT.paramBool = not IN.paramBool @@ -93,6 +97,8 @@ namespace rlogic::internal OUT.array = {10,20,30,44,50} OUT.struct.nested.data1 = IN.paramString OUT.struct.nested.data2 = IN.paramInt32 + OUT.anchorData1 = IN.anchorData1 + OUT.anchorData2 = IN.anchorData2 end )", {}, "foo"); @@ -165,11 +171,13 @@ namespace rlogic::internal *script->getOutputs()->getChild("paramFloat"), *cameraBinding->getInputs()->getChild("frustum")->getChild("leftPlane")); - // use weak link because of circular dependency. The link has no meaning, it is just - // needed to make the setup valid (fee of dangling content) + // use weak link because of circular dependency + engine.linkWeak( + *anchor->getOutputs()->getChild("viewportCoords"), + *script->getInputs()->getChild("anchorData1")); engine.linkWeak( *anchor->getOutputs()->getChild("depth"), - *script->getInputs()->getChild("paramFloat_3")); + *script->getInputs()->getChild("anchorData2")); engine.update(); @@ -844,8 +852,29 @@ namespace rlogic::internal TEST_F(ALogicViewerLua, anchorPointByName) { - auto* coords = getOutput("foo", "viewportCoords"); - EXPECT_TRUE(coords); + // unlink anchor from script inputs so that we can overwrite values + unlinkInput(*getInput("foo", "anchorData1")); + unlinkInput(*getInput("foo", "anchorData2")); + + // first overwrite with some dummy values to 'reset' them + EXPECT_EQ(Result(), loadLua(R"( + rlogic.scripts.foo.IN.anchorData1.value = { 1, 2 } + rlogic.scripts.foo.IN.anchorData2.value = 3 + )")); + auto* outScript = getNode("foo"); + EXPECT_FLOAT_EQ(1.f, GetOutput(outScript, "anchorData1")->get().value()[0]); + EXPECT_FLOAT_EQ(2.f, GetOutput(outScript, "anchorData1")->get().value()[1]); + EXPECT_FLOAT_EQ(3.f, GetOutput(outScript, "anchorData2")->get().value()); + + // now access values from anchor point and assign them to script inputs, overwriting the dummy values from before + EXPECT_EQ(Result(), loadLua(R"( + rlogic.scripts.foo.IN.anchorData1.value = { rlogic.anchorPoints.foo.OUT.viewportCoords.value[1], rlogic.anchorPoints.foo.OUT.viewportCoords.value[2] } + rlogic.scripts.foo.IN.anchorData2.value = rlogic.anchorPoints.foo.OUT.depth.value + )")); + + EXPECT_FLOAT_EQ(0.f, GetOutput(outScript, "anchorData1")->get().value()[0]); + EXPECT_FLOAT_EQ(8.f, GetOutput(outScript, "anchorData1")->get().value()[1]); + EXPECT_FLOAT_EQ(-0.01010102f, GetOutput(outScript, "anchorData2")->get().value()); } TEST_F(ALogicViewerLua, interfaceById) @@ -964,10 +993,19 @@ namespace rlogic::internal TEST_F(ALogicViewerLua, anchorPointById) { - auto* node = getNode("foo"); - ASSERT_EQ(8u, node->getId()); - auto* ticker = GetOutput(node, "viewportCoords"); - EXPECT_TRUE(ticker); + // unlink anchor from script inputs so that we can overwrite values + unlinkInput(*getInput("foo", "anchorData1")); + unlinkInput(*getInput("foo", "anchorData2")); + + EXPECT_EQ(Result(), loadLua(R"( + rlogic.scripts.foo.IN.anchorData1.value = { rlogic.anchorPoints[8].OUT.viewportCoords.value[1], rlogic.anchorPoints[8].OUT.viewportCoords.value[2] } + rlogic.scripts.foo.IN.anchorData2.value = rlogic.anchorPoints[8].OUT.depth.value + )")); + + auto* outScript = getNode("foo"); + EXPECT_FLOAT_EQ(0.f, GetOutput(outScript, "anchorData1")->get().value()[0]); + EXPECT_FLOAT_EQ(8.f, GetOutput(outScript, "anchorData1")->get().value()[1]); + EXPECT_FLOAT_EQ(-0.01010102f, GetOutput(outScript, "anchorData2")->get().value()); } TEST_F(ALogicViewerLua, animationNodeById) diff --git a/unittests/api/SkinBindingTest.cpp b/unittests/api/SkinBindingTest.cpp index 92a3064..84efca7 100644 --- a/unittests/api/SkinBindingTest.cpp +++ b/unittests/api/SkinBindingTest.cpp @@ -171,6 +171,51 @@ namespace rlogic::internal EXPECT_NEAR(expectedMat2[i], mat2[i], 1e-4f) << i; } + TEST_F(ASkinBinding, CalculatesSameValuesAfterLoadingFromFile) + { + WithTempDirectory tmpDir; + + m_jointNodes[0]->setRotation(1.f, 2.f, 3.f); + m_jointNodes[1]->setTranslation(-1.f, -2.f, -3.f); + EXPECT_TRUE(m_logicEngine.update()); + EXPECT_TRUE(m_logicEngine.saveToFile("tmp.logic")); + // change to dummy values in shared scene + const std::array dummyData{ 0.f }; + m_appearance->setInputValueMatrix44f(m_uniform, 2u, dummyData.data()); + + // load from file, update and expect unfiforms matching original values + LogicEngine loadedLogic{ m_logicEngine.getFeatureLevel() }; + EXPECT_TRUE(loadedLogic.loadFromFile("tmp.logic", m_scene)); + EXPECT_TRUE(loadedLogic.update()); + + const matrix44f expectedMat1 = { + 0.998f, -0.0523f, 0.0349f, 0.f, + 0.0529f, 0.9984f, -0.0174f, 0.f, + -0.0339f, 0.01925f, 0.9992f, 0.f, + -0.00209f, -0.00235f, 0.00227f, 1.f + }; + const matrix44f expectedMat2 = { + 1.f, 0.f, 0.f, 0.f, + 0.f, 1.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + -1.f, -2.f, -3.f, 1.f + }; + + std::array uniformData{}; + m_appearance->getInputValueMatrix44f(m_uniform, 2u, uniformData.data()); + + matrix44f mat1{}; + matrix44f mat2{}; + std::copy(uniformData.cbegin(), uniformData.cbegin() + 16u, mat1.begin()); + std::copy(uniformData.cbegin() + 16u, uniformData.cend(), mat2.begin()); + + for (size_t i = 0u; i < 16u; ++i) + EXPECT_NEAR(expectedMat1[i], mat1[i], 1e-4f) << i; + + for (size_t i = 0u; i < 16u; ++i) + EXPECT_NEAR(expectedMat2[i], mat2[i], 1e-4f) << i; + } + class ASkinBinding_SerializationLifecycle : public ASkinBinding { protected: