From f61dcb2ec3dba8ebe0c8adc50cc2586d124a4aaf Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 19 May 2022 15:53:05 +0800 Subject: [PATCH] Allow reading spm vertices in physics --- src/physics/physical_object.cpp | 20 ++++++++++++++++++++ src/tracks/track.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/physics/physical_object.cpp b/src/physics/physical_object.cpp index ef2eafa02..06021d423 100644 --- a/src/physics/physical_object.cpp +++ b/src/physics/physical_object.cpp @@ -511,6 +511,26 @@ void PhysicalObject::init(const PhysicalObject::Settings& settings) material ); } // for j } + else if (mb->getVertexType() == video::EVT_SKINNED_MESH) + { + irr::video::S3DVertexSkinnedMesh* mbVertices = + (video::S3DVertexSkinnedMesh*)mb->getVertices(); + for(unsigned int j=0; jgetIndexCount(); j+=3) + { + for(unsigned int k=0; k<3; k++) + { + int indx=mbIndices[j+k]; + core::vector3df v = mbVertices[indx].m_position; + //mat.transformVect(v); + vertices[k]=v; + normals[k]=MiniGLM::decompressVector3(mbVertices[indx].m_normal); + } // for k + triangle_mesh->addTriangle(vertices[0], vertices[1], + vertices[2], normals[0], + normals[1], normals[2], + material ); + } // for j + } } // for icreateCollisionShape(); diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index d22814fee..f0fbcbcb4 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -1134,6 +1134,32 @@ void Track::convertTrackToBullet(scene::ISceneNode *node) normals[k] = mbVertices[indx].Normal; } // for k + if (tmesh) + { + tmesh->addTriangle(vertices[0], vertices[1], + vertices[2], normals[0], + normals[1], normals[2], + material); + } + } // for j + } // for matrix_index + } + else if (mb->getVertexType() == video::EVT_SKINNED_MESH) + { + video::S3DVertexSkinnedMesh* mbVertices = (video::S3DVertexSkinnedMesh*)mb->getVertices(); + for (unsigned int matrix_index = 0; matrix_index < matrices.size(); matrix_index++) + { + for (unsigned int j = 0; j < mb->getIndexCount(); j += 3) + { + for (unsigned int k = 0; k < 3; k++) + { + int indx = mbIndices[j + k]; + core::vector3df v = mbVertices[indx].m_position; + matrices[matrix_index].transformVect(v); + vertices[k] = v; + normals[k] = MiniGLM::decompressVector3(mbVertices[indx].m_normal); + } // for k + if (tmesh) { tmesh->addTriangle(vertices[0], vertices[1],