Merging r6493 through r6517 from trunk to ogl-es branch
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6518 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
@@ -108,17 +108,97 @@ namespace scene
|
||||
\param numVertices Number of vertices in the array.
|
||||
\param indices Pointer to index array.
|
||||
\param numIndices Number of indices in array. */
|
||||
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
|
||||
{
|
||||
// TODO
|
||||
// We simply assume it has the same vertex and index type as this object. If other types are passed this will crash
|
||||
append(getVertexType(), vertices, numVertices, getIndexType(), indices, numIndices, updateBoundingBox);
|
||||
}
|
||||
|
||||
//! Append the meshbuffer to the current buffer
|
||||
/** Only works for compatible vertex types
|
||||
\param other Buffer to append to this one. */
|
||||
virtual void append(const IMeshBuffer* const other) IRR_OVERRIDE
|
||||
/** \param other Buffer to append to this one. */
|
||||
virtual void append(const IMeshBuffer* const other, bool updateBoundingBox=true) IRR_OVERRIDE
|
||||
{
|
||||
// TODO
|
||||
append(other->getVertexType(), other->getVertices(), other->getVertexCount(), other->getIndexType(), other->getIndices(), other->getIndexCount(), updateBoundingBox);
|
||||
}
|
||||
|
||||
void append(video::E_VERTEX_TYPE vertexType, const void* const vertices, u32 numVertices, video::E_INDEX_TYPE indexType, const void* const indices, u32 numIndices, bool updateBoundingBox)
|
||||
{
|
||||
if (vertices == getVertices() || indices == getIndices()) // can't do that because we're doing reallocations on those blocks
|
||||
return;
|
||||
|
||||
const u32 vertexCount = getVertexCount();
|
||||
|
||||
VertexBuffer->reallocate(vertexCount+numVertices, false);
|
||||
if ( vertexType == getVertexType() )
|
||||
{
|
||||
const irr::u32 typeSize = getVertexPitchFromType(vertexType);
|
||||
VertexBuffer->set_used(vertexCount+numVertices);
|
||||
irr::u8* target = &static_cast<irr::u8*>(VertexBuffer->pointer())[vertexCount*typeSize];
|
||||
memcpy(target, vertices, numVertices*typeSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ( vertexType )
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
for (u32 i=0; i<numVertices; ++i)
|
||||
{
|
||||
VertexBuffer->push_back(static_cast<const video::S3DVertex*>(vertices)[i]);
|
||||
}
|
||||
break;
|
||||
case video::EVT_2TCOORDS:
|
||||
for (u32 i=0; i<numVertices; ++i)
|
||||
{
|
||||
VertexBuffer->push_back(static_cast<const video::S3DVertex2TCoords*>(vertices)[i]);
|
||||
}
|
||||
break;
|
||||
case video::EVT_TANGENTS:
|
||||
for (u32 i=0; i<numVertices; ++i)
|
||||
{
|
||||
VertexBuffer->push_back(static_cast<const video::S3DVertexTangents*>(vertices)[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( updateBoundingBox && numVertices > 0)
|
||||
{
|
||||
if ( vertexCount == 0 )
|
||||
BoundingBox.reset( static_cast<const video::S3DVertex*>(vertices)[0].Pos );
|
||||
|
||||
const u32 typePitch = getVertexPitchFromType(vertexType);
|
||||
const irr::u8* v8 = static_cast<const irr::u8*>(vertices);
|
||||
for (u32 i=0; i<numVertices; ++i, v8 += typePitch)
|
||||
{
|
||||
BoundingBox.addInternalPoint(reinterpret_cast<const video::S3DVertex*>(v8)->Pos);
|
||||
}
|
||||
}
|
||||
|
||||
IndexBuffer->reallocate(getIndexCount()+numIndices, false);
|
||||
switch ( indexType )
|
||||
{
|
||||
case video::EIT_16BIT:
|
||||
{
|
||||
const irr::u16* indices16 = reinterpret_cast<const irr::u16*>(indices);
|
||||
for (u32 i=0; i<numIndices; ++i)
|
||||
{
|
||||
// Note: This can overflow, not checked. Will result in broken models, but no crashes.
|
||||
IndexBuffer->push_back(indices16[i]+vertexCount);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case video::EIT_32BIT:
|
||||
{
|
||||
const irr::u32* indices32 = reinterpret_cast<const irr::u32*>(indices);
|
||||
for (u32 i=0; i<numIndices; ++i)
|
||||
{
|
||||
IndexBuffer->push_back(indices32[i]+vertexCount);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setDirty();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user