code clean up + check in examples
This commit is contained in:
@@ -17,12 +17,12 @@ struct Constraint
|
||||
btAlignedObjectArray<const btSoftBody::RContact*> m_contact;
|
||||
btAlignedObjectArray<btVector3> m_direction;
|
||||
btAlignedObjectArray<btScalar> m_value;
|
||||
// the magnitude of the total impulse the node applied to the rb in the normal direction in the cg solve
|
||||
btAlignedObjectArray<btScalar> m_accumulated_normal_impulse;
|
||||
|
||||
Constraint(const btSoftBody::RContact& rcontact)
|
||||
{
|
||||
m_contact.push_back(&rcontact);
|
||||
m_direction.push_back(rcontact.m_cti.m_normal);
|
||||
m_value.push_back(0);
|
||||
append(rcontact);
|
||||
}
|
||||
|
||||
Constraint(const btVector3 dir)
|
||||
@@ -30,30 +30,56 @@ struct Constraint
|
||||
m_contact.push_back(nullptr);
|
||||
m_direction.push_back(dir);
|
||||
m_value.push_back(0);
|
||||
m_accumulated_normal_impulse.push_back(0);
|
||||
}
|
||||
|
||||
Constraint()
|
||||
{
|
||||
m_contact.push_back(nullptr);
|
||||
m_direction.push_back(btVector3(0,0,0));
|
||||
m_value.push_back(0);
|
||||
m_accumulated_normal_impulse.push_back(0);
|
||||
}
|
||||
|
||||
void append(const btSoftBody::RContact& rcontact)
|
||||
{
|
||||
m_contact.push_back(&rcontact);
|
||||
m_direction.push_back(rcontact.m_cti.m_normal);
|
||||
m_value.push_back(0);
|
||||
m_accumulated_normal_impulse.push_back(0);
|
||||
}
|
||||
|
||||
~Constraint()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct Friction
|
||||
{
|
||||
btAlignedObjectArray<bool> m_static;
|
||||
btAlignedObjectArray<btScalar> m_impulse;
|
||||
btAlignedObjectArray<btScalar> m_dv;
|
||||
btAlignedObjectArray<btVector3> m_direction;
|
||||
btAlignedObjectArray<btVector3> m_direction_prev;
|
||||
|
||||
btAlignedObjectArray<bool> m_static; // whether the friction is static
|
||||
btAlignedObjectArray<btScalar> m_impulse; // the impulse magnitude the node feels
|
||||
btAlignedObjectArray<btScalar> m_dv; // the dv magnitude of the node
|
||||
btAlignedObjectArray<btVector3> m_direction; // the direction of the friction for the node
|
||||
|
||||
|
||||
btAlignedObjectArray<bool> m_static_prev;
|
||||
btAlignedObjectArray<btScalar> m_impulse_prev;
|
||||
btAlignedObjectArray<btScalar> m_dv_prev;
|
||||
btAlignedObjectArray<btVector3> m_direction_prev;
|
||||
|
||||
btAlignedObjectArray<bool> m_released;
|
||||
btAlignedObjectArray<bool> m_released; // whether the contact is released
|
||||
|
||||
btAlignedObjectArray<btScalar> m_accumulated_normal_impulse;
|
||||
|
||||
|
||||
// the total impulse the node applied to the rb in the tangential direction in the cg solve
|
||||
btAlignedObjectArray<btVector3> m_accumulated_tangent_impulse;
|
||||
Friction()
|
||||
{
|
||||
append();
|
||||
}
|
||||
|
||||
void append()
|
||||
{
|
||||
m_static.push_back(false);
|
||||
m_static_prev.push_back(false);
|
||||
@@ -67,7 +93,6 @@ struct Friction
|
||||
m_dv.push_back(0);
|
||||
m_dv_prev.push_back(0);
|
||||
|
||||
m_accumulated_normal_impulse.push_back(0);
|
||||
m_accumulated_tangent_impulse.push_back(btVector3(0,0,0));
|
||||
m_released.push_back(false);
|
||||
}
|
||||
@@ -100,7 +125,7 @@ public:
|
||||
// apply the constraints
|
||||
virtual void operator()(TVStack& x) = 0;
|
||||
|
||||
virtual void setConstraintDirections() = 0;
|
||||
virtual void setConstraints() = 0;
|
||||
|
||||
// update the constraints
|
||||
virtual void update(const TVStack& dv, const TVStack& backup_v) = 0;
|
||||
|
||||
Reference in New Issue
Block a user