From dbc5b189c777e548488087f5312ee668c7b11609 Mon Sep 17 00:00:00 2001 From: Irlan Date: Wed, 3 Apr 2019 14:53:10 -0300 Subject: [PATCH] Add sewing lines to pattern mesh for completeness. --- src/bounce/cloth/garment/garment_mesh.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/bounce/cloth/garment/garment_mesh.cpp b/src/bounce/cloth/garment/garment_mesh.cpp index 1d54f89..3d107ba 100644 --- a/src/bounce/cloth/garment/garment_mesh.cpp +++ b/src/bounce/cloth/garment/garment_mesh.cpp @@ -186,4 +186,21 @@ void b3GarmentMesh::Set(b3Garment* g, float32 desiredArea) { b3Set(meshes + i, desiredArea, garment->patterns[i]); } + + // It's okay to do run the following code because + // the first vertices of a sewing pattern mesh are the vertices of its + // corresponding sewing pattern. + sewingCount = garment->sewingCount; + sewingLines = (b3GarmentMeshSewingLine*)b3Alloc(garment->sewingCount * sizeof(b3GarmentMeshSewingLine)); + for (u32 i = 0; i < garment->sewingCount; ++i) + { + b3SewingLine* sewingLine = garment->sewingLines + i; + b3GarmentMeshSewingLine* line = sewingLines + i; + + line->s1 = sewingLine->p1; + line->v1 = sewingLine->v1; + + line->s2 = sewingLine->p2; + line->v2 = sewingLine->v2; + } } \ No newline at end of file