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

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