From 66d189ce633118a6362d48f56acdb6b202ee2a77 Mon Sep 17 00:00:00 2001 From: cutealien Date: Wed, 13 Dec 2023 14:14:12 +0000 Subject: [PATCH] Bugfix: CTriangleSelector::getTriangles with bbox no longer ignores transform matrix So far it only used the inverse of the node transformation to calculate the box used to check Which gave wrong results as soon as one tried to pass an additional matrix transformation Wasn't ever used internally or by examples in Irrlicht, so I guess no one ever noticed (also in some cases this still worked accidentally). git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6577 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 1 + source/Irrlicht/CTriangleSelector.cpp | 28 +++++++++++++-------------- tests/tests-last-passed-at.txt | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/changes.txt b/changes.txt index b064fd0f..b91bb00e 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,7 @@ -------------------------- Changes in 1.9 (not yet released) +- Bugfix: CTriangleSelector::getTriangles with bounding-box parameter no longer ignores an additionally passed matrix transformation in the box check - Fix: CGUITabControl now catching EMIE_LMOUSE_PRESSED_DOWN - Add options for transparency node sorting algorithm. - CImageWriterPNG now also supports the writeImageToFile param to allow setting compressing level. 0 stays default, 1-10 for range increasing compression level. diff --git a/source/Irrlicht/CTriangleSelector.cpp b/source/Irrlicht/CTriangleSelector.cpp index 8186950c..d02f2572 100644 --- a/source/Irrlicht/CTriangleSelector.cpp +++ b/source/Irrlicht/CTriangleSelector.cpp @@ -337,20 +337,6 @@ void CTriangleSelector::getTriangles(core::triangle3df* triangles, update(); core::matrix4 mat(core::matrix4::EM4CONST_NOTHING); - core::aabbox3df tBox(box); - - if (SceneNode && useNodeTransform) - { - if ( SceneNode->getAbsoluteTransformation().getInverse(mat) ) - mat.transformBoxEx(tBox); - else - { - // TODO: else is not yet handled optimally. - // If a node has an axis scaled to 0 we return all triangles without any check - return getTriangles(triangles, arraySize, outTriangleCount, - transform, useNodeTransform, outTriangleInfo ); - } - } if (transform) mat = *transform; else @@ -358,6 +344,20 @@ void CTriangleSelector::getTriangles(core::triangle3df* triangles, if (SceneNode && useNodeTransform) mat *= SceneNode->getAbsoluteTransformation(); + core::aabbox3df tBox(box); + core::matrix4 invMat(core::matrix4::EM4CONST_NOTHING); + if ( mat.getInverse(invMat) ) + { + invMat.transformBoxEx(tBox); + } + else + { + // TODO: else is not yet handled optimally. + // If a node has an axis scaled to 0 we return all triangles without any check + return getTriangles(triangles, arraySize, outTriangleCount, + transform, useNodeTransform, outTriangleInfo ); + } + outTriangleCount = 0; if (!tBox.intersectsWithBox(BoundingBox)) diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index 61976c19..ee7e9c09 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 72 tests of 72 passed. Compiled as DEBUG -Test suite pass at GMT Wed Nov 22 14:39:17 2023 +Test suite pass at GMT Wed Dec 13 14:06:37 2023