Made the scenenode parameter for selectors const.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1120 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2007-12-21 15:41:51 +00:00
parent 379b7570d7
commit 78a681194d
9 changed files with 35 additions and 34 deletions

View File

@ -29,7 +29,7 @@ CMetaTriangleSelector::~CMetaTriangleSelector()
s32 CMetaTriangleSelector::getTriangleCount() const
{
s32 count = 0;
for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i)
for (u32 i=0; i<TriangleSelectors.size(); ++i)
count += TriangleSelectors[i]->getTriangleCount();
return count;
@ -43,14 +43,14 @@ void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 array
{
s32 outWritten = 0;
for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i)
for (u32 i=0; i<TriangleSelectors.size(); ++i)
{
s32 t = 0;
TriangleSelectors[i]->getTriangles(triangles + outWritten, arraySize - outWritten, t, transform);
outWritten += t;
}
outTriangleCount = outWritten;
outTriangleCount = outWritten;
}
@ -62,7 +62,7 @@ void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 array
{
s32 outWritten = 0;
for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i)
for (u32 i=0; i<TriangleSelectors.size(); ++i)
{
s32 t = 0;
TriangleSelectors[i]->getTriangles(triangles + outWritten, arraySize - outWritten, t,
@ -70,7 +70,7 @@ void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 array
outWritten += t;
}
outTriangleCount = outWritten;
outTriangleCount = outWritten;
}
@ -82,7 +82,7 @@ void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 array
{
s32 outWritten = 0;
for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i)
for (u32 i=0; i<TriangleSelectors.size(); ++i)
{
s32 t = 0;
TriangleSelectors[i]->getTriangles(triangles + outWritten, arraySize - outWritten, t,
@ -90,7 +90,7 @@ void CMetaTriangleSelector::getTriangles(core::triangle3df* triangles, s32 array
outWritten += t;
}
outTriangleCount = outWritten;
outTriangleCount = outWritten;
}
@ -111,7 +111,7 @@ void CMetaTriangleSelector::addTriangleSelector(ITriangleSelector* toAdd)
//! Removes a specific triangle selector which was added before from the collection.
bool CMetaTriangleSelector::removeTriangleSelector(ITriangleSelector* toRemove)
{
for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i)
for (u32 i=0; i<TriangleSelectors.size(); ++i)
if (toRemove == TriangleSelectors[i])
{
TriangleSelectors[i]->drop();
@ -127,14 +127,13 @@ bool CMetaTriangleSelector::removeTriangleSelector(ITriangleSelector* toRemove)
//! Removes all triangle selectors from the collection.
void CMetaTriangleSelector::removeAllTriangleSelectors()
{
for (s32 i=0; i<(s32)TriangleSelectors.size(); ++i)
for (u32 i=0; i<TriangleSelectors.size(); ++i)
TriangleSelectors[i]->drop();
TriangleSelectors.clear();
}
} // end namespace scene
} // end namespace irr

View File

@ -13,8 +13,8 @@ namespace scene
{
//! constructor
COctTreeTriangleSelector::COctTreeTriangleSelector(IMesh* mesh,
ISceneNode* node, s32 minimalPolysPerNode)
COctTreeTriangleSelector::COctTreeTriangleSelector(const IMesh* mesh,
const ISceneNode* node, s32 minimalPolysPerNode)
: CTriangleSelector(mesh, node), Root(0), NodeCount(0),
MinimalPolysPerNode(minimalPolysPerNode)
{

View File

@ -20,12 +20,12 @@ class COctTreeTriangleSelector : public CTriangleSelector
public:
//! Constructs a selector based on a mesh
COctTreeTriangleSelector(IMesh* mesh, ISceneNode* node, s32 minimalPolysPerNode);
COctTreeTriangleSelector(const IMesh* mesh, const ISceneNode* node, s32 minimalPolysPerNode);
~COctTreeTriangleSelector();
virtual ~COctTreeTriangleSelector();
//! Gets all triangles which lie within a specific bounding box.
void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const;
//! Gets all triangles which have or may have contact with a 3d line.
@ -64,7 +64,6 @@ private:
SOctTreeNode* Root;
s32 NodeCount;
s32 MinimalPolysPerNode;
};
} // end namespace scene

View File

@ -47,11 +47,11 @@ void CTerrainTriangleSelector::setTriangleData(ITerrainSceneNode* node, s32 LOD)
for (int o=0; o<TrianglePatches.NumPatches; ++o)
TrianglePatches.TrianglePatchArray.push_back(SGeoMipMapTrianglePatch());
s32 tIndex = 0;
for(s32 x = 0; x < terrainNode->TerrainData.PatchCount; ++x )
{
for(s32 z = 0; z < terrainNode->TerrainData.PatchCount; ++z )
{
s32 tIndex = x * terrainNode->TerrainData.PatchCount + z;
TrianglePatches.TrianglePatchArray[tIndex].NumTriangles = 0;
TrianglePatches.TrianglePatchArray[tIndex].Box = terrainNode->getBoundingBox( x, z );
u32 indexCount = terrainNode->getIndicesForPatch( indices, x, z, LOD );
@ -67,6 +67,7 @@ void CTerrainTriangleSelector::setTriangleData(ITerrainSceneNode* node, s32 LOD)
}
TrianglePatches.TotalTriangles += TrianglePatches.TrianglePatchArray[tIndex].NumTriangles;
++tIndex;
}
}
}
@ -146,10 +147,7 @@ void CTerrainTriangleSelector::getTriangles(core::triangle3df* triangles, s32 ar
s32& outTriangleCount, const core::line3d<f32>& line,
const core::matrix4* transform) const
{
s32 count = TrianglePatches.TotalTriangles;
if (count > arraySize)
count = arraySize;
const s32 count = core::min_((s32)TrianglePatches.TotalTriangles, arraySize);
core::matrix4 mat;

View File

@ -10,7 +10,6 @@
#define __C_TERRAIN_TRIANGLE_SELECTOR_H__
#include "ITriangleSelector.h"
#include "IMesh.h"
#include "irrArray.h"
namespace irr
@ -32,7 +31,7 @@ public:
CTerrainTriangleSelector(ITerrainSceneNode* node, s32 LOD );
//! Destructor
~CTerrainTriangleSelector();
virtual ~CTerrainTriangleSelector();
//! Clears and sets triangle data
virtual void setTriangleData ( ITerrainSceneNode* node, s32 LOD );
@ -47,7 +46,7 @@ public:
//! Gets all triangles which have or may have contact with a 3d line.
virtual void getTriangles ( core::triangle3df* triangles, s32 arraySize,
s32& outTriangleCount, const core::line3d<f32>& line,
s32& outTriangleCount, const core::line3d<f32>& line,
const core::matrix4* transform = 0 ) const;
//! Returns amount of all available triangles in this selector

View File

@ -11,7 +11,7 @@ namespace scene
{
//! constructor
CTriangleBBSelector::CTriangleBBSelector(ISceneNode* node)
CTriangleBBSelector::CTriangleBBSelector(const ISceneNode* node)
: CTriangleSelector(node)
{
#ifdef _DEBUG
@ -32,7 +32,7 @@ void CTriangleBBSelector::getTriangles(core::triangle3df* triangles,
return;
// construct triangles
core::aabbox3d<f32> box = SceneNode->getBoundingBox();
const core::aabbox3d<f32>& box = SceneNode->getBoundingBox();
core::vector3df edges[8];
box.getEdges(edges);

View File

@ -18,7 +18,7 @@ class CTriangleBBSelector : public CTriangleSelector
public:
//! Constructs a selector based on a mesh
CTriangleBBSelector(ISceneNode* node);
CTriangleBBSelector(const ISceneNode* node);
//! Gets all triangles.
virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,

View File

@ -12,7 +12,7 @@ namespace scene
{
//! constructor
CTriangleSelector::CTriangleSelector(ISceneNode* node)
CTriangleSelector::CTriangleSelector(const ISceneNode* node)
: SceneNode(node)
{
#ifdef _DEBUG
@ -22,7 +22,7 @@ CTriangleSelector::CTriangleSelector(ISceneNode* node)
//! constructor
CTriangleSelector::CTriangleSelector(IMesh* mesh, ISceneNode* node)
CTriangleSelector::CTriangleSelector(const IMesh* mesh, const ISceneNode* node)
: SceneNode(node)
{
#ifdef _DEBUG
@ -30,6 +30,12 @@ CTriangleSelector::CTriangleSelector(IMesh* mesh, ISceneNode* node)
#endif
const u32 cnt = mesh->getMeshBufferCount();
u32 totalFaceCount = 0;
for (u32 j=0; j<cnt; ++j)
totalFaceCount += mesh->getMeshBuffer(j)->getIndexCount();
totalFaceCount /= 3;
Triangles.reallocate(totalFaceCount);
for (u32 i=0; i<cnt; ++i)
{
const IMeshBuffer* buf = mesh->getMeshBuffer(i);
@ -49,7 +55,7 @@ CTriangleSelector::CTriangleSelector(IMesh* mesh, ISceneNode* node)
//! constructor
CTriangleSelector::CTriangleSelector(core::aabbox3d<f32> box, ISceneNode* node)
CTriangleSelector::CTriangleSelector(const core::aabbox3d<f32>& box, const ISceneNode* node)
: SceneNode(node)
{
#ifdef _DEBUG

View File

@ -22,13 +22,13 @@ class CTriangleSelector : public ITriangleSelector
public:
//! Constructs a selector based on a mesh
CTriangleSelector(ISceneNode* node);
CTriangleSelector(const ISceneNode* node);
//! Constructs a selector based on a mesh
CTriangleSelector(IMesh* mesh, ISceneNode* node);
CTriangleSelector(const IMesh* mesh, const ISceneNode* node);
//! Constructs a selector based on a bounding box
CTriangleSelector(core::aabbox3d<f32> box, ISceneNode* node);
CTriangleSelector(const core::aabbox3d<f32>& box, const ISceneNode* node);
//! Gets all triangles.
void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
@ -48,7 +48,7 @@ public:
protected:
ISceneNode* SceneNode;
const ISceneNode* SceneNode;
mutable core::array<core::triangle3df> Triangles;
};