diff options
| author | Marijn Tamis <[email protected]> | 2018-05-03 18:22:48 +0200 |
|---|---|---|
| committer | Marijn Tamis <[email protected]> | 2018-05-03 18:22:48 +0200 |
| commit | ca32c59a58d37c1822e185a2d5f3d0d3e8943593 (patch) | |
| tree | b06b9eec03f34344ef8fc31aa147b2714d3962ee /NvCloth/samples/SampleBase/renderer/ClothRenderMesh.cpp | |
| parent | Forced rename of platform folders in cmake dir. Git didn't pick this up before. (diff) | |
| download | nvcloth-ca32c59a58d37c1822e185a2d5f3d0d3e8943593.tar.xz nvcloth-ca32c59a58d37c1822e185a2d5f3d0d3e8943593.zip | |
NvCloth 1.1.4 Release. (24070740)
Diffstat (limited to 'NvCloth/samples/SampleBase/renderer/ClothRenderMesh.cpp')
| -rw-r--r-- | NvCloth/samples/SampleBase/renderer/ClothRenderMesh.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/NvCloth/samples/SampleBase/renderer/ClothRenderMesh.cpp b/NvCloth/samples/SampleBase/renderer/ClothRenderMesh.cpp index 1183bdb..492324a 100644 --- a/NvCloth/samples/SampleBase/renderer/ClothRenderMesh.cpp +++ b/NvCloth/samples/SampleBase/renderer/ClothRenderMesh.cpp @@ -34,15 +34,21 @@ void gatherIndices(std::vector<uint16_t>& indices, indices.push_back(static_cast<uint16_t>(tIt.ptr()[1])); indices.push_back(static_cast<uint16_t>(tIt.ptr()[2])); } - qIt = PxMakeIterator(reinterpret_cast<const T*>(quads.data), quads.stride); - for (PxU32 i = 0; i < quads.count; ++i, ++qIt) + + //Only do quads in case there wasn't triangle data provided + // otherwise we risk to render triangles double + if(indices.size() == 0) { - indices.push_back(static_cast<uint16_t>(qIt.ptr()[0])); - indices.push_back(static_cast<uint16_t>(qIt.ptr()[1])); - indices.push_back(static_cast<uint16_t>(qIt.ptr()[2])); - indices.push_back(static_cast<uint16_t>(qIt.ptr()[0])); - indices.push_back(static_cast<uint16_t>(qIt.ptr()[2])); - indices.push_back(static_cast<uint16_t>(qIt.ptr()[3])); + qIt = PxMakeIterator(reinterpret_cast<const T*>(quads.data), quads.stride); + for (PxU32 i = 0; i < quads.count; ++i, ++qIt) + { + indices.push_back(static_cast<uint16_t>(qIt.ptr()[0])); + indices.push_back(static_cast<uint16_t>(qIt.ptr()[1])); + indices.push_back(static_cast<uint16_t>(qIt.ptr()[2])); + indices.push_back(static_cast<uint16_t>(qIt.ptr()[0])); + indices.push_back(static_cast<uint16_t>(qIt.ptr()[2])); + indices.push_back(static_cast<uint16_t>(qIt.ptr()[3])); + } } } @@ -147,6 +153,9 @@ void ClothRenderMesh::initialize(const void* vertices, uint32_t numVertices, uin V(mDevice->CreateBuffer(&bufferDesc, &indexBufferData, &mIndexBuffer)); } + std::vector<uint32_t> offsets; + offsets.push_back(0); + setSubmeshOffsets(offsets); } ClothRenderMesh::~ClothRenderMesh() @@ -197,7 +206,7 @@ void ClothRenderMesh::update(const PxVec3* positions, uint32_t numVertices) } } -void ClothRenderMesh::render(ID3D11DeviceContext& context) const +void ClothRenderMesh::render(ID3D11DeviceContext& context, int submesh) const { context.IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); @@ -207,8 +216,11 @@ void ClothRenderMesh::render(ID3D11DeviceContext& context) const context.IASetIndexBuffer(mIndexBuffer, DXGI_FORMAT_R16_UINT, 0); + int firstIndex = mSubmeshOffsets[submesh]; + int indexCount = mSubmeshOffsets[submesh+1] - firstIndex; + if (mIndexBuffer) - context.DrawIndexed(mNumFaces*3, 0, 0); + context.DrawIndexed(indexCount, firstIndex, 0); else context.Draw(mNumVertices, 0); }
\ No newline at end of file |