mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-10 09:43:52 +01:00
Fix uninitialized variable in CTriangleSelector and code cleanup
CTriangleSelector constructor with IAnimatedMeshSceneNode parameter didn't initialize MeshBuffer. Not used internally, so no big problem, but it got passed back to users in some cases Replaced SCollisionTriangleRange, by CTriangleSelector::SBufferTriangleRange. Was a bad idea to use a struct which is for something else just because some member were the same (my fault, sorry). Also started unifying the case of using ranges vs not using them. Can maybe even get rid of the non-ranges case in future. Or unify the duplicated code for getting triangles at least. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6579 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
70b2e3a255
commit
8372a70f21
@ -182,8 +182,8 @@ void COctreeTriangleSelector::getTriangles(core::triangle3df* triangles,
|
||||
triRange.RangeSize = trianglesWritten;
|
||||
triRange.Selector = this;
|
||||
triRange.SceneNode = SceneNode;
|
||||
triRange.MeshBuffer = MeshBuffer;
|
||||
triRange.MaterialIndex = MaterialIndex;
|
||||
triRange.MeshBuffer = SingleBufferRange.MeshBuffer;
|
||||
triRange.MaterialIndex = SingleBufferRange.MaterialIndex;
|
||||
outTriangleInfo->push_back(triRange);
|
||||
}
|
||||
|
||||
@ -274,8 +274,8 @@ void COctreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arr
|
||||
triRange.RangeSize = trianglesWritten;
|
||||
triRange.Selector = this;
|
||||
triRange.SceneNode = SceneNode;
|
||||
triRange.MeshBuffer = MeshBuffer;
|
||||
triRange.MaterialIndex = MaterialIndex;
|
||||
triRange.MeshBuffer = SingleBufferRange.MeshBuffer;
|
||||
triRange.MaterialIndex = SingleBufferRange.MaterialIndex;
|
||||
outTriangleInfo->push_back(triRange);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace scene
|
||||
|
||||
//! constructor
|
||||
CTriangleSelector::CTriangleSelector(ISceneNode* node)
|
||||
: SceneNode(node), MeshBuffer(0), MaterialIndex(0), AnimatedNode(0), LastMeshFrame(0)
|
||||
: SceneNode(node), AnimatedNode(0), LastMeshFrame(0)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CTriangleSelector");
|
||||
@ -27,7 +27,7 @@ CTriangleSelector::CTriangleSelector(ISceneNode* node)
|
||||
|
||||
//! constructor
|
||||
CTriangleSelector::CTriangleSelector(const core::aabbox3d<f32>& box, ISceneNode* node)
|
||||
: SceneNode(node), MeshBuffer(0), MaterialIndex(0), AnimatedNode(0), LastMeshFrame(0)
|
||||
: SceneNode(node), AnimatedNode(0), LastMeshFrame(0)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CTriangleSelector");
|
||||
@ -40,7 +40,7 @@ CTriangleSelector::CTriangleSelector(const core::aabbox3d<f32>& box, ISceneNode*
|
||||
|
||||
//! constructor
|
||||
CTriangleSelector::CTriangleSelector(const IMesh* mesh, ISceneNode* node, bool separateMeshbuffers)
|
||||
: SceneNode(node), MeshBuffer(0), MaterialIndex(0), AnimatedNode(0), LastMeshFrame(0)
|
||||
: SceneNode(node), AnimatedNode(0), LastMeshFrame(0)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CTriangleSelector");
|
||||
@ -50,12 +50,14 @@ CTriangleSelector::CTriangleSelector(const IMesh* mesh, ISceneNode* node, bool s
|
||||
}
|
||||
|
||||
CTriangleSelector::CTriangleSelector(const IMeshBuffer* meshBuffer, irr::u32 materialIndex, ISceneNode* node)
|
||||
: SceneNode(node), MeshBuffer(meshBuffer), MaterialIndex(materialIndex), AnimatedNode(0), LastMeshFrame(0)
|
||||
: SceneNode(node), AnimatedNode(0), LastMeshFrame(0)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CTriangleSelector");
|
||||
#endif
|
||||
|
||||
SingleBufferRange.MeshBuffer = meshBuffer;
|
||||
SingleBufferRange.MaterialIndex = materialIndex;
|
||||
createFromMeshBuffer(meshBuffer);
|
||||
}
|
||||
|
||||
@ -90,7 +92,7 @@ void CTriangleSelector::createFromMesh(const IMesh* mesh, bool createBufferRange
|
||||
u32 totalFaceCount = 0;
|
||||
for (u32 j=0; j<cnt; ++j)
|
||||
{
|
||||
SCollisionTriangleRange range;
|
||||
SBufferTriangleRange range;
|
||||
range.MeshBuffer = mesh->getMeshBuffer(j);
|
||||
range.MaterialIndex = j;
|
||||
range.RangeSize = range.MeshBuffer->getIndexCount() / 3;
|
||||
@ -301,8 +303,8 @@ void CTriangleSelector::getTriangles(core::triangle3df* triangles,
|
||||
triRange.RangeSize = cnt;
|
||||
triRange.Selector = this;
|
||||
triRange.SceneNode = SceneNode;
|
||||
triRange.MeshBuffer = MeshBuffer;
|
||||
triRange.MaterialIndex = MaterialIndex;
|
||||
triRange.MeshBuffer = SingleBufferRange.MeshBuffer;
|
||||
triRange.MaterialIndex = SingleBufferRange.MaterialIndex;
|
||||
outTriangleInfo->push_back(triRange);
|
||||
}
|
||||
else
|
||||
@ -445,8 +447,8 @@ void CTriangleSelector::getTriangles(core::triangle3df* triangles,
|
||||
triRange.RangeSize = triangleCount;
|
||||
triRange.Selector = this;
|
||||
triRange.SceneNode = SceneNode;
|
||||
triRange.MeshBuffer = MeshBuffer;
|
||||
triRange.MaterialIndex = MaterialIndex;
|
||||
triRange.MeshBuffer = SingleBufferRange.MeshBuffer;
|
||||
triRange.MaterialIndex = SingleBufferRange.MaterialIndex;
|
||||
outTriangleInfo->push_back(triRange);
|
||||
}
|
||||
}
|
||||
|
@ -91,14 +91,34 @@ protected:
|
||||
//! since the last time it was updated.
|
||||
virtual void update(void) const;
|
||||
|
||||
irr::core::array<SCollisionTriangleRange> BufferRanges;
|
||||
struct SBufferTriangleRange
|
||||
{
|
||||
SBufferTriangleRange()
|
||||
: RangeStart(0), RangeSize(0), MeshBuffer(0), MaterialIndex(0)
|
||||
{}
|
||||
|
||||
//! First index in Triangles array
|
||||
irr::u32 RangeStart;
|
||||
|
||||
//! Number of elements in Triangles array
|
||||
irr::u32 RangeSize;
|
||||
|
||||
//! Meshbuffer from which the triangles are from
|
||||
//! Is 0 when we use a single range for all buffers
|
||||
const IMeshBuffer* MeshBuffer;
|
||||
|
||||
//! Index of selected material in the SceneNode.
|
||||
//! Only valid when MeshBuffer is also set, otherwise 0
|
||||
irr::u32 MaterialIndex;
|
||||
};
|
||||
|
||||
SBufferTriangleRange SingleBufferRange; // When avoiding extra heap allocations
|
||||
irr::core::array<SBufferTriangleRange> BufferRanges;
|
||||
|
||||
ISceneNode* SceneNode;
|
||||
mutable core::array<core::triangle3df> Triangles; // (mutable for CTriangleBBSelector)
|
||||
mutable core::aabbox3df BoundingBox; // Allows for trivial rejection
|
||||
|
||||
const IMeshBuffer* MeshBuffer; // non-zero when the selector is for a single meshbuffer
|
||||
irr::u32 MaterialIndex; // Only set when MeshBuffer is non-zero
|
||||
IAnimatedMeshSceneNode* AnimatedNode;
|
||||
mutable u32 LastMeshFrame;
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
Tests finished. 72 tests of 72 passed.
|
||||
Compiled as DEBUG
|
||||
Test suite pass at GMT Wed Dec 13 15:00:54 2023
|
||||
Test suite pass at GMT Wed Dec 13 16:04:52 2023
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user