diff --git a/libraries/hfm/src/hfm/HFM.h b/libraries/hfm/src/hfm/HFM.h index c61f03d070..bfea8a66af 100644 --- a/libraries/hfm/src/hfm/HFM.h +++ b/libraries/hfm/src/hfm/HFM.h @@ -260,6 +260,8 @@ public: graphics::MeshPointer _mesh; bool wasCompressed { false }; + + MeshIndexedTrianglesPos _meshAsIndexedTrianglePos; }; /// A single animation frame. diff --git a/libraries/hfm/src/hfm/HFMModelMath.cpp b/libraries/hfm/src/hfm/HFMModelMath.cpp index 0026378060..cf25c5fed6 100644 --- a/libraries/hfm/src/hfm/HFMModelMath.cpp +++ b/libraries/hfm/src/hfm/HFMModelMath.cpp @@ -139,4 +139,24 @@ ReweightedDeformers getReweightedDeformers(const size_t numMeshVertices, const s return reweightedDeformers; } + +MeshIndexedTrianglesPos generateMeshIndexedTrianglePos(const std::vector& srcVertices, const std::vector srcParts) { + + auto newIndicesCount = 0; + for (const auto& part : srcParts) { + newIndicesCount += part.triangleIndices.size() + part.quadTrianglesIndices.size(); + } + + MeshIndexedTrianglesPos dest; + dest.indices.reserve(newIndicesCount); + for (const auto& part : srcParts) { + dest.indices.insert(dest.indices.end(), part.triangleIndices.cbegin(), part.triangleIndices.cend()); + dest.indices.insert(dest.indices.end(), part.quadTrianglesIndices.cbegin(), part.quadTrianglesIndices.cend()); + } + + dest.vertices = srcVertices; + + return dest; +} + }; diff --git a/libraries/hfm/src/hfm/HFMModelMath.h b/libraries/hfm/src/hfm/HFMModelMath.h index b80adad3d0..59c64fc490 100644 --- a/libraries/hfm/src/hfm/HFMModelMath.h +++ b/libraries/hfm/src/hfm/HFMModelMath.h @@ -36,6 +36,16 @@ public: const uint16_t DEFAULT_SKINNING_WEIGHTS_PER_VERTEX = 4; ReweightedDeformers getReweightedDeformers(const size_t numMeshVertices, const std::vector skinClusters, const uint16_t weightsPerVertex = DEFAULT_SKINNING_WEIGHTS_PER_VERTEX); + + +struct MeshIndexedTrianglesPos { +public: + std::vector vertices; + std::vector indices; +}; + +MeshIndexedTrianglesPos generateMeshIndexedTrianglePos(const std::vector& srcVertices, const std::vector srcParts); + }; #endif // #define hifi_hfm_ModelMath_h