From 7bed29df5e48f0041bc71ad31077ee60a04f0297 Mon Sep 17 00:00:00 2001 From: Irlan <-> Date: Wed, 30 May 2018 16:32:45 -0300 Subject: [PATCH] remove default radius --- examples/testbed/tests/pinned_cloth.h | 1 - examples/testbed/tests/shirt.h | 1 - examples/testbed/tests/table_cloth.h | 1 - examples/testbed/tests/tension_mapping.h | 11 +++++------ include/bounce/dynamics/cloth/cloth.h | 10 ++-------- src/bounce/dynamics/cloth/cloth.cpp | 11 ++++++++++- src/bounce/dynamics/cloth/spring_force.cpp | 6 +++--- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/examples/testbed/tests/pinned_cloth.h b/examples/testbed/tests/pinned_cloth.h index 785c106..da00c56 100644 --- a/examples/testbed/tests/pinned_cloth.h +++ b/examples/testbed/tests/pinned_cloth.h @@ -39,7 +39,6 @@ public: b3ClothDef def; def.mesh = &m_rectangleClothMesh; - def.radius = 0.05f; def.density = 0.2f; def.structural = 10000.0f; def.damping = 0.0f; diff --git a/examples/testbed/tests/shirt.h b/examples/testbed/tests/shirt.h index 0cd2e13..158b8f1 100644 --- a/examples/testbed/tests/shirt.h +++ b/examples/testbed/tests/shirt.h @@ -53,7 +53,6 @@ public: // Create cloth b3ClothDef def; - def.radius = 0.2f; def.mesh = &m_shirtClothMesh; def.density = 0.2f; def.structural = 10000.0f; diff --git a/examples/testbed/tests/table_cloth.h b/examples/testbed/tests/table_cloth.h index 3f4bd17..cbaad9b 100644 --- a/examples/testbed/tests/table_cloth.h +++ b/examples/testbed/tests/table_cloth.h @@ -40,7 +40,6 @@ public: b3ClothDef def; def.mesh = &m_rectangleClothMesh; - def.radius = 0.05f; def.density = 0.2f; def.structural = 10000.0f; def.damping = 0.0f; diff --git a/examples/testbed/tests/tension_mapping.h b/examples/testbed/tests/tension_mapping.h index d49abbb..39f9f23 100644 --- a/examples/testbed/tests/tension_mapping.h +++ b/examples/testbed/tests/tension_mapping.h @@ -75,7 +75,6 @@ public: b3ClothDef def; def.mesh = &m_rectangleClothMesh; - def.radius = 0.2f; def.density = 0.2f; def.structural = 10000.0f; @@ -157,16 +156,16 @@ public: g_draw->DrawSolidTriangle(n2, v1, v3, v2, color); } + if (m_clothDragger.IsSelected() == true) + { + g_draw->DrawSegment(m_clothDragger.GetPointA(), m_clothDragger.GetPointB(), b3Color_white); + } + extern u32 b3_clothSolverIterations; g_draw->DrawString(b3Color_white, "Iterations = %u", b3_clothSolverIterations); float32 E = m_cloth->GetEnergy(); g_draw->DrawString(b3Color_white, "E = %f", E); - - if (m_clothDragger.IsSelected() == true) - { - g_draw->DrawSegment(m_clothDragger.GetPointA(), m_clothDragger.GetPointB(), b3Color_white); - } } static Test* Create() diff --git a/include/bounce/dynamics/cloth/cloth.h b/include/bounce/dynamics/cloth/cloth.h index 3fef21b..0dce055 100644 --- a/include/bounce/dynamics/cloth/cloth.h +++ b/include/bounce/dynamics/cloth/cloth.h @@ -52,7 +52,6 @@ struct b3ClothDef { mesh = nullptr; density = 0.0f; - radius = 0.05f; structural = 0.0f; bending = 0.0f; damping = 0.0f; @@ -61,11 +60,6 @@ struct b3ClothDef // Cloth mesh b3ClothMesh* mesh; - // Radius - // This should be a small value. It can be used for correcting visual artifacts when - // the masses are colliding against a solid. - float32 radius; - // Cloth density in kg/m^3 float32 density; @@ -91,13 +85,13 @@ public: // Create a particle. b3Particle* CreateParticle(const b3ParticleDef& def); - // Destroy a particle + // Destroy a given particle. void DestroyParticle(b3Particle* particle); // Create a force. b3Force* CreateForce(const b3ForceDef& def); - // Destroy a force. + // Destroy a given force. void DestroyForce(b3Force* force); // Perform a ray cast with the cloth. diff --git a/src/bounce/dynamics/cloth/cloth.cpp b/src/bounce/dynamics/cloth/cloth.cpp index 77b4b0f..10bd692 100644 --- a/src/bounce/dynamics/cloth/cloth.cpp +++ b/src/bounce/dynamics/cloth/cloth.cpp @@ -31,7 +31,7 @@ #define B3_FORCE_THRESHOLD 0.005f -#define B3_CLOTH_BENDING 1 +#define B3_CLOTH_BENDING 0 #define B3_CLOTH_FRICTION 1 @@ -271,6 +271,15 @@ b3Particle* b3Cloth::CreateParticle(const b3ParticleDef& def) void b3Cloth::DestroyParticle(b3Particle* particle) { + for (u32 i = 0; i > m_mesh->vertexCount; ++i) + { + if (m_mesh->particles[i] == particle) + { + m_mesh->particles[i] = NULL; + break; + } + } + m_particleList.Remove(particle); particle->~b3Particle(); m_particleBlocks.Free(particle); diff --git a/src/bounce/dynamics/cloth/spring_force.cpp b/src/bounce/dynamics/cloth/spring_force.cpp index d4fe97b..bdc91b3 100644 --- a/src/bounce/dynamics/cloth/spring_force.cpp +++ b/src/bounce/dynamics/cloth/spring_force.cpp @@ -94,12 +94,12 @@ void b3SpringForce::Apply(const b3ClothSolverData* data) b3SymMat33& dfdx = *data->dfdx; b3SymMat33& dfdv = *data->dfdv; - f[m_p1->m_solverId] += m_f; - f[m_p2->m_solverId] -= m_f; - u32 i1 = m_p1->m_solverId; u32 i2 = m_p2->m_solverId; + f[i1] += m_f; + f[i2] -= m_f; + b3Mat33 Jx11 = m_Jx; b3Mat33 Jx12 = -Jx11; b3Mat33 Jx21 = Jx12;