diff --git a/lib/irrlicht/include/IMesh.h b/lib/irrlicht/include/IMesh.h index 8e0bcc2d3..a5b124c70 100644 --- a/lib/irrlicht/include/IMesh.h +++ b/lib/irrlicht/include/IMesh.h @@ -66,6 +66,10 @@ namespace scene indices have changed. Otherwise, changes won't be updated on the GPU in the next render cycle. */ virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0; + + /** This is used in server without graphics to free all mesh vertex buffer if + possible, for example: kart, attachment and power model (because they are not used in physics). */ + virtual void freeMeshVertexBuffer() {} }; } // end namespace scene diff --git a/lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp b/lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp index cc2bec034..0c745530a 100644 --- a/lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp +++ b/lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp @@ -23,7 +23,7 @@ CSkinnedMesh::CSkinnedMesh() LastAnimatedFrame(-1), SkinnedLastFrame(false), InterpolationMode(EIM_LINEAR), HasAnimation(false), PreparedForSkinning(false), - AnimateNormals(true), HardwareSkinning(false) + AnimateNormals(true), m_deleted_vertex_buffer(false) { #ifdef _DEBUG setDebugName("CSkinnedMesh"); @@ -74,12 +74,8 @@ void CSkinnedMesh::setAnimationSpeed(f32 fps) //! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. IMesh* CSkinnedMesh::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) { - const bool is_hw_skinning_before = HardwareSkinning; - if (is_hw_skinning_before) - { - HardwareSkinning = false; - LastAnimatedFrame = -1; - } + if (m_deleted_vertex_buffer) + return this; //animate(frame,startFrameLoop, endFrameLoop); if (frame==-1) return this; @@ -87,9 +83,6 @@ IMesh* CSkinnedMesh::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 animateMesh((f32)frame, 1.0f); skinMesh(); - if (is_hw_skinning_before) - HardwareSkinning = true; - return this; } @@ -103,7 +96,7 @@ IMesh* CSkinnedMesh::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 //! blend: {0-old position, 1-New position} void CSkinnedMesh::animateMesh(f32 frame, f32 blend) { - if (HardwareSkinning && LastAnimatedFrame==frame) + if (LastAnimatedFrame==frame) { SkinnedLastFrame=false; return; @@ -732,20 +725,6 @@ const core::array &CSkinnedMesh::getAllJoints() const return AllJoints; } - -//! (This feature is not implementated in irrlicht yet) -bool CSkinnedMesh::setHardwareSkinning(bool on) -{ - if (HardwareSkinning!=on) - { - if (on) - toStaticPose(); - - HardwareSkinning=on; - } - return HardwareSkinning; -} - void CSkinnedMesh::toStaticPose() { for (u32 i=0; i & buffer = *SkinningBuffers; @@ -1397,6 +1376,27 @@ void CSkinnedMesh::addJoints(core::array &jointChildSceneNodes, SkinnedLastFrame=false; } +void CSkinnedMesh::freeMeshVertexBuffer() +{ + if (m_deleted_vertex_buffer) + return; + for (u32 i=0; iVertices_Tangents.clear(); + LocalBuffers[j]->Vertices_2TCoords.clear(); + LocalBuffers[j]->Vertices_Standard.clear(); + LocalBuffers[j]->Indices.clear(); + } + } + AllJoints.clear(); + m_deleted_vertex_buffer = true; +} + } // end namespace scene } // end namespace irr diff --git a/lib/irrlicht/source/Irrlicht/CSkinnedMesh.h b/lib/irrlicht/source/Irrlicht/CSkinnedMesh.h index d2cc52b2e..39580157e 100644 --- a/lib/irrlicht/source/Irrlicht/CSkinnedMesh.h +++ b/lib/irrlicht/source/Irrlicht/CSkinnedMesh.h @@ -117,7 +117,7 @@ namespace scene virtual bool isStatic(); //! (This feature is not implemented in irrlicht yet) - virtual bool setHardwareSkinning(bool on); + virtual bool setHardwareSkinning(bool on) { return false; } //Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_ //these functions will use the needed arrays, set values, etc to help the loaders @@ -176,6 +176,8 @@ namespace scene core::array RootJoints; + virtual void freeMeshVertexBuffer(); + private: void toStaticPose(); @@ -222,7 +224,7 @@ private: bool HasAnimation; bool PreparedForSkinning; bool AnimateNormals; - bool HardwareSkinning; + bool m_deleted_vertex_buffer; }; } // end namespace scene