Commit e4f59b2d authored by cutealien's avatar cutealien

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
parent 34ffc48c
-------------------------- --------------------------
Changes in 1.9 (not yet released) 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. - 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 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. - Resetting Randomizer with 0 or no longer breaks it (will be set to 1). Same for other numbers for which it wasn't defined.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "ISceneNode.h" #include "ISceneNode.h"
#include "IMeshBuffer.h" #include "IMeshBuffer.h"
#include "IAnimatedMeshSceneNode.h" #include "IAnimatedMeshSceneNode.h"
#include "SSkinMeshBuffer.h"
namespace irr namespace irr
{ {
...@@ -89,6 +90,7 @@ void CTriangleSelector::updateFromMesh(const IMesh* mesh) const ...@@ -89,6 +90,7 @@ void CTriangleSelector::updateFromMesh(const IMesh* mesh) const
if (!mesh) if (!mesh)
return; return;
bool skinnnedMesh = mesh->getMeshType() == EAMT_SKINNED;
u32 meshBuffers = mesh->getMeshBufferCount(); u32 meshBuffers = mesh->getMeshBufferCount();
u32 triangleCount = 0; u32 triangleCount = 0;
...@@ -99,6 +101,22 @@ void CTriangleSelector::updateFromMesh(const IMesh* mesh) const ...@@ -99,6 +101,22 @@ void CTriangleSelector::updateFromMesh(const IMesh* mesh) const
u32 idxCnt = buf->getIndexCount(); u32 idxCnt = buf->getIndexCount();
const u16* indices = buf->getIndices(); const u16* indices = buf->getIndices();
if ( skinnnedMesh )
{
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) for (u32 index = 0; index < idxCnt; index += 3)
{ {
core::triangle3df& tri = Triangles[triangleCount++]; core::triangle3df& tri = Triangles[triangleCount++];
...@@ -110,6 +128,7 @@ void CTriangleSelector::updateFromMesh(const IMesh* mesh) const ...@@ -110,6 +128,7 @@ void CTriangleSelector::updateFromMesh(const IMesh* mesh) const
BoundingBox.addInternalPoint(tri.pointC); BoundingBox.addInternalPoint(tri.pointC);
} }
} }
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment