Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Tönne <lukas.toenne@gmail.com>2014-10-31 16:23:32 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2015-01-20 11:30:05 +0300
commitc3968861b3e5a81e138003cca2b51a040a0ed454 (patch)
treec197df6f86c76ead3e76c9b3f4fc7caa0f4b584d /source/blender/physics
parentaea309779f631e4f0bb6fa2a38f39d4f4db4de97 (diff)
Debug drawing feature to visualize the hair continuum grid.
Diffstat (limited to 'source/blender/physics')
-rw-r--r--source/blender/physics/intern/BPH_mass_spring.cpp8
-rw-r--r--source/blender/physics/intern/hair_volume.c34
-rw-r--r--source/blender/physics/intern/implicit.h1
3 files changed, 40 insertions, 3 deletions
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index 821b08ce334..55475d06d8d 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -601,6 +601,11 @@ static void cloth_continuum_step(ClothModifierData *clmd)
float gmin[3], gmax[3];
int i;
+ /* clear grid info */
+ zero_v3_int(clmd->hair_grid_res);
+ zero_v3(clmd->hair_grid_min);
+ zero_v3(clmd->hair_grid_max);
+
hair_get_boundbox(clmd, gmin, gmax);
/* gather velocities & density */
@@ -637,6 +642,9 @@ static void cloth_continuum_step(ClothModifierData *clmd)
BPH_mass_spring_set_new_velocity(data, i, nv);
}
+ /* store basic grid info in the modifier data */
+ BPH_hair_volume_grid_geometry(vertex_grid, NULL, clmd->hair_grid_res, clmd->hair_grid_min, clmd->hair_grid_max);
+
BPH_hair_volume_free_vertex_grid(vertex_grid);
}
}
diff --git a/source/blender/physics/intern/hair_volume.c b/source/blender/physics/intern/hair_volume.c
index 87f202bbb2c..b5c41880268 100644
--- a/source/blender/physics/intern/hair_volume.c
+++ b/source/blender/physics/intern/hair_volume.c
@@ -38,9 +38,14 @@
/* ================ Volumetric Hair Interaction ================
* adapted from
- * Volumetric Methods for Simulation and Rendering of Hair
- * by Lena Petrovic, Mark Henne and John Anderson
- * Pixar Technical Memo #06-08, Pixar Animation Studios
+ *
+ * Volumetric Methods for Simulation and Rendering of Hair
+ * (Petrovic, Henne, Anderson, Pixar Technical Memo #06-08, Pixar Animation Studios)
+ *
+ * as well as
+ *
+ * "Detail Preserving Continuum Simulation of Straight Hair"
+ * (McAdams, Selle 2009)
*/
/* Note about array indexing:
@@ -113,6 +118,10 @@ BLI_INLINE int hair_grid_interp_weights(int res, const float gmin[3], const floa
uvw[1] = (vec[1] - gmin[1]) / scale[1] - (float)j;
uvw[2] = (vec[2] - gmin[2]) / scale[2] - (float)k;
+// BLI_assert(0.0f <= uvw[0] && uvw[0] <= 1.0001f);
+// BLI_assert(0.0f <= uvw[1] && uvw[1] <= 1.0001f);
+// BLI_assert(0.0f <= uvw[2] && uvw[2] <= 1.0001f);
+
return offset;
}
@@ -244,6 +253,15 @@ BLI_INLINE float dist_tent_v3f3(const float a[3], float x, float y, float z)
return w;
}
+BLI_INLINE float weights_sum(const float weights[8])
+{
+ float totweight = 0.0f;
+ int i;
+ for (i = 0; i < 8; ++i)
+ totweight += weights[i];
+ return totweight;
+}
+
/* returns the grid array offset as well to avoid redundant calculation */
static int hair_grid_weights(int res, const float gmin[3], const float scale[3], const float vec[3], float weights[8])
{
@@ -268,6 +286,8 @@ static int hair_grid_weights(int res, const float gmin[3], const float scale[3],
weights[6] = dist_tent_v3f3(uvw, (float)i , (float)(j+1), (float)(k+1));
weights[7] = dist_tent_v3f3(uvw, (float)(i+1), (float)(j+1), (float)(k+1));
+// BLI_assert(fabsf(weights_sum(weights) - 1.0f) < 0.0001f);
+
return offset;
}
@@ -409,6 +429,14 @@ void BPH_hair_volume_free_vertex_grid(HairVertexGrid *grid)
}
}
+void BPH_hair_volume_grid_geometry(HairVertexGrid *grid, float cellsize[3], int res[3], float gmin[3], float gmax[3])
+{
+ if (cellsize) copy_v3_v3(cellsize, grid->scale);
+ if (res) { res[0] = res[1] = res[2] = grid->res; }
+ if (gmin) copy_v3_v3(gmin, grid->gmin);
+ if (gmax) copy_v3_v3(gmax, grid->gmax);
+}
+
#if 0
static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd, lfVector *lX, unsigned int numverts)
{
diff --git a/source/blender/physics/intern/implicit.h b/source/blender/physics/intern/implicit.h
index 012125b4c87..9ec7e763415 100644
--- a/source/blender/physics/intern/implicit.h
+++ b/source/blender/physics/intern/implicit.h
@@ -170,6 +170,7 @@ struct HairColliderGrid;
struct HairVertexGrid *BPH_hair_volume_create_vertex_grid(int res, const float gmin[3], const float gmax[3]);
void BPH_hair_volume_free_vertex_grid(struct HairVertexGrid *grid);
+void BPH_hair_volume_grid_geometry(struct HairVertexGrid *grid, float cellsize[3], int res[3], float gmin[3], float gmax[3]);
void BPH_hair_volume_add_vertex(struct HairVertexGrid *grid, const float x[3], const float v[3]);
void BPH_hair_volume_normalize_vertex_grid(struct HairVertexGrid *grid);