Commit fcbf4a1a authored by bitplane's avatar bitplane

Removed array::erase from loops in Octtree.h and COctTreeTriangleSelector.cpp,...

Removed array::erase from loops in Octtree.h and COctTreeTriangleSelector.cpp, they now generate a lot faster.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@684 dfc29bdd-3216-0410-991c-e03cc46cb475
parent db6011aa
Changes in version 1.3.1 (?? Mar 2007) Changes in version 1.3.1 (?? Mar 2007)
- Some fixes in the 3d basic structures: plane3d.classifyPointRelation no - Some fixes in the 3d basic structures: plane3d.classifyPointRelation now
correctly returns the relation, it returned the opposite before. Also correctly returns the relation, it returned the opposite before. Also
renamed existsInterSection to existsIntersection for consistency. renamed existsInterSection to existsIntersection for consistency.
triangle3d.isOnSameSide is now private - it's just a helper class not triangle3d.isOnSameSide is now private - it's just a helper class not
...@@ -89,6 +89,8 @@ Changes in version 1.3.1 (?? Mar 2007) ...@@ -89,6 +89,8 @@ Changes in version 1.3.1 (?? Mar 2007)
- Fixed a crash when using Octtrees caused by unnecessary dropping of meshes when - Fixed a crash when using Octtrees caused by unnecessary dropping of meshes when
deserializing the scene node. deserializing the scene node.
- Removed an array::erase from Octtrees and Octtree triangle selector.
GUI: GUI:
- Fixed a messagebox focus bug when no 'okay' button was present - Fixed a messagebox focus bug when no 'okay' button was present
......
...@@ -70,6 +70,7 @@ void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node) ...@@ -70,6 +70,7 @@ void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node)
node->Box.getEdges(edges); node->Box.getEdges(edges);
core::aabbox3d<f32> box; core::aabbox3d<f32> box;
core::array<core::triangle3df> keepTriangles;
// calculate children // calculate children
...@@ -85,10 +86,19 @@ void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node) ...@@ -85,10 +86,19 @@ void COctTreeTriangleSelector::constructOctTree(SOctTreeNode* node)
if (node->Triangles[i].isTotalInsideBox(box)) if (node->Triangles[i].isTotalInsideBox(box))
{ {
node->Child[ch]->Triangles.push_back(node->Triangles[i]); node->Child[ch]->Triangles.push_back(node->Triangles[i]);
node->Triangles.erase(i); //node->Triangles.erase(i);
--i; //--i;
} }
else
{
keepTriangles.push_back(node->Triangles[i]);
} }
}
memcpy(node->Triangles.pointer(), keepTriangles.pointer(),
sizeof(core::triangle3df)*keepTriangles.size());
node->Triangles.set_used(keepTriangles.size());
keepTriangles.set_used(0);
if (node->Child[ch]->Triangles.empty()) if (node->Child[ch]->Triangles.empty())
{ {
......
...@@ -189,6 +189,7 @@ private: ...@@ -189,6 +189,7 @@ private:
// calculate all children // calculate all children
core::aabbox3d<f32> box; core::aabbox3d<f32> box;
core::array<u16> keepIndices;
if (totalPrimitives > minimalPolysPerNode && !Box.isEmpty()) if (totalPrimitives > minimalPolysPerNode && !Box.isEmpty())
for (s32 ch=0; ch<8; ++ch) for (s32 ch=0; ch<8; ++ch)
...@@ -219,13 +220,19 @@ private: ...@@ -219,13 +220,19 @@ private:
tic.Indices.push_back((*indices)[i].Indices[t+1]); tic.Indices.push_back((*indices)[i].Indices[t+1]);
tic.Indices.push_back((*indices)[i].Indices[t+2]); tic.Indices.push_back((*indices)[i].Indices[t+2]);
(*indices)[i].Indices.erase(t, 3);
t-=3;
added = true; added = true;
} }
else
{
keepIndices.push_back((*indices)[i].Indices[t]);
keepIndices.push_back((*indices)[i].Indices[t+1]);
keepIndices.push_back((*indices)[i].Indices[t+2]);
}
} }
memcpy( (*indices)[i].Indices.pointer(), keepIndices.pointer(), keepIndices.size()*sizeof(u16));
(*indices)[i].Indices.set_used(keepIndices.size());
keepIndices.set_used(0);
} }
if (added) if (added)
......
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