42static float I[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
46 return value > 0.0f ?
int(value) :
int(value) - 1;
51 return value -
floorf(value);
56 return res[0] * res[1] * res[2];
74#define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis) \
75 min_ii(max_ii(int((vec[axis] - gmin[axis]) * scale), 0), res[axis] - 2)
86 return i + (j + k * res[1]) * res[0];
90 const int res[3],
const float gmin[3],
float scale,
const float vec[3],
float uvw[3])
97 offset = i + (j + k * res[1]) * res[0];
99 uvw[0] = (vec[0] - gmin[0]) * scale -
float(i);
100 uvw[1] = (vec[1] - gmin[1]) * scale -
float(j);
101 uvw[2] = (vec[2] - gmin[2]) * scale -
float(k);
104 BLI_assert(0.0f <= uvw[0] && uvw[0] <= 1.0001f);
105 BLI_assert(0.0f <= uvw[1] && uvw[1] <= 1.0001f);
106 BLI_assert(0.0f <= uvw[2] && uvw[2] <= 1.0001f);
120 float density_gradient[3],
121 float velocity_gradient[3][3])
124 float uvw[3], muvw[3];
125 int res2 = res[1] * res[0];
129 muvw[0] = 1.0f - uvw[0];
130 muvw[1] = 1.0f - uvw[1];
131 muvw[2] = 1.0f - uvw[2];
133 data[0] = grid[offset];
134 data[1] = grid[offset + 1];
135 data[2] = grid[offset + res[0]];
136 data[3] = grid[offset + res[0] + 1];
137 data[4] = grid[offset + res2];
138 data[5] = grid[offset + res2 + 1];
139 data[6] = grid[offset + res2 + res[0]];
140 data[7] = grid[offset + res2 + res[0] + 1];
143 *density = muvw[2] * (muvw[1] * (muvw[0] * data[0].density + uvw[0] * data[1].density) +
144 uvw[1] * (muvw[0] * data[2].density + uvw[0] * data[3].density)) +
145 uvw[2] * (muvw[1] * (muvw[0] * data[4].density + uvw[0] * data[5].density) +
146 uvw[1] * (muvw[0] * data[6].density + uvw[0] * data[7].density));
151 for (k = 0; k < 3; k++) {
152 velocity[k] = muvw[2] *
153 (muvw[1] * (muvw[0] * data[0].velocity[k] + uvw[0] * data[1].velocity[k]) +
154 uvw[1] * (muvw[0] * data[2].velocity[k] + uvw[0] * data[3].velocity[k])) +
156 (muvw[1] * (muvw[0] * data[4].velocity[k] + uvw[0] * data[5].velocity[k]) +
157 uvw[1] * (muvw[0] * data[6].velocity[k] + uvw[0] * data[7].velocity[k]));
163 for (k = 0; k < 3; k++) {
164 vel_smooth[k] = muvw[2] * (muvw[1] * (muvw[0] * data[0].velocity_smooth[k] +
165 uvw[0] * data[1].velocity_smooth[k]) +
166 uvw[1] * (muvw[0] * data[2].velocity_smooth[k] +
167 uvw[0] * data[3].velocity_smooth[k])) +
168 uvw[2] * (muvw[1] * (muvw[0] * data[4].velocity_smooth[k] +
169 uvw[0] * data[5].velocity_smooth[k]) +
170 uvw[1] * (muvw[0] * data[6].velocity_smooth[k] +
171 uvw[0] * data[7].velocity_smooth[k]));
175 if (density_gradient) {
176 density_gradient[0] = muvw[1] * muvw[2] * (data[0].density - data[1].density) +
177 uvw[1] * muvw[2] * (data[2].density - data[3].density) +
178 muvw[1] * uvw[2] * (data[4].density - data[5].density) +
179 uvw[1] * uvw[2] * (data[6].density - data[7].density);
181 density_gradient[1] = muvw[2] * muvw[0] * (data[0].density - data[2].density) +
182 uvw[2] * muvw[0] * (data[4].density - data[6].density) +
183 muvw[2] * uvw[0] * (data[1].density - data[3].density) +
184 uvw[2] * uvw[0] * (data[5].density - data[7].density);
186 density_gradient[2] = muvw[2] * muvw[0] * (data[0].density - data[4].density) +
187 uvw[2] * muvw[0] * (data[1].density - data[5].density) +
188 muvw[2] * uvw[0] * (data[2].density - data[6].density) +
189 uvw[2] * uvw[0] * (data[3].density - data[7].density);
192 if (velocity_gradient) {
208 float gdensity, gvelocity[3], ggrad[3], gvelgrad[3][3], gradlen;
226 if (gradlen > 0.0f) {
241 float velocity_smooth[3],
242 float density_gradient[3],
243 float velocity_gradient[3][3])
258 HairGrid *grid,
const float x[3],
const float v[3],
float fluid_factor,
float r_v[3])
260 float gdensity, gvelocity[3], gvel_smooth[3], ggrad[3], gvelgrad[3][3];
261 float v_pic[3], v_flip[3];
288 for (i = 0; i <
size; i++) {
289 zero_v3(grid->verts[i].velocity);
290 zero_v3(grid->verts[i].velocity_smooth);
291 grid->verts[i].density = 0.0f;
292 grid->verts[i].samples = 0;
298 return !(vec[0] < gmin[0] || vec[1] < gmin[1] || vec[2] < gmin[2] || vec[0] > gmax[0] ||
299 vec[1] > gmax[1] || vec[2] > gmax[2]);
304 float w = (1.0f -
fabsf(a[0] - x)) * (1.0f -
fabsf(a[1] - y)) * (1.0f -
fabsf(a[2] -
z));
310 float totweight = 0.0f;
312 for (i = 0; i < 8; i++) {
313 totweight += weights[i];
320 const int res[3],
const float gmin[3],
float scale,
const float vec[3],
float weights[8])
328 offset = i + (j + k * res[1]) * res[0];
330 uvw[0] = (vec[0] - gmin[0]) * scale;
331 uvw[1] = (vec[1] - gmin[1]) * scale;
332 uvw[2] = (vec[2] - gmin[2]) * scale;
335 weights[1] =
dist_tent_v3f3(uvw,
float(i + 1),
float(j),
float(k));
336 weights[2] =
dist_tent_v3f3(uvw,
float(i),
float(j + 1),
float(k));
337 weights[3] =
dist_tent_v3f3(uvw,
float(i + 1),
float(j + 1),
float(k));
338 weights[4] =
dist_tent_v3f3(uvw,
float(i),
float(j),
float(k + 1));
339 weights[5] =
dist_tent_v3f3(uvw,
float(i + 1),
float(j),
float(k + 1));
340 weights[6] =
dist_tent_v3f3(uvw,
float(i),
float(j + 1),
float(k + 1));
341 weights[7] =
dist_tent_v3f3(uvw,
float(i + 1),
float(j + 1),
float(k + 1));
357 const int res[3] = {grid->res[0], grid->res[1], grid->res[2]};
368 for (di = 0; di < 2; di++) {
369 for (dj = 0; dj < 2; dj++) {
370 for (dk = 0; dk < 2; dk++) {
371 int voffset = offset + di + (dj + dk * res[1]) * res[0];
372 int iw = di + dj * 2 + dk * 4;
374 grid->verts[voffset].density += weights[iw];
391 float closest[3], lambda, dist, weight;
396 weight = (radius - dist) * dist_scale;
410 const float a =
fabsf(
v[0]);
412 const float c =
fabsf(
v[2]);
413 return a >
b ? (a > c ? 0 : 2) : (
b > c ? 1 : 2);
442 const float radius = 1.5f;
443 const float dist_scale = grid->inv_cellsize;
454 float loc_j[3] = {loc[0], loc[1], loc[2]};
455 loc_j[axis_j] +=
float(jmin);
456 for (j = jmin; j <= jmax; j++, vert_j += stride_j, loc_j[axis_j] += 1.0f) {
459 float loc_k[3] = {loc_j[0], loc_j[1], loc_j[2]};
460 loc_k[axis_k] +=
float(kmin);
461 for (k = kmin; k <= kmax; k++, vert_k += stride_k, loc_k[axis_k] += 1.0f) {
463 hair_volume_eval_grid_vertex(vert_k, loc_k, radius, dist_scale, x2,
v2, x3, v3);
467 float wloc[3], x2w[3], x3w[3];
472 if (vert_k->samples > 0) {
476 if (grid->debug_value) {
483 x2w,
len_v3v3(wloc, x2w), 0.2, 0.7, 0.2,
"grid", 255, i, j, k);
510 const int res[3] = {grid->res[0], grid->res[1], grid->res[2]};
513 const int axis0 = major_axis_v3(dir2);
514 const int axis1 = (axis0 + 1) % 3;
515 const int axis2 = (axis0 + 2) % 3;
518 const int strides[3] = {1, res[0], res[0] * res[1]};
519 const int stride0 = strides[axis0];
520 const int stride1 = strides[axis1];
521 const int stride2 = strides[axis2];
526 const float inc1 = dir2[axis1] / dir2[axis0];
527 const float inc2 = dir2[axis2] / dir2[axis0];
530 const float *start = x2[axis0] < x3[axis0] ? x2 : x3;
531 const float *end = x2[axis0] < x3[axis0] ? x3 : x2;
532 const float start0 = start[axis0], start1 = start[axis1], start2 = start[axis2];
533 const float end0 = end[axis0];
542 int j0, k0, j0_prev, k0_prev;
545 for (i = imin; i <= imax; i++) {
546 float shift1, shift2;
547 int jmin, jmax, kmin, kmax;
549 h = std::clamp(
float(i), start0, end0);
551 shift1 = start1 + (h - start0) * inc1;
552 shift2 = start2 + (h - start0) * inc2;
561 jmin =
min_ii(j0, j0_prev);
562 jmax =
max_ii(j0, j0_prev);
563 kmin =
min_ii(k0, k0_prev);
564 kmax =
max_ii(k0, k0_prev);
571 vert0 = grid->verts + i * stride0;
572 loc0[axis0] =
float(i);
576 hair_volume_add_segment_2D(grid,
615 weight = (radius - dist) * dist_scale;
640 const float radius = 1.5f;
641 const float dist_scale = grid->inv_cellsize;
643 const int res[3] = {grid->res[0], grid->res[1], grid->res[2]};
644 const int stride[3] = {1, res[0], res[0] * res[1]};
645 const int num_samples = 10;
649 for (s = 0; s < num_samples; s++) {
664 for (k = kmin; k <= kmax; k++) {
665 for (j = jmin; j <= jmax; j++) {
666 for (i = imin; i <= imax; i++) {
668 HairGridVert *vert = grid->verts + i * stride[0] + j * stride[1] + k * stride[2];
682 for (i = 0; i <
size; i++) {
683 float density = grid->verts[i].density;
684 if (density > 0.0f) {
685 mul_v3_fl(grid->verts[i].velocity, 1.0f / density);
698 float target_density,
702 return strength *
logf(target_density / density);
710 float target_density,
711 float target_strength)
713 const float flowfac = grid->cellsize;
714 const float inv_flowfac = 1.0f / grid->cellsize;
717 const int res[3] = {grid->res[0], grid->res[1], grid->res[2]};
718 const int resA[3] = {grid->res[0] + 2, grid->res[1] + 2, grid->res[2] + 2};
720 const int stride0 = 1;
721 const int stride1 = grid->res[0];
722 const int stride2 = grid->res[1] * grid->res[0];
723 const int strideA0 = 1;
724 const int strideA1 = grid->res[0] + 2;
725 const int strideA2 = (grid->res[1] + 2) * (grid->res[0] + 2);
727 const int num_cells = res[0] * res[1] * res[2];
728 const int num_cellsA = (res[0] + 2) * (res[1] + 2) * (res[2] + 2);
730 HairGridVert *vert_start = grid->verts - (stride0 + stride1 + stride2);
734#define MARGIN_i0 (i < 1)
735#define MARGIN_j0 (j < 1)
736#define MARGIN_k0 (k < 1)
737#define MARGIN_i1 (i >= resA[0] - 1)
738#define MARGIN_j1 (j >= resA[1] - 1)
739#define MARGIN_k1 (k >= resA[2] - 1)
741#define NEIGHBOR_MARGIN_i0 (i < 2)
742#define NEIGHBOR_MARGIN_j0 (j < 2)
743#define NEIGHBOR_MARGIN_k0 (k < 2)
744#define NEIGHBOR_MARGIN_i1 (i >= resA[0] - 2)
745#define NEIGHBOR_MARGIN_j1 (j >= resA[1] - 2)
746#define NEIGHBOR_MARGIN_k1 (k >= resA[2] - 2)
752 for (k = 0; k < resA[2]; k++) {
753 for (j = 0; j < resA[1]; j++) {
754 for (i = 0; i < resA[0]; i++) {
755 int u = i * strideA0 + j * strideA1 + k * strideA2;
764 vert = vert_start + i * stride0 + j * stride1 + k * stride2;
767 float dx = 0.0f, dy = 0.0f, dz = 0.0f;
769 dx += v0[0] - (vert - stride0)->velocity[0];
772 dx += (vert + stride0)->velocity[0] - v0[0];
775 dy += v0[1] - (vert - stride1)->velocity[1];
778 dy += (vert + stride1)->velocity[1] - v0[1];
781 dz += v0[2] - (vert - stride2)->velocity[2];
784 dz += (vert + stride2)->velocity[2] - v0[2];
787 float divergence = -0.5f * flowfac * (dx + dy + dz);
791 vert->
density, target_density, target_strength);
798 B[u] = divergence - target;
802 float wloc[3], loc[3];
803 float col0[3] = {0.0, 0.0, 0.0};
804 float colp[3] = {0.0, 1.0, 1.0};
805 float coln[3] = {1.0, 0.0, 1.0};
809 loc[0] =
float(i - 1);
810 loc[1] =
float(j - 1);
811 loc[2] =
float(k - 1);
814 if (divergence > 0.0f) {
815 fac = std::clamp(divergence * target_strength, 0.0, 1.0);
819 fac = std::clamp(-divergence * target_strength, 0.0, 1.0);
824 grid->debug_data, wloc, 0.01f,
col[0],
col[1],
col[2],
"grid", 5522, i, j, k);
844 A.reserve(Eigen::VectorXi::Constant(num_cellsA, 7));
846 for (k = 0; k < resA[2]; k++) {
847 for (j = 0; j < resA[1]; j++) {
848 for (i = 0; i < resA[0]; i++) {
849 int u = i * strideA0 + j * strideA1 + k * strideA2;
853 vert = vert_start + i * stride0 + j * stride1 + k * stride2;
855 int neighbors_lo = 0;
856 int neighbors_hi = 0;
857 int non_solid_neighbors = 0;
858 int neighbor_lo_index[3];
859 int neighbor_hi_index[3];
867 neighbor_lo_index[neighbors_lo++] = u - strideA2;
870 neighbor_lo_index[neighbors_lo++] = u - strideA1;
873 neighbor_lo_index[neighbors_lo++] = u - strideA0;
876 neighbor_hi_index[neighbors_hi++] = u + strideA0;
879 neighbor_hi_index[neighbors_hi++] = u + strideA1;
882 neighbor_hi_index[neighbors_hi++] = u + strideA2;
886 non_solid_neighbors = 6;
888 for (n = 0; n < neighbors_lo; n++) {
889 A.insert(neighbor_lo_index[n], u) = -1.0f;
891 A.insert(u, u) =
float(non_solid_neighbors);
892 for (n = 0; n < neighbors_hi; n++) {
893 A.insert(neighbor_hi_index[n], u) = -1.0f;
897 A.insert(u, u) = 1.0f;
904 cg.setMaxIterations(100);
905 cg.setTolerance(0.01f);
911 if (cg.info() == Eigen::Success) {
913 for (k = 0; k < resA[2]; k++) {
914 for (j = 0; j < resA[1]; j++) {
915 for (i = 0; i < resA[0]; i++) {
916 int u = i * strideA0 + j * strideA1 + k * strideA2;
923 vert = vert_start + i * stride0 + j * stride1 + k * stride2;
925 float p_left = p[u - strideA0];
926 float p_right = p[u + strideA0];
927 float p_down = p[u - strideA1];
928 float p_up = p[u + strideA1];
929 float p_bottom = p[u - strideA2];
930 float p_top = p[u + strideA2];
934 dvel[0] = p_right - p_left;
935 dvel[1] = p_up - p_down;
936 dvel[2] = p_top - p_bottom;
954 int slice = (offset - grid->gmin[axis]) / grid->cellsize;
956 for (k = 0; k < resA[2]; k++) {
957 for (j = 0; j < resA[1]; j++) {
958 for (i = 0; i < resA[0]; i++) {
959 int u = i * strideA0 + j * strideA1 + k * strideA2;
966 vert = vert_start + i * stride0 + j * stride1 + k * stride2;
968 float wloc[3], loc[3];
969 float col0[3] = {0.0, 0.0, 0.0};
970 float colp[3] = {0.0, 1.0, 1.0};
971 float coln[3] = {1.0, 0.0, 1.0};
975 loc[0] =
float(i - 1);
976 loc[1] =
float(j - 1);
977 loc[2] =
float(k - 1);
980 float pressure = p[u];
981 if (pressure > 0.0f) {
982 fac = std::clamp(pressure * grid->debug1, 0.0, 1.0);
986 fac = std::clamp(-pressure * grid->debug1, 0.0, 1.0);
991 grid->debug_data, wloc, 0.01f,
col[0],
col[1],
col[2],
"grid", 5533, i, j, k);
999 grid->debug_data, wloc, dvel, 1, 1, 1,
"grid", 5566, i, j, k);
1004 float d = std::clamp(vert->
density * grid->debug2, 0.0f, 1.0f);
1005 float col0[3] = {0.3, 0.3, 0.3};
1006 float colp[3] = {0.0, 0.0, 1.0};
1013 grid->debug_data, wloc,
col[0],
col[1],
col[2],
"grid", 5544, i, j, k);
1027 for (i = 0, vert = grid->verts; i < num_cells; i++, vert++) {
1039BLI_INLINE void hair_volume_filter_box_convolute(
1040 HairVertexGrid *grid,
float invD,
const int kernel_size[3],
int i,
int j,
int k)
1042 int res = grid->res;
1044 int minp =
max_ii(i - kernel_size[0], 0), maxp =
min_ii(i + kernel_size[0], res - 1);
1045 int minq =
max_ii(j - kernel_size[1], 0), maxq =
min_ii(j + kernel_size[1], res - 1);
1046 int minr =
max_ii(k - kernel_size[2], 0), maxr =
min_ii(k + kernel_size[2], res - 1);
1047 int offset, kernel_offset, kernel_dq, kernel_dr;
1051 offset = i + (j + k * res) * res;
1052 verts = grid->verts;
1055 kernel_offset = minp + (minq + minr * res) * res;
1057 kernel_dr = res * res;
1058 for (r = minr; r <= maxr; r++) {
1059 for (q = minq; q <= maxq; q++) {
1060 for (p = minp; p <= maxp; p++) {
1066 kernel_offset += kernel_dq;
1068 kernel_offset += kernel_dr;
1072void SIM_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid,
int kernel_size)
1075 int kernel_sizev[3] = {kernel_size, kernel_size, kernel_size};
1080 if (kernel_size <= 0) {
1084 tot = kernel_size * 2 + 1;
1085 invD = 1.0f /
float(tot * tot * tot);
1088 for (i = 0; i <
size; i++) {
1089 zero_v3(grid->verts[i].velocity_smooth);
1092 for (i = 0; i < grid->res; i++) {
1093 for (j = 0; j < grid->res; j++) {
1094 for (k = 0; k < grid->res; k++) {
1095 hair_volume_filter_box_convolute(grid, invD, kernel_sizev, i, j, k);
1101 for (i = 0; i <
size; i++) {
1102 copy_v3_v3(grid->verts[i].velocity, grid->verts[i].velocity_smooth);
1108 const float gmin[3],
1109 const float gmax[3])
1113 int resmin[3], resmax[3], res[3];
1114 float gmin_margin[3], gmax_margin[3];
1120 if (cellsize <= 0.0f) {
1123 scale = 1.0f / cellsize;
1126 for (i = 0; i < 3; i++) {
1128 resmax[i] =
floor_int(gmax[i] * scale) + 1;
1134 res[i] = resmax[i] - resmin[i] + 1;
1138 resmax[i] = resmin[i] + 4;
1146 gmin_margin[i] =
float(resmin[i]) * cellsize;
1147 gmax_margin[i] =
float(resmax[i]) * cellsize;
1151 grid = MEM_cnew<HairGrid>(
"hair grid");
1152 grid->res[0] = res[0];
1153 grid->res[1] = res[1];
1154 grid->res[2] = res[2];
1157 grid->cellsize = cellsize;
1158 grid->inv_cellsize = scale;
1175 HairGrid *grid,
float *cellsize,
int res[3],
float gmin[3],
float gmax[3])
1178 *cellsize = grid->cellsize;
1196 int res = hair_grid_res;
1201 float gmin[3], gmax[3], scale[3];
1207 hair_volume_get_boundbox(lX, numverts, gmin, gmax);
1208 hair_grid_get_scale(res, gmin, gmax, scale);
1213 for (i = 0; i <
size; i++) {
1214 zero_v3(collgrid[i].velocity);
1220 if (colliders && collfac > 0.0f) {
1228 for (
v = 0;
v <
col->collmd->numverts;
v++, loc0++, loc1++) {
1239 for (di = 0; di < 2; di++) {
1240 for (dj = 0; dj < 2; dj++) {
1241 for (dk = 0; dk < 2; dk++) {
1242 int voffset = offset + di + (dj + dk * res) * res;
1243 int iw = di + dj * 2 + dk * 4;
1245 collgrid[voffset].
density += weights[iw];
1246 madd_v3_v3fl(collgrid[voffset].velocity, vel, weights[iw]);
1256 for (i = 0; i <
size; i++) {
1257 float density = collgrid[i].
density;
1258 if (density > 0.0f) {
1259 mul_v3_fl(collgrid[i].velocity, 1.0f / density);
void BKE_collider_cache_free(struct ListBase **colliders)
struct ListBase * BKE_collider_cache_create(struct Depsgraph *depsgraph, struct Object *self, struct Collection *collection)
#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,...)
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3])
void sub_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void mul_m3_fl(float R[3][3], float f)
void zero_m3(float m[3][3])
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
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 copy_v3_v3_int(int r[3], const int a[3])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
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 normalize_v3(float n[3])
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
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.
local_group_size(16, 16) .push_constant(Type b
const Depsgraph * depsgraph
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
Eigen::ConjugateGradient< lMatrix, Eigen::Lower, Eigen::DiagonalPreconditioner< Scalar > > ConjugateGradient
Eigen::SparseMatrix< Scalar > lMatrix
BLI_INLINE int hair_grid_interp_weights(const int res[3], const float gmin[3], float scale, const float vec[3], float uvw[3])
#define NEIGHBOR_MARGIN_j0
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])
#define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis)
#define NEIGHBOR_MARGIN_k0
void SIM_hair_volume_grid_velocity(HairGrid *grid, const float x[3], const float v[3], float fluid_factor, float r_v[3])
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 floor_int(float value)
#define NEIGHBOR_MARGIN_i1
#define NEIGHBOR_MARGIN_i0
BLI_INLINE int hair_grid_size(const int res[3])
static const float density_threshold
BLI_INLINE float dist_tent_v3f3(const float a[3], float x, float y, float z)
#define NEIGHBOR_MARGIN_j1
void SIM_hair_volume_grid_clear(HairGrid *grid)
#define NEIGHBOR_MARGIN_k1
BLI_INLINE void grid_to_world(HairGrid *grid, float vecw[3], const float vec[3])
BLI_INLINE int hair_grid_weights(const int res[3], const float gmin[3], float scale, const float vec[3], float weights[8])
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])
BLI_INLINE float weights_sum(const float weights[8])
BLI_INLINE float floor_mod(float value)
BLI_INLINE bool hair_grid_point_valid(const float vec[3], const float gmin[3], const float gmax[3])
void SIM_hair_volume_grid_geometry(HairGrid *grid, float *cellsize, int res[3], float gmin[3], float gmax[3])
void SIM_hair_volume_free_vertex_grid(HairGrid *grid)
BLI_INLINE float hair_volume_density_divergence(float density, float target_density, float strength)
bool SIM_hair_volume_solve_divergence(HairGrid *grid, float, float target_density, float target_strength)
BLI_INLINE int hair_grid_offset(const float vec[3], const int res[3], const float gmin[3], float scale)
void SIM_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[3])
HairGrid * SIM_hair_volume_create_vertex_grid(float cellsize, const float gmin[3], const float gmax[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])
void SIM_hair_volume_normalize_vertex_grid(HairGrid *grid)
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])
#define MAX_HAIR_GRID_RES
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
struct ClothSimSettings * sim_parms