11#ifdef IMPLICIT_SOLVER_BLENDER
27# pragma GCC diagnostic ignored "-Wtype-limits"
30# define CLOTH_PARALLEL_LIMIT 1024
38static float I[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
39static float ZERO[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
44# defineDO_INLINE inline
46# defineDO_INLINE static
72 to[0] = from[0] * scalar;
73 to[1] = from[1] * scalar;
74 to[2] = from[2] * scalar;
97static void print_fvector(
float m3[3])
99 printf(
"%f\n%f\n%f\n\n", m3[0], m3[1], m3[2]);
106DO_INLINE void print_lfvector(
float (*fLongVector)[3],
uint verts)
109 for (i = 0; i < verts; i++) {
110 print_fvector(fLongVector[i]);
125 if (fLongVector !=
nullptr) {
126 MEM_delete(fLongVector);
133 memcpy(to, from, verts *
sizeof(
lfVector));
139 for (i = 0; i < verts; i++) {
146 memset(to, 0.0f, verts *
sizeof(
lfVector));
153 for (i = 0; i < verts; i++) {
162 for (i = 0; i < verts; i++) {
163 VECSUBMUL(to[i], fLongVector[i], scalar);
179 for (
const int i : range) {
180 temp +=
dot_v3v3(fLongVectorA[i], fLongVectorB[i]);
187 for (
uint i = 0; i < verts; i++) {
188 temp +=
dot_v3v3(fLongVectorA[i], fLongVectorB[i]);
195 float (*fLongVectorA)[3],
196 float (*fLongVectorB)[3],
201 for (i = 0; i < verts; i++) {
202 add_v3_v3v3(to[i], fLongVectorA[i], fLongVectorB[i]);
207 float (*to)[3],
float (*fLongVectorA)[3],
float (*fLongVectorB)[3],
float bS,
uint verts)
211 for (i = 0; i < verts; i++) {
212 VECADDS(to[i], fLongVectorA[i], fLongVectorB[i], bS);
217 float (*fLongVectorA)[3],
219 float (*fLongVectorB)[3],
225 for (i = 0; i < verts; i++) {
226 VECADDSS(to[i], fLongVectorA[i], aS, fLongVectorB[i], bS);
231 float (*to)[3],
float (*fLongVectorA)[3],
float (*fLongVectorB)[3],
float bS,
uint verts)
234 for (i = 0; i < verts; i++) {
235 VECSUBS(to[i], fLongVectorA[i], fLongVectorB[i], bS);
240 float (*fLongVectorA)[3],
241 float (*fLongVectorB)[3],
246 for (i = 0; i < verts; i++) {
247 sub_v3_v3v3(to[i], fLongVectorA[i], fLongVectorB[i]);
255static void print_fmatrix(
float m3[3][3])
257 printf(
"%f\t%f\t%f\n", m3[0][0], m3[0][1], m3[0][2]);
258 printf(
"%f\t%f\t%f\n", m3[1][0], m3[1][1], m3[1][2]);
259 printf(
"%f\t%f\t%f\n\n", m3[2][0], m3[2][1], m3[2][2]);
266 for (i = 0; i < m[0].vcount + m[0].scount; i++) {
268 print_fmatrix(m[i].m);
278 for (i = 0; i < numverts; i++) {
293 int tot = m[0].vcount + m[0].scount;
294 int size = m[0].vcount * 3;
298 for (q = 0; q < tot; q++) {
302 for (j = 0; j < 3; j++) {
303 for (i = 0; i < 3; i++) {
305 if (t[k + i + (
l + j) * size] != 0.0f) {
306 printf(
"warning: overwriting value at %d, %d\n", m[q].r, m[q].c);
310 t[k + i + (k + j) * size] += m[q].m[i][j];
313 t[k + i + (
l + j) * size] += m[q].m[i][j];
314 t[
l + j + (k + i) * size] += m[q].m[j][i];
320 for (j = 0; j <
size; j++) {
321 if (j > 0 && j % 3 == 0) {
325 for (i = 0; i <
size; i++) {
326 if (i > 0 && i % 3 == 0) {
360DO_INLINE float det_fmatrix(
float m[3][3])
362 return m[0][0] * m[1][1] * m[2][2] + m[1][0] * m[2][1] * m[0][2] + m[0][1] * m[1][2] * m[2][0] -
363 m[0][0] * m[1][2] * m[2][1] - m[0][1] * m[1][0] * m[2][2] - m[2][0] * m[1][1] * m[0][2];
366DO_INLINE void inverse_fmatrix(
float to[3][3],
float from[3][3])
371 if ((d = det_fmatrix(from)) == 0) {
374 for (i = 0; i < 3; i++) {
375 for (j = 0; j < 3; j++) {
376 int i1 = (i + 1) % 3;
377 int i2 = (i + 2) % 3;
378 int j1 = (j + 1) % 3;
379 int j2 = (j + 2) % 3;
381 to[j][i] = (from[i1][j1] * from[i2][j2] - from[i1][j2] * from[i2][j1]) / d;
410 to[0] = matrix[0][0] * from[0] + matrix[1][0] * from[1] + matrix[2][0] * from[2];
411 to[1] = matrix[0][1] * from[0] + matrix[1][1] * from[1] + matrix[2][1] * from[2];
412 to[2] = matrix[0][2] * from[0] + matrix[1][2] * from[1] + matrix[2][2] * from[2];
425 const float matrixA[3][3],
426 const float matrixB[3][3])
434 float to[3][3],
const float matrixA[3][3],
float aS,
const float matrixB[3][3],
float bS)
436 VECSUBADDSS(to[0], matrixA[0], aS, matrixB[0], bS);
437 VECSUBADDSS(to[1], matrixA[1], aS, matrixB[1], bS);
438 VECSUBADDSS(to[2], matrixA[2], aS, matrixB[2], bS);
442 const float matrixA[3][3],
443 const float matrixB[3][3])
463 to[0] += matrix[0][0] * from[0] + matrix[1][0] * from[1] + matrix[2][0] * from[2];
464 to[1] += matrix[0][1] * from[0] + matrix[1][1] * from[1] + matrix[2][1] * from[2];
465 to[2] += matrix[0][2] * from[0] + matrix[1][2] * from[1] + matrix[2][2] * from[2];
497 r[0][0] += m[0][0] * f;
498 r[0][1] += m[0][1] * f;
499 r[0][2] += m[0][2] * f;
500 r[1][0] += m[1][0] * f;
501 r[1][1] += m[1][1] * f;
502 r[1][2] += m[1][2] * f;
503 r[2][0] += m[2][0] * f;
504 r[2][1] += m[2][1] * f;
505 r[2][2] += m[2][2] * f;
519 for (i = 0; i < m3[0].vcount + m3[0].scount; i++) {
520 print_fmatrix(m3[i].m);
536 "cloth_implicit_alloc_matrix");
543 for (i = 0; i < verts; i++) {
552 if (matrix !=
nullptr) {
561 memcpy(to, from,
sizeof(
fmatrix3x3) * (from[0].vcount + from[0].scount));
570 for (i = 0; i < matrix[0].
vcount + matrix[0].
scount; i++) {
580 float tmatrix[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
582 for (i = 0; i < matrix[0].
vcount; i++) {
585 for (j = matrix[0].vcount; j < matrix[0].
vcount + matrix[0].
scount; j++) {
628 for (i = 0; i < matrix[0].
vcount + matrix[0].
scount; i++) {
750 for (i = 0; i < S[0].vcount; i++) {
761 uint conjgrad_loopcount = 0, conjgrad_looplimit = 100;
762 float conjgrad_epsilon = 0.0001f ;
764 float s, starget, a, s_prev;
765 uint numverts = lA[0].vcount;
786 starget = s *
sqrtf(conjgrad_epsilon);
788 while (s > starget && conjgrad_loopcount < conjgrad_looplimit) {
810 conjgrad_loopcount++;
821 return conjgrad_loopcount < conjgrad_looplimit;
833 uint conjgrad_loopcount = 0, conjgrad_looplimit = 100;
834 float conjgrad_epsilon = 0.01f;
843 float bnorm2, delta_new, delta_old, delta_target, alpha;
851 delta_target = conjgrad_epsilon * conjgrad_epsilon * bnorm2;
865# ifdef IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
876 while (delta_new > delta_target && conjgrad_loopcount < conjgrad_looplimit) {
888 delta_old = delta_new;
894 conjgrad_loopcount++;
897# ifdef IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
913 result->iterations = conjgrad_loopcount;
914 result->error = bnorm2 > 0.0f ?
sqrtf(delta_new / bnorm2) : 0.0f;
917 return conjgrad_loopcount < conjgrad_looplimit;
922DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *
P, fmatrix3x3 *Pinv)
927 [&](
const IndexRange &range) {
931 inverse_fmatrix(Pinv[i].m,
P[i].m);
938static int cg_filtered_pre(
lfVector *dv,
946 uint numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit = 100;
947 float delta0 = 0, deltaNew = 0, deltaOld = 0, alpha = 0;
948 float conjgrad_epsilon = 0.0001;
954 BuildPPinv(lA,
P, Pinv);
963 mul_prevfmatrix_lfvector(p, Pinv, r);
968 delta0 = deltaNew *
sqrt(conjgrad_epsilon);
974 while ((deltaNew > delta0) && (iterations < conjgrad_looplimit)) {
986 mul_prevfmatrix_lfvector(h, Pinv, r);
1000 printf(
"cg_filtered_pre time: %f\n",
float(end - start));
1008 printf(
"iterations: %d\n", iterations);
1010 return iterations < conjgrad_looplimit;
1015static int cg_filtered_pre(
lfVector *dv,
1024 uint numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit = 100;
1025 float delta0 = 0, deltaNew = 0, deltaOld = 0, alpha = 0, tol = 0;
1033 BuildPPinv(lA,
P, Pinv);
1036 sub_bfmatrix_Smatrix(bigI, bigI, S);
1053 mul_prevfmatrix_lfvector(p, Pinv, r);
1057 mul_prevfmatrix_lfvector(btemp, Pinv, bhat);
1071 mul_prevfmatrix_lfvector(p, Pinv, r);
1076 delta0 = deltaNew *
sqrt(conjgrad_epsilon);
1085 while ((deltaNew > delta0 * tol * tol) && (iterations < conjgrad_looplimit)) {
1097 mul_prevfmatrix_lfvector(h, Pinv, r);
1100 deltaOld = deltaNew;
1111 printf(
"cg_filtered_pre time: %f\n",
float(end - start));
1123 return iterations < conjgrad_looplimit;
1129 uint numverts =
data->dFdV[0].vcount;
1153 printf(
"cg_filtered calc time: %f\n",
float(end - start));
1166 int numverts =
data->M[0].vcount;
1176 int numverts =
data->M[0].vcount;
1189# ifdef CLOTH_ROOT_FRAME
1260 int s =
data->M[0].vcount +
data->num_blocks;
1278 int i, numverts =
data->S[0].vcount;
1279 for (i = 0; i < numverts; i++) {
1295 float m[3][3], p[3], q[3], u[3], cmat[3][3];
1318 float m[3][3], p[3], u[3], cmat[3][3];
1333 int numverts =
data->M[0].vcount;
1338 data->num_blocks = 0;
1343 const float acceleration[3],
1344 const float omega[3],
1345 const float domega_dt[3],
1348# ifdef CLOTH_ROOT_FRAME
1349 float acc[3],
w[3], dwdt[3];
1350 float f[3], dfdx[3][3], dfdv[3][3];
1351 float euler[3], coriolis[3], centrifugal[3], rotvel[3];
1352 float deuler[3][3], dcoriolis[3][3], dcentrifugal[3][3], drotvel[3][3];
1408 int i, numverts =
data->M[0].vcount;
1409 for (i = 0; i < numverts; i++) {
1422 Implicit_Data *
data,
int i,
const float f[3],
float dfdx[3][3],
float dfdv[3][3])
1424 float tf[3], tdfdx[3][3], tdfdv[3][3];
1454 const float effector_scale = 0.02f;
1455 const int vs[3] = {v1,
v2, v3};
1456 float win[3], nor[3], area;
1457 float factor, base_force;
1463 factor = effector_scale * area / 3.0f;
1466 for (
int i = 0; i < 3; i++) {
1483 base_force = force[0] + force[1] + force[2];
1494 const float effector_scale = 0.02f;
1495 const int vs[3] = {v1,
v2, v3};
1497 float factor, base_force[3];
1503 factor = effector_scale * area / 3.0f;
1508 for (
int i = 0; i < 3; i++) {
1516 for (
int i = 0; i < 3; i++) {
1539 float common_pressure,
1540 const float *vertex_pressure,
1541 const float weights[3])
1544 float factor, base_force;
1550 factor = area / 3.0f;
1551 base_force = common_pressure * factor;
1562 if (vertex_pressure) {
1563 copy_v3_fl3(force, vertex_pressure[v1], vertex_pressure[
v2], vertex_pressure[v3]);
1566 base_force += force[0] + force[1] + force[2];
1581 const float wind[3],
1586 const float density = 0.01f;
1587 float cos_alpha, sin_alpha, cross_section;
1588 float windlen =
len_v3(wind);
1590 if (windlen == 0.0f) {
1596 cos_alpha =
dot_v3v3(wind, dir) / windlen;
1597 sin_alpha =
sqrtf(1.0f - cos_alpha * cos_alpha);
1598 cross_section = radius * (
float(
M_PI) * radius * sin_alpha +
length * cos_alpha);
1604 Implicit_Data *
data,
int v1,
int v2,
float radius1,
float radius2,
const float (*winvec)[3])
1606 float win[3], dir[3],
length;
1607 float f[3], dfdx[3][3], dfdv[3][3];
1624 const float (*winvec)[3])
1626 const float density = 0.01f;
1677 float xxxx = xxx *
x;
1678 return (-11.541f * xxxx + 34.193f * xxx - 39.083f * xx + 23.116f *
x - 9.713f);
1686 return (-46.164f * xxx + 102.579f * xx - 78.166f *
x + 23.116f);
1692 float fbstar_fl = cb * (
length -
L);
1694 if (tempfb_fl < fbstar_fl) {
1705 float fbstar_fl = cb * (
length -
L);
1707 if (tempfb_fl < fbstar_fl) {
1725 *r_length =
len_v3(r_extent);
1730 if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
1731 (((
length -
L) * 100.0f /
L) > clmd->sim_parms->maxspringlen))
1734 s->flags |= CSPRING_FLAG_DEACTIVATE;
1752 const float dfdx[3][3],
1753 const float dfdv[3][3])
1773 float stiffness_tension,
1774 float damping_tension,
1775 float stiffness_compression,
1776 float damping_compression,
1777 bool resist_compress,
1781 float extent[3],
length, dir[3], vel[3];
1782 float f[3], dfdx[3][3], dfdv[3][3];
1791 if ((
length >= restlen &&
length > 0) || resist_compress) {
1792 float stretch_force;
1794 damping = damping_tension;
1796 stretch_force = stiffness_tension * (
length - restlen);
1797 if (clamp_force > 0.0f && stretch_force > clamp_force) {
1798 stretch_force = clamp_force;
1804 else if (new_compress) {
1807 float kb = stiffness_compression;
1810 damping = damping_compression;
1834 float extent[3],
length, dir[3], vel[3];
1840 float f[3], dfdx[3][3], dfdv[3][3];
1864 for (
int i = 0; i <
len; i++) {
1880 r_avg[0] = (
data[i][0] +
data[j][0]) * 0.5f;
1881 r_avg[1] = (
data[i][1] +
data[j][1]) * 0.5f;
1882 r_avg[2] = (
data[i][2] +
data[j][2]) * 0.5f;
1917 float dir_e[3], vel_e[3];
1924 *r_angle =
bend_angle(r_dir_a, r_dir_b, dir_e);
1946 float angle, dir_a[3], dir_b[3], vel_a[3], vel_b[3];
1947 float f_a[3], f_b[3], f_e[3];
1951 spring_angle(
data, i, j, i_a, i_b, len_a, len_b, dir_a, dir_b, &
angle, vel_a, vel_b);
1954 force = stiffness * (
angle - restang);
1962 for (
x = 0;
x < len_a;
x++) {
1966 for (
x = 0;
x < len_b;
x++) {
1988 Implicit_Data *
data,
int i,
int j,
float edge[3],
float dir[3],
float grad_dir[3][3])
2009 const float goal[3],
2017 float edge_ij[3], dir_ij[3];
2018 float edge_jk[3], dir_jk[3];
2019 float vel_ij[3], vel_jk[3], vel_ortho[3];
2020 float f_bend[3], f_damp[3];
2080 const float goal[3],
2086 const float delta = 0.00001f;
2087 float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
2099 for (a = 0; a < 3; a++) {
2101 data, i, j, k, goal, stiffness, damping, q, dvec_pos[a], dvec_null[a], f);
2105 data, i, j, k, goal, stiffness, damping, q, dvec_neg[a], dvec_null[a], f);
2108 for (
b = 0;
b < 3;
b++) {
2109 dfdx[a][
b] /= delta;
2119 const float goal[3],
2125 const float delta = 0.00001f;
2126 float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
2138 for (a = 0; a < 3; a++) {
2140 data, i, j, k, goal, stiffness, damping, q, dvec_null[a], dvec_pos[a], f);
2144 data, i, j, k, goal, stiffness, damping, q, dvec_null[a], dvec_neg[a], f);
2147 for (
b = 0;
b < 3;
b++) {
2148 dfdv[a][
b] /= delta;
2157 const float target[3],
2166 float dfj_dxi[3][3], dfj_dxj[3][3], dfk_dxi[3][3], dfk_dxj[3][3], dfk_dxk[3][3];
2167 float dfj_dvi[3][3], dfj_dvj[3][3], dfk_dvi[3][3], dfk_dvj[3][3], dfk_dvk[3][3];
2169 const float vecnull[3] = {0.0f, 0.0f, 0.0f};
2177 spring_hairbend_forces(
data, i, j, k, goal, stiffness, damping, k, vecnull, vecnull, fk);
2220 float edge_ij[3], dir_ij[3], grad_dir_ij[3][3];
2221 float edge_jk[3], dir_jk[3], grad_dir_jk[3][3];
2222 float dist[3], vel_jk[3], vel_jk_ortho[3], projvel[3];
2225 float fi[3], fj[3], fk[3];
2226 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];
2268 madd_m3_m3fl(dfk_dxi, grad_dir_ij, stiffness * restlen);
2270 madd_m3_m3fl(dfk_dxj, grad_dir_ij, -stiffness * restlen);
2307 const float goal_x[3],
2308 const float goal_v[3],
2312 float root_goal_x[3], root_goal_v[3], extent[3],
length, dir[3], vel[3];
2313 float f[3], dfdx[3][3], dfdv[3][3];
#define VECADDS(v1, v2, v3, bS)
#define VECSUBS(v1, v2, v3, bS)
#define VECADDSS(v1, v2, aS, v3, bS)
#define VECSUBADDSS(v1, v2, aS, v3, bS)
#define VECSUBMUL(v1, v2, aS)
Platform independent time functions.
Read Blender memory allocation and freeing.
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
constexpr IndexRange()=default
float length(VecOp< float, D >) RET
#define CLOTH_PARALLEL_LIMIT
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
int size(const AssetLibraryReference *library_reference)
void parallel_invoke(Functions &&...functions)
Value parallel_deterministic_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
DO_INLINE void mul_fmatrix_fvector(float *to, const float matrix[3][3], const float from[3])
BLI_INLINE float fbderiv(float length, float L)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
BLI_INLINE void print_lvector(const lVector3f &v)
MINLINE void negate_v3_v3(float r[3], const float a[3])
void mul_m3_v3(const float M[3][3], float r[3])
void SIM_mass_spring_get_velocity(struct Implicit_Data *data, int index, float v[3])
void SIM_mass_spring_clear_forces(struct Implicit_Data *data)
@ SIM_SOLVER_NO_CONVERGENCE
DO_INLINE fmatrix3x3 * create_bfmatrix(uint verts, uint springs)
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)
BLI_INLINE void root_to_world_v3(Implicit_Data *data, int index, float r[3], const float v[3])
BLI_INLINE float bend_angle(const float dir_a[3], const float dir_b[3], const float dir_e[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])
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])
MINLINE void copy_v3_v3(float r[3], const float a[3])
BLI_INLINE float fbstar(float length, float L, float kb, float cb)
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_force_pressure(struct Implicit_Data *data, int v1, int v2, int v3, float common_pressure, const float *vertex_pressure, const float weights[3])
void negate_m3(float R[3][3])
DO_INLINE void initdiag_fmatrixS(float to[3][3], float aS)
DO_INLINE void del_bfmatrix(fmatrix3x3 *matrix)
void SIM_mass_spring_add_constraint_ndof0(struct Implicit_Data *data, int index, const float dV[3])
ATTR_WARN_UNUSED_RESULT const BMLoop * l
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
DO_INLINE void mul_fmatrix_S(float matrix[3][3], float scalar)
void copy_m3_m3(float m1[3][3], const float m2[3][3])
BLI_INLINE void implicit_print_matrix_elem(float v)
BLI_INLINE float fb(float length, float L)
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])
Implicit_Data * SIM_mass_spring_solver_create(int numverts, int numsprings)
BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, float L, float k)
float SIM_tri_area(struct Implicit_Data *data, int v1, int v2, int v3)
BLI_INLINE void cross_m3_v3m3(float r[3][3], const float v[3], const float m[3][3])
BLI_INLINE void poly_norm(lfVector *data, int i, int j, int *inds, int len, float r_dir[3])
void SIM_mass_spring_force_vertex_wind(struct Implicit_Data *data, int v, float radius, const float(*winvec)[3])
DO_INLINE void mul_fvector_S(float to[3], const float from[3], float scalar)
DO_INLINE void sub_fmatrix_fmatrix(float to[3][3], const float matrixA[3][3], const float matrixB[3][3])
DO_INLINE void add_lfvector_lfvectorS(float(*to)[3], float(*fLongVectorA)[3], float(*fLongVectorB)[3], float bS, uint verts)
BLI_INLINE void edge_norm(lfVector *data, int i, int j, float r_dir[3])
void SIM_mass_spring_set_rest_transform(struct Implicit_Data *data, int index, float tfm[3][3])
ATTR_WARN_UNUSED_RESULT const BMVert * v
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
BLI_INLINE void world_to_root_m3(Implicit_Data *data, int index, float r[3][3], const float m[3][3])
void SIM_mass_spring_force_gravity(struct Implicit_Data *data, int index, float mass, const float g[3])
void SIM_mass_spring_clear_constraints(struct Implicit_Data *data)
DO_INLINE void mul_fvectorT_fvectorS(float to[3][3], float vectorA[3], float vectorB[3], float aS)
bool SIM_mass_spring_force_spring_bending_hair(struct Implicit_Data *data, int i, int j, int k, const float target[3], float stiffness, float damping)
void SIM_mass_spring_set_new_velocity(struct Implicit_Data *data, int index, const float v[3])
MINLINE void mul_v3_fl(float r[3], float f)
BLI_INLINE void dfdv_damp(float to[3][3], const float dir[3], float damping)
BLI_INLINE void spring_hairbend_estimate_dfdx(Implicit_Data *data, int i, int j, int k, const float goal[3], float stiffness, float damping, int q, float dfdx[3][3])
MINLINE void sub_v3_v3(float r[3], const float a[3])
void SIM_mass_spring_set_vertex_mass(struct Implicit_Data *data, int index, float mass)
DO_INLINE void muladd_fmatrixT_fvector(float to[3], const float matrix[3][3], const float from[3])
DO_INLINE float dot_lfvector(float(*fLongVectorA)[3], float(*fLongVectorB)[3], uint verts)
DO_INLINE void cp_fmatrix(float to[3][3], const float from[3][3])
void mul_transposed_m3_v3(const float M[3][3], float r[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
DO_INLINE void add_fmatrix_fmatrix(float to[3][3], const float matrixA[3][3], const float matrixB[3][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 * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
static void edge_wind_vertex(const float dir[3], float length, float radius, const float wind[3], float f[3], float[3][3], float[3][3])
void transpose_m3(float R[3][3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, ImplicitSolverResult *result)
void SIM_mass_spring_set_new_position(struct Implicit_Data *data, int index, const float x[3])
BMesh const char void * data
DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
BLI_INLINE void spring_angle(Implicit_Data *data, int i, int j, int *i_a, int *i_b, int len_a, int len_b, float r_dir_a[3], float r_dir_b[3], float *r_angle, float r_vel_a[3], float r_vel_b[3])
DO_INLINE void submul_lfvectorS(float(*to)[3], float(*fLongVector)[3], float scalar, uint verts)
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])
bool SIM_mass_spring_solve_velocities(struct Implicit_Data *data, float dt, struct ImplicitSolverResult *result)
void SIM_mass_spring_get_new_velocity(struct Implicit_Data *data, int index, float v[3])
DO_INLINE lfVector * create_lfvector(uint verts)
DO_INLINE void subadd_fmatrixS_fmatrixS(float to[3][3], const float matrixA[3][3], float aS, const float matrixB[3][3], float bS)
void SIM_mass_spring_apply_result(struct Implicit_Data *data)
void SIM_mass_spring_force_drag(struct Implicit_Data *data, float drag)
static float calc_nor_area_tri(float nor[3], const float v1[3], const float v2[3], const float v3[3])
BLI_INLINE void spring_grad_dir(Implicit_Data *data, int i, int j, float edge[3], float dir[3], float grad_dir[3][3])
DO_INLINE void cp_bfmatrix(fmatrix3x3 *to, fmatrix3x3 *from)
BLI_INLINE void world_to_root_v3(Implicit_Data *data, int index, float r[3], const float v[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
BLI_INLINE void init_fmatrix(fmatrix3x3 *matrix, int r, int c)
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)
DO_INLINE void subadd_bfmatrixS_bfmatrixS(fmatrix3x3 *to, fmatrix3x3 *from, float aS, fmatrix3x3 *matrix, float bS)
MINLINE void zero_v3(float r[3])
bool SIM_mass_spring_force_spring_angular(struct Implicit_Data *data, int i, int j, int *i_a, int *i_b, int len_a, int len_b, float restang, float stiffness, float damping)
BLI_INLINE void cross_v3_identity(float r[3][3], const float v[3])
float SIM_tri_tetra_volume_signed_6x(struct Implicit_Data *data, int v1, int v2, int v3)
void SIM_mass_spring_get_motion_state(struct Implicit_Data *data, int index, float x[3], float v[3])
bool SIM_mass_spring_force_spring_bending(struct Implicit_Data *data, int i, int j, float restlen, float kb, float cb)
BLI_INLINE void edge_avg(lfVector *data, int i, int j, float r_avg[3])
DO_INLINE void cp_lfvector(float(*to)[3], float(*from)[3], uint verts)
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float normalize_v3(float n[3])
MINLINE void add_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])
void mul_m3_fl(float R[3][3], float f)
DO_INLINE void mul_lfvectorS(float(*to)[3], float(*fLongVector)[3], float scalar, uint verts)
DO_INLINE void sub_lfvector_lfvectorS(float(*to)[3], float(*fLongVectorA)[3], float(*fLongVectorB)[3], float bS, uint verts)
BLI_INLINE void outerproduct(float r[3][3], const float a[3], const float b[3])
MINLINE void copy_v3_fl3(float v[3], float x, float y, float z)
DO_INLINE void zero_lfvector(float(*to)[3], uint verts)
void SIM_mass_spring_set_velocity(struct Implicit_Data *data, int index, const float v[3])
void unit_m3(float m[3][3])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
BLI_INLINE void spring_hairbend_estimate_dfdv(Implicit_Data *data, int i, int j, int k, const float goal[3], float stiffness, float damping, int q, float dfdv[3][3])
DO_INLINE void mul_bfmatrix_lfvector(float(*to)[3], fmatrix3x3 *from, lfVector *fLongVector)
BLI_INLINE void poly_avg(lfVector *data, const int *inds, int len, float r_avg[3])
void SIM_mass_spring_solver_free(Implicit_Data *id)
static int SIM_mass_spring_add_block(Implicit_Data *data, int v1, int v2)
BLI_INLINE void root_to_world_m3(Implicit_Data *data, int index, float r[3][3], const float m[3][3])
double BLI_time_now_seconds()
DO_INLINE void init_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
void SIM_mass_spring_set_position(struct Implicit_Data *data, int index, const float x[3])
void zero_m3(float m[3][3])
DO_INLINE void init_lfvector(float(*fLongVector)[3], const float vector[3], uint verts)
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)
DO_INLINE void add_lfvectorS_lfvectorS(float(*to)[3], float(*fLongVectorA)[3], float aS, float(*fLongVectorB)[3], float bS, uint verts)
DO_INLINE void mul_fvector_fmatrix(float *to, const float *from, const float matrix[3][3])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void SIM_mass_spring_force_face_wind(struct Implicit_Data *data, int v1, int v2, int v3, const float(*winvec)[3])
BLI_INLINE void spring_hairbend_forces(Implicit_Data *data, int i, int j, int k, const float goal[3], float stiffness, float damping, int q, const float dx[3], const float dv[3], float r_f[3])
float volume_tri_tetrahedron_signed_v3_6x(const float v1[3], const float v2[3], const float v3[3])
BLI_INLINE void madd_m3_m3fl(float r[3][3], const float m[3][3], float f)
DO_INLINE void muladd_fmatrix_fvector(float to[3], const float matrix[3][3], const float from[3])
DO_INLINE void del_lfvector(float(*fLongVector)[3])
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
DO_INLINE void sub_lfvector_lfvector(float(*to)[3], float(*fLongVectorA)[3], float(*fLongVectorB)[3], uint verts)
void sub_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void SIM_mass_spring_add_constraint_ndof2(struct Implicit_Data *data, int index, const float c1[3], const float dV[3])
void SIM_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3])
DO_INLINE void add_lfvector_lfvector(float(*to)[3], float(*fLongVectorA)[3], float(*fLongVectorB)[3], uint verts)
void SIM_mass_spring_force_face_extern(struct Implicit_Data *data, int v1, int v2, int v3, const float(*forcevec)[3])
void SIM_mass_spring_get_new_position(struct Implicit_Data *data, int index, float x[3])
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_solve_positions(struct Implicit_Data *data, float dt)
void add_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
CCL_NAMESPACE_BEGIN struct Window V