Better API naming. Enable self-collision by default.
This commit is contained in:
parent
170793896d
commit
9765e72ab9
@ -45,9 +45,9 @@ bool b3ClothDragger::StartDragging()
|
|||||||
m_triangle = m_mesh->triangles + rayOut.triangle;
|
m_triangle = m_mesh->triangles + rayOut.triangle;
|
||||||
m_x = rayOut.fraction;
|
m_x = rayOut.fraction;
|
||||||
|
|
||||||
b3Particle* p1 = m_cloth->GetVertexParticle(m_triangle->v1);
|
b3Particle* p1 = m_cloth->GetParticle(m_triangle->v1);
|
||||||
b3Particle* p2 = m_cloth->GetVertexParticle(m_triangle->v2);
|
b3Particle* p2 = m_cloth->GetParticle(m_triangle->v2);
|
||||||
b3Particle* p3 = m_cloth->GetVertexParticle(m_triangle->v3);
|
b3Particle* p3 = m_cloth->GetParticle(m_triangle->v3);
|
||||||
|
|
||||||
b3Vec3 v1 = p1->GetPosition();
|
b3Vec3 v1 = p1->GetPosition();
|
||||||
b3Vec3 v2 = p2->GetPosition();
|
b3Vec3 v2 = p2->GetPosition();
|
||||||
@ -133,13 +133,13 @@ void b3ClothDragger::Drag()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
b3Particle* p1 = m_cloth->GetVertexParticle(m_triangle->v1);
|
b3Particle* p1 = m_cloth->GetParticle(m_triangle->v1);
|
||||||
p1->ApplyTranslation(dx);
|
p1->ApplyTranslation(dx);
|
||||||
|
|
||||||
b3Particle* p2 = m_cloth->GetVertexParticle(m_triangle->v2);
|
b3Particle* p2 = m_cloth->GetParticle(m_triangle->v2);
|
||||||
p2->ApplyTranslation(dx);
|
p2->ApplyTranslation(dx);
|
||||||
|
|
||||||
b3Particle* p3 = m_cloth->GetVertexParticle(m_triangle->v3);
|
b3Particle* p3 = m_cloth->GetParticle(m_triangle->v3);
|
||||||
p3->ApplyTranslation(dx);
|
p3->ApplyTranslation(dx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,9 +172,9 @@ void b3ClothDragger::StopDragging()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_cloth->GetVertexParticle(m_triangle->v1)->SetType(m_t1);
|
m_cloth->GetParticle(m_triangle->v1)->SetType(m_t1);
|
||||||
m_cloth->GetVertexParticle(m_triangle->v2)->SetType(m_t2);
|
m_cloth->GetParticle(m_triangle->v2)->SetType(m_t2);
|
||||||
m_cloth->GetVertexParticle(m_triangle->v3)->SetType(m_t3);
|
m_cloth->GetParticle(m_triangle->v3)->SetType(m_t3);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_triangle = nullptr;
|
m_triangle = nullptr;
|
||||||
@ -184,9 +184,9 @@ b3Vec3 b3ClothDragger::GetPointA() const
|
|||||||
{
|
{
|
||||||
B3_ASSERT(IsDragging() == true);
|
B3_ASSERT(IsDragging() == true);
|
||||||
|
|
||||||
b3Vec3 A = m_cloth->GetVertexParticle(m_triangle->v1)->GetPosition();
|
b3Vec3 A = m_cloth->GetParticle(m_triangle->v1)->GetPosition();
|
||||||
b3Vec3 B = m_cloth->GetVertexParticle(m_triangle->v2)->GetPosition();
|
b3Vec3 B = m_cloth->GetParticle(m_triangle->v2)->GetPosition();
|
||||||
b3Vec3 C = m_cloth->GetVertexParticle(m_triangle->v3)->GetPosition();
|
b3Vec3 C = m_cloth->GetParticle(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;
|
||||||
}
|
}
|
||||||
|
@ -130,8 +130,15 @@ public:
|
|||||||
u32 v1 = s->GetParticle1()->GetVertex();
|
u32 v1 = s->GetParticle1()->GetVertex();
|
||||||
u32 v2 = s->GetParticle2()->GetVertex();
|
u32 v2 = s->GetParticle2()->GetVertex();
|
||||||
|
|
||||||
tension[v1] += s->GetActionForce();
|
if (v1 != ~0)
|
||||||
tension[v2] -= s->GetActionForce();
|
{
|
||||||
|
tension[v1] += s->GetActionForce();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v2 != ~0)
|
||||||
|
{
|
||||||
|
tension[v2] -= s->GetActionForce();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,13 +146,13 @@ public:
|
|||||||
{
|
{
|
||||||
b3ClothMeshTriangle* t = mesh->triangles + i;
|
b3ClothMeshTriangle* t = mesh->triangles + i;
|
||||||
|
|
||||||
b3Vec3 v1 = m_cloth->GetVertexParticle(t->v1)->GetPosition();
|
b3Vec3 v1 = m_cloth->GetParticle(t->v1)->GetPosition();
|
||||||
b3Vec3 v2 = m_cloth->GetVertexParticle(t->v2)->GetPosition();
|
b3Vec3 v2 = m_cloth->GetParticle(t->v2)->GetPosition();
|
||||||
b3Vec3 v3 = m_cloth->GetVertexParticle(t->v3)->GetPosition();
|
b3Vec3 v3 = m_cloth->GetParticle(t->v3)->GetPosition();
|
||||||
|
|
||||||
b3Draw_draw->DrawSegment(v1, v2, b3Color_black);
|
g_draw->DrawSegment(v1, v2, b3Color_black);
|
||||||
b3Draw_draw->DrawSegment(v2, v3, b3Color_black);
|
g_draw->DrawSegment(v2, v3, b3Color_black);
|
||||||
b3Draw_draw->DrawSegment(v3, v1, b3Color_black);
|
g_draw->DrawSegment(v3, v1, b3Color_black);
|
||||||
|
|
||||||
b3Vec3 f1 = tension[t->v1];
|
b3Vec3 f1 = tension[t->v1];
|
||||||
float32 L1 = b3Length(f1);
|
float32 L1 = b3Length(f1);
|
||||||
|
@ -133,8 +133,8 @@ public:
|
|||||||
// Return the cloth mesh proxy.
|
// Return the cloth mesh proxy.
|
||||||
const b3ClothMesh* GetMesh() const;
|
const b3ClothMesh* GetMesh() const;
|
||||||
|
|
||||||
// Return the particle associated with the given vertex.
|
// Return the cloth particle given vertex index.
|
||||||
b3Particle* GetVertexParticle(u32 i);
|
b3Particle* GetParticle(u32 i);
|
||||||
|
|
||||||
// Return the cloth triangle given the triangle index.
|
// Return the cloth triangle given the triangle index.
|
||||||
b3ClothTriangle* GetTriangle(u32 i);
|
b3ClothTriangle* GetTriangle(u32 i);
|
||||||
@ -179,8 +179,8 @@ private:
|
|||||||
// Proxy mesh
|
// Proxy mesh
|
||||||
const b3ClothMesh* m_mesh;
|
const b3ClothMesh* m_mesh;
|
||||||
|
|
||||||
// Vertex particles
|
// Particles
|
||||||
b3Particle** m_vertexParticles;
|
b3Particle** m_particles;
|
||||||
|
|
||||||
// Triangles
|
// Triangles
|
||||||
b3ClothTriangle* m_triangles;
|
b3ClothTriangle* m_triangles;
|
||||||
|
@ -67,6 +67,9 @@ private:
|
|||||||
|
|
||||||
// AABB Proxy
|
// AABB Proxy
|
||||||
b3ClothAABBProxy m_aabbProxy;
|
b3ClothAABBProxy m_aabbProxy;
|
||||||
|
|
||||||
|
// Broadphase ID
|
||||||
|
u32 m_broadPhaseId;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline u32 b3ClothTriangle::GetTriangle() const
|
inline u32 b3ClothTriangle::GetTriangle() const
|
||||||
|
@ -102,8 +102,7 @@ enum b3ClothAABBProxyType
|
|||||||
struct b3ClothAABBProxy
|
struct b3ClothAABBProxy
|
||||||
{
|
{
|
||||||
b3ClothAABBProxyType type;
|
b3ClothAABBProxyType type;
|
||||||
void* data;
|
void* owner;
|
||||||
u32 broadPhaseId;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// A cloth particle.
|
// A cloth particle.
|
||||||
@ -229,6 +228,9 @@ private:
|
|||||||
// AABB Proxy
|
// AABB Proxy
|
||||||
b3ClothAABBProxy m_aabbProxy;
|
b3ClothAABBProxy m_aabbProxy;
|
||||||
|
|
||||||
|
// Broadphase ID
|
||||||
|
u32 m_broadPhaseId;
|
||||||
|
|
||||||
// Links to the cloth particle list.
|
// Links to the cloth particle list.
|
||||||
b3Particle* m_prev;
|
b3Particle* m_prev;
|
||||||
b3Particle* m_next;
|
b3Particle* m_next;
|
||||||
|
@ -33,8 +33,6 @@
|
|||||||
|
|
||||||
#include <bounce/common/draw.h>
|
#include <bounce/common/draw.h>
|
||||||
|
|
||||||
#define B3_ENABLE_SELF_COLLISION 0
|
|
||||||
|
|
||||||
static B3_FORCE_INLINE u32 b3NextIndex(u32 i)
|
static B3_FORCE_INLINE u32 b3NextIndex(u32 i)
|
||||||
{
|
{
|
||||||
return i + 1 < 3 ? i + 1 : 0;
|
return i + 1 < 3 ? i + 1 : 0;
|
||||||
@ -166,7 +164,7 @@ b3Cloth::b3Cloth(const b3ClothDef& def) :
|
|||||||
const b3ClothMesh* m = m_mesh;
|
const b3ClothMesh* m = m_mesh;
|
||||||
|
|
||||||
// Initialize particles
|
// Initialize particles
|
||||||
m_vertexParticles = (b3Particle**)b3Alloc(m->vertexCount * sizeof(b3Particle*));
|
m_particles = (b3Particle**)b3Alloc(m->vertexCount * sizeof(b3Particle*));
|
||||||
for (u32 i = 0; i < m->vertexCount; ++i)
|
for (u32 i = 0; i < m->vertexCount; ++i)
|
||||||
{
|
{
|
||||||
b3ParticleDef pd;
|
b3ParticleDef pd;
|
||||||
@ -178,7 +176,7 @@ b3Cloth::b3Cloth(const b3ClothDef& def) :
|
|||||||
b3Particle* p = CreateParticle(pd);
|
b3Particle* p = CreateParticle(pd);
|
||||||
|
|
||||||
p->m_vertex = i;
|
p->m_vertex = i;
|
||||||
m_vertexParticles[i] = p;
|
m_particles[i] = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute mass
|
// Compute mass
|
||||||
@ -205,8 +203,8 @@ b3Cloth::b3Cloth(const b3ClothDef& def) :
|
|||||||
aabb.Extend(triangle->m_radius);
|
aabb.Extend(triangle->m_radius);
|
||||||
|
|
||||||
triangle->m_aabbProxy.type = e_triangleProxy;
|
triangle->m_aabbProxy.type = e_triangleProxy;
|
||||||
triangle->m_aabbProxy.data = triangle;
|
triangle->m_aabbProxy.owner = triangle;
|
||||||
triangle->m_aabbProxy.broadPhaseId = m_contactManager.m_broadPhase.CreateProxy(aabb, &triangle->m_aabbProxy);
|
triangle->m_broadPhaseId = m_contactManager.m_broadPhase.CreateProxy(aabb, &triangle->m_aabbProxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize forces
|
// Initialize forces
|
||||||
@ -225,8 +223,8 @@ b3Cloth::b3Cloth(const b3ClothDef& def) :
|
|||||||
{
|
{
|
||||||
b3UniqueEdge* e = uniqueEdges + i;
|
b3UniqueEdge* e = uniqueEdges + i;
|
||||||
|
|
||||||
b3Particle* p1 = m_vertexParticles[e->v1];
|
b3Particle* p1 = m_particles[e->v1];
|
||||||
b3Particle* p2 = m_vertexParticles[e->v2];
|
b3Particle* p2 = m_particles[e->v2];
|
||||||
|
|
||||||
b3SpringForceDef fd;
|
b3SpringForceDef fd;
|
||||||
fd.Initialize(p1, p2, def.structural, def.damping);
|
fd.Initialize(p1, p2, def.structural, def.damping);
|
||||||
@ -242,10 +240,10 @@ b3Cloth::b3Cloth(const b3ClothDef& def) :
|
|||||||
{
|
{
|
||||||
b3SharedEdge* e = sharedEdges + i;
|
b3SharedEdge* e = sharedEdges + i;
|
||||||
|
|
||||||
b3Particle* p1 = m_vertexParticles[e->v1];
|
b3Particle* p1 = m_particles[e->v1];
|
||||||
b3Particle* p2 = m_vertexParticles[e->v2];
|
b3Particle* p2 = m_particles[e->v2];
|
||||||
b3Particle* p3 = m_vertexParticles[e->nsv1];
|
b3Particle* p3 = m_particles[e->nsv1];
|
||||||
b3Particle* p4 = m_vertexParticles[e->nsv2];
|
b3Particle* p4 = m_particles[e->nsv2];
|
||||||
|
|
||||||
b3SpringForceDef fd;
|
b3SpringForceDef fd;
|
||||||
fd.Initialize(p3, p4, def.bending, def.damping);
|
fd.Initialize(p3, p4, def.bending, def.damping);
|
||||||
@ -264,8 +262,8 @@ b3Cloth::b3Cloth(const b3ClothDef& def) :
|
|||||||
{
|
{
|
||||||
b3ClothMeshSewingLine* line = m->sewingLines + i;
|
b3ClothMeshSewingLine* line = m->sewingLines + i;
|
||||||
|
|
||||||
b3Particle* p1 = m_vertexParticles[line->v1];
|
b3Particle* p1 = m_particles[line->v1];
|
||||||
b3Particle* p2 = m_vertexParticles[line->v2];
|
b3Particle* p2 = m_particles[line->v2];
|
||||||
|
|
||||||
b3SpringForceDef fd;
|
b3SpringForceDef fd;
|
||||||
fd.Initialize(p1, p2, def.structural, def.damping);
|
fd.Initialize(p1, p2, def.structural, def.damping);
|
||||||
@ -282,7 +280,7 @@ b3Cloth::b3Cloth(const b3ClothDef& def) :
|
|||||||
|
|
||||||
b3Cloth::~b3Cloth()
|
b3Cloth::~b3Cloth()
|
||||||
{
|
{
|
||||||
b3Free(m_vertexParticles);
|
b3Free(m_particles);
|
||||||
b3Free(m_triangles);
|
b3Free(m_triangles);
|
||||||
|
|
||||||
b3Particle* p = m_particleList.m_head;
|
b3Particle* p = m_particleList.m_head;
|
||||||
@ -311,8 +309,8 @@ b3Particle* b3Cloth::CreateParticle(const b3ParticleDef& def)
|
|||||||
aabb.Set(p->m_position, p->m_radius);
|
aabb.Set(p->m_position, p->m_radius);
|
||||||
|
|
||||||
p->m_aabbProxy.type = e_particleProxy;
|
p->m_aabbProxy.type = e_particleProxy;
|
||||||
p->m_aabbProxy.data = p;
|
p->m_aabbProxy.owner = p;
|
||||||
p->m_aabbProxy.broadPhaseId = m_contactManager.m_broadPhase.CreateProxy(aabb, &p->m_aabbProxy);
|
p->m_broadPhaseId = m_contactManager.m_broadPhase.CreateProxy(aabb, &p->m_aabbProxy);
|
||||||
|
|
||||||
m_particleList.PushFront(p);
|
m_particleList.PushFront(p);
|
||||||
|
|
||||||
@ -341,7 +339,7 @@ void b3Cloth::DestroyParticle(b3Particle* particle)
|
|||||||
particle->DestroyContacts();
|
particle->DestroyContacts();
|
||||||
|
|
||||||
// Destroy AABB proxy
|
// Destroy AABB proxy
|
||||||
m_contactManager.m_broadPhase.DestroyProxy(particle->m_aabbProxy.broadPhaseId);
|
m_contactManager.m_broadPhase.DestroyProxy(particle->m_broadPhaseId);
|
||||||
|
|
||||||
m_particleList.Remove(particle);
|
m_particleList.Remove(particle);
|
||||||
particle->~b3Particle();
|
particle->~b3Particle();
|
||||||
@ -371,10 +369,10 @@ float32 b3Cloth::GetEnergy() const
|
|||||||
return 0.5f * E;
|
return 0.5f * E;
|
||||||
}
|
}
|
||||||
|
|
||||||
b3Particle* b3Cloth::GetVertexParticle(u32 i)
|
b3Particle* b3Cloth::GetParticle(u32 i)
|
||||||
{
|
{
|
||||||
B3_ASSERT(i < m_mesh->vertexCount);
|
B3_ASSERT(i < m_mesh->vertexCount);
|
||||||
return m_vertexParticles[i];
|
return m_particles[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
b3ClothTriangle* b3Cloth::GetTriangle(u32 i)
|
b3ClothTriangle* b3Cloth::GetTriangle(u32 i)
|
||||||
@ -407,9 +405,9 @@ void b3Cloth::ComputeMass()
|
|||||||
|
|
||||||
float32 mass = rho * area;
|
float32 mass = rho * area;
|
||||||
|
|
||||||
b3Particle* p1 = m_vertexParticles[triangle->v1];
|
b3Particle* p1 = m_particles[triangle->v1];
|
||||||
b3Particle* p2 = m_vertexParticles[triangle->v2];
|
b3Particle* p2 = m_particles[triangle->v2];
|
||||||
b3Particle* p3 = m_vertexParticles[triangle->v3];
|
b3Particle* p3 = m_particles[triangle->v3];
|
||||||
|
|
||||||
p1->m_mass += inv3 * mass;
|
p1->m_mass += inv3 * mass;
|
||||||
p2->m_mass += inv3 * mass;
|
p2->m_mass += inv3 * mass;
|
||||||
@ -438,7 +436,7 @@ struct b3ClothRayCastSingleCallback
|
|||||||
return input.maxFraction;
|
return input.maxFraction;
|
||||||
}
|
}
|
||||||
|
|
||||||
b3ClothTriangle* triangle = (b3ClothTriangle*)proxy->data;
|
b3ClothTriangle* triangle = (b3ClothTriangle*)proxy->owner;
|
||||||
u32 triangleIndex = triangle->GetTriangle();
|
u32 triangleIndex = triangle->GetTriangle();
|
||||||
|
|
||||||
b3RayCastOutput subOutput;
|
b3RayCastOutput subOutput;
|
||||||
@ -495,9 +493,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_vertexParticles[triangle->v1]->m_position;
|
b3Vec3 v1 = m_particles[triangle->v1]->m_position;
|
||||||
b3Vec3 v2 = m_vertexParticles[triangle->v2]->m_position;
|
b3Vec3 v2 = m_particles[triangle->v2]->m_position;
|
||||||
b3Vec3 v3 = m_vertexParticles[triangle->v3]->m_position;
|
b3Vec3 v3 = m_particles[triangle->v3]->m_position;
|
||||||
|
|
||||||
return b3RayCast(output, input, v1, v2, v3);
|
return b3RayCast(output, input, v1, v2, v3);
|
||||||
}
|
}
|
||||||
@ -556,7 +554,7 @@ void b3Cloth::UpdateParticleBodyContacts()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
b3AABB3 aabb = m_contactManager.m_broadPhase.GetAABB(p->m_aabbProxy.broadPhaseId);
|
b3AABB3 aabb = m_contactManager.m_broadPhase.GetAABB(p->m_broadPhaseId);
|
||||||
|
|
||||||
b3ClothUpdateContactsQueryListener listener;
|
b3ClothUpdateContactsQueryListener listener;
|
||||||
listener.sphere.vertex = p->m_position;
|
listener.sphere.vertex = p->m_position;
|
||||||
@ -681,9 +679,9 @@ void b3Cloth::Step(float32 dt, u32 velocityIterations, u32 positionIterations)
|
|||||||
{
|
{
|
||||||
b3ClothMeshTriangle* triangle = m_mesh->triangles + i;
|
b3ClothMeshTriangle* triangle = m_mesh->triangles + i;
|
||||||
|
|
||||||
b3Particle* p1 = m_vertexParticles[triangle->v1];
|
b3Particle* p1 = m_particles[triangle->v1];
|
||||||
b3Particle* p2 = m_vertexParticles[triangle->v2];
|
b3Particle* p2 = m_particles[triangle->v2];
|
||||||
b3Particle* p3 = m_vertexParticles[triangle->v3];
|
b3Particle* p3 = m_particles[triangle->v3];
|
||||||
|
|
||||||
b3Vec3 v1 = p1->m_velocity;
|
b3Vec3 v1 = p1->m_velocity;
|
||||||
b3Vec3 v2 = p2->m_velocity;
|
b3Vec3 v2 = p2->m_velocity;
|
||||||
@ -696,12 +694,8 @@ void b3Cloth::Step(float32 dt, u32 velocityIterations, u32 positionIterations)
|
|||||||
m_triangles[i].Synchronize(displacement);
|
m_triangles[i].Synchronize(displacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if B3_ENABLE_SELF_COLLISION
|
|
||||||
|
|
||||||
// Find new self-contacts
|
// Find new self-contacts
|
||||||
m_contactManager.FindNewContacts();
|
m_contactManager.FindNewContacts();
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void b3Cloth::Draw() const
|
void b3Cloth::Draw() const
|
||||||
@ -741,8 +735,8 @@ void b3Cloth::Draw() const
|
|||||||
for (u32 i = 0; i < m->sewingLineCount; ++i)
|
for (u32 i = 0; i < m->sewingLineCount; ++i)
|
||||||
{
|
{
|
||||||
b3ClothMeshSewingLine* s = m->sewingLines + i;
|
b3ClothMeshSewingLine* s = m->sewingLines + i;
|
||||||
b3Particle* p1 = m_vertexParticles[s->v1];
|
b3Particle* p1 = m_particles[s->v1];
|
||||||
b3Particle* p2 = m_vertexParticles[s->v2];
|
b3Particle* p2 = m_particles[s->v2];
|
||||||
|
|
||||||
b3Draw_draw->DrawSegment(p1->m_position, p2->m_position, b3Color_white);
|
b3Draw_draw->DrawSegment(p1->m_position, p2->m_position, b3Color_white);
|
||||||
}
|
}
|
||||||
@ -751,9 +745,9 @@ void b3Cloth::Draw() const
|
|||||||
{
|
{
|
||||||
b3ClothMeshTriangle* t = m->triangles + i;
|
b3ClothMeshTriangle* t = m->triangles + i;
|
||||||
|
|
||||||
b3Particle* p1 = m_vertexParticles[t->v1];
|
b3Particle* p1 = m_particles[t->v1];
|
||||||
b3Particle* p2 = m_vertexParticles[t->v2];
|
b3Particle* p2 = m_particles[t->v2];
|
||||||
b3Particle* p3 = m_vertexParticles[t->v3];
|
b3Particle* p3 = m_particles[t->v3];
|
||||||
|
|
||||||
b3Vec3 v1 = p1->m_position;
|
b3Vec3 v1 = p1->m_position;
|
||||||
b3Vec3 v2 = p2->m_position;
|
b3Vec3 v2 = p2->m_position;
|
||||||
|
@ -61,13 +61,13 @@ void b3ClothContactManager::AddPair(void* data1, void* data2)
|
|||||||
B3_ASSERT(proxy1->type == e_particleProxy);
|
B3_ASSERT(proxy1->type == e_particleProxy);
|
||||||
B3_ASSERT(proxy2->type == e_triangleProxy);
|
B3_ASSERT(proxy2->type == e_triangleProxy);
|
||||||
|
|
||||||
b3Particle* p1 = (b3Particle*)proxy1->data;
|
b3Particle* p1 = (b3Particle*)proxy1->owner;
|
||||||
|
|
||||||
b3ClothTriangle* t2 = (b3ClothTriangle*)proxy2->data;
|
b3ClothTriangle* t2 = (b3ClothTriangle*)proxy2->owner;
|
||||||
b3ClothMeshTriangle* triangle = m_cloth->m_mesh->triangles + t2->m_triangle;
|
b3ClothMeshTriangle* triangle = m_cloth->m_mesh->triangles + t2->m_triangle;
|
||||||
b3Particle* p2 = m_cloth->m_vertexParticles[triangle->v1];
|
b3Particle* p2 = m_cloth->m_particles[triangle->v1];
|
||||||
b3Particle* p3 = m_cloth->m_vertexParticles[triangle->v2];
|
b3Particle* p3 = m_cloth->m_particles[triangle->v2];
|
||||||
b3Particle* p4 = m_cloth->m_vertexParticles[triangle->v3];
|
b3Particle* p4 = m_cloth->m_particles[triangle->v3];
|
||||||
|
|
||||||
// Check if there is a contact between the two entities.
|
// Check if there is a contact between the two entities.
|
||||||
for (b3ParticleTriangleContact* c = m_particleTriangleContactList.m_head; c; c = c->m_next)
|
for (b3ParticleTriangleContact* c = m_particleTriangleContactList.m_head; c; c = c->m_next)
|
||||||
@ -146,8 +146,8 @@ void b3ClothContactManager::UpdateContacts()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 proxy1 = c->m_p1->m_aabbProxy.broadPhaseId;
|
u32 proxy1 = c->m_p1->m_broadPhaseId;
|
||||||
u32 proxy2 = c->m_t2->m_aabbProxy.broadPhaseId;
|
u32 proxy2 = c->m_t2->m_broadPhaseId;
|
||||||
|
|
||||||
// Destroy the contact if primitive AABBs are not overlapping.
|
// Destroy the contact if primitive AABBs are not overlapping.
|
||||||
bool overlap = m_broadPhase.TestOverlap(proxy1, proxy2);
|
bool overlap = m_broadPhase.TestOverlap(proxy1, proxy2);
|
||||||
|
@ -24,9 +24,9 @@ void b3ClothTriangle::Synchronize(const b3Vec3& displacement)
|
|||||||
{
|
{
|
||||||
b3ClothMeshTriangle* triangle = m_cloth->m_mesh->triangles + m_triangle;
|
b3ClothMeshTriangle* triangle = m_cloth->m_mesh->triangles + m_triangle;
|
||||||
|
|
||||||
b3Particle* p1 = m_cloth->m_vertexParticles[triangle->v1];
|
b3Particle* p1 = m_cloth->m_particles[triangle->v1];
|
||||||
b3Particle* p2 = m_cloth->m_vertexParticles[triangle->v2];
|
b3Particle* p2 = m_cloth->m_particles[triangle->v2];
|
||||||
b3Particle* p3 = m_cloth->m_vertexParticles[triangle->v3];
|
b3Particle* p3 = m_cloth->m_particles[triangle->v3];
|
||||||
|
|
||||||
b3Vec3 x1 = p1->m_position;
|
b3Vec3 x1 = p1->m_position;
|
||||||
b3Vec3 x2 = p2->m_position;
|
b3Vec3 x2 = p2->m_position;
|
||||||
@ -36,5 +36,5 @@ void b3ClothTriangle::Synchronize(const b3Vec3& displacement)
|
|||||||
aabb.Set(x1, x2, x3);
|
aabb.Set(x1, x2, x3);
|
||||||
aabb.Extend(m_radius);
|
aabb.Extend(m_radius);
|
||||||
|
|
||||||
m_cloth->m_contactManager.m_broadPhase.MoveProxy(m_aabbProxy.broadPhaseId, aabb, displacement);
|
m_cloth->m_contactManager.m_broadPhase.MoveProxy(m_broadPhaseId, aabb, displacement);
|
||||||
}
|
}
|
@ -76,7 +76,7 @@ void b3Particle::Synchronize(const b3Vec3& displacement)
|
|||||||
b3AABB3 aabb;
|
b3AABB3 aabb;
|
||||||
aabb.Set(m_position, m_radius);
|
aabb.Set(m_position, m_radius);
|
||||||
|
|
||||||
m_cloth->m_contactManager.m_broadPhase.MoveProxy(m_aabbProxy.broadPhaseId, aabb, displacement);
|
m_cloth->m_contactManager.m_broadPhase.MoveProxy(m_broadPhaseId, aabb, displacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void b3Particle::SynchronizeTriangles()
|
void b3Particle::SynchronizeTriangles()
|
||||||
@ -140,5 +140,5 @@ void b3Particle::SetType(b3ParticleType type)
|
|||||||
DestroyContacts();
|
DestroyContacts();
|
||||||
|
|
||||||
// Move the proxy so new contacts can be created.
|
// Move the proxy so new contacts can be created.
|
||||||
m_cloth->m_contactManager.m_broadPhase.TouchProxy(m_aabbProxy.broadPhaseId);
|
m_cloth->m_contactManager.m_broadPhase.TouchProxy(m_broadPhaseId);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user