Use a particle tree for cloth

This commit is contained in:
Irlan
2019-06-03 17:50:43 -03:00
parent 17bddf5426
commit 92cdb42dca
6 changed files with 117 additions and 63 deletions

View File

@ -23,6 +23,7 @@
#include <bounce/common/template/list.h>
#include <bounce/common/memory/stack_allocator.h>
#include <bounce/common/memory/block_pool.h>
#include <bounce/collision/trees/dynamic_tree.h>
class b3World;
class b3Shape;
@ -138,12 +139,11 @@ public:
// Debug draw the cloth using the associated cloth mesh.
void Draw() const;
private:
friend class b3Particle;
// Compute mass of each particle.
void ComputeMass();
// Update body contacts.
void UpdateBodyContacts();
// Update contacts
void UpdateContacts();
@ -173,7 +173,10 @@ private:
// List of particles
b3List2<b3Particle> m_particleList;
// Particle tree
b3DynamicTree m_particleTree;
// List of forces
b3List2<b3Force> m_forceList;
};

View File

@ -152,6 +152,9 @@ private:
b3Particle(const b3ParticleDef& def, b3Cloth* cloth);
~b3Particle();
// Synchronize AABB
void Synchronize();
// Type
b3ParticleType m_type;
@ -193,12 +196,15 @@ private:
// Solution
b3Vec3 m_x;
//
// Parent cloth
b3Cloth* m_cloth;
// Contact
b3ParticleBodyContact m_bodyContact;
// Particle tree identifier
u32 m_treeId;
//
b3Particle* m_prev;
@ -220,6 +226,8 @@ inline void b3Particle::SetPosition(const b3Vec3& position)
{
m_position = position;
m_translation.SetZero();
Synchronize();
}
inline const b3Vec3& b3Particle::GetPosition() const
@ -249,6 +257,8 @@ inline float32 b3Particle::GetMass() const
inline void b3Particle::SetRadius(float32 radius)
{
m_radius = radius;
Synchronize();
}
inline float32 b3Particle::GetRadius() const