From 60596d25dd0070bd810341f6ee75bc4b108b0aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Garramu=C3=B1o?= Date: Sat, 9 Mar 2024 12:16:50 -0300 Subject: [PATCH] Fixed rotation for annotations. --- mrv2/lib/mrvGL/mrvGLViewport.cpp | 4 ++++ mrv2/lib/mrvGL/mrvGLViewport.h | 2 ++ mrv2/lib/mrvGL/mrvGLViewportPrims.cpp | 17 +++++++++++++++++ mrv2/lib/mrvPy/USD.cpp | 15 ++++++++++++--- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/mrv2/lib/mrvGL/mrvGLViewport.cpp b/mrv2/lib/mrvGL/mrvGLViewport.cpp index d67514a21..3baf1b4e2 100644 --- a/mrv2/lib/mrvGL/mrvGLViewport.cpp +++ b/mrv2/lib/mrvGL/mrvGLViewport.cpp @@ -535,6 +535,10 @@ namespace mrv CHECK_GL; } + if (p.environmentMapOptions.type == + EnvironmentMapOptions::kNone) + mvp = _notRotatedMatrix(); + if (p.showAnnotations && gl.annotation) { CHECK_GL; diff --git a/mrv2/lib/mrvGL/mrvGLViewport.h b/mrv2/lib/mrvGL/mrvGLViewport.h index 384928537..c2cf2c6ad 100644 --- a/mrv2/lib/mrvGL/mrvGLViewport.h +++ b/mrv2/lib/mrvGL/mrvGLViewport.h @@ -48,6 +48,8 @@ namespace mrv math::Matrix4x4f _createEnvironmentMap(); math::Matrix4x4f _createTexturedRectangle(); + + math::Matrix4x4f _notRotatedMatrix(); void _calculateColorArea(mrv::area::Info& info); diff --git a/mrv2/lib/mrvGL/mrvGLViewportPrims.cpp b/mrv2/lib/mrvGL/mrvGLViewportPrims.cpp index 7beea03de..6896debd0 100644 --- a/mrv2/lib/mrvGL/mrvGLViewportPrims.cpp +++ b/mrv2/lib/mrvGL/mrvGLViewportPrims.cpp @@ -232,4 +232,21 @@ namespace mrv return pm * vm * to * rm * tm; } + math::Matrix4x4f Viewport::_notRotatedMatrix() + { + TLRENDER_P(); + + const auto& viewportSize = getViewportSize(); + + const math::Matrix4x4f& vm = + math::translate(math::Vector3f(p.viewPos.x, p.viewPos.y, 0.F)) * + math::scale(math::Vector3f(p.viewZoom, p.viewZoom, 1.F)); + + const auto pm = math::ortho( + 0.F, static_cast(viewportSize.w), 0.F, + static_cast(viewportSize.h), -1.F, 1.F); + + return pm * vm; + } + } // namespace mrv diff --git a/mrv2/lib/mrvPy/USD.cpp b/mrv2/lib/mrvPy/USD.cpp index 44875171b..fabbc9684 100644 --- a/mrv2/lib/mrvPy/USD.cpp +++ b/mrv2/lib/mrvPy/USD.cpp @@ -31,12 +31,15 @@ Contains all classes and enums related to USD (Universal Scene Description). .def(py::init<>()) .def( py::init< - std::string, int, float, tl::usd::DrawMode, bool, bool, size_t, - size_t>(), + std::string, int, float, tl::usd::DrawMode, bool, bool, bool, bool, + size_t, size_t>(), py::arg("rendererName") = 0, py::arg("renderWidth") = 1920, py::arg("complexity") = 1.F, py::arg("drawMode") = tl::usd::DrawMode::ShadedSmooth, - py::arg("enableLighting") = true, py::arg("sRGB") = true, + py::arg("enableLighting") = true, + py::arg("enableSceneLights") = false, + py::arg("enableSceneMaterials") = false, + py::arg("sRGB") = true, py::arg("stageCache") = 10, py::arg("diskCache") = 0) .def_readwrite( "rendererName", &usd::RenderOptions::rendererName, @@ -52,6 +55,12 @@ Contains all classes and enums related to USD (Universal Scene Description). .def_readwrite( "enableLighting", &usd::RenderOptions::enableLighting, _("Enable Lighting")) + .def_readwrite( + "enableSceneLights", &usd::RenderOptions::enableLighting, + _("Enable Scene Lights")) + .def_readwrite( + "enableSceneMaterials", &usd::RenderOptions::enableLighting, + _("Enable Scene Materials")) .def_readwrite("sRGB", &usd::RenderOptions::sRGB, _("Enable sRGB")) .def_readwrite( "stageCache", &usd::RenderOptions::stageCache,