Fix: CTriangleSelector no longer ignores meshbuffer transformations from skinned meshes.

Thanks @AlexAzazel for report and test-model.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5270 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2016-03-06 19:00:04 +00:00
parent 34ffc48cd5
commit e4f59b2d49
2 changed files with 28 additions and 8 deletions

View File

@ -1,6 +1,7 @@
--------------------------
Changes in 1.9 (not yet released)
- Fix: CTriangleSelector no longer ignores meshbuffer transformations from skinned meshes (thx @AlexAzazel for report and test-model).
- Randomizer now returns range 0..randMax as documented and no longer 1..randMax as it did before. randMax got reduced by 1.
Note: You will generally get different numbers than before! If you need the exact old calculations, please check the corresponding sources in Irrlicht 1.8 in os.cpp/.h
- Resetting Randomizer with 0 or no longer breaks it (will be set to 1). Same for other numbers for which it wasn't defined.

View File

@ -6,6 +6,7 @@
#include "ISceneNode.h"
#include "IMeshBuffer.h"
#include "IAnimatedMeshSceneNode.h"
#include "SSkinMeshBuffer.h"
namespace irr
{
@ -89,6 +90,7 @@ void CTriangleSelector::updateFromMesh(const IMesh* mesh) const
if (!mesh)
return;
bool skinnnedMesh = mesh->getMeshType() == EAMT_SKINNED;
u32 meshBuffers = mesh->getMeshBufferCount();
u32 triangleCount = 0;
@ -99,15 +101,32 @@ void CTriangleSelector::updateFromMesh(const IMesh* mesh) const
u32 idxCnt = buf->getIndexCount();
const u16* indices = buf->getIndices();
for (u32 index = 0; index < idxCnt; index += 3)
if ( skinnnedMesh )
{
core::triangle3df& tri = Triangles[triangleCount++];
tri.pointA = buf->getPosition(indices[index + 0]);
tri.pointB = buf->getPosition(indices[index + 1]);
tri.pointC = buf->getPosition(indices[index + 2]);
BoundingBox.addInternalPoint(tri.pointA);
BoundingBox.addInternalPoint(tri.pointB);
BoundingBox.addInternalPoint(tri.pointC);
const core::matrix4& bufferTransform = ((scene::SSkinMeshBuffer*)buf)->Transformation;
for (u32 index = 0; index < idxCnt; index += 3)
{
core::triangle3df& tri = Triangles[triangleCount++];
bufferTransform.transformVect(tri.pointA, buf->getPosition(indices[index + 0]));
bufferTransform.transformVect(tri.pointB, buf->getPosition(indices[index + 1]));
bufferTransform.transformVect(tri.pointC, buf->getPosition(indices[index + 2]));
BoundingBox.addInternalPoint(tri.pointA);
BoundingBox.addInternalPoint(tri.pointB);
BoundingBox.addInternalPoint(tri.pointC);
}
}
else
{
for (u32 index = 0; index < idxCnt; index += 3)
{
core::triangle3df& tri = Triangles[triangleCount++];
tri.pointA = buf->getPosition(indices[index + 0]);
tri.pointB = buf->getPosition(indices[index + 1]);
tri.pointC = buf->getPosition(indices[index + 2]);
BoundingBox.addInternalPoint(tri.pointA);
BoundingBox.addInternalPoint(tri.pointB);
BoundingBox.addInternalPoint(tri.pointC);
}
}
}
}