diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-11-13 18:06:39 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-01-20 11:30:07 +0300 |
commit | b3cbafb96630c370d1750fc8cb59053ddae0d6f2 (patch) | |
tree | ad196084618e3f631656751a27da1b03006f6930 /source/blender/physics/intern/BPH_mass_spring.cpp | |
parent | a754c0af4088aaa7d1799351db1d03b9250a0d2e (diff) |
Implementation of a target density feature for the hair simulation.
This allows setting a target density which the fluid simulation will
take into account as an additional term in the pressure Poisson
equation. Based on two papers
"Detail Preserving Continuum Simulation of Straight Hair" (McAdams et al. 2009)
and
"Two-way Coupled SPH and Particle Level Set Fluid Simulation" (Losasso et al. 2008)
Currently the target pressure is specified directly, but it will be
a lot more convenient to define this in terms of a geometric value such
as "number of hairs per area" (combined with hair "thickness").
Conflicts:
source/blender/physics/intern/BPH_mass_spring.cpp
Diffstat (limited to 'source/blender/physics/intern/BPH_mass_spring.cpp')
-rw-r--r-- | source/blender/physics/intern/BPH_mass_spring.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp index a20f1617505..d911a431b23 100644 --- a/source/blender/physics/intern/BPH_mass_spring.cpp +++ b/source/blender/physics/intern/BPH_mass_spring.cpp @@ -1017,8 +1017,8 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt) const float fluid_factor = 0.95f; /* blend between PIC and FLIP methods */
float smoothfac = parms->velocity_smooth;
- float pressfac = parms->pressure;
- float minpress = parms->pressure_threshold;
+ float denstarget = parms->density_target;
+ float densfac = parms->density_strength;
float gmin[3], gmax[3];
int i;
@@ -1030,14 +1030,15 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt) hair_get_boundbox(clmd, gmin, gmax);
/* gather velocities & density */
- if (smoothfac > 0.0f || pressfac > 0.0f) {
+ if (smoothfac > 0.0f || densfac > 0.0f) {
HairGrid *grid = BPH_hair_volume_create_vertex_grid(clmd->sim_parms->voxel_cell_size, gmin, gmax);
BPH_hair_volume_set_debug_data(grid, clmd->debug_data);
+// BPH_hair_volume_set_debug_value(grid, (int)(spring2->ij == clmd->sim_parms->density_target));
cloth_continuum_fill_grid(grid, cloth);
/* main hair continuum solver */
- BPH_hair_volume_solve_divergence(grid, dt);
+ BPH_hair_volume_solve_divergence(grid, dt, denstarget, densfac);
for (i = 0, vert = cloth->verts; i < numverts; i++, vert++) {
float x[3], v[3], nv[3];
|