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-11-06 14:32:35 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2015-01-20 11:30:06 +0300
commite3dcbc36796fcf8b9c86a3d964a65966a4ad399e (patch)
tree9eba34f0a7ffc96185707b2163f3ed4c0b4303ab /source/blender/physics
parentdddf088375c78dd47675eeeb734a6380e50bd292 (diff)
Renamed HairVertexGrid to HairGrid, since it's not actually storing
hair vertex data. Conflicts: source/blender/physics/intern/BPH_mass_spring.cpp
Diffstat (limited to 'source/blender/physics')
-rw-r--r--source/blender/physics/intern/BPH_mass_spring.cpp41
-rw-r--r--source/blender/physics/intern/hair_volume.c32
-rw-r--r--source/blender/physics/intern/implicit.h24
3 files changed, 45 insertions, 52 deletions
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index 16828d83f6e..67042014971 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -590,19 +590,12 @@ static void cloth_calc_volume_force(ClothModifierData *clmd)
/* returns active vertexes' motion state, or original location the vertex is disabled */
BLI_INLINE bool cloth_get_grid_location(Implicit_Data *data, const float cell_scale[3], const float cell_offset[3],
- ClothVertex *vert, float x[3], float v[3])
+ ClothVertex *vert, int index, float x[3], float v[3])
{
bool is_motion_state;
- if (vert->solver_index < 0) {
- copy_v3_v3(x, vert->x);
- copy_v3_v3(v, vert->v);
- is_motion_state = false;
- }
- else {
- BPH_mass_spring_get_position(data, vert->solver_index, x);
- BPH_mass_spring_get_new_velocity(data, vert->solver_index, v);
- is_motion_state = true;
- }
+ BPH_mass_spring_get_position(data, index, x);
+ BPH_mass_spring_get_new_velocity(data, index, v);
+ is_motion_state = true;
mul_v3_v3(x, cell_scale);
add_v3_v3(x, cell_offset);
@@ -630,7 +623,7 @@ BLI_INLINE LinkNode *hair_spring_next(LinkNode *spring_link)
* (3,4), (2,3), (1,2)
* This is currently the only way to figure out hair geometry inside this code ...
*/
-static LinkNode *cloth_continuum_add_hair_segments(HairVertexGrid *grid, const float cell_scale[3], const float cell_offset[3], Cloth *cloth, LinkNode *spring_link)
+static LinkNode *cloth_continuum_add_hair_segments(HairGrid *grid, const float cell_scale[3], const float cell_offset[3], Cloth *cloth, LinkNode *spring_link)
{
Implicit_Data *data = cloth->implicit;
LinkNode *next_spring_link = NULL; /* return value */
@@ -650,9 +643,9 @@ static LinkNode *cloth_continuum_add_hair_segments(HairVertexGrid *grid, const f
zero_v3(dir2);
vert3 = &verts[spring3->kl];
- cloth_get_grid_location(data, cell_scale, cell_offset, vert3, x3, v3);
+ cloth_get_grid_location(data, cell_scale, cell_offset, vert3, spring3->kl, x3, v3);
vert4 = &verts[spring3->ij];
- cloth_get_grid_location(data, cell_scale, cell_offset, vert4, x4, v4);
+ cloth_get_grid_location(data, cell_scale, cell_offset, vert4, spring3->ij, x4, v4);
sub_v3_v3v3(dir3, x4, x3);
normalize_v3(dir3);
@@ -677,7 +670,7 @@ static LinkNode *cloth_continuum_add_hair_segments(HairVertexGrid *grid, const f
if (spring_link) {
spring3 = (ClothSpring *)spring_link->link;
vert4 = &verts[spring3->ij];
- cloth_get_grid_location(data, cell_scale, cell_offset, vert4, x4, v4);
+ cloth_get_grid_location(data, cell_scale, cell_offset, vert4, spring3->ij, x4, v4);
sub_v3_v3v3(dir3, x4, x3);
normalize_v3(dir3);
}
@@ -719,7 +712,7 @@ static LinkNode *cloth_continuum_add_hair_segments(HairVertexGrid *grid, const f
return next_spring_link;
}
-static void cloth_continuum_fill_grid(HairVertexGrid *grid, Cloth *cloth)
+static void cloth_continuum_fill_grid(HairGrid *grid, Cloth *cloth)
{
#if 0
Implicit_Data *data = cloth->implicit;
@@ -784,12 +777,12 @@ static void cloth_continuum_step(ClothModifierData *clmd)
/* gather velocities & density */
if (smoothfac > 0.0f || pressfac > 0.0f) {
- HairVertexGrid *vertex_grid = BPH_hair_volume_create_vertex_grid(clmd->sim_parms->voxel_res, gmin, gmax);
- BPH_hair_volume_set_debug_data(vertex_grid, clmd->debug_data);
+ HairGrid *grid = BPH_hair_volume_create_vertex_grid(clmd->sim_parms->voxel_res, gmin, gmax);
+ BPH_hair_volume_set_debug_data(grid, clmd->debug_data);
- BPH_hair_volume_grid_geometry(vertex_grid, cellsize, NULL, NULL, NULL);
+ BPH_hair_volume_grid_geometry(grid, cellsize, NULL, NULL, NULL);
- cloth_continuum_fill_grid(vertex_grid, cloth);
+ cloth_continuum_fill_grid(grid, cloth);
#if 0
/* apply velocity filter */
@@ -803,7 +796,7 @@ static void cloth_continuum_step(ClothModifierData *clmd)
BPH_mass_spring_get_position(data, i, x);
BPH_mass_spring_get_new_velocity(data, i, v);
- BPH_hair_volume_grid_velocity(vertex_grid, x, v, fluid_factor, nv);
+ BPH_hair_volume_grid_velocity(grid, x, v, fluid_factor, nv);
interp_v3_v3v3(nv, v, nv, smoothfac);
@@ -812,7 +805,7 @@ static void cloth_continuum_step(ClothModifierData *clmd)
}
/* 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_grid_geometry(grid, NULL, clmd->hair_grid_res, clmd->hair_grid_min, clmd->hair_grid_max);
#if 0 /* DEBUG hair velocity vector field */
{
@@ -849,7 +842,7 @@ static void cloth_continuum_step(ClothModifierData *clmd)
}
#endif
- BPH_hair_volume_free_vertex_grid(vertex_grid);
+ BPH_hair_volume_free_vertex_grid(grid);
}
}
@@ -1019,7 +1012,7 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
bool BPH_cloth_solver_get_texture_data(Object *UNUSED(ob), ClothModifierData *clmd, VoxelData *vd)
{
Cloth *cloth = clmd->clothObject;
- HairVertexGrid *grid;
+ HairGrid *grid;
float gmin[3], gmax[3];
if (!clmd->clothObject || !clmd->clothObject->implicit)
diff --git a/source/blender/physics/intern/hair_volume.c b/source/blender/physics/intern/hair_volume.c
index a1c6cb6602a..77c3af345c6 100644
--- a/source/blender/physics/intern/hair_volume.c
+++ b/source/blender/physics/intern/hair_volume.c
@@ -84,14 +84,14 @@ typedef struct HairGridVert {
float velocity_smooth[3];
} HairGridVert;
-typedef struct HairVertexGrid {
+typedef struct HairGrid {
HairGridVert *verts;
int res;
float gmin[3], gmax[3];
float scale[3];
struct SimDebugData *debug_data;
-} HairVertexGrid;
+} HairGrid;
#define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis) ( min_ii( max_ii( (int)((vec[axis] - gmin[axis]) / scale[axis]), 0), res-2 ) )
@@ -204,7 +204,7 @@ static void hair_velocity_collision(const HairGridVert *collgrid, const float gm
}
#endif
-void BPH_hair_volume_vertex_grid_forces(HairVertexGrid *grid, const float x[3], const float v[3],
+void BPH_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])
{
@@ -228,13 +228,13 @@ void BPH_hair_volume_vertex_grid_forces(HairVertexGrid *grid, const float x[3],
mul_m3_fl(dfdv, smoothfac);
}
-void BPH_hair_volume_grid_interpolate(HairVertexGrid *grid, const float x[3],
+void BPH_hair_volume_grid_interpolate(HairGrid *grid, const float x[3],
float *density, float velocity[3], float density_gradient[3], float velocity_gradient[3][3])
{
hair_grid_interpolate(grid->verts, grid->res, grid->gmin, grid->scale, x, density, velocity, density_gradient, velocity_gradient);
}
-void BPH_hair_volume_grid_velocity(HairVertexGrid *grid, const float x[3], const float v[3],
+void BPH_hair_volume_grid_velocity(HairGrid *grid, const float x[3], const float v[3],
float fluid_factor,
float r_v[3])
{
@@ -296,7 +296,7 @@ static int hair_grid_weights(int res, const float gmin[3], const float scale[3],
return offset;
}
-void BPH_hair_volume_add_vertex(HairVertexGrid *grid, const float x[3], const float v[3])
+void BPH_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[3])
{
int res = grid->res;
float weights[8];
@@ -345,7 +345,7 @@ BLI_INLINE int major_axis_v3(const float v[3])
return v[0] > v[1] ? (v[0] > v[2] ? 0 : 2) : (v[1] > v[2] ? 1 : 2);
}
-BLI_INLINE void grid_to_world(HairVertexGrid *grid, float vecw[3], const float vec[3])
+BLI_INLINE void grid_to_world(HairGrid *grid, float vecw[3], const float vec[3])
{
copy_v3_v3(vecw, vec);
mul_v3_v3(vecw, grid->scale);
@@ -359,7 +359,7 @@ BLI_INLINE void grid_to_world(HairVertexGrid *grid, float vecw[3], const float v
*
*
*/
-void BPH_hair_volume_add_segment(HairVertexGrid *grid,
+void BPH_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 dir2[3], const float UNUSED(dir3[3]))
@@ -483,7 +483,7 @@ void BPH_hair_volume_add_segment(HairVertexGrid *grid,
}
}
-void BPH_hair_volume_normalize_vertex_grid(HairVertexGrid *grid)
+void BPH_hair_volume_normalize_vertex_grid(HairGrid *grid)
{
int i, size = hair_grid_size(grid->res);
/* divide velocity with density */
@@ -565,11 +565,11 @@ void BPH_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid, int kernel_siz
}
#endif
-HairVertexGrid *BPH_hair_volume_create_vertex_grid(int res, const float gmin[3], const float gmax[3])
+HairGrid *BPH_hair_volume_create_vertex_grid(int res, const float gmin[3], const float gmax[3])
{
float cellsize[3], gmin_margin[3], gmax_margin[3];
int size;
- HairVertexGrid *grid;
+ HairGrid *grid;
int i;
/* original cell size, before adding margin */
@@ -581,7 +581,7 @@ HairVertexGrid *BPH_hair_volume_create_vertex_grid(int res, const float gmin[3],
sub_v3_v3v3(gmin_margin, gmin, cellsize);
add_v3_v3v3(gmax_margin, gmax, cellsize);
- grid = MEM_callocN(sizeof(HairVertexGrid), "hair vertex grid");
+ grid = MEM_callocN(sizeof(HairGrid), "hair grid");
grid->res = res;
copy_v3_v3(grid->gmin, gmin_margin);
copy_v3_v3(grid->gmax, gmax_margin);
@@ -597,7 +597,7 @@ HairVertexGrid *BPH_hair_volume_create_vertex_grid(int res, const float gmin[3],
return grid;
}
-void BPH_hair_volume_free_vertex_grid(HairVertexGrid *grid)
+void BPH_hair_volume_free_vertex_grid(HairGrid *grid)
{
if (grid) {
if (grid->verts)
@@ -606,12 +606,12 @@ void BPH_hair_volume_free_vertex_grid(HairVertexGrid *grid)
}
}
-void BPH_hair_volume_set_debug_data(HairVertexGrid *grid, SimDebugData *debug_data)
+void BPH_hair_volume_set_debug_data(HairGrid *grid, SimDebugData *debug_data)
{
grid->debug_data = debug_data;
}
-void BPH_hair_volume_grid_geometry(HairVertexGrid *grid, float cellsize[3], int res[3], float gmin[3], float gmax[3])
+void BPH_hair_volume_grid_geometry(HairGrid *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; }
@@ -691,7 +691,7 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
}
#endif
-bool BPH_hair_volume_get_texture_data(HairVertexGrid *grid, VoxelData *vd)
+bool BPH_hair_volume_get_texture_data(HairGrid *grid, VoxelData *vd)
{
int totres, i;
int depth;
diff --git a/source/blender/physics/intern/implicit.h b/source/blender/physics/intern/implicit.h
index 26f5ba3618f..eba2df411af 100644
--- a/source/blender/physics/intern/implicit.h
+++ b/source/blender/physics/intern/implicit.h
@@ -165,35 +165,35 @@ bool BPH_mass_spring_force_spring_goal(struct Implicit_Data *data, int i, const
/* ======== Hair Volumetric Forces ======== */
-struct HairVertexGrid;
+struct HairGrid;
struct Object;
struct VoxelData;
-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_set_debug_data(struct HairVertexGrid *grid, struct SimDebugData *debug_data);
-void BPH_hair_volume_grid_geometry(struct HairVertexGrid *grid, float cellsize[3], int res[3], float gmin[3], float gmax[3]);
+struct HairGrid *BPH_hair_volume_create_vertex_grid(int res, const float gmin[3], const float gmax[3]);
+void BPH_hair_volume_free_vertex_grid(struct HairGrid *grid);
+void BPH_hair_volume_set_debug_data(struct HairGrid *grid, struct SimDebugData *debug_data);
+void BPH_hair_volume_grid_geometry(struct HairGrid *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_add_segment(struct HairVertexGrid *grid,
+void BPH_hair_volume_add_vertex(struct HairGrid *grid, const float x[3], const float v[3]);
+void BPH_hair_volume_add_segment(struct HairGrid *grid,
const float x1[3], const float v1[3], const float x2[3], const float v2[3],
const float x3[3], const float v3[3], const float x4[3], const float v4[3],
const float dir1[3], const float dir2[3], const float dir3[3]);
-void BPH_hair_volume_normalize_vertex_grid(struct HairVertexGrid *grid);
+void BPH_hair_volume_normalize_vertex_grid(struct HairGrid *grid);
#if 0 /* XXX weighting is incorrect, disabled for now */
void BPH_hair_volume_vertex_grid_filter_box(struct HairVertexGrid *grid, int kernel_size);
#endif
-void BPH_hair_volume_grid_interpolate(struct HairVertexGrid *grid, const float x[3],
+void BPH_hair_volume_grid_interpolate(struct HairGrid *grid, const float x[3],
float *density, float velocity[3], float density_gradient[3], float velocity_gradient[3][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)
*/
-void BPH_hair_volume_grid_velocity(struct HairVertexGrid *grid, const float x[3], const float v[3],
+void BPH_hair_volume_grid_velocity(struct HairGrid *grid, const float x[3], const float v[3],
float fluid_factor,
float r_v[3]);
/* XXX Warning: expressing grid effects on velocity as a force is not very stable,
@@ -202,11 +202,11 @@ void BPH_hair_volume_grid_velocity(struct HairVertexGrid *grid, const float x[3]
* "Detail Preserving Continuum Simulation of Straight Hair"
* (McAdams, Selle 2009)
*/
-void BPH_hair_volume_vertex_grid_forces(struct HairVertexGrid *grid, const float x[3], const float v[3],
+void BPH_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]);
-bool BPH_hair_volume_get_texture_data(struct HairVertexGrid *grid, struct VoxelData *vd);
+bool BPH_hair_volume_get_texture_data(struct HairGrid *grid, struct VoxelData *vd);
#ifdef __cplusplus
}