use gravity
This commit is contained in:
@ -65,7 +65,7 @@ struct b3SpringClothDef
|
|||||||
// Mass radius
|
// Mass radius
|
||||||
float32 r;
|
float32 r;
|
||||||
|
|
||||||
// Force due to gravity
|
// Acceleration due to gravity (m/s^2)
|
||||||
b3Vec3 gravity;
|
b3Vec3 gravity;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -136,11 +136,11 @@ public:
|
|||||||
// Return the cloth mesh used to initialize this cloth.
|
// Return the cloth mesh used to initialize this cloth.
|
||||||
b3Mesh* GetMesh() const;
|
b3Mesh* GetMesh() const;
|
||||||
|
|
||||||
// Set the gravitational force applied to this cloth.
|
// Set the gravitational acceleration applied to this cloth.
|
||||||
// This force is applied at each time step.
|
// Units are m/s^2.
|
||||||
void SetGravity(const b3Vec3& gravity);
|
void SetGravity(const b3Vec3& gravity);
|
||||||
|
|
||||||
// Return the gravitational force applied to this cloth.
|
// Return the gravitational acceleration applied to this cloth.
|
||||||
const b3Vec3& GetGravity() const;
|
const b3Vec3& GetGravity() const;
|
||||||
|
|
||||||
// Set the type of a given point mass.
|
// Set the type of a given point mass.
|
||||||
|
@ -485,12 +485,12 @@ void b3SpringCloth::Step(float32 dt)
|
|||||||
// Update contacts
|
// Update contacts
|
||||||
UpdateContacts();
|
UpdateContacts();
|
||||||
|
|
||||||
// Apply gravity
|
// Apply gravity forces
|
||||||
for (u32 i = 0; i < m_massCount; ++i)
|
for (u32 i = 0; i < m_massCount; ++i)
|
||||||
{
|
{
|
||||||
if (m_types[i] == b3MassType::e_dynamicMass)
|
if (m_types[i] == b3MassType::e_dynamicMass)
|
||||||
{
|
{
|
||||||
m_f[i] += m_gravity;
|
m_f[i] += m_m[i] * m_gravity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user