Blender
V3.3
|
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "DNA_texture_types.h"
#include "BKE_effect.h"
#include "eigen_utils.h"
#include "implicit.h"
Go to the source code of this file.
Classes | |
struct | HairGridVert |
struct | HairGrid |
Macros | |
#define | HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis) (min_ii(max_ii((int)((vec[axis] - gmin[axis]) * scale), 0), res[axis] - 2)) |
#define | MARGIN_i0 (i < 1) |
#define | MARGIN_j0 (j < 1) |
#define | MARGIN_k0 (k < 1) |
#define | MARGIN_i1 (i >= resA[0] - 1) |
#define | MARGIN_j1 (j >= resA[1] - 1) |
#define | MARGIN_k1 (k >= resA[2] - 1) |
#define | NEIGHBOR_MARGIN_i0 (i < 2) |
#define | NEIGHBOR_MARGIN_j0 (j < 2) |
#define | NEIGHBOR_MARGIN_k0 (k < 2) |
#define | NEIGHBOR_MARGIN_i1 (i >= resA[0] - 2) |
#define | NEIGHBOR_MARGIN_j1 (j >= resA[1] - 2) |
#define | NEIGHBOR_MARGIN_k1 (k >= resA[2] - 2) |
Functions | |
BLI_INLINE int | floor_int (float value) |
BLI_INLINE float | floor_mod (float value) |
BLI_INLINE int | hair_grid_size (const int res[3]) |
BLI_INLINE int | hair_grid_offset (const float vec[3], const int res[3], const float gmin[3], float scale) |
BLI_INLINE int | hair_grid_interp_weights (const int res[3], const float gmin[3], float scale, const float vec[3], float uvw[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_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 | 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]) |
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_clear (HairGrid *grid) |
BLI_INLINE bool | hair_grid_point_valid (const float vec[3], const float gmin[3], const float gmax[3]) |
BLI_INLINE float | dist_tent_v3f3 (const float a[3], float x, float y, float z) |
BLI_INLINE float | weights_sum (const float weights[8]) |
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 | grid_to_world (HairGrid *grid, float vecw[3], const float vec[3]) |
void | SIM_hair_volume_add_vertex (HairGrid *grid, const float x[3], const float v[3]) |
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]) |
void | SIM_hair_volume_add_segment (HairGrid *grid, const float UNUSED(x1[3]), const float UNUSED(v1[3]), const float x2[3], const float v2[3], const float x3[3], const float v3[3], const float UNUSED(x4[3]), const float UNUSED(v4[3]), const float UNUSED(dir1[3]), const float UNUSED(dir2[3]), const float UNUSED(dir3[3])) |
void | SIM_hair_volume_normalize_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) |
HairGrid * | SIM_hair_volume_create_vertex_grid (float cellsize, const float gmin[3], const float gmax[3]) |
void | SIM_hair_volume_free_vertex_grid (HairGrid *grid) |
void | SIM_hair_volume_grid_geometry (HairGrid *grid, float *cellsize, int res[3], float gmin[3], float gmax[3]) |
Variables | |
static float | I [3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}} |
static const float | density_threshold = 0.001f |
#define HAIR_GRID_INDEX_AXIS | ( | vec, | |
res, | |||
gmin, | |||
scale, | |||
axis | |||
) | (min_ii(max_ii((int)((vec[axis] - gmin[axis]) * scale), 0), res[axis] - 2)) |
Definition at line 70 of file hair_volume.cpp.
#define MARGIN_i0 (i < 1) |
#define MARGIN_i1 (i >= resA[0] - 1) |
#define MARGIN_j0 (j < 1) |
#define MARGIN_j1 (j >= resA[1] - 1) |
#define MARGIN_k0 (k < 1) |
#define MARGIN_k1 (k >= resA[2] - 1) |
#define NEIGHBOR_MARGIN_i0 (i < 2) |
#define NEIGHBOR_MARGIN_i1 (i >= resA[0] - 2) |
#define NEIGHBOR_MARGIN_j0 (j < 2) |
#define NEIGHBOR_MARGIN_j1 (j >= resA[1] - 2) |
#define NEIGHBOR_MARGIN_k0 (k < 2) |
#define NEIGHBOR_MARGIN_k1 (k >= resA[2] - 2) |
Definition at line 298 of file hair_volume.cpp.
References Freestyle::a, fabsf, w(), x, y, and z.
Referenced by hair_grid_weights().
BLI_INLINE int floor_int | ( | float | value | ) |
Definition at line 40 of file hair_volume.cpp.
Referenced by SIM_hair_volume_add_segment(), and SIM_hair_volume_create_vertex_grid().
BLI_INLINE float floor_mod | ( | float | value | ) |
Definition at line 45 of file hair_volume.cpp.
References floorf.
BLI_INLINE void grid_to_world | ( | HairGrid * | grid, |
float | vecw[3], | ||
const float | vec[3] | ||
) |
Definition at line 344 of file hair_volume.cpp.
References add_v3_v3(), HairGrid::cellsize, copy_v3_v3(), HairGrid::gmin, and mul_v3_fl().
Referenced by SIM_hair_volume_solve_divergence().
BLI_INLINE int hair_grid_interp_weights | ( | const int | res[3], |
const float | gmin[3], | ||
float | scale, | ||
const float | vec[3], | ||
float | uvw[3] | ||
) |
Definition at line 85 of file hair_volume.cpp.
References BLI_assert, HAIR_GRID_INDEX_AXIS, and offset.
Referenced by hair_grid_interpolate().
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] | ||
) |
Definition at line 108 of file hair_volume.cpp.
References data, usdtokens::density(), hair_grid_interp_weights(), offset, and zero_m3().
Referenced by SIM_hair_volume_grid_interpolate(), SIM_hair_volume_grid_velocity(), and SIM_hair_volume_vertex_grid_forces().
BLI_INLINE int hair_grid_offset | ( | const float | vec[3], |
const int | res[3], | ||
const float | gmin[3], | ||
float | scale | ||
) |
Definition at line 73 of file hair_volume.cpp.
References HAIR_GRID_INDEX_AXIS.
BLI_INLINE bool hair_grid_point_valid | ( | const float | vec[3], |
const float | gmin[3], | ||
const float | gmax[3] | ||
) |
Definition at line 292 of file hair_volume.cpp.
Referenced by SIM_hair_volume_add_vertex().
BLI_INLINE int hair_grid_size | ( | const int | res[3] | ) |
Definition at line 50 of file hair_volume.cpp.
Referenced by SIM_hair_volume_create_vertex_grid(), SIM_hair_volume_grid_clear(), and SIM_hair_volume_normalize_vertex_grid().
BLI_INLINE int hair_grid_weights | ( | const int | res[3], |
const float | gmin[3], | ||
float | scale, | ||
const float | vec[3], | ||
float | weights[8] | ||
) |
Definition at line 315 of file hair_volume.cpp.
References dist_tent_v3f3(), HAIR_GRID_INDEX_AXIS, and offset.
Referenced by SIM_hair_volume_add_vertex().
BLI_INLINE float hair_volume_density_divergence | ( | float | density, |
float | target_density, | ||
float | strength | ||
) |
Definition at line 693 of file hair_volume.cpp.
References usdtokens::density(), density_threshold, and logf.
Referenced by SIM_hair_volume_solve_divergence().
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] | ||
) |
Definition at line 600 of file hair_volume.cpp.
References HairGridVert::density, len_v3v3(), madd_v3_v3fl(), HairGridVert::samples, v, HairGridVert::velocity, and x.
Referenced by SIM_hair_volume_add_segment().
void SIM_hair_volume_add_segment | ( | HairGrid * | grid, |
const float | UNUSEDx1[3], | ||
const float | UNUSEDv1[3], | ||
const float | x2[3], | ||
const float | v2[3], | ||
const float | x3[3], | ||
const float | v3[3], | ||
const float | UNUSEDx4[3], | ||
const float | UNUSEDv4[3], | ||
const float | UNUSEDdir1[3], | ||
const float | UNUSEDdir2[3], | ||
const float | UNUSEDdir3[3] | ||
) |
Definition at line 620 of file hair_volume.cpp.
References float(), floor_int(), hair_volume_eval_grid_vertex_sample(), interp_v3_v3v3(), HairGrid::inv_cellsize, max_ii(), min_ii(), num_samples, HairGrid::res, stride, v, v2, HairGrid::verts, x, and x2.
Referenced by cloth_continuum_add_hair_segments().
Definition at line 351 of file hair_volume.cpp.
References HairGridVert::density, HairGrid::gmax, HairGrid::gmin, hair_grid_point_valid(), hair_grid_weights(), HairGrid::inv_cellsize, madd_v3_v3fl(), offset, HairGrid::res, v, HairGridVert::velocity, HairGrid::verts, and x.
Referenced by cloth_continuum_fill_grid().
HairGrid* SIM_hair_volume_create_vertex_grid | ( | float | cellsize, |
const float | gmin[3], | ||
const float | gmax[3] | ||
) |
Definition at line 1103 of file hair_volume.cpp.
References HairGrid::cellsize, copy_v3_v3(), float(), floor_int(), HairGrid::gmax, HairGrid::gmin, hair_grid_size(), HairGrid::inv_cellsize, MAX_HAIR_GRID_RES, MEM_callocN, HairGrid::res, size(), sub_v3_v3v3(), and HairGrid::verts.
Referenced by cloth_continuum_step().
Definition at line 1160 of file hair_volume.cpp.
References MEM_freeN, and HairGrid::verts.
Referenced by cloth_continuum_step().
Definition at line 280 of file hair_volume.cpp.
References HairGridVert::density, hair_grid_size(), HairGrid::res, HairGridVert::samples, size(), HairGridVert::velocity, HairGridVert::velocity_smooth, HairGrid::verts, and zero_v3().
void SIM_hair_volume_grid_geometry | ( | HairGrid * | grid, |
float * | cellsize, | ||
int | res[3], | ||
float | gmin[3], | ||
float | gmax[3] | ||
) |
Definition at line 1170 of file hair_volume.cpp.
References HairGrid::cellsize, copy_v3_v3(), copy_v3_v3_int(), HairGrid::gmax, HairGrid::gmin, and HairGrid::res.
Referenced by cloth_continuum_fill_grid(), and cloth_continuum_step().
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] | ||
) |
Definition at line 233 of file hair_volume.cpp.
References usdtokens::density(), HairGrid::gmin, hair_grid_interpolate(), HairGrid::inv_cellsize, HairGrid::res, HairGrid::verts, and x.
Referenced by cloth_continuum_step().
void SIM_hair_volume_grid_velocity | ( | struct HairGrid * | grid, |
const float | x[3], | ||
const float | v[3], | ||
float | fluid_factor, | ||
float | r_v[3] | ||
) |
Effect of fluid simulation grid on velocities. fluid_factor controls blending between PIC (Particle-in-Cell) and FLIP (Fluid-Implicit-Particle) methods (0 = only PIC, 1 = only FLIP)
Definition at line 253 of file hair_volume.cpp.
References add_v3_v3(), copy_v3_v3(), HairGrid::gmin, hair_grid_interpolate(), interp_v3_v3v3(), HairGrid::inv_cellsize, HairGrid::res, sub_v3_v3v3(), v, HairGrid::verts, and x.
Referenced by cloth_continuum_step().
Definition at line 674 of file hair_volume.cpp.
References usdtokens::density(), HairGridVert::density, hair_grid_size(), mul_v3_fl(), HairGrid::res, size(), HairGridVert::velocity, and HairGrid::verts.
Referenced by cloth_continuum_fill_grid().
bool SIM_hair_volume_solve_divergence | ( | HairGrid * | grid, |
float | dt, | ||
float | target_density, | ||
float | target_strength | ||
) |
Definition at line 704 of file hair_volume.cpp.
References A, add_v3_v3v3(), B, BKE_sim_debug_data_add_circle, BKE_sim_debug_data_add_dot, BKE_sim_debug_data_add_vector, BLI_assert, HairGrid::cellsize, CLAMPIS, col, usdtokens::density(), HairGridVert::density, density_threshold, float(), HairGrid::gmin, grid_to_world(), hair_volume_density_divergence(), interp_v3_v3v3(), MARGIN_i0, MARGIN_i1, MARGIN_j0, MARGIN_j1, MARGIN_k0, MARGIN_k1, mul_v3_fl(), NEIGHBOR_MARGIN_i0, NEIGHBOR_MARGIN_i1, NEIGHBOR_MARGIN_j0, NEIGHBOR_MARGIN_j1, NEIGHBOR_MARGIN_k0, NEIGHBOR_MARGIN_k1, offset, HairGrid::res, sub_v3_v3v3(), HairGridVert::velocity, HairGridVert::velocity_smooth, HairGrid::verts, and zero_v3().
Referenced by cloth_continuum_step().
void SIM_hair_volume_vertex_grid_forces | ( | struct 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] | ||
) |
WARNING: expressing grid effects on velocity as a force is not very stable, due to discontinuities in interpolated values! Better use hybrid approaches such as described in "Detail Preserving Continuum Simulation of Straight Hair" (McAdams, Selle 2009)
Definition at line 194 of file hair_volume.cpp.
References HairGrid::gmin, hair_grid_interpolate(), I, HairGrid::inv_cellsize, madd_v3_v3fl(), mul_m3_fl(), mul_v3_fl(), mul_v3_v3fl(), normalize_v3(), HairGrid::res, sub_m3_m3m3(), sub_v3_v3(), v, HairGrid::verts, x, zero_m3(), and zero_v3().
BLI_INLINE float weights_sum | ( | const float | weights[8] | ) |
Definition at line 304 of file hair_volume.cpp.
|
static |
Definition at line 687 of file hair_volume.cpp.
Referenced by hair_volume_density_divergence(), and SIM_hair_volume_solve_divergence().
|
static |
Definition at line 38 of file hair_volume.cpp.
Referenced by SIM_hair_volume_vertex_grid_forces().