Commit 74f1e2e9 authored by hybrid's avatar hybrid

Enhanced the meshbuffer interface. moved the recalculateBoundingBox from...

Enhanced the meshbuffer interface. moved the recalculateBoundingBox from MeshManipulator to IMeshBuffer by exposing the already existing methods. Some initial append methods added.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@833 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 43b6bb65
......@@ -25,9 +25,6 @@ namespace scene
#endif
}
//! destructor
~CMeshBuffer() {};
//! returns the material of this meshbuffer
virtual const video::SMaterial& getMaterial() const
{
......@@ -114,6 +111,46 @@ namespace scene
return sizeof ( T );
}
//! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices)
{
const u32 vertexCount = getVertexCount();
u32 i;
Vertices.reallocate(vertexCount+numVertices);
for (i=0; i<numVertices; ++i)
{
Vertices.push_back(reinterpret_cast<const T* const>(vertices)[i]);
BoundingBox.addInternalPoint(reinterpret_cast<const T* const>(vertices)[i].Pos);
}
Indices.reallocate(getIndexCount()+numIndices);
for (i=0; i<numIndices; ++i)
{
Indices.push_back(indices[i]+vertexCount);
}
}
//! append the meshbuffer to the current buffer
virtual void append(const IMeshBuffer* const other)
{
const u32 vertexCount = getVertexCount();
u32 i;
Vertices.reallocate(vertexCount+other->getVertexCount());
for (i=0; i<other->getVertexCount(); ++i)
{
Vertices.push_back(reinterpret_cast<const T*>(other->getVertices())[i]);
}
Indices.reallocate(getIndexCount()+other->getIndexCount());
for (i=0; i<other->getIndexCount(); ++i)
{
Indices.push_back(other->getIndices()[i]+vertexCount);
}
BoundingBox.addInternalBox(other->getBoundingBox());
}
//! Material for this meshbuffer.
video::SMaterial Material;
//! Vertices of this buffer
......
......@@ -147,8 +147,6 @@ namespace scene
//! Holding Frame Data for a Mesh
struct SMD3MeshBuffer : public IUnknown
{
virtual ~ SMD3MeshBuffer () {}
SMD3MeshHeader MeshHeader;
core::array < core::stringc > Shader;
......@@ -188,8 +186,6 @@ namespace scene
rotation.set ( angle.X * core::DEGTORAD, angle.Y * core::DEGTORAD, angle.Z * core::DEGTORAD );
}
virtual ~SMD3QuaterionTag() {}
core::stringc Name;
core::vector3df position;
core::quaternion rotation;
......@@ -203,9 +199,6 @@ namespace scene
// holds a assoziative list of named quaternions
struct SMD3QuaterionTagList : public virtual IUnknown
{
SMD3QuaterionTagList () {}
virtual ~SMD3QuaterionTagList () {}
SMD3QuaterionTag* get ( const core::stringc& name )
{
SMD3QuaterionTag search ( name );
......@@ -234,7 +227,7 @@ namespace scene
//! Holding Frames Buffers and Tag Infos
struct SMD3Mesh: public IUnknown
{
virtual ~SMD3Mesh()
~SMD3Mesh()
{
for (u32 i=0; i<Buffer.size(); ++i)
Buffer[i]->drop();
......
......@@ -97,6 +97,14 @@ enum E_PRIMITIVE_TYPE
//! set user axis aligned bounding box
virtual void setBoundingBox( const core::aabbox3df& box) = 0;
//! recalculates the bounding box. should be called if the mesh changed.
virtual void recalculateBoundingBox() = 0;
//! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) = 0;
//! append the meshbuffer to the current buffer
virtual void append(const IMeshBuffer* const other) = 0;
};
} // end namespace scene
......
......@@ -96,17 +96,14 @@ namespace scene
//! Unweld vertices
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const = 0;
//! Recalculates the bounding box for a meshbuffer
virtual void recalculateBoundingBox(scene::IMeshBuffer* buffer) const = 0;
//! Returns amount of polygons in mesh.
virtual s32 getPolyCount(scene::IMesh* mesh) const = 0;
virtual s32 getPolyCount(IMesh* mesh) const = 0;
//! Returns amount of polygons in mesh.
virtual s32 getPolyCount(scene::IAnimatedMesh* mesh) const = 0;
virtual s32 getPolyCount(IAnimatedMesh* mesh) const = 0;
//! create a new AnimatedMesh and adds the mesh to it
virtual IAnimatedMesh * createAnimatedMesh(scene::IMesh* mesh,
virtual IAnimatedMesh * createAnimatedMesh(IMesh* mesh,
scene::E_ANIMATED_MESH_TYPE type = scene::EAMT_UNKNOWN) const = 0;
};
......
......@@ -311,7 +311,13 @@ private:
}
//! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices)
{}
//! append the meshbuffer to the current buffer
virtual void append(const IMeshBuffer* const other)
{}
......
......@@ -157,6 +157,14 @@ namespace scene
//! returns the byte size (stride, pitch) of the vertex
virtual u32 getVertexPitch() const;
//! recalculates the bounding box. should be called if the mesh changed.
virtual void recalculateBoundingBox() {}
//! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
//! append the meshbuffer to the current buffer
virtual void append(const IMeshBuffer* const other) {}
video::SMaterial Material; //! material for this meshBuffer.
core::array<video::S3DVertex> *Vertices; //! Array of vertices
......
......@@ -1241,7 +1241,7 @@ void CColladaFileLoader::readPolygonSection(io::IXMLReaderUTF8* reader,
SceneManager->getMeshManipulator()->recalculateNormals(buffer);
// recalculate bounding box
SceneManager->getMeshManipulator()->recalculateBoundingBox(buffer);
buffer->recalculateBoundingBox();
// add mesh buffer
mesh->addMeshBuffer(buffer);
......
......@@ -410,54 +410,6 @@ void CMeshManipulator::scaleMesh(scene::IMesh* mesh, const core::vector3df& scal
//! Recalculates the bounding box for a meshbuffer
void CMeshManipulator::recalculateBoundingBox(scene::IMeshBuffer* buffer) const
{
core::aabbox3df box;
const u32 vtxcnt = buffer->getVertexCount();
if ( 0 == vtxcnt )
{
buffer->setBoundingBox( box );
return;
}
void* v = buffer->getVertices();
u32 i;
switch(buffer->getVertexType())
{
case video::EVT_STANDARD:
{
box.reset(((video::S3DVertex*)v)[0].Pos);
for ( i=1; i<vtxcnt; ++i)
box.addInternalPoint(((video::S3DVertex*)v)[i].Pos);
}
break;
case video::EVT_2TCOORDS:
{
box.reset(((video::S3DVertex2TCoords*)v)[0].Pos);
for ( i=1; i<vtxcnt; ++i)
box.addInternalPoint(((video::S3DVertex2TCoords*)v)[i].Pos);
}
break;
case video::EVT_TANGENTS:
{
box.reset(((video::S3DVertexTangents*)v)[0].Pos);
for ( i=1; i<vtxcnt; ++i)
box.addInternalPoint(((video::S3DVertexTangents*)v)[i].Pos);
}
break;
}
buffer->setBoundingBox( box );
}
//! Clones a static IMesh into a modifyable SMesh.
SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const
{
......
......@@ -81,9 +81,6 @@ public:
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const;
//! Recalculates the bounding box for a meshbuffer
virtual void recalculateBoundingBox(scene::IMeshBuffer* buffer) const;
//! Returns amount of polygons in mesh.
virtual s32 getPolyCount(scene::IMesh* mesh) const;
......
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