Add updateBoundingBox parameter to IMeshBuffer::append and some fixes and optimizations
Fix: When appending to an empty mesh boundingbox has to be initialized with first position Adding updateBoundingBox parameter as there is a bit costs involved in updating that and it might not be necessary at that point Default is still to do it - and with the default parameter it's at least compile compatible to old interface (unless users created their own meshbuffers). Optimizing the copying of vertices in CDynamicMeshBuffer::append by using memset when possible instead of pushing each vertex (which goes through quite a few virtual functions) git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6496 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
@@ -193,7 +193,7 @@ namespace scene
|
||||
or the main buffer is of standard type. Otherwise, behavior is
|
||||
undefined. Also can't append it's own vertices/indices to itself.
|
||||
*/
|
||||
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) IRR_OVERRIDE
|
||||
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices, bool updateBoundingBox=true) IRR_OVERRIDE
|
||||
{
|
||||
if (vertices == getVertices() || indices == getIndices()) // can't do that because we're doing reallocations on those blocks
|
||||
return;
|
||||
@@ -205,7 +205,15 @@ namespace scene
|
||||
for (i=0; i<numVertices; ++i)
|
||||
{
|
||||
Vertices.push_back(static_cast<const T*>(vertices)[i]);
|
||||
BoundingBox.addInternalPoint(static_cast<const T*>(vertices)[i].Pos);
|
||||
}
|
||||
|
||||
if ( updateBoundingBox && numVertices > 0)
|
||||
{
|
||||
if ( vertexCount == 0 )
|
||||
BoundingBox.reset(static_cast<const T*>(vertices)[0].Pos);
|
||||
|
||||
for (i=0; i<numVertices; ++i)
|
||||
BoundingBox.addInternalPoint(static_cast<const T*>(vertices)[i].Pos);
|
||||
}
|
||||
|
||||
Indices.reallocate(getIndexCount()+numIndices, false);
|
||||
@@ -219,12 +227,12 @@ namespace scene
|
||||
|
||||
|
||||
//! Append the meshbuffer to the current buffer
|
||||
virtual void append(const IMeshBuffer* const other) IRR_OVERRIDE
|
||||
virtual void append(const IMeshBuffer* const other, bool updateBoundingBox=true) IRR_OVERRIDE
|
||||
{
|
||||
if ( getVertexType() != other->getVertexType() )
|
||||
return;
|
||||
|
||||
append(other->getVertices(), other->getVertexCount(), other->getIndices(), other->getIndexCount());
|
||||
append(other->getVertices(), other->getVertexCount(), other->getIndices(), other->getIndexCount(), updateBoundingBox);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user