16#ifndef BT_MASS_SPRING_H
17#define BT_MASS_SPRING_H
68 size_t id1 = node1->
index;
69 size_t id2 = node2->
index;
82 force[id1] += scaled_force;
83 force[id2] -= scaled_force;
105 size_t id1 = node1->
index;
106 size_t id2 = node2->
index;
112 btVector3 scaled_force = scaled_stiffness * (dir - dir_normalized * r);
113 force[id1] += scaled_force;
114 force[id2] -= scaled_force;
135 size_t id1 = node1->
index;
136 size_t id2 = node2->
index;
138 btVector3 local_scaled_df = scaled_k_damp * (dv[id2] - dv[id1]);
144 local_scaled_df = scaled_k_damp * (dv[id2] - dv[id1]).
dot(dir) * dir;
147 df[id1] += local_scaled_df;
148 df[id2] -= local_scaled_df;
169 size_t id1 = node1->
index;
170 size_t id2 = node2->
index;
176 for (
int d = 0; d < 3; ++d)
179 diagA[id1][d] -= scaled_k_damp * dir[d] * dir[d];
181 diagA[id2][d] -= scaled_k_damp * dir[d] * dir[d];
187 for (
int d = 0; d < 3; ++d)
190 diagA[id1][d] -= scaled_k_damp;
192 diagA[id2][d] -= scaled_k_damp;
241 dampingForce.
resize(sz + 1);
242 for (
int i = 0; i < dampingForce.
size(); ++i)
243 dampingForce[i].setZero();
251 energy -= dampingForce[node.
index].dot(node.
m_v) / dt;
272 size_t id1 = node1->
index;
273 size_t id2 = node2->
index;
284 scaled_df -= scaled_k * dir_normalized.
dot(dx_diff) * dir_normalized;
285 scaled_df += scaled_k * dir_normalized.
dot(dx_diff) * ((dir_norm - r) / dir_norm) * dir_normalized;
286 scaled_df -= scaled_k * ((dir_norm - r) / dir_norm) * dx_diff;
289 df[id1] += scaled_df;
290 df[id2] -= scaled_df;
const T & btMax(const T &a, const T &b)
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
int size() const
return the number of elements in the array
void resize(int newsize, const T &fillData=T())
The btSoftBody is an class to simulate cloth and volumetric soft bodies.
btVector3 can be used to represent 3D points and vectors.
btScalar dot(const btVector3 &v) const
Return the dot product.
btScalar norm() const
Return the norm (length) of the vector.
btVector3 normalized() const
Return a normalized version of this vector.