26 #ifdef IMPLICIT_SOLVER_EIGEN
29 # define USE_EIGEN_CONSTRAINED_CG
32 # pragma GCC diagnostic push
37 # ifndef IMPLICIT_ENABLE_EIGEN_DEBUG
39 # define IMPLICIT_NDEBUG
44 # include <Eigen/Sparse>
45 # include <Eigen/src/Core/util/DisableStupidWarnings.h>
47 # ifdef USE_EIGEN_CONSTRAINED_CG
51 # ifndef IMPLICIT_ENABLE_EIGEN_DEBUG
52 # ifndef IMPLICIT_NDEBUG
55 # undef IMPLICIT_NDEBUG
60 # pragma GCC diagnostic pop
86 static float I[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
91 class fVector :
public Eigen::Vector3f {
99 fVector(
const ctype &
v)
101 for (
int k = 0; k < 3; k++) {
108 for (
int k = 0; k < 3; k++) {
123 class fMatrix :
public Eigen::Matrix3f {
125 typedef float (*ctype)[3];
131 fMatrix(
const ctype &
v)
133 for (
int k = 0; k < 3; k++) {
134 for (
int l = 0;
l < 3;
l++) {
135 coeffRef(
l, k) =
v[k][
l];
142 for (
int k = 0; k < 3; k++) {
143 for (
int l = 0;
l < 3;
l++) {
144 coeffRef(
l, k) =
v[k][
l];
152 return (ctype)
data();
159 class lVector :
public Eigen::VectorXf {
161 typedef Eigen::VectorXf base_t;
173 float *v3(
int vertex)
175 return &coeffRef(3 * vertex);
178 const float *v3(
int vertex)
const
180 return &coeffRef(3 * vertex);
184 typedef Eigen::Triplet<Scalar>
Triplet;
187 typedef Eigen::SparseMatrix<Scalar>
lMatrix;
205 void reserve(
int numverts)
208 m_trips.reserve(numverts * 9);
211 void add(
int i,
int j,
const fMatrix &m)
215 for (
int k = 0; k < 3; k++) {
216 for (
int l = 0;
l < 3;
l++) {
217 m_trips.push_back(
Triplet(i + k, j +
l, m.coeff(
l, k)));
222 void sub(
int i,
int j,
const fMatrix &m)
226 for (
int k = 0; k < 3; k++) {
227 for (
int l = 0;
l < 3;
l++) {
228 m_trips.push_back(
Triplet(i + k, j +
l, -m.coeff(
l, k)));
233 inline void construct(
lMatrix &m)
235 m.setFromTriplets(m_trips.begin(), m_trips.end());
243 # ifdef USE_EIGEN_CORE
244 typedef Eigen::ConjugateGradient<lMatrix, Eigen::Lower, Eigen::DiagonalPreconditioner<Scalar>>
247 # ifdef USE_EIGEN_CONSTRAINED_CG
251 Eigen::DiagonalPreconditioner<Scalar>>
254 using Eigen::ComputationInfo;
258 for (
int i = 0; i <
v.rows(); i++) {
259 if (i > 0 && i % 3 == 0) {
263 printf(
"%f,\n",
v[i]);
269 for (
int j = 0; j < m.rows(); j++) {
270 if (j > 0 && j % 3 == 0) {
274 for (
int i = 0; i < m.cols(); i++) {
275 if (i > 0 && i % 3 == 0) {
287 m.reserve(Eigen::VectorXi::Constant(m.cols(), num));
292 return v.data() + 3 * vertex;
297 return v.data() + 3 * vertex;
305 for (
int l = 0;
l < 3;
l++) {
306 for (
int k = 0; k < 3; k++) {
307 tlist.push_back(
Triplet(i + k, j +
l, m[k][
l]));
316 for (
int l = 0;
l < 3;
l++) {
317 for (
int k = 0; k < 3; k++) {
318 tlist.push_back(
Triplet(i + k, j +
l, m[k][
l] * factor));
326 t.setFromTriplets(tlist.begin(), tlist.end());
333 t.setFromTriplets(tlist.begin(), tlist.end());
340 t.setFromTriplets(tlist.begin(), tlist.end());
374 r[0][0] += m[0][0] * f;
375 r[0][1] += m[0][1] * f;
376 r[0][2] += m[0][2] * f;
377 r[1][0] += m[1][0] * f;
378 r[1][1] += m[1][1] * f;
379 r[1][2] += m[1][2] * f;
380 r[2][0] += m[2][0] * f;
381 r[2][1] += m[2][1] * f;
382 r[2][2] += m[2][2] * f;
387 r[0][0] =
a[0][0] + b[0][0] * f;
388 r[0][1] =
a[0][1] + b[0][1] * f;
389 r[0][2] =
a[0][2] + b[0][2] * f;
390 r[1][0] =
a[1][0] + b[1][0] * f;
391 r[1][1] =
a[1][1] + b[1][1] * f;
392 r[1][2] =
a[1][2] + b[1][2] * f;
393 r[2][0] =
a[2][0] + b[2][0] * f;
394 r[2][1] =
a[2][1] + b[2][1] * f;
395 r[2][2] =
a[2][2] + b[2][2] * f;
399 typedef std::vector<fMatrix> fMatrixVector;
406 void resize(
int numverts)
408 this->numverts = numverts;
409 int tot = 3 * numverts;
413 dFdX.resize(tot, tot);
414 dFdV.resize(tot, tot);
416 tfm.resize(numverts,
I);
430 iM.reserve(numverts);
431 idFdX.reserve(numverts);
432 idFdV.reserve(numverts);
433 iS.reserve(numverts);
459 lMatrixCtor idFdX, idFdV;
516 # ifdef USE_EIGEN_CORE
519 # ifdef USE_EIGEN_CONSTRAINED_CG
520 typedef ConstraintConjGrad solver_t;
529 cg.setMaxIterations(100);
530 cg.setTolerance(0.01f);
532 # ifdef USE_EIGEN_CONSTRAINED_CG
533 cg.filter() =
data->S;
541 # ifdef IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
542 printf(
"==== A ====\n");
544 printf(
"==== z ====\n");
546 printf(
"==== B ====\n");
548 printf(
"==== S ====\n");
552 # ifdef USE_EIGEN_CORE
555 # ifdef USE_EIGEN_CONSTRAINED_CG
559 # ifdef IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
560 printf(
"==== dV ====\n");
562 printf(
"========\n");
571 case Eigen::NoConvergence:
574 case Eigen::InvalidInput:
577 case Eigen::NumericalIssue:
582 result->iterations = cg.iterations();
583 result->error = cg.error();
585 return cg.info() == Eigen::Success;
607 data->iM.add(index, index, m);
612 # ifdef CLOTH_ROOT_FRAME
669 int numverts =
data->numverts;
670 for (
int i = 0; i < numverts; i++) {
671 data->iS.add(i, i,
I);
678 data->iS.sub(index, index,
I);
684 Implicit_Data *
data,
int index,
const float c1[3],
const float c2[3],
const float dV[3])
686 float m[3][3], p[3], q[3], u[3], cmat[3][3];
697 data->iS.sub(index, index, m);
709 float m[3][3], p[3], u[3], cmat[3][3];
715 data->iS.sub(index, index, m);
725 data->dFdX.setZero();
726 data->dFdV.setZero();
731 const float acceleration[3],
732 const float omega[3],
733 const float domega_dt[3],
736 # ifdef CLOTH_ROOT_FRAME
737 float acc[3],
w[3], dwdt[3];
738 float f[3], dfdx[3][3], dfdv[3][3];
739 float euler[3], coriolis[3], centrifugal[3], rotvel[3];
740 float deuler[3][3], dcoriolis[3][3], dcentrifugal[3][3], drotvel[3][3];
773 data->idFdX.add(index, index, dfdx);
774 data->idFdV.add(index, index, dfdv);
796 int numverts =
data->numverts;
797 for (
int i = 0; i < numverts; i++) {
805 data->idFdV.add(i, i, tmp);
810 struct Implicit_Data *
data,
int i,
const float f[3],
float dfdx[3][3],
float dfdv[3][3])
812 float tf[3], tdfdx[3][3], tdfdv[3][3];
818 data->idFdX.add(i, i, tdfdx);
819 data->idFdV.add(i, i, tdfdv);
841 const float effector_scale = 0.02f;
847 factor = effector_scale *
area / 3.0f;
861 const float effector_scale = 0.01;
915 return (-11.541f *
powf(
x, 4) + 34.193f *
powf(
x, 3) - 39.083f *
powf(
x, 2) + 23.116f *
x -
923 return (-46.164f *
powf(
x, 3) + 102.579f *
powf(
x, 2) - 78.166f *
x + 23.116f);
929 float fbstar_fl = cb * (
length -
L);
931 if (tempfb_fl < fbstar_fl) {
943 float fbstar_fl = cb * (
length -
L);
945 if (tempfb_fl < fbstar_fl) {
964 *r_length =
len_v3(r_extent);
969 if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
970 (((
length -
L) * 100.0f /
L) > clmd->sim_parms->maxspringlen)) {
972 s->flags |= CSPRING_FLAG_DEACTIVATE;
987 Implicit_Data *
data,
int i,
int j,
const float f[3],
float dfdx[3][3],
float dfdv[3][3])
992 data->idFdX.add(i, i, dfdx);
993 data->idFdX.add(j, j, dfdx);
994 data->idFdX.sub(i, j, dfdx);
995 data->idFdX.sub(j, i, dfdx);
997 data->idFdV.add(i, i, dfdv);
998 data->idFdV.add(j, j, dfdv);
999 data->idFdV.sub(i, j, dfdv);
1000 data->idFdV.sub(j, i, dfdv);
1015 float extent[3],
length, dir[3], vel[3];
1020 if (
length > restlen || no_compress) {
1021 float stretch_force, f[3], dfdx[3][3], dfdv[3][3];
1023 stretch_force = stiffness * (
length - restlen);
1024 if (clamp_force > 0.0f && stretch_force > clamp_force) {
1025 stretch_force = clamp_force;
1076 float extent[3],
length, dir[3], vel[3];
1082 float f[3], dfdx[3][3], dfdv[3][3];
1128 Implicit_Data *
data,
int i,
int j,
float edge[3],
float dir[3],
float grad_dir[3][3])
1149 const float goal[3],
1157 float edge_ij[3], dir_ij[3];
1158 float edge_jk[3], dir_jk[3];
1159 float vel_ij[3], vel_jk[3], vel_ortho[3];
1160 float f_bend[3], f_damp[3];
1220 const float goal[3],
1226 const float delta = 0.00001f;
1227 float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
1239 for (
a = 0;
a < 3;
a++) {
1240 spring_angbend_forces(
1241 data, i, j, k, goal, stiffness, damping, q, dvec_pos[
a], dvec_null[
a], f);
1244 spring_angbend_forces(
1245 data, i, j, k, goal, stiffness, damping, q, dvec_neg[
a], dvec_null[
a], f);
1248 for (b = 0; b < 3; b++) {
1249 dfdx[
a][b] /= delta;
1259 const float goal[3],
1265 const float delta = 0.00001f;
1266 float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
1278 for (
a = 0;
a < 3;
a++) {
1279 spring_angbend_forces(
1280 data, i, j, k, goal, stiffness, damping, q, dvec_null[
a], dvec_pos[
a], f);
1283 spring_angbend_forces(
1284 data, i, j, k, goal, stiffness, damping, q, dvec_null[
a], dvec_neg[
a], f);
1287 for (b = 0; b < 3; b++) {
1288 dfdv[
a][b] /= delta;
1300 const float target[3],
1306 float dfj_dxi[3][3], dfj_dxj[3][3], dfk_dxi[3][3], dfk_dxj[3][3], dfk_dxk[3][3];
1307 float dfj_dvi[3][3], dfj_dvj[3][3], dfk_dvi[3][3], dfk_dvj[3][3], dfk_dvk[3][3];
1309 const float vecnull[3] = {0.0f, 0.0f, 0.0f};
1313 spring_angbend_forces(
data, i, j, k, goal, stiffness, damping, k, vecnull, vecnull, fk);
1316 spring_angbend_estimate_dfdx(
data, i, j, k, goal, stiffness, damping, i, dfk_dxi);
1317 spring_angbend_estimate_dfdx(
data, i, j, k, goal, stiffness, damping, j, dfk_dxj);
1318 spring_angbend_estimate_dfdx(
data, i, j, k, goal, stiffness, damping, k, dfk_dxk);
1324 spring_angbend_estimate_dfdv(
data, i, j, k, goal, stiffness, damping, i, dfk_dvi);
1325 spring_angbend_estimate_dfdv(
data, i, j, k, goal, stiffness, damping, j, dfk_dvj);
1326 spring_angbend_estimate_dfdv(
data, i, j, k, goal, stiffness, damping, k, dfk_dvk);
1337 data->idFdX.add(j, j, dfj_dxj);
1338 data->idFdX.add(k, k, dfk_dxk);
1340 data->idFdX.add(i, j, dfj_dxi);
1341 data->idFdX.add(j, i, dfj_dxi);
1342 data->idFdX.add(j, k, dfk_dxj);
1343 data->idFdX.add(k, j, dfk_dxj);
1344 data->idFdX.add(i, k, dfk_dxi);
1345 data->idFdX.add(k, i, dfk_dxi);
1347 data->idFdV.add(j, j, dfj_dvj);
1348 data->idFdV.add(k, k, dfk_dvk);
1350 data->idFdV.add(i, j, dfj_dvi);
1351 data->idFdV.add(j, i, dfj_dvi);
1352 data->idFdV.add(j, k, dfk_dvj);
1353 data->idFdV.add(k, j, dfk_dvj);
1354 data->idFdV.add(i, k, dfk_dvi);
1355 data->idFdV.add(k, i, dfk_dvi);
1362 float edge_ij[3], dir_ij[3], grad_dir_ij[3][3];
1363 float edge_jk[3], dir_jk[3], grad_dir_jk[3][3];
1364 float dist[3], vel_jk[3], vel_jk_ortho[3], projvel[3];
1367 float fi[3], fj[3], fk[3];
1368 float dfi_dxi[3][3], dfj_dxi[3][3], dfj_dxj[3][3], dfk_dxi[3][3], dfk_dxj[3][3], dfk_dxk[3][3];
1410 madd_m3_m3fl(dfk_dxi, grad_dir_ij, stiffness * restlen);
1412 madd_m3_m3fl(dfk_dxj, grad_dir_ij, -stiffness * restlen);
1449 const float goal_x[3],
1450 const float goal_v[3],
1457 float root_goal_x[3], root_goal_v[3], extent[3],
length, dir[3], vel[3];
1458 float f[3], dfdx[3][3], dfdv[3][3];
1479 data->idFdX.add(i, i, dfdx);
1480 data->idFdV.add(i, i, dfdv);
typedef float(TangentPoint)[2]
void sub_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void negate_m3(float R[3][3])
void copy_m3_m3(float m1[3][3], const float m2[3][3])
void unit_m3(float m[3][3])
void mul_m3_fl(float R[3][3], float f)
void add_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void zero_m3(float m[3][3])
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
void transpose_m3(float R[3][3])
void mul_transposed_m3_v3(const float M[3][3], float r[3])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void madd_m3_m3m3fl(float R[3][3], const float A[3][3], const float B[3][3], const float f)
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
Object is a sort of wrapper for general info.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
int SIM_mass_spring_solver_numvert(struct Implicit_Data *id)
@ SIM_SOLVER_INVALID_INPUT
@ SIM_SOLVER_NUMERICAL_ISSUE
@ SIM_SOLVER_NO_CONVERGENCE
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
btGeneric6DofConstraint & operator=(btGeneric6DofConstraint &other)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
void reset()
clear internal cached data and reset random seed
A conjugate gradient solver for sparse self-adjoint problems with additional constraints.
BLI_INLINE void madd_m3_m3fl(float r[3][3], const float m[3][3], float f)
Eigen::ConjugateGradient< lMatrix, Eigen::Lower, Eigen::DiagonalPreconditioner< Scalar > > ConjugateGradient
std::vector< Triplet > TripletList
BLI_INLINE void print_lmatrix(const lMatrix &m)
Eigen::SparseMatrix< Scalar > lMatrix
BLI_INLINE void print_lvector(const lVector3f &v)
Eigen::Triplet< Scalar > Triplet
void SIM_mass_spring_add_constraint_ndof1(struct Implicit_Data *data, int index, const float c1[3], const float c2[3], const float dV[3])
void SIM_mass_spring_get_motion_state(struct Implicit_Data *data, int index, float x[3], float v[3])
void SIM_mass_spring_add_constraint_ndof0(struct Implicit_Data *data, int index, const float dV[3])
void SIM_mass_spring_force_reference_frame(struct Implicit_Data *data, int index, const float acceleration[3], const float omega[3], const float domega_dt[3], float mass)
void SIM_mass_spring_force_edge_wind(struct Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float(*winvec)[3])
void SIM_mass_spring_set_new_velocity(struct Implicit_Data *data, int index, const float v[3])
bool SIM_mass_spring_force_spring_goal(struct Implicit_Data *data, int i, const float goal_x[3], const float goal_v[3], float stiffness, float damping)
void SIM_mass_spring_set_vertex_mass(struct Implicit_Data *data, int index, float mass)
void SIM_mass_spring_set_motion_state(struct Implicit_Data *data, int index, const float x[3], const float v[3])
bool SIM_mass_spring_force_spring_linear(struct Implicit_Data *data, int i, int j, float restlen, float stiffness_tension, float damping_tension, float stiffness_compression, float damping_compression, bool resist_compress, bool new_compress, float clamp_force)
bool SIM_mass_spring_force_spring_bending(struct Implicit_Data *data, int i, int j, float restlen, float kb, float cb)
void SIM_mass_spring_apply_result(struct Implicit_Data *data)
void SIM_mass_spring_set_position(struct Implicit_Data *data, int index, const float x[3])
void SIM_mass_spring_add_constraint_ndof2(struct Implicit_Data *data, int index, const float c1[3], const float dV[3])
BLI_INLINE void implicit_print_matrix_elem(float v)
void SIM_mass_spring_force_face_wind(struct Implicit_Data *data, int v1, int v2, int v3, const float(*winvec)[3])
void SIM_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3])
bool SIM_mass_spring_solve_velocities(struct Implicit_Data *data, float dt, struct ImplicitSolverResult *result)
void SIM_mass_spring_force_drag(struct Implicit_Data *data, float drag)
void SIM_mass_spring_clear_constraints(struct Implicit_Data *data)
bool SIM_mass_spring_solve_positions(struct Implicit_Data *data, float dt)
void SIM_mass_spring_get_new_velocity(struct Implicit_Data *data, int index, float v[3])
void SIM_mass_spring_set_velocity(struct Implicit_Data *data, int index, const float v[3])
void SIM_mass_spring_force_extern(struct Implicit_Data *data, int i, const float f[3], float dfdx[3][3], float dfdv[3][3])
void SIM_mass_spring_force_gravity(struct Implicit_Data *data, int index, float mass, const float g[3])
void SIM_mass_spring_set_rest_transform(struct Implicit_Data *data, int index, float tfm[3][3])
void SIM_mass_spring_clear_forces(struct Implicit_Data *data)
BLI_INLINE void apply_spring(Implicit_Data *data, int i, int j, const float f[3], const float dfdx[3][3], const float dfdv[3][3])
BLI_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
DO_INLINE void mul_fvectorT_fvector(float to[3][3], const float vectorA[3], const float vectorB[3])
BLI_INLINE void cross_m3_v3m3(float r[3][3], const float v[3], const float m[3][3])
BLI_INLINE float fb(float length, float L)
DO_INLINE void mul_fmatrix_S(float matrix[3][3], float scalar)
Implicit_Data * SIM_mass_spring_solver_create(int numverts, int numsprings)
BLI_INLINE float fbderiv(float length, float L)
BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[3], float r_dir[3], float *r_length, float r_vel[3])
BLI_INLINE void root_to_world_m3(Implicit_Data *data, int index, float r[3][3], const float m[3][3])
void SIM_mass_spring_solver_free(Implicit_Data *id)
BLI_INLINE void cross_v3_identity(float r[3][3], const float v[3])
BLI_INLINE void outerproduct(float r[3][3], const float a[3], const float b[3])
DO_INLINE void sub_fmatrix_fmatrix(float to[3][3], const float matrixA[3][3], const float matrixB[3][3])
struct Implicit_Data Implicit_Data
BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, float L, float k)
BLI_INLINE void spring_grad_dir(Implicit_Data *data, int i, int j, float edge[3], float dir[3], float grad_dir[3][3])
static float calc_nor_area_tri(float nor[3], const float v1[3], const float v2[3], const float v3[3])
BLI_INLINE void root_to_world_v3(Implicit_Data *data, int index, float r[3], const float v[3])
BLI_INLINE void world_to_root_m3(Implicit_Data *data, int index, float r[3][3], const float m[3][3])
BLI_INLINE float fbstar(float length, float L, float kb, float cb)
BLI_INLINE void world_to_root_v3(Implicit_Data *data, int index, float r[3], const float v[3])
BLI_INLINE void dfdv_damp(float to[3][3], const float dir[3], float damping)
static void add(GHash *messages, MemArena *memarena, const Message *msg)
static void area(int d1, int d2, int e1, int e2, float weights[2])