remove function
This commit is contained in:
parent
eb8a7eefe8
commit
7a1d50465c
@ -32,8 +32,6 @@ public:
|
|||||||
{
|
{
|
||||||
Test::Step();
|
Test::Step();
|
||||||
|
|
||||||
m_cloth->Apply();
|
|
||||||
|
|
||||||
m_cloth->Draw();
|
m_cloth->Draw();
|
||||||
|
|
||||||
extern u32 b3_clothSolverIterations;
|
extern u32 b3_clothSolverIterations;
|
||||||
|
@ -97,8 +97,6 @@ public:
|
|||||||
{
|
{
|
||||||
Test::Step();
|
Test::Step();
|
||||||
|
|
||||||
m_cloth->Apply();
|
|
||||||
|
|
||||||
b3ClothMesh* mesh = m_cloth->GetMesh();
|
b3ClothMesh* mesh = m_cloth->GetMesh();
|
||||||
|
|
||||||
b3StackArray<b3Vec3, 256> tension;
|
b3StackArray<b3Vec3, 256> tension;
|
||||||
@ -126,9 +124,9 @@ public:
|
|||||||
{
|
{
|
||||||
b3ClothMeshTriangle* t = m_rectangleClothMesh.triangles + i;
|
b3ClothMeshTriangle* t = m_rectangleClothMesh.triangles + i;
|
||||||
|
|
||||||
b3Vec3 v1 = mesh->vertices[t->v1];
|
b3Vec3 v1 = mesh->particles[t->v1]->GetPosition();
|
||||||
b3Vec3 v2 = mesh->vertices[t->v2];
|
b3Vec3 v2 = mesh->particles[t->v2]->GetPosition();
|
||||||
b3Vec3 v3 = mesh->vertices[t->v3];
|
b3Vec3 v3 = mesh->particles[t->v3]->GetPosition();
|
||||||
|
|
||||||
b3Draw_draw->DrawSegment(v1, v2, b3Color_black);
|
b3Draw_draw->DrawSegment(v1, v2, b3Color_black);
|
||||||
b3Draw_draw->DrawSegment(v2, v3, b3Color_black);
|
b3Draw_draw->DrawSegment(v2, v3, b3Color_black);
|
||||||
|
@ -192,9 +192,9 @@ public:
|
|||||||
{
|
{
|
||||||
B3_ASSERT(IsDragging() == true);
|
B3_ASSERT(IsDragging() == true);
|
||||||
|
|
||||||
b3Vec3 A = m_mesh->vertices[m_triangle->v1];
|
b3Vec3 A = m_mesh->particles[m_triangle->v1]->GetPosition();
|
||||||
b3Vec3 B = m_mesh->vertices[m_triangle->v2];
|
b3Vec3 B = m_mesh->particles[m_triangle->v2]->GetPosition();
|
||||||
b3Vec3 C = m_mesh->vertices[m_triangle->v3];
|
b3Vec3 C = m_mesh->particles[m_triangle->v3]->GetPosition();
|
||||||
|
|
||||||
return m_u * A + m_v * B + (1.0f - m_u - m_v) * C;
|
return m_u * A + m_v * B + (1.0f - m_u - m_v) * C;
|
||||||
}
|
}
|
||||||
|
@ -123,9 +123,6 @@ public:
|
|||||||
// Get the next cloth in the world cloth list.
|
// Get the next cloth in the world cloth list.
|
||||||
b3Cloth* GetNext();
|
b3Cloth* GetNext();
|
||||||
|
|
||||||
// Set the positions of the mesh vertices to the positions of their associated particles.
|
|
||||||
void Apply() const;
|
|
||||||
|
|
||||||
// Debug draw the cloth using the associated cloth mesh.
|
// Debug draw the cloth using the associated cloth mesh.
|
||||||
void Draw() const;
|
void Draw() const;
|
||||||
private:
|
private:
|
||||||
|
@ -160,6 +160,9 @@ private:
|
|||||||
// Applied external force
|
// Applied external force
|
||||||
b3Vec3 m_force;
|
b3Vec3 m_force;
|
||||||
|
|
||||||
|
// Applied external translation
|
||||||
|
b3Vec3 m_translation;
|
||||||
|
|
||||||
// Mass
|
// Mass
|
||||||
float32 m_mass;
|
float32 m_mass;
|
||||||
|
|
||||||
@ -175,9 +178,6 @@ private:
|
|||||||
// Cloth mesh vertex index.
|
// Cloth mesh vertex index.
|
||||||
u32 m_vertex;
|
u32 m_vertex;
|
||||||
|
|
||||||
// Applied external translation
|
|
||||||
b3Vec3 m_translation;
|
|
||||||
|
|
||||||
// Contact
|
// Contact
|
||||||
b3BodyContact m_contact;
|
b3BodyContact m_contact;
|
||||||
|
|
||||||
|
@ -270,13 +270,9 @@ b3Particle* b3Cloth::CreateParticle(const b3ParticleDef& def)
|
|||||||
|
|
||||||
void b3Cloth::DestroyParticle(b3Particle* particle)
|
void b3Cloth::DestroyParticle(b3Particle* particle)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i > m_mesh->vertexCount; ++i)
|
if (particle->m_vertex != ~0)
|
||||||
{
|
{
|
||||||
if (m_mesh->particles[i] == particle)
|
m_mesh->particles[particle->m_vertex] = NULL;
|
||||||
{
|
|
||||||
m_mesh->particles[i] = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_particleList.Remove(particle);
|
m_particleList.Remove(particle);
|
||||||
@ -417,9 +413,9 @@ bool b3Cloth::RayCast(b3RayCastOutput* output, const b3RayCastInput* input, u32
|
|||||||
B3_ASSERT(triangleIndex < m_mesh->triangleCount);
|
B3_ASSERT(triangleIndex < m_mesh->triangleCount);
|
||||||
b3ClothMeshTriangle* triangle = m_mesh->triangles + triangleIndex;
|
b3ClothMeshTriangle* triangle = m_mesh->triangles + triangleIndex;
|
||||||
|
|
||||||
b3Vec3 v1 = m_mesh->vertices[triangle->v1];
|
b3Vec3 v1 = m_mesh->particles[triangle->v1]->m_position;
|
||||||
b3Vec3 v2 = m_mesh->vertices[triangle->v2];
|
b3Vec3 v2 = m_mesh->particles[triangle->v2]->m_position;
|
||||||
b3Vec3 v3 = m_mesh->vertices[triangle->v3];
|
b3Vec3 v3 = m_mesh->particles[triangle->v3]->m_position;
|
||||||
|
|
||||||
b3Vec3 p1 = input->p1;
|
b3Vec3 p1 = input->p1;
|
||||||
b3Vec3 p2 = input->p2;
|
b3Vec3 p2 = input->p2;
|
||||||
@ -738,17 +734,6 @@ void b3Cloth::Step(float32 dt, const b3Vec3& gravity)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void b3Cloth::Apply() const
|
|
||||||
{
|
|
||||||
for (b3Particle* p = m_particleList.m_head; p; p = p->m_next)
|
|
||||||
{
|
|
||||||
if (p->m_vertex != ~0)
|
|
||||||
{
|
|
||||||
m_mesh->vertices[p->m_vertex] = p->m_position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void b3Cloth::Draw() const
|
void b3Cloth::Draw() const
|
||||||
{
|
{
|
||||||
for (b3Particle* p = m_particleList.m_head; p; p = p->m_next)
|
for (b3Particle* p = m_particleList.m_head; p; p = p->m_next)
|
||||||
|
@ -91,7 +91,10 @@ void b3ClothSolver::ApplyForces()
|
|||||||
|
|
||||||
void b3AccelerationConstraint::Apply(const b3ClothSolverData* data)
|
void b3AccelerationConstraint::Apply(const b3ClothSolverData* data)
|
||||||
{
|
{
|
||||||
(*data->z)[i1] = z;
|
b3DiagMat33& sS = *data->S;
|
||||||
|
b3DenseVec3& sz = *data->z;
|
||||||
|
|
||||||
|
sz[i1] = z;
|
||||||
|
|
||||||
b3Mat33 I; I.SetIdentity();
|
b3Mat33 I; I.SetIdentity();
|
||||||
|
|
||||||
@ -99,22 +102,22 @@ void b3AccelerationConstraint::Apply(const b3ClothSolverData* data)
|
|||||||
{
|
{
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
(*data->S)[i1] = I;
|
sS[i1] = I;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
(*data->S)[i1] = I - b3Outer(p, p);
|
sS[i1] = I - b3Outer(p, p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
(*data->S)[i1] = I - b3Outer(p, p) - b3Outer(q, q);
|
sS[i1] = I - b3Outer(p, p) - b3Outer(q, q);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
(*data->S)[i1].SetZero();
|
sS[i1].SetZero();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -129,6 +132,7 @@ void b3ClothSolver::ApplyConstraints()
|
|||||||
{
|
{
|
||||||
b3DiagMat33& S = *m_solverData.S;
|
b3DiagMat33& S = *m_solverData.S;
|
||||||
b3DenseVec3& z = *m_solverData.z;
|
b3DenseVec3& z = *m_solverData.z;
|
||||||
|
float32 h = m_solverData.dt;
|
||||||
|
|
||||||
S.SetIdentity();
|
S.SetIdentity();
|
||||||
z.SetZero();
|
z.SetZero();
|
||||||
|
@ -31,6 +31,7 @@ b3Particle::b3Particle(const b3ParticleDef& def, b3Cloth* cloth)
|
|||||||
{
|
{
|
||||||
m_cloth = cloth;
|
m_cloth = cloth;
|
||||||
m_type = def.type;
|
m_type = def.type;
|
||||||
|
|
||||||
m_position = def.position;
|
m_position = def.position;
|
||||||
m_velocity = def.velocity;
|
m_velocity = def.velocity;
|
||||||
m_force = def.force;
|
m_force = def.force;
|
||||||
@ -42,13 +43,10 @@ b3Particle::b3Particle(const b3ParticleDef& def, b3Cloth* cloth)
|
|||||||
m_x.SetZero();
|
m_x.SetZero();
|
||||||
m_vertex = ~0;
|
m_vertex = ~0;
|
||||||
|
|
||||||
m_contact.f_active = false;
|
|
||||||
m_contact.n_active = false;
|
m_contact.n_active = false;
|
||||||
m_contact.t1_active = false;
|
m_contact.t1_active = false;
|
||||||
m_contact.t2_active = false;
|
m_contact.t2_active = false;
|
||||||
m_contact.Fn = 0.0f;
|
m_contact.f_active = false;
|
||||||
m_contact.Ft1 = 0.0f;
|
|
||||||
m_contact.Ft2 = 0.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b3Particle::~b3Particle()
|
b3Particle::~b3Particle()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user