37static float I[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
41 return value > 0.0f ? int(value) : int(value) - 1;
46 return value -
floorf(value);
51 return res[0] * res[1] * res[2];
69#define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis) \
70 min_ii(max_ii(int((vec[axis] - gmin[axis]) * scale), 0), res[axis] - 2)
81 return i + (j + k * res[1]) * res[0];
85 const int res[3],
const float gmin[3],
float scale,
const float vec[3],
float uvw[3])
92 offset = i + (j + k * res[1]) * res[0];
94 uvw[0] = (vec[0] - gmin[0]) *
scale -
float(i);
95 uvw[1] = (vec[1] - gmin[1]) *
scale -
float(j);
96 uvw[2] = (vec[2] - gmin[2]) *
scale -
float(k);
99 BLI_assert(0.0f <= uvw[0] && uvw[0] <= 1.0001f);
100 BLI_assert(0.0f <= uvw[1] && uvw[1] <= 1.0001f);
101 BLI_assert(0.0f <= uvw[2] && uvw[2] <= 1.0001f);
115 float density_gradient[3],
116 float velocity_gradient[3][3])
119 float uvw[3], muvw[3];
120 int res2 = res[1] * res[0];
124 muvw[0] = 1.0f - uvw[0];
125 muvw[1] = 1.0f - uvw[1];
126 muvw[2] = 1.0f - uvw[2];
128 data[0] = grid[offset];
129 data[1] = grid[offset + 1];
130 data[2] = grid[offset + res[0]];
131 data[3] = grid[offset + res[0] + 1];
132 data[4] = grid[offset + res2];
133 data[5] = grid[offset + res2 + 1];
134 data[6] = grid[offset + res2 + res[0]];
135 data[7] = grid[offset + res2 + res[0] + 1];
138 *density = muvw[2] * (muvw[1] * (muvw[0] *
data[0].density + uvw[0] *
data[1].density) +
139 uvw[1] * (muvw[0] *
data[2].density + uvw[0] *
data[3].density)) +
140 uvw[2] * (muvw[1] * (muvw[0] *
data[4].density + uvw[0] *
data[5].density) +
141 uvw[1] * (muvw[0] *
data[6].density + uvw[0] *
data[7].density));
146 for (k = 0; k < 3; k++) {
147 velocity[k] = muvw[2] *
148 (muvw[1] * (muvw[0] *
data[0].velocity[k] + uvw[0] *
data[1].velocity[k]) +
149 uvw[1] * (muvw[0] *
data[2].velocity[k] + uvw[0] *
data[3].velocity[k])) +
151 (muvw[1] * (muvw[0] *
data[4].velocity[k] + uvw[0] *
data[5].velocity[k]) +
152 uvw[1] * (muvw[0] *
data[6].velocity[k] + uvw[0] *
data[7].velocity[k]));
158 for (k = 0; k < 3; k++) {
159 vel_smooth[k] = muvw[2] * (muvw[1] * (muvw[0] *
data[0].velocity_smooth[k] +
160 uvw[0] *
data[1].velocity_smooth[k]) +
161 uvw[1] * (muvw[0] *
data[2].velocity_smooth[k] +
162 uvw[0] *
data[3].velocity_smooth[k])) +
163 uvw[2] * (muvw[1] * (muvw[0] *
data[4].velocity_smooth[k] +
164 uvw[0] *
data[5].velocity_smooth[k]) +
165 uvw[1] * (muvw[0] *
data[6].velocity_smooth[k] +
166 uvw[0] *
data[7].velocity_smooth[k]));
170 if (density_gradient) {
171 density_gradient[0] = muvw[1] * muvw[2] * (
data[0].density -
data[1].density) +
172 uvw[1] * muvw[2] * (
data[2].density -
data[3].density) +
173 muvw[1] * uvw[2] * (
data[4].density -
data[5].density) +
174 uvw[1] * uvw[2] * (
data[6].density -
data[7].density);
176 density_gradient[1] = muvw[2] * muvw[0] * (
data[0].density -
data[2].density) +
177 uvw[2] * muvw[0] * (
data[4].density -
data[6].density) +
178 muvw[2] * uvw[0] * (
data[1].density -
data[3].density) +
179 uvw[2] * uvw[0] * (
data[5].density -
data[7].density);
181 density_gradient[2] = muvw[2] * muvw[0] * (
data[0].density -
data[4].density) +
182 uvw[2] * muvw[0] * (
data[1].density -
data[5].density) +
183 muvw[2] * uvw[0] * (
data[2].density -
data[6].density) +
184 uvw[2] * uvw[0] * (
data[3].density -
data[7].density);
187 if (velocity_gradient) {
203 float gdensity, gvelocity[3], ggrad[3], gvelgrad[3][3], gradlen;
221 if (gradlen > 0.0f) {
236 float velocity_smooth[3],
237 float density_gradient[3],
238 float velocity_gradient[3][3])
253 HairGrid *grid,
const float x[3],
const float v[3],
float fluid_factor,
float r_v[3])
255 float gdensity, gvelocity[3], gvel_smooth[3], ggrad[3], gvelgrad[3][3];
256 float v_pic[3], v_flip[3];
283 for (i = 0; i < size; i++) {
293 return !(vec[0] < gmin[0] || vec[1] < gmin[1] || vec[2] < gmin[2] || vec[0] > gmax[0] ||
294 vec[1] > gmax[1] || vec[2] > gmax[2]);
305 float totweight = 0.0f;
307 for (i = 0; i < 8; i++) {
308 totweight += weights[i];
315 const int res[3],
const float gmin[3],
float scale,
const float vec[3],
float weights[8])
323 offset = i + (j + k * res[1]) * res[0];
325 uvw[0] = (vec[0] - gmin[0]) *
scale;
326 uvw[1] = (vec[1] - gmin[1]) *
scale;
327 uvw[2] = (vec[2] - gmin[2]) *
scale;
330 weights[1] =
dist_tent_v3f3(uvw,
float(i + 1),
float(j),
float(k));
331 weights[2] =
dist_tent_v3f3(uvw,
float(i),
float(j + 1),
float(k));
332 weights[3] =
dist_tent_v3f3(uvw,
float(i + 1),
float(j + 1),
float(k));
333 weights[4] =
dist_tent_v3f3(uvw,
float(i),
float(j),
float(k + 1));
334 weights[5] =
dist_tent_v3f3(uvw,
float(i + 1),
float(j),
float(k + 1));
335 weights[6] =
dist_tent_v3f3(uvw,
float(i),
float(j + 1),
float(k + 1));
336 weights[7] =
dist_tent_v3f3(uvw,
float(i + 1),
float(j + 1),
float(k + 1));
352 const int res[3] = {grid->
res[0], grid->
res[1], grid->
res[2]};
363 for (di = 0; di < 2; di++) {
364 for (dj = 0; dj < 2; dj++) {
365 for (dk = 0; dk < 2; dk++) {
366 int voffset = offset + di + (dj + dk * res[1]) * res[0];
367 int iw = di + dj * 2 + dk * 4;
377BLI_INLINE void hair_volume_eval_grid_vertex(HairGridVert *vert,
386 float closest[3], lambda, dist, weight;
391 weight = (radius - dist) * dist_scale;
398 vert->density += weight;
405 const float a =
fabsf(
v[0]);
407 const float c =
fabsf(
v[2]);
408 return a >
b ? (a > c ? 0 : 2) : (
b > c ? 1 : 2);
437 const float radius = 1.5f;
438 const float dist_scale = grid->inv_cellsize;
449 float loc_j[3] = {loc[0], loc[1], loc[2]};
450 loc_j[axis_j] +=
float(jmin);
451 for (j = jmin; j <= jmax; j++, vert_j += stride_j, loc_j[axis_j] += 1.0f) {
454 float loc_k[3] = {loc_j[0], loc_j[1], loc_j[2]};
455 loc_k[axis_k] +=
float(kmin);
456 for (k = kmin; k <= kmax; k++, vert_k += stride_k, loc_k[axis_k] += 1.0f) {
458 hair_volume_eval_grid_vertex(vert_k, loc_k, radius, dist_scale, x2,
v2, x3, v3);
462 float wloc[3], x2w[3], x3w[3];
467 if (vert_k->samples > 0) {
471 if (grid->debug_value) {
478 x2w,
len_v3v3(wloc, x2w), 0.2, 0.7, 0.2,
"grid", 255, i, j, k);
505 const int res[3] = {grid->res[0], grid->res[1], grid->res[2]};
508 const int axis0 = major_axis_v3(dir2);
509 const int axis1 = (axis0 + 1) % 3;
510 const int axis2 = (axis0 + 2) % 3;
513 const int strides[3] = {1, res[0], res[0] * res[1]};
514 const int stride0 = strides[axis0];
515 const int stride1 = strides[axis1];
516 const int stride2 = strides[axis2];
521 const float inc1 = dir2[axis1] / dir2[axis0];
522 const float inc2 = dir2[axis2] / dir2[axis0];
525 const float *start = x2[axis0] < x3[axis0] ? x2 : x3;
526 const float *end = x2[axis0] < x3[axis0] ? x3 : x2;
527 const float start0 = start[axis0], start1 = start[axis1], start2 = start[axis2];
528 const float end0 = end[axis0];
537 int j0, k0, j0_prev, k0_prev;
540 for (i = imin; i <= imax; i++) {
541 float shift1, shift2;
542 int jmin, jmax, kmin, kmax;
544 h = std::clamp(
float(i), start0, end0);
546 shift1 = start1 + (h - start0) * inc1;
547 shift2 = start2 + (h - start0) * inc2;
556 jmin =
min_ii(j0, j0_prev);
557 jmax =
max_ii(j0, j0_prev);
558 kmin =
min_ii(k0, k0_prev);
559 kmax =
max_ii(k0, k0_prev);
566 vert0 = grid->verts + i * stride0;
567 loc0[axis0] =
float(i);
571 hair_volume_add_segment_2D(grid,
610 weight = (radius - dist) * dist_scale;
614 vert->density += weight;
635 const float radius = 1.5f;
638 const int res[3] = {grid->
res[0], grid->
res[1], grid->
res[2]};
639 const int stride[3] = {1, res[0], res[0] * res[1]};
640 const int num_samples = 10;
644 for (s = 0; s < num_samples; s++) {
659 for (k = kmin; k <= kmax; k++) {
660 for (j = jmin; j <= jmax; j++) {
661 for (i = imin; i <= imax; i++) {
663 HairGridVert *vert = grid->
verts + i * stride[0] + j * stride[1] + k * stride[2];
677 for (i = 0; i < size; i++) {
679 if (density > 0.0f) {
693 float target_density,
697 return strength *
logf(target_density / density);
705 float target_density,
706 float target_strength)
708 const float flowfac = grid->
cellsize;
709 const float inv_flowfac = 1.0f / grid->
cellsize;
712 const int res[3] = {grid->
res[0], grid->
res[1], grid->
res[2]};
713 const int resA[3] = {grid->
res[0] + 2, grid->
res[1] + 2, grid->
res[2] + 2};
715 const int stride0 = 1;
716 const int stride1 = grid->
res[0];
717 const int stride2 = grid->
res[1] * grid->
res[0];
718 const int strideA0 = 1;
719 const int strideA1 = grid->
res[0] + 2;
720 const int strideA2 = (grid->
res[1] + 2) * (grid->
res[0] + 2);
722 const int num_cells = res[0] * res[1] * res[2];
723 const int num_cellsA = (res[0] + 2) * (res[1] + 2) * (res[2] + 2);
729#define MARGIN_i0 (i < 1)
730#define MARGIN_j0 (j < 1)
731#define MARGIN_k0 (k < 1)
732#define MARGIN_i1 (i >= resA[0] - 1)
733#define MARGIN_j1 (j >= resA[1] - 1)
734#define MARGIN_k1 (k >= resA[2] - 1)
736#define NEIGHBOR_MARGIN_i0 (i < 2)
737#define NEIGHBOR_MARGIN_j0 (j < 2)
738#define NEIGHBOR_MARGIN_k0 (k < 2)
739#define NEIGHBOR_MARGIN_i1 (i >= resA[0] - 2)
740#define NEIGHBOR_MARGIN_j1 (j >= resA[1] - 2)
741#define NEIGHBOR_MARGIN_k1 (k >= resA[2] - 2)
747 for (k = 0; k < resA[2]; k++) {
748 for (j = 0; j < resA[1]; j++) {
749 for (i = 0; i < resA[0]; i++) {
750 int u = i * strideA0 + j * strideA1 + k * strideA2;
759 vert = vert_start + i * stride0 + j * stride1 + k * stride2;
761 const float *v0 = vert->velocity;
762 float dx = 0.0f, dy = 0.0f, dz = 0.0f;
764 dx += v0[0] - (vert - stride0)->velocity[0];
767 dx += (vert + stride0)->velocity[0] - v0[0];
770 dy += v0[1] - (vert - stride1)->velocity[1];
773 dy += (vert + stride1)->velocity[1] - v0[1];
776 dz += v0[2] - (vert - stride2)->velocity[2];
779 dz += (vert + stride2)->velocity[2] - v0[2];
782 float divergence = -0.5f * flowfac * (dx + dy + dz);
786 vert->density, target_density, target_strength);
793 B[u] = divergence - target;
797 float wloc[3], loc[3];
798 float col0[3] = {0.0, 0.0, 0.0};
799 float colp[3] = {0.0, 1.0, 1.0};
800 float coln[3] = {1.0, 0.0, 1.0};
804 loc[0] =
float(i - 1);
805 loc[1] =
float(j - 1);
806 loc[2] =
float(k - 1);
809 if (divergence > 0.0f) {
810 fac = std::clamp(divergence * target_strength, 0.0, 1.0);
814 fac = std::clamp(-divergence * target_strength, 0.0, 1.0);
819 grid->debug_data, wloc, 0.01f, col[0], col[1], col[2],
"grid", 5522, i, j, k);
839 A.reserve(Eigen::VectorXi::Constant(num_cellsA, 7));
841 for (k = 0; k < resA[2]; k++) {
842 for (j = 0; j < resA[1]; j++) {
843 for (i = 0; i < resA[0]; i++) {
844 int u = i * strideA0 + j * strideA1 + k * strideA2;
848 vert = vert_start + i * stride0 + j * stride1 + k * stride2;
850 int neighbors_lo = 0;
851 int neighbors_hi = 0;
852 int non_solid_neighbors = 0;
853 int neighbor_lo_index[3];
854 int neighbor_hi_index[3];
862 neighbor_lo_index[neighbors_lo++] = u - strideA2;
865 neighbor_lo_index[neighbors_lo++] = u - strideA1;
868 neighbor_lo_index[neighbors_lo++] = u - strideA0;
871 neighbor_hi_index[neighbors_hi++] = u + strideA0;
874 neighbor_hi_index[neighbors_hi++] = u + strideA1;
877 neighbor_hi_index[neighbors_hi++] = u + strideA2;
881 non_solid_neighbors = 6;
883 for (n = 0; n < neighbors_lo; n++) {
884 A.insert(neighbor_lo_index[n], u) = -1.0f;
886 A.insert(u, u) =
float(non_solid_neighbors);
887 for (n = 0; n < neighbors_hi; n++) {
888 A.insert(neighbor_hi_index[n], u) = -1.0f;
892 A.insert(u, u) = 1.0f;
899 cg.setMaxIterations(100);
900 cg.setTolerance(0.01f);
906 if (cg.info() == Eigen::Success) {
908 for (k = 0; k < resA[2]; k++) {
909 for (j = 0; j < resA[1]; j++) {
910 for (i = 0; i < resA[0]; i++) {
911 int u = i * strideA0 + j * strideA1 + k * strideA2;
918 vert = vert_start + i * stride0 + j * stride1 + k * stride2;
920 float p_left = p[u - strideA0];
921 float p_right = p[u + strideA0];
922 float p_down = p[u - strideA1];
923 float p_up = p[u + strideA1];
924 float p_bottom = p[u - strideA2];
925 float p_top = p[u + strideA2];
929 dvel[0] = p_right - p_left;
930 dvel[1] = p_up - p_down;
931 dvel[2] = p_top - p_bottom;
935 add_v3_v3v3(vert->velocity_smooth, vert->velocity, dvel);
938 zero_v3(vert->velocity_smooth);
949 int slice = (offset - grid->
gmin[axis]) / grid->
cellsize;
951 for (k = 0; k < resA[2]; k++) {
952 for (j = 0; j < resA[1]; j++) {
953 for (i = 0; i < resA[0]; i++) {
954 int u = i * strideA0 + j * strideA1 + k * strideA2;
961 vert = vert_start + i * stride0 + j * stride1 + k * stride2;
963 float wloc[3], loc[3];
964 float col0[3] = {0.0, 0.0, 0.0};
965 float colp[3] = {0.0, 1.0, 1.0};
966 float coln[3] = {1.0, 0.0, 1.0};
970 loc[0] =
float(i - 1);
971 loc[1] =
float(j - 1);
972 loc[2] =
float(k - 1);
975 float pressure = p[u];
976 if (pressure > 0.0f) {
977 fac = std::clamp(pressure * grid->debug1, 0.0, 1.0);
981 fac = std::clamp(-pressure * grid->debug1, 0.0, 1.0);
986 grid->debug_data, wloc, 0.01f, col[0], col[1], col[2],
"grid", 5533, i, j, k);
991 sub_v3_v3v3(dvel, vert->velocity_smooth, vert->velocity);
994 grid->debug_data, wloc, dvel, 1, 1, 1,
"grid", 5566, i, j, k);
999 float d = std::clamp(vert->density * grid->debug2, 0.0f, 1.0f);
1000 float col0[3] = {0.3, 0.3, 0.3};
1001 float colp[3] = {0.0, 0.0, 1.0};
1008 grid->debug_data, wloc, col[0], col[1], col[2],
"grid", 5544, i, j, k);
1022 for (i = 0, vert = grid->
verts; i < num_cells; i++, vert++) {
1023 zero_v3(vert->velocity_smooth);
1034BLI_INLINE void hair_volume_filter_box_convolute(
1035 HairVertexGrid *grid,
float invD,
const int kernel_size[3],
int i,
int j,
int k)
1037 int res = grid->res;
1039 int minp =
max_ii(i - kernel_size[0], 0), maxp =
min_ii(i + kernel_size[0], res - 1);
1040 int minq =
max_ii(j - kernel_size[1], 0), maxq =
min_ii(j + kernel_size[1], res - 1);
1041 int minr =
max_ii(k - kernel_size[2], 0), maxr =
min_ii(k + kernel_size[2], res - 1);
1042 int offset, kernel_offset, kernel_dq, kernel_dr;
1043 HairGridVert *verts;
1046 offset = i + (j + k * res) * res;
1047 verts = grid->verts;
1048 vel_smooth = verts[offset].velocity_smooth;
1050 kernel_offset = minp + (minq + minr * res) * res;
1052 kernel_dr = res * res;
1053 for (r = minr; r <= maxr; r++) {
1054 for (q = minq; q <= maxq; q++) {
1055 for (p = minp; p <= maxp; p++) {
1057 madd_v3_v3fl(vel_smooth, verts[kernel_offset].velocity, invD);
1061 kernel_offset += kernel_dq;
1063 kernel_offset += kernel_dr;
1067void SIM_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid,
int kernel_size)
1070 int kernel_sizev[3] = {kernel_size, kernel_size, kernel_size};
1075 if (kernel_size <= 0) {
1079 tot = kernel_size * 2 + 1;
1080 invD = 1.0f /
float(tot * tot * tot);
1083 for (i = 0; i <
size; i++) {
1084 zero_v3(grid->verts[i].velocity_smooth);
1087 for (i = 0; i < grid->res; i++) {
1088 for (j = 0; j < grid->res; j++) {
1089 for (k = 0; k < grid->res; k++) {
1090 hair_volume_filter_box_convolute(grid, invD, kernel_sizev, i, j, k);
1096 for (i = 0; i <
size; i++) {
1097 copy_v3_v3(grid->verts[i].velocity, grid->verts[i].velocity_smooth);
1103 const float gmin[3],
1104 const float gmax[3])
1108 int resmin[3], resmax[3], res[3];
1109 float gmin_margin[3], gmax_margin[3];
1115 if (cellsize <= 0.0f) {
1118 scale = 1.0f / cellsize;
1121 for (i = 0; i < 3; i++) {
1129 res[i] = resmax[i] - resmin[i] + 1;
1133 resmax[i] = resmin[i] + 4;
1141 gmin_margin[i] =
float(resmin[i]) * cellsize;
1142 gmax_margin[i] =
float(resmax[i]) * cellsize;
1147 grid->
res[0] = res[0];
1148 grid->
res[1] = res[1];
1149 grid->
res[2] = res[2];
1163 MEM_delete(grid->
verts);
1170 HairGrid *grid,
float *cellsize,
int res[3],
float gmin[3],
float gmax[3])
1187static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
1191 int res = hair_grid_res;
1193 HairGridVert *collgrid;
1194 ListBaseT<ColliderCache> *colliders;
1195 ColliderCache *col =
nullptr;
1196 float gmin[3], gmax[3],
scale[3];
1198 float collfac = 2.0f * clmd->sim_parms->collider_friction;
1202 hair_volume_get_boundbox(lX, numverts, gmin, gmax);
1203 hair_grid_get_scale(res, gmin, gmax,
scale);
1208 for (i = 0; i <
size; i++) {
1209 zero_v3(collgrid[i].velocity);
1210 collgrid[i].density = 0.0f;
1215 if (colliders && collfac > 0.0f) {
1216 for (col = colliders->first; col; col = col->next) {
1217 float3 *loc0 = col->collmd->x;
1218 float3 *loc1 = col->collmd->xnew;
1223 for (
v = 0;
v < col->collmd->numverts;
v++, loc0++, loc1++) {
1234 for (di = 0; di < 2; di++) {
1235 for (dj = 0; dj < 2; dj++) {
1236 for (dk = 0; dk < 2; dk++) {
1237 int voffset = offset + di + (dj + dk * res) * res;
1238 int iw = di + dj * 2 + dk * 4;
1240 collgrid[voffset].density += weights[iw];
1241 madd_v3_v3fl(collgrid[voffset].velocity, vel, weights[iw]);
1251 for (i = 0; i <
size; i++) {
1252 float density = collgrid[i].density;
1253 if (density > 0.0f) {
1254 mul_v3_fl(collgrid[i].velocity, 1.0f / density);
#define BKE_sim_debug_data_add_dot(p, r, g, b, category,...)
#define BKE_sim_debug_data_add_vector(p, d, r, g, b, category,...)
#define BKE_sim_debug_data_add_line(p1, p2, r, g, b, category,...)
#define BKE_sim_debug_data_add_circle(p, radius, r, g, b, category,...)
Read Blender memory allocation and freeing.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
bool closest(btVector3 &v)
float3x3 scale(float3x3 mat, float2 scale)
#define NEIGHBOR_MARGIN_j0
#define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis)
#define NEIGHBOR_MARGIN_k0
#define NEIGHBOR_MARGIN_i1
#define NEIGHBOR_MARGIN_i0
#define NEIGHBOR_MARGIN_j1
#define NEIGHBOR_MARGIN_k1
#define MAX_HAIR_GRID_RES
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str)
int size(const AssetLibraryReference *library_reference)
constexpr StringRefNull radius
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
BLI_INLINE bool hair_grid_point_valid(const float vec[3], const float gmin[3], const float gmax[3])
static const float density_threshold
MINLINE void copy_v3_v3(float r[3], const float a[3])
void BKE_collider_cache_free(ListBaseT< ColliderCache > **colliders)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void SIM_hair_volume_normalize_vertex_grid(HairGrid *grid)
MINLINE void copy_v3_v3_int(int r[3], const int a[3])
void SIM_hair_volume_free_vertex_grid(HairGrid *grid)
Eigen::SparseMatrix< Scalar > lMatrix
BLI_INLINE int hair_grid_size(const int res[3])
BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid, const int res[3], const float gmin[3], float scale, const float vec[3], float *density, float velocity[3], float vel_smooth[3], float density_gradient[3], float velocity_gradient[3][3])
MINLINE int max_ii(int a, int b)
BLI_INLINE float hair_volume_density_divergence(float density, float target_density, float strength)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void SIM_hair_volume_grid_interpolate(HairGrid *grid, const float x[3], float *density, float velocity[3], float velocity_smooth[3], float density_gradient[3], float velocity_gradient[3][3])
BLI_INLINE int hair_grid_weights(const int res[3], const float gmin[3], float scale, const float vec[3], float weights[8])
MINLINE void mul_v3_fl(float r[3], float f)
BLI_INLINE int floor_int(float value)
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
void SIM_hair_volume_vertex_grid_forces(HairGrid *grid, const float x[3], const float v[3], float smoothfac, float pressurefac, float minpressure, 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)
BLI_INLINE int hair_grid_offset(const float vec[3], const int res[3], const float gmin[3], float scale)
ListBaseT< ColliderCache > * BKE_collider_cache_create(struct Depsgraph *depsgraph, struct Object *self, struct Collection *collection)
BMesh const char void * data
Eigen::ConjugateGradient< lMatrix, Eigen::Lower, Eigen::DiagonalPreconditioner< Scalar > > ConjugateGradient
void SIM_hair_volume_grid_velocity(HairGrid *grid, const float x[3], const float v[3], float fluid_factor, float r_v[3])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
BLI_INLINE float floor_mod(float value)
BLI_INLINE void hair_volume_eval_grid_vertex_sample(HairGridVert *vert, const float loc[3], float radius, float dist_scale, const float x[3], const float v[3])
MINLINE void zero_v3(float r[3])
void SIM_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[3])
BLI_INLINE int hair_grid_interp_weights(const int res[3], const float gmin[3], float scale, const float vec[3], float uvw[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])
void SIM_hair_volume_add_segment(HairGrid *grid, const float[3], const float[3], const float x2[3], const float v2[3], const float x3[3], const float v3[3], const float[3], const float[3], const float[3], const float[3], const float[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)
HairGrid * SIM_hair_volume_create_vertex_grid(float cellsize, const float gmin[3], const float gmax[3])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3])
void SIM_hair_volume_grid_clear(HairGrid *grid)
void zero_m3(float m[3][3])
bool SIM_hair_volume_solve_divergence(HairGrid *grid, float, float target_density, float target_strength)
VecBase< float, 3 > float3
BLI_INLINE void grid_to_world(HairGrid *grid, float vecw[3], const float vec[3])
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE int min_ii(int a, int b)
void sub_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void SIM_hair_volume_grid_geometry(HairGrid *grid, float *cellsize, int res[3], float gmin[3], float gmax[3])
BLI_INLINE float weights_sum(const float weights[8])
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
BLI_INLINE float dist_tent_v3f3(const float a[3], float x, float y, float z)
void vert(const int vert_id, float4 &position)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float