diff --git a/include/CMeshBuffer.h b/include/CMeshBuffer.h index 2e30819e..14ec360a 100644 --- a/include/CMeshBuffer.h +++ b/include/CMeshBuffer.h @@ -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(vertices)[i]); + BoundingBox.addInternalPoint(reinterpret_cast(vertices)[i].Pos); + } + + Indices.reallocate(getIndexCount()+numIndices); + for (i=0; igetVertexCount()); + for (i=0; igetVertexCount(); ++i) + { + Vertices.push_back(reinterpret_cast(other->getVertices())[i]); + } + + Indices.reallocate(getIndexCount()+other->getIndexCount()); + for (i=0; igetIndexCount(); ++i) + { + Indices.push_back(other->getIndices()[i]+vertexCount); + } + BoundingBox.addInternalBox(other->getBoundingBox()); + } + //! Material for this meshbuffer. video::SMaterial Material; //! Vertices of this buffer diff --git a/include/IAnimatedMeshMD3.h b/include/IAnimatedMeshMD3.h index 364e415e..81027e4e 100644 --- a/include/IAnimatedMeshMD3.h +++ b/include/IAnimatedMeshMD3.h @@ -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; idrop(); diff --git a/include/IMeshBuffer.h b/include/IMeshBuffer.h index 329f92b6..3d5ca571 100644 --- a/include/IMeshBuffer.h +++ b/include/IMeshBuffer.h @@ -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 diff --git a/include/IMeshManipulator.h b/include/IMeshManipulator.h index 6c046e9f..d6724c2e 100644 --- a/include/IMeshManipulator.h +++ b/include/IMeshManipulator.h @@ -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(IMesh* mesh) const = 0; //! Returns amount of polygons in mesh. - virtual s32 getPolyCount(scene::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; }; diff --git a/source/Irrlicht/CAnimatedMeshB3d.h b/source/Irrlicht/CAnimatedMeshB3d.h index f2f701cc..1113dea8 100644 --- a/source/Irrlicht/CAnimatedMeshB3d.h +++ b/source/Irrlicht/CAnimatedMeshB3d.h @@ -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) + {} diff --git a/source/Irrlicht/CAnimatedMeshMS3D.h b/source/Irrlicht/CAnimatedMeshMS3D.h index 93e8536a..7c8af370 100644 --- a/source/Irrlicht/CAnimatedMeshMS3D.h +++ b/source/Irrlicht/CAnimatedMeshMS3D.h @@ -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 *Vertices; //! Array of vertices diff --git a/source/Irrlicht/CColladaFileLoader.cpp b/source/Irrlicht/CColladaFileLoader.cpp index 517729e1..c13b9471 100644 --- a/source/Irrlicht/CColladaFileLoader.cpp +++ b/source/Irrlicht/CColladaFileLoader.cpp @@ -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); diff --git a/source/Irrlicht/CMeshManipulator.cpp b/source/Irrlicht/CMeshManipulator.cpp index f9bc9dc5..69befc75 100644 --- a/source/Irrlicht/CMeshManipulator.cpp +++ b/source/Irrlicht/CMeshManipulator.cpp @@ -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; isetBoundingBox( box ); -} - - - //! Clones a static IMesh into a modifyable SMesh. SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const { diff --git a/source/Irrlicht/CMeshManipulator.h b/source/Irrlicht/CMeshManipulator.h index 1c3bd5ec..88b8843f 100644 --- a/source/Irrlicht/CMeshManipulator.h +++ b/source/Irrlicht/CMeshManipulator.h @@ -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;