From b3cbafb96630c370d1750fc8cb59053ddae0d6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Thu, 13 Nov 2014 16:06:39 +0100 Subject: 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 --- source/blender/physics/intern/BPH_mass_spring.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/physics/intern/BPH_mass_spring.cpp') 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]; -- cgit v1.2.3