mirror of
https://github.com/minetest/irrlicht.git
synced 2024-12-25 23:47:30 +01:00
updateTriangles in CTriangleSelector can handle some broken meshes without crash now.
Before it crashed when index-count wasn't a multiple of 3, now it just doesn't create the last triangle then. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6110 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
9062ac91af
commit
13a232aa9b
@ -127,22 +127,22 @@ static void updateTriangles(u32& triangleCount, core::array<core::triangle3df>&
|
|||||||
{
|
{
|
||||||
if ( bufferTransform )
|
if ( bufferTransform )
|
||||||
{
|
{
|
||||||
for (u32 index = 0; index < idxCnt; index += 3)
|
for (u32 index = 2; index < idxCnt; index += 3)
|
||||||
{
|
{
|
||||||
core::triangle3df& tri = triangles[triangleCount++];
|
core::triangle3df& tri = triangles[triangleCount++];
|
||||||
bufferTransform->transformVect( tri.pointA, (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index + 0]*vertexPitch])).Pos );
|
bufferTransform->transformVect( tri.pointA, (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index - 2]*vertexPitch])).Pos );
|
||||||
bufferTransform->transformVect( tri.pointB, (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index + 1]*vertexPitch])).Pos );
|
bufferTransform->transformVect( tri.pointB, (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index - 1]*vertexPitch])).Pos );
|
||||||
bufferTransform->transformVect( tri.pointC, (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index + 2]*vertexPitch])).Pos );
|
bufferTransform->transformVect( tri.pointC, (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index - 0]*vertexPitch])).Pos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (u32 index = 0; index < idxCnt; index += 3)
|
for (u32 index = 2; index < idxCnt; index += 3)
|
||||||
{
|
{
|
||||||
core::triangle3df& tri = triangles[triangleCount++];
|
core::triangle3df& tri = triangles[triangleCount++];
|
||||||
tri.pointA = (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index + 0]*vertexPitch])).Pos;
|
tri.pointA = (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index - 2]*vertexPitch])).Pos;
|
||||||
tri.pointB = (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index + 1]*vertexPitch])).Pos;
|
tri.pointB = (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index - 1]*vertexPitch])).Pos;
|
||||||
tri.pointC = (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index + 2]*vertexPitch])).Pos;
|
tri.pointC = (*reinterpret_cast<const video::S3DVertex*>(&vertices[indices[index - 0]*vertexPitch])).Pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user