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
This commit is contained in:
cutealien 2023-12-13 14:14:12 +00:00
parent 952f11f806
commit 66d189ce63
3 changed files with 16 additions and 15 deletions

View File

@ -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.

View File

@ -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))

View File

@ -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