MCPcopy Create free account
hub / github.com/DiligentGraphics/DiligentFX / ReindexBufferSource

Function ReindexBufferSource

Hydrogent/src/HnMesh.cpp:839–863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

837}
838
839static std::shared_ptr<pxr::HdBufferSource> ReindexBufferSource(const pxr::HdBufferSource& SrcSource,
840 const pxr::VtVec3iArray& Indices)
841{
842 const Uint8* pSrcData = static_cast<const Uint8*>(SrcSource.GetData());
843 const pxr::HdType ElementType = SrcSource.GetTupleType().type;
844 const size_t ElementSize = HdDataSizeOfType(ElementType);
845
846 std::shared_ptr<TriangulatedFaceBufferSource> ReindexedSource =
847 std::make_shared<TriangulatedFaceBufferSource>(SrcSource.GetName(), SrcSource.GetTupleType(), Indices.size() * 3);
848
849 std::vector<Uint8>& DstData = ReindexedSource->GetData();
850 VERIFY_EXPR(DstData.size() == Indices.size() * 3 * ElementSize);
851 Uint8* pDst = DstData.data();
852 for (size_t i = 0; i < Indices.size(); ++i)
853 {
854 const pxr::GfVec3i& Tri = Indices[i];
855 for (size_t v = 0; v < 3; ++v)
856 {
857 const auto* pSrc = pSrcData + Tri[v] * ElementSize;
858 memcpy(pDst + (i * 3 + v) * ElementSize, pSrc, ElementSize);
859 }
860 }
861
862 return ReindexedSource;
863}
864
865void HnMesh::ConvertVertexPrimvarSources(FaceSourcesMapType&& FaceSources)
866{

Callers 1

Calls 2

GetDataMethod · 0.80
GetTupleTypeMethod · 0.80

Tested by

no test coverage detected