From be24adc9ef6a73aa9e0f06da6014911e6a8a80d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Sat, 8 Nov 2014 19:34:16 +0100 Subject: Implemented PIC and FLIP methods for combining the fluid grid simulation with the Lagrangian hair model. --- source/blender/physics/intern/hair_volume.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/blender/physics') diff --git a/source/blender/physics/intern/hair_volume.cpp b/source/blender/physics/intern/hair_volume.cpp index cd4e6503965..f59df71d7e9 100644 --- a/source/blender/physics/intern/hair_volume.cpp +++ b/source/blender/physics/intern/hair_volume.cpp @@ -220,11 +220,18 @@ void BPH_hair_volume_grid_velocity(HairGrid *grid, const float x[3], const float float r_v[3]) { float gdensity, gvelocity[3], gvel_smooth[3], ggrad[3], gvelgrad[3][3]; + float v_pic[3], v_flip[3]; hair_grid_interpolate(grid->verts, grid->res, grid->gmin, grid->inv_cellsize, x, &gdensity, gvelocity, gvel_smooth, ggrad, gvelgrad); - /* XXX TODO implement FLIP method and use fluid_factor to blend between FLIP and PIC */ - copy_v3_v3(r_v, gvel_smooth); + /* velocity according to PIC method (Particle-in-Cell) */ + copy_v3_v3(v_pic, gvel_smooth); + + /* velocity according to FLIP method (Fluid-Implicit-Particle) */ + sub_v3_v3v3(v_flip, gvel_smooth, gvelocity); + add_v3_v3(v_flip, v); + + interp_v3_v3v3(r_v, v_pic, v_flip, fluid_factor); } void BPH_hair_volume_grid_clear(HairGrid *grid) -- cgit v1.2.3