diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-16 15:37:21 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-16 15:37:21 +0300 |
commit | 9b6088cb9da4df1a893361997fc1a22986bf6f2e (patch) | |
tree | d5536a6fb7808f0b20e5c70ff993f9b4220593fd /source/blender/simulation/intern | |
parent | 9363c4de0635394548fa2eb8d205581313029775 (diff) |
Simulation: Change BPH prefix to SIM
In a previous commit the `physics` folder has been renamed to `simulation`.
This commit updates the function/file prefix accordingly.
Diffstat (limited to 'source/blender/simulation/intern')
-rw-r--r-- | source/blender/simulation/intern/SIM_mass_spring.cpp (renamed from source/blender/simulation/intern/BPH_mass_spring.cpp) | 156 | ||||
-rw-r--r-- | source/blender/simulation/intern/hair_volume.cpp | 26 | ||||
-rw-r--r-- | source/blender/simulation/intern/implicit.h | 96 | ||||
-rw-r--r-- | source/blender/simulation/intern/implicit_blender.c | 94 | ||||
-rw-r--r-- | source/blender/simulation/intern/implicit_eigen.cpp | 70 |
5 files changed, 221 insertions, 221 deletions
diff --git a/source/blender/simulation/intern/BPH_mass_spring.cpp b/source/blender/simulation/intern/SIM_mass_spring.cpp index 051f11aa1d9..4834d6d351c 100644 --- a/source/blender/simulation/intern/BPH_mass_spring.cpp +++ b/source/blender/simulation/intern/SIM_mass_spring.cpp @@ -38,7 +38,7 @@ #include "BKE_collision.h" #include "BKE_effect.h" -#include "BPH_mass_spring.h" +#include "SIM_mass_spring.h" #include "implicit.h" #include "DEG_depsgraph.h" @@ -104,7 +104,7 @@ static void cloth_calc_pressure_gradient(ClothModifierData *clmd, float pt[3]; for (unsigned int i = 0; i < mvert_num; i++) { - BPH_mass_spring_get_position(data, i, pt); + SIM_mass_spring_get_position(data, i, pt); r_vertex_pressure[i] = dot_v3v3(pt, gradient_vector); } } @@ -127,7 +127,7 @@ static float cloth_calc_volume(ClothModifierData *clmd) const MVertTri *vt = &tri[i]; if (cloth_get_pressure_weights(clmd, vt, weights)) { - vol += BPH_tri_tetra_volume_signed_6x(data, vt->tri[0], vt->tri[1], vt->tri[2]); + vol += SIM_tri_tetra_volume_signed_6x(data, vt->tri[0], vt->tri[1], vt->tri[2]); } } @@ -179,7 +179,7 @@ static float cloth_calc_average_pressure(ClothModifierData *clmd, const float *v const MVertTri *vt = &tri[i]; if (cloth_get_pressure_weights(clmd, vt, weights)) { - float area = BPH_tri_area(data, vt->tri[0], vt->tri[1], vt->tri[2]); + float area = SIM_tri_area(data, vt->tri[0], vt->tri[1], vt->tri[2]); total_force += (vertex_pressure[vt->tri[0]] + vertex_pressure[vt->tri[1]] + vertex_pressure[vt->tri[2]]) * @@ -191,7 +191,7 @@ static float cloth_calc_average_pressure(ClothModifierData *clmd, const float *v return total_force / total_area; } -int BPH_cloth_solver_init(Object *UNUSED(ob), ClothModifierData *clmd) +int SIM_cloth_solver_init(Object *UNUSED(ob), ClothModifierData *clmd) { Cloth *cloth = clmd->clothObject; ClothVertex *verts = cloth->verts; @@ -200,30 +200,30 @@ int BPH_cloth_solver_init(Object *UNUSED(ob), ClothModifierData *clmd) unsigned int i, nondiag; nondiag = cloth_count_nondiag_blocks(cloth); - cloth->implicit = id = BPH_mass_spring_solver_create(cloth->mvert_num, nondiag); + cloth->implicit = id = SIM_mass_spring_solver_create(cloth->mvert_num, nondiag); for (i = 0; i < cloth->mvert_num; i++) { - BPH_mass_spring_set_vertex_mass(id, i, verts[i].mass); + SIM_mass_spring_set_vertex_mass(id, i, verts[i].mass); } for (i = 0; i < cloth->mvert_num; i++) { - BPH_mass_spring_set_motion_state(id, i, verts[i].x, ZERO); + SIM_mass_spring_set_motion_state(id, i, verts[i].x, ZERO); } return 1; } -void BPH_cloth_solver_free(ClothModifierData *clmd) +void SIM_cloth_solver_free(ClothModifierData *clmd) { Cloth *cloth = clmd->clothObject; if (cloth->implicit) { - BPH_mass_spring_solver_free(cloth->implicit); + SIM_mass_spring_solver_free(cloth->implicit); cloth->implicit = NULL; } } -void BKE_cloth_solver_set_positions(ClothModifierData *clmd) +void SIM_cloth_solver_set_positions(ClothModifierData *clmd) { Cloth *cloth = clmd->clothObject; ClothVertex *verts = cloth->verts; @@ -234,17 +234,17 @@ void BKE_cloth_solver_set_positions(ClothModifierData *clmd) for (i = 0; i < mvert_num; i++) { if (cloth_hairdata) { ClothHairData *root = &cloth_hairdata[i]; - BPH_mass_spring_set_rest_transform(id, i, root->rot); + SIM_mass_spring_set_rest_transform(id, i, root->rot); } else { - BPH_mass_spring_set_rest_transform(id, i, I3); + SIM_mass_spring_set_rest_transform(id, i, I3); } - BPH_mass_spring_set_motion_state(id, i, verts[i].x, verts[i].v); + SIM_mass_spring_set_motion_state(id, i, verts[i].x, verts[i].v); } } -void BKE_cloth_solver_set_volume(ClothModifierData *clmd) +void SIM_cloth_solver_set_volume(ClothModifierData *clmd) { Cloth *cloth = clmd->clothObject; @@ -265,12 +265,12 @@ static void cloth_setup_constraints(ClothModifierData *clmd) const float ZERO[3] = {0.0f, 0.0f, 0.0f}; - BPH_mass_spring_clear_constraints(data); + SIM_mass_spring_clear_constraints(data); for (v = 0; v < mvert_num; v++) { if (verts[v].flags & CLOTH_VERT_FLAG_PINNED) { /* pinned vertex constraints */ - BPH_mass_spring_add_constraint_ndof0(data, v, ZERO); /* velocity is defined externally */ + SIM_mass_spring_add_constraint_ndof0(data, v, ZERO); /* velocity is defined externally */ } verts[v].impulse_count = 0; @@ -388,7 +388,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) k = scaling * s->restlen * 0.1f; /* Multiplying by 0.1, just to scale the forces to more reasonable values. */ - BPH_mass_spring_force_spring_angular( + SIM_mass_spring_force_spring_angular( data, s->ij, s->kl, s->pa, s->pb, s->la, s->lb, s->restang, k, parms->bending_damping); #endif } @@ -409,7 +409,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) /* TODO: verify, half verified (couldn't see error) * sewing springs usually have a large distance at first so clamp the force so we don't get * tunneling through collision objects. */ - BPH_mass_spring_force_spring_linear(data, + SIM_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, @@ -427,7 +427,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) s->lin_stiffness * fabsf(parms->max_compression - parms->compression); k_compression = scaling_compression / (parms->avg_spring_len + FLT_EPSILON); - BPH_mass_spring_force_spring_linear(data, + SIM_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, @@ -465,7 +465,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) k_compression_damp = 0.0f; } - BPH_mass_spring_force_spring_linear(data, + SIM_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, @@ -488,7 +488,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) scaling = parms->shear + s->lin_stiffness * fabsf(parms->max_shear - parms->shear); k = scaling / (parms->avg_spring_len + FLT_EPSILON); - BPH_mass_spring_force_spring_linear(data, + SIM_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, @@ -513,7 +513,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) // Fix for [#45084] for cloth stiffness must have cb proportional to kb cb = kb * parms->bending_damping; - BPH_mass_spring_force_spring_bending(data, s->ij, s->kl, s->restlen, kb, cb); + SIM_mass_spring_force_spring_bending(data, s->ij, s->kl, s->restlen, kb, cb); #endif } else if (s->type & CLOTH_SPRING_TYPE_BENDING_HAIR) { @@ -534,14 +534,14 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) /* XXX assuming same restlen for ij and jk segments here, * this can be done correctly for hair later. */ - BPH_mass_spring_force_spring_bending_hair(data, s->ij, s->kl, s->mn, s->target, kb, cb); + SIM_mass_spring_force_spring_bending_hair(data, s->ij, s->kl, s->mn, s->target, kb, cb); # if 0 { float x_kl[3], x_mn[3], v[3], d[3]; - BPH_mass_spring_get_motion_state(data, s->kl, x_kl, v); - BPH_mass_spring_get_motion_state(data, s->mn, x_mn, v); + SIM_mass_spring_get_motion_state(data, s->kl, x_kl, v); + SIM_mass_spring_get_motion_state(data, s->mn, x_mn, v); BKE_sim_debug_data_add_dot(clmd->debug_data, x_kl, 0.9, 0.9, 0.9, "target", 7980, s->kl); BKE_sim_debug_data_add_line( @@ -569,7 +569,7 @@ static void hair_get_boundbox(ClothModifierData *clmd, float gmin[3], float gmax INIT_MINMAX(gmin, gmax); for (i = 0; i < mvert_num; i++) { float x[3]; - BPH_mass_spring_get_motion_state(data, i, x, NULL); + SIM_mass_spring_get_motion_state(data, i, x, NULL); DO_MINMAX(x, gmin, gmax); } } @@ -599,7 +599,7 @@ static void cloth_calc_force( vert = cloth->verts; for (i = 0; i < cloth->mvert_num; i++, vert++) { - BPH_mass_spring_force_gravity(data, i, vert->mass, gravity); + SIM_mass_spring_force_gravity(data, i, vert->mass, gravity); /* Vertex goal springs */ if ((!(vert->flags & CLOTH_VERT_FLAG_PINNED)) && (vert->goal > FLT_EPSILON)) { @@ -613,7 +613,7 @@ static void cloth_calc_force( k = vert->goal * clmd->sim_parms->goalspring / (clmd->sim_parms->avg_spring_len + FLT_EPSILON); - BPH_mass_spring_force_spring_goal( + SIM_mass_spring_force_spring_goal( data, i, goal_x, goal_v, k, clmd->sim_parms->goalfrict * 0.01f); } } @@ -622,7 +622,7 @@ static void cloth_calc_force( /* cloth_calc_volume_force(clmd); */ #ifdef CLOTH_FORCE_DRAG - BPH_mass_spring_force_drag(data, drag); + SIM_mass_spring_force_drag(data, drag); #endif /* handle pressure forces (making sure that this never gets computed for hair). */ if ((parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE) && (clmd->hairdata == NULL)) { @@ -694,7 +694,7 @@ static void cloth_calc_force( const MVertTri *vt = &tri[i]; if (cloth_get_pressure_weights(clmd, vt, weights)) { - BPH_mass_spring_force_pressure(data, + SIM_mass_spring_force_pressure(data, vt->tri[0], vt->tri[1], vt->tri[2], @@ -724,7 +724,7 @@ static void cloth_calc_force( float x[3], v[3]; EffectedPoint epoint; - BPH_mass_spring_get_motion_state(data, i, x, v); + SIM_mass_spring_get_motion_state(data, i, x, v); pd_point_from_loc(scene, x, v, i, &epoint); BKE_effectors_apply(effectors, NULL, @@ -743,10 +743,10 @@ static void cloth_calc_force( for (i = 0; i < cloth->primitive_num; i++) { const MVertTri *vt = &tri[i]; if (has_wind) { - BPH_mass_spring_force_face_wind(data, vt->tri[0], vt->tri[1], vt->tri[2], winvec); + SIM_mass_spring_force_face_wind(data, vt->tri[0], vt->tri[1], vt->tri[2], winvec); } if (has_force) { - BPH_mass_spring_force_face_extern(data, vt->tri[0], vt->tri[1], vt->tri[2], forcevec); + SIM_mass_spring_force_face_extern(data, vt->tri[0], vt->tri[1], vt->tri[2], forcevec); } } } @@ -761,11 +761,11 @@ static void cloth_calc_force( if (hairdata) { hair_ij = &hairdata[spring->ij]; hair_kl = &hairdata[spring->kl]; - BPH_mass_spring_force_edge_wind( + SIM_mass_spring_force_edge_wind( data, spring->ij, spring->kl, hair_ij->radius, hair_kl->radius, winvec); } else { - BPH_mass_spring_force_edge_wind(data, spring->ij, spring->kl, 1.0f, 1.0f, winvec); + SIM_mass_spring_force_edge_wind(data, spring->ij, spring->kl, 1.0f, 1.0f, winvec); } } } @@ -776,10 +776,10 @@ static void cloth_calc_force( for (i = 0; i < cloth->mvert_num; i++, vert++) { if (hairdata) { ClothHairData *hair = &hairdata[i]; - BPH_mass_spring_force_vertex_wind(data, i, hair->radius, winvec); + SIM_mass_spring_force_vertex_wind(data, i, hair->radius, winvec); } else { - BPH_mass_spring_force_vertex_wind(data, i, 1.0f, winvec); + SIM_mass_spring_force_vertex_wind(data, i, 1.0f, winvec); } } #endif @@ -806,8 +806,8 @@ BLI_INLINE void cloth_get_grid_location(Implicit_Data *data, float x[3], float v[3]) { - BPH_mass_spring_get_position(data, index, x); - BPH_mass_spring_get_new_velocity(data, index, v); + SIM_mass_spring_get_position(data, index, x); + SIM_mass_spring_get_new_velocity(data, index, v); mul_v3_fl(x, cell_scale); add_v3_v3(x, cell_offset); @@ -902,7 +902,7 @@ static LinkNode *cloth_continuum_add_hair_segments(HairGrid *grid, zero_v3(dir3); } - BPH_hair_volume_add_segment( + SIM_hair_volume_add_segment( grid, x1, v1, x2, v2, x3, v3, x4, v4, spring1 ? dir1 : NULL, dir2, spring3 ? dir3 : NULL); } @@ -921,7 +921,7 @@ static void cloth_continuum_fill_grid(HairGrid *grid, Cloth *cloth) float x[3], v[3]; cloth_get_vertex_motion_state(data, vert, x, v); - BPH_hair_volume_add_vertex(grid, x, v); + SIM_hair_volume_add_vertex(grid, x, v); } #else LinkNode *link; @@ -930,7 +930,7 @@ static void cloth_continuum_fill_grid(HairGrid *grid, Cloth *cloth) /* scale and offset for transforming vertex locations into grid space * (cell size is 0..1, gmin becomes origin) */ - BPH_hair_volume_grid_geometry(grid, &cellsize, NULL, gmin, NULL); + SIM_hair_volume_grid_geometry(grid, &cellsize, NULL, gmin, NULL); cell_scale = cellsize > 0.0f ? 1.0f / cellsize : 0.0f; mul_v3_v3fl(cell_offset, gmin, cell_scale); negate_v3(cell_offset); @@ -946,7 +946,7 @@ static void cloth_continuum_fill_grid(HairGrid *grid, Cloth *cloth) } } #endif - BPH_hair_volume_normalize_vertex_grid(grid); + SIM_hair_volume_normalize_vertex_grid(grid); } static void cloth_continuum_step(ClothModifierData *clmd, float dt) @@ -977,31 +977,31 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt) /* gather velocities & density */ if (smoothfac > 0.0f || density_strength > 0.0f) { - HairGrid *grid = BPH_hair_volume_create_vertex_grid( + HairGrid *grid = SIM_hair_volume_create_vertex_grid( clmd->sim_parms->voxel_cell_size, gmin, gmax); cloth_continuum_fill_grid(grid, cloth); /* main hair continuum solver */ - BPH_hair_volume_solve_divergence(grid, dt, density_target, density_strength); + SIM_hair_volume_solve_divergence(grid, dt, density_target, density_strength); for (i = 0, vert = cloth->verts; i < mvert_num; i++, vert++) { float x[3], v[3], nv[3]; /* calculate volumetric velocity influence */ - BPH_mass_spring_get_position(data, i, x); - BPH_mass_spring_get_new_velocity(data, i, v); + SIM_mass_spring_get_position(data, i, x); + SIM_mass_spring_get_new_velocity(data, i, v); - BPH_hair_volume_grid_velocity(grid, x, v, fluid_factor, nv); + SIM_hair_volume_grid_velocity(grid, x, v, fluid_factor, nv); interp_v3_v3v3(nv, v, nv, smoothfac); /* apply on hair data */ - BPH_mass_spring_set_new_velocity(data, i, nv); + SIM_mass_spring_set_new_velocity(data, i, nv); } /* store basic grid info in the modifier data */ - BPH_hair_volume_grid_geometry(grid, + SIM_hair_volume_grid_geometry(grid, &clmd->hair_grid_cellsize, clmd->hair_grid_res, clmd->hair_grid_min, @@ -1034,7 +1034,7 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt) madd_v3_v3fl(x, b, (float)j / (float)(size - 1)); zero_v3(v); - BPH_hair_volume_grid_interpolate(grid, x, &gdensity, gvel, gvel_smooth, NULL, NULL); + SIM_hair_volume_grid_interpolate(grid, x, &gdensity, gvel, gvel_smooth, NULL, NULL); // BKE_sim_debug_data_add_circle( // clmd->debug_data, x, gdensity, 0.7, 0.3, 1, @@ -1074,7 +1074,7 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt) } #endif - BPH_hair_volume_free_vertex_grid(grid); + SIM_hair_volume_free_vertex_grid(grid); } } @@ -1099,7 +1099,7 @@ static void cloth_calc_volume_force(ClothModifierData *clmd) /* gather velocities & density */ if (smoothfac > 0.0f || pressfac > 0.0f) { - HairVertexGrid *vertex_grid = BPH_hair_volume_create_vertex_grid( + HairVertexGrid *vertex_grid = SIM_hair_volume_create_vertex_grid( clmd->sim_parms->voxel_res, gmin, gmax); vert = cloth->verts; @@ -1111,11 +1111,11 @@ static void cloth_calc_volume_force(ClothModifierData *clmd) copy_v3_v3(v, vert->v); } else { - BPH_mass_spring_get_motion_state(data, vert->solver_index, x, v); + SIM_mass_spring_get_motion_state(data, vert->solver_index, x, v); } - BPH_hair_volume_add_vertex(vertex_grid, x, v); + SIM_hair_volume_add_vertex(vertex_grid, x, v); } - BPH_hair_volume_normalize_vertex_grid(vertex_grid); + SIM_hair_volume_normalize_vertex_grid(vertex_grid); vert = cloth->verts; for (i = 0; i < mvert_num; i++, vert++) { @@ -1126,14 +1126,14 @@ static void cloth_calc_volume_force(ClothModifierData *clmd) } /* calculate volumetric forces */ - BPH_mass_spring_get_motion_state(data, vert->solver_index, x, v); - BPH_hair_volume_vertex_grid_forces( + SIM_mass_spring_get_motion_state(data, vert->solver_index, x, v); + SIM_hair_volume_vertex_grid_forces( vertex_grid, x, v, smoothfac, pressfac, minpress, f, dfdx, dfdv); /* apply on hair data */ - BPH_mass_spring_force_extern(data, vert->solver_index, f, dfdx, dfdv); + SIM_mass_spring_force_extern(data, vert->solver_index, f, dfdx, dfdv); } - BPH_hair_volume_free_vertex_grid(vertex_grid); + SIM_hair_volume_free_vertex_grid(vertex_grid); } } #endif @@ -1148,8 +1148,8 @@ static void cloth_calc_average_acceleration(ClothModifierData *clmd, float dt) for (i = 0; i < mvert_num; i++) { float v[3], nv[3]; - BPH_mass_spring_get_velocity(data, i, v); - BPH_mass_spring_get_new_velocity(data, i, nv); + SIM_mass_spring_get_velocity(data, i, v); + SIM_mass_spring_get_new_velocity(data, i, nv); sub_v3_v3(nv, v); add_v3_v3(total, nv); @@ -1181,11 +1181,11 @@ static void cloth_solve_collisions( return; } - BPH_mass_spring_solve_positions(id, dt); + SIM_mass_spring_solve_positions(id, dt); /* Update verts to current positions. */ for (i = 0; i < mvert_num; i++) { - BPH_mass_spring_get_new_position(id, i, verts[i].tx); + SIM_mass_spring_get_new_position(id, i, verts[i].tx); sub_v3_v3v3(verts[i].tv, verts[i].tx, verts[i].txold); zero_v3(verts[i].dcvel); @@ -1201,9 +1201,9 @@ static void cloth_solve_collisions( continue; } - BPH_mass_spring_get_new_velocity(id, i, verts[i].tv); + SIM_mass_spring_get_new_velocity(id, i, verts[i].tv); madd_v3_v3fl(verts[i].tv, verts[i].dcvel, time_multiplier); - BPH_mass_spring_set_new_velocity(id, i, verts[i].tv); + SIM_mass_spring_set_new_velocity(id, i, verts[i].tv); } } } @@ -1224,7 +1224,7 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r if (sres->status) { /* already initialized ? */ /* error only makes sense for successful iterations */ - if (result->status == BPH_SOLVER_SUCCESS) { + if (result->status == SIM_SOLVER_SUCCESS) { sres->min_error = min_ff(sres->min_error, result->error); sres->max_error = max_ff(sres->max_error, result->error); sres->avg_error += result->error * dt; @@ -1236,7 +1236,7 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r } else { /* error only makes sense for successful iterations */ - if (result->status == BPH_SOLVER_SUCCESS) { + if (result->status == SIM_SOLVER_SUCCESS) { sres->min_error = sres->max_error = result->error; sres->avg_error += result->error * dt; } @@ -1248,7 +1248,7 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r sres->status |= result->status; } -int BPH_cloth_solve( +int SIM_cloth_solve( Depsgraph *depsgraph, Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors) { /* Hair currently is a cloth sim in disguise ... @@ -1287,7 +1287,7 @@ int BPH_cloth_solve( // mul_v3_fl(v, clmd->sim_parms->stepsPerFrame); /* divide by time_scale to prevent constrained velocities from being multiplied */ mul_v3_fl(v, 1.0f / clmd->sim_parms->time_scale); - BPH_mass_spring_set_velocity(id, i, v); + SIM_mass_spring_set_velocity(id, i, v); } } } @@ -1303,13 +1303,13 @@ int BPH_cloth_solve( cloth_setup_constraints(clmd); /* initialize forces to zero */ - BPH_mass_spring_clear_forces(id); + SIM_mass_spring_clear_forces(id); // calculate forces cloth_calc_force(scene, clmd, frame, effectors, step); // calculate new velocity and position - BPH_mass_spring_solve_velocities(id, dt, &result); + SIM_mass_spring_solve_velocities(id, dt, &result); cloth_record_result(clmd, &result, dt); /* Calculate collision impulses. */ @@ -1323,8 +1323,8 @@ int BPH_cloth_solve( cloth_calc_average_acceleration(clmd, dt); } - BPH_mass_spring_solve_positions(id, dt); - BPH_mass_spring_apply_result(id); + SIM_mass_spring_solve_positions(id, dt); + SIM_mass_spring_apply_result(id); /* move pinned verts to correct position */ for (i = 0; i < mvert_num; i++) { @@ -1335,11 +1335,11 @@ int BPH_cloth_solve( * delta locations from being multiplied */ interp_v3_v3v3( x, verts[i].xold, verts[i].xconst, (step + dt) / clmd->sim_parms->time_scale); - BPH_mass_spring_set_position(id, i, x); + SIM_mass_spring_set_position(id, i, x); } } - BPH_mass_spring_get_motion_state(id, i, verts[i].txold, NULL); + SIM_mass_spring_get_motion_state(id, i, verts[i].txold, NULL); } step += dt; @@ -1347,7 +1347,7 @@ int BPH_cloth_solve( /* copy results back to cloth data */ for (i = 0; i < mvert_num; i++) { - BPH_mass_spring_get_motion_state(id, i, verts[i].x, verts[i].v); + SIM_mass_spring_get_motion_state(id, i, verts[i].x, verts[i].v); copy_v3_v3(verts[i].txold, verts[i].x); } diff --git a/source/blender/simulation/intern/hair_volume.cpp b/source/blender/simulation/intern/hair_volume.cpp index 1764d0a910c..c80ae69ce73 100644 --- a/source/blender/simulation/intern/hair_volume.cpp +++ b/source/blender/simulation/intern/hair_volume.cpp @@ -205,7 +205,7 @@ BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid, } } -void BPH_hair_volume_vertex_grid_forces(HairGrid *grid, +void SIM_hair_volume_vertex_grid_forces(HairGrid *grid, const float x[3], const float v[3], float smoothfac, @@ -244,7 +244,7 @@ void BPH_hair_volume_vertex_grid_forces(HairGrid *grid, mul_m3_fl(dfdv, smoothfac); } -void BPH_hair_volume_grid_interpolate(HairGrid *grid, +void SIM_hair_volume_grid_interpolate(HairGrid *grid, const float x[3], float *density, float velocity[3], @@ -264,7 +264,7 @@ void BPH_hair_volume_grid_interpolate(HairGrid *grid, velocity_gradient); } -void BPH_hair_volume_grid_velocity( +void SIM_hair_volume_grid_velocity( HairGrid *grid, const float x[3], const float v[3], float fluid_factor, float r_v[3]) { float gdensity, gvelocity[3], gvel_smooth[3], ggrad[3], gvelgrad[3][3]; @@ -291,7 +291,7 @@ void BPH_hair_volume_grid_velocity( interp_v3_v3v3(r_v, v_pic, v_flip, fluid_factor); } -void BPH_hair_volume_grid_clear(HairGrid *grid) +void SIM_hair_volume_grid_clear(HairGrid *grid) { const int size = hair_grid_size(grid->res); int i; @@ -362,7 +362,7 @@ BLI_INLINE void grid_to_world(HairGrid *grid, float vecw[3], const float vec[3]) add_v3_v3(vecw, grid->gmin); } -void BPH_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[3]) +void SIM_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[3]) { const int res[3] = {grid->res[0], grid->res[1], grid->res[2]}; float weights[8]; @@ -503,7 +503,7 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid, * The radius of influence around a segment is assumed to be at most 2*cellsize, * i.e. only cells containing the segment and their direct neighbors are examined. */ -void BPH_hair_volume_add_segment(HairGrid *grid, +void SIM_hair_volume_add_segment(HairGrid *grid, const float x1[3], const float v1[3], const float x2[3], @@ -633,7 +633,7 @@ BLI_INLINE void hair_volume_eval_grid_vertex_sample(HairGridVert *vert, /* XXX simplified test implementation using a series of discrete sample along the segment, * instead of finding the closest point for all affected grid vertices. */ -void BPH_hair_volume_add_segment(HairGrid *grid, +void SIM_hair_volume_add_segment(HairGrid *grid, const float UNUSED(x1[3]), const float UNUSED(v1[3]), const float x2[3], @@ -684,7 +684,7 @@ void BPH_hair_volume_add_segment(HairGrid *grid, } #endif -void BPH_hair_volume_normalize_vertex_grid(HairGrid *grid) +void SIM_hair_volume_normalize_vertex_grid(HairGrid *grid) { int i, size = hair_grid_size(grid->res); /* divide velocity with density */ @@ -715,7 +715,7 @@ BLI_INLINE float hair_volume_density_divergence(float density, } } -bool BPH_hair_volume_solve_divergence(HairGrid *grid, +bool SIM_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target_density, float target_strength) @@ -1078,7 +1078,7 @@ BLI_INLINE void hair_volume_filter_box_convolute( } } -void BPH_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid, int kernel_size) +void SIM_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid, int kernel_size) { int size = hair_grid_size(grid->res); int kernel_sizev[3] = {kernel_size, kernel_size, kernel_size}; @@ -1113,7 +1113,7 @@ void BPH_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid, int kernel_siz } #endif -HairGrid *BPH_hair_volume_create_vertex_grid(float cellsize, +HairGrid *SIM_hair_volume_create_vertex_grid(float cellsize, const float gmin[3], const float gmax[3]) { @@ -1170,7 +1170,7 @@ HairGrid *BPH_hair_volume_create_vertex_grid(float cellsize, return grid; } -void BPH_hair_volume_free_vertex_grid(HairGrid *grid) +void SIM_hair_volume_free_vertex_grid(HairGrid *grid) { if (grid) { if (grid->verts) { @@ -1180,7 +1180,7 @@ void BPH_hair_volume_free_vertex_grid(HairGrid *grid) } } -void BPH_hair_volume_grid_geometry( +void SIM_hair_volume_grid_geometry( HairGrid *grid, float *cellsize, int res[3], float gmin[3], float gmax[3]) { if (cellsize) { diff --git a/source/blender/simulation/intern/implicit.h b/source/blender/simulation/intern/implicit.h index 8bc09755180..17dfb8b88b9 100644 --- a/source/blender/simulation/intern/implicit.h +++ b/source/blender/simulation/intern/implicit.h @@ -65,87 +65,87 @@ BLI_INLINE void implicit_print_matrix_elem(float v) printf("%-8.3f", v); } -void BPH_mass_spring_set_vertex_mass(struct Implicit_Data *data, int index, float mass); -void BPH_mass_spring_set_rest_transform(struct Implicit_Data *data, int index, float rot[3][3]); +void SIM_mass_spring_set_vertex_mass(struct Implicit_Data *data, int index, float mass); +void SIM_mass_spring_set_rest_transform(struct Implicit_Data *data, int index, float rot[3][3]); -void BPH_mass_spring_set_motion_state(struct Implicit_Data *data, +void SIM_mass_spring_set_motion_state(struct Implicit_Data *data, int index, const float x[3], const float v[3]); -void BPH_mass_spring_set_position(struct Implicit_Data *data, int index, const float x[3]); -void BPH_mass_spring_set_velocity(struct Implicit_Data *data, int index, const float v[3]); -void BPH_mass_spring_get_motion_state(struct Implicit_Data *data, +void SIM_mass_spring_set_position(struct Implicit_Data *data, int index, const float x[3]); +void SIM_mass_spring_set_velocity(struct Implicit_Data *data, int index, const float v[3]); +void SIM_mass_spring_get_motion_state(struct Implicit_Data *data, int index, float x[3], float v[3]); -void BPH_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3]); -void BPH_mass_spring_get_velocity(struct Implicit_Data *data, int index, float v[3]); +void SIM_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3]); +void SIM_mass_spring_get_velocity(struct Implicit_Data *data, int index, float v[3]); /* access to modified motion state during solver step */ -void BPH_mass_spring_get_new_position(struct Implicit_Data *data, int index, float x[3]); -void BPH_mass_spring_set_new_position(struct Implicit_Data *data, int index, const float x[3]); -void BPH_mass_spring_get_new_velocity(struct Implicit_Data *data, int index, float v[3]); -void BPH_mass_spring_set_new_velocity(struct Implicit_Data *data, int index, const float v[3]); +void SIM_mass_spring_get_new_position(struct Implicit_Data *data, int index, float x[3]); +void SIM_mass_spring_set_new_position(struct Implicit_Data *data, int index, const float x[3]); +void SIM_mass_spring_get_new_velocity(struct Implicit_Data *data, int index, float v[3]); +void SIM_mass_spring_set_new_velocity(struct Implicit_Data *data, int index, const float v[3]); -void BPH_mass_spring_clear_constraints(struct Implicit_Data *data); -void BPH_mass_spring_add_constraint_ndof0(struct Implicit_Data *data, +void SIM_mass_spring_clear_constraints(struct Implicit_Data *data); +void SIM_mass_spring_add_constraint_ndof0(struct Implicit_Data *data, int index, const float dV[3]); -void BPH_mass_spring_add_constraint_ndof1(struct Implicit_Data *data, +void SIM_mass_spring_add_constraint_ndof1(struct Implicit_Data *data, int index, const float c1[3], const float c2[3], const float dV[3]); -void BPH_mass_spring_add_constraint_ndof2(struct Implicit_Data *data, +void SIM_mass_spring_add_constraint_ndof2(struct Implicit_Data *data, int index, const float c1[3], const float dV[3]); -bool BPH_mass_spring_solve_velocities(struct Implicit_Data *data, +bool SIM_mass_spring_solve_velocities(struct Implicit_Data *data, float dt, struct ImplicitSolverResult *result); -bool BPH_mass_spring_solve_positions(struct Implicit_Data *data, float dt); -void BPH_mass_spring_apply_result(struct Implicit_Data *data); +bool SIM_mass_spring_solve_positions(struct Implicit_Data *data, float dt); +void SIM_mass_spring_apply_result(struct Implicit_Data *data); /* Clear the force vector at the beginning of the time step */ -void BPH_mass_spring_clear_forces(struct Implicit_Data *data); +void SIM_mass_spring_clear_forces(struct Implicit_Data *data); /* Fictitious forces introduced by moving coordinate systems */ -void BPH_mass_spring_force_reference_frame(struct Implicit_Data *data, +void SIM_mass_spring_force_reference_frame(struct Implicit_Data *data, int index, const float acceleration[3], const float omega[3], const float domega_dt[3], float mass); /* Simple uniform gravity force */ -void BPH_mass_spring_force_gravity(struct Implicit_Data *data, +void SIM_mass_spring_force_gravity(struct Implicit_Data *data, int index, float mass, const float g[3]); /* Global drag force (velocity damping) */ -void BPH_mass_spring_force_drag(struct Implicit_Data *data, float drag); +void SIM_mass_spring_force_drag(struct Implicit_Data *data, float drag); /* Custom external force */ -void BPH_mass_spring_force_extern( +void SIM_mass_spring_force_extern( struct Implicit_Data *data, int i, const float f[3], float dfdx[3][3], float dfdv[3][3]); /* Wind force, acting on a face (only generates pressure from the normal component) */ -void BPH_mass_spring_force_face_wind( +void SIM_mass_spring_force_face_wind( struct Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3]); /* Arbitrary per-unit-area vector force field acting on a face. */ -void BPH_mass_spring_force_face_extern( +void SIM_mass_spring_force_face_extern( struct Implicit_Data *data, int v1, int v2, int v3, const float (*forcevec)[3]); /* Wind force, acting on an edge */ -void BPH_mass_spring_force_edge_wind(struct Implicit_Data *data, +void SIM_mass_spring_force_edge_wind(struct Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float (*winvec)[3]); /* Wind force, acting on a vertex */ -void BPH_mass_spring_force_vertex_wind(struct Implicit_Data *data, +void SIM_mass_spring_force_vertex_wind(struct Implicit_Data *data, int v, float radius, const float (*winvec)[3]); /* Linear spring force between two points */ -bool BPH_mass_spring_force_spring_linear(struct Implicit_Data *data, +bool SIM_mass_spring_force_spring_linear(struct Implicit_Data *data, int i, int j, float restlen, @@ -157,7 +157,7 @@ bool BPH_mass_spring_force_spring_linear(struct Implicit_Data *data, bool new_compress, float clamp_force); /* Angular spring force between two polygons */ -bool BPH_mass_spring_force_spring_angular(struct Implicit_Data *data, +bool SIM_mass_spring_force_spring_angular(struct Implicit_Data *data, int i, int j, int *i_a, @@ -168,10 +168,10 @@ bool BPH_mass_spring_force_spring_angular(struct Implicit_Data *data, float stiffness, float damping); /* Bending force, forming a triangle at the base of two structural springs */ -bool BPH_mass_spring_force_spring_bending( +bool SIM_mass_spring_force_spring_bending( struct Implicit_Data *data, int i, int j, float restlen, float kb, float cb); /* Angular bending force based on local target vectors */ -bool BPH_mass_spring_force_spring_bending_hair(struct Implicit_Data *data, +bool SIM_mass_spring_force_spring_bending_hair(struct Implicit_Data *data, int i, int j, int k, @@ -179,17 +179,17 @@ bool BPH_mass_spring_force_spring_bending_hair(struct Implicit_Data *data, float stiffness, float damping); /* Global goal spring */ -bool BPH_mass_spring_force_spring_goal(struct Implicit_Data *data, +bool SIM_mass_spring_force_spring_goal(struct Implicit_Data *data, int i, const float goal_x[3], const float goal_v[3], float stiffness, float damping); -float BPH_tri_tetra_volume_signed_6x(struct Implicit_Data *data, int v1, int v2, int v3); -float BPH_tri_area(struct Implicit_Data *data, int v1, int v2, int v3); +float SIM_tri_tetra_volume_signed_6x(struct Implicit_Data *data, int v1, int v2, int v3); +float SIM_tri_area(struct Implicit_Data *data, int v1, int v2, int v3); -void BPH_mass_spring_force_pressure(struct Implicit_Data *data, +void SIM_mass_spring_force_pressure(struct Implicit_Data *data, int v1, int v2, int v3, @@ -203,16 +203,16 @@ struct HairGrid; #define MAX_HAIR_GRID_RES 256 -struct HairGrid *BPH_hair_volume_create_vertex_grid(float cellsize, +struct HairGrid *SIM_hair_volume_create_vertex_grid(float cellsize, const float gmin[3], const float gmax[3]); -void BPH_hair_volume_free_vertex_grid(struct HairGrid *grid); -void BPH_hair_volume_grid_geometry( +void SIM_hair_volume_free_vertex_grid(struct HairGrid *grid); +void SIM_hair_volume_grid_geometry( struct HairGrid *grid, float *cellsize, int res[3], float gmin[3], float gmax[3]); -void BPH_hair_volume_grid_clear(struct HairGrid *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, +void SIM_hair_volume_grid_clear(struct HairGrid *grid); +void SIM_hair_volume_add_vertex(struct HairGrid *grid, const float x[3], const float v[3]); +void SIM_hair_volume_add_segment(struct HairGrid *grid, const float x1[3], const float v1[3], const float x2[3], @@ -225,17 +225,17 @@ void BPH_hair_volume_add_segment(struct HairGrid *grid, const float dir2[3], const float dir3[3]); -void BPH_hair_volume_normalize_vertex_grid(struct HairGrid *grid); +void SIM_hair_volume_normalize_vertex_grid(struct HairGrid *grid); -bool BPH_hair_volume_solve_divergence(struct HairGrid *grid, +bool SIM_hair_volume_solve_divergence(struct HairGrid *grid, float dt, float target_density, float target_strength); #if 0 /* XXX weighting is incorrect, disabled for now */ -void BPH_hair_volume_vertex_grid_filter_box(struct HairVertexGrid *grid, int kernel_size); +void SIM_hair_volume_vertex_grid_filter_box(struct HairVertexGrid *grid, int kernel_size); #endif -void BPH_hair_volume_grid_interpolate(struct HairGrid *grid, +void SIM_hair_volume_grid_interpolate(struct HairGrid *grid, const float x[3], float *density, float velocity[3], @@ -247,7 +247,7 @@ void BPH_hair_volume_grid_interpolate(struct HairGrid *grid, * 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( +void SIM_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, * due to discontinuities in interpolated values! @@ -255,7 +255,7 @@ void BPH_hair_volume_grid_velocity( * "Detail Preserving Continuum Simulation of Straight Hair" * (McAdams, Selle 2009) */ -void BPH_hair_volume_vertex_grid_forces(struct HairGrid *grid, +void SIM_hair_volume_vertex_grid_forces(struct HairGrid *grid, const float x[3], const float v[3], float smoothfac, diff --git a/source/blender/simulation/intern/implicit_blender.c b/source/blender/simulation/intern/implicit_blender.c index 54d38f3c10b..856572aa3f5 100644 --- a/source/blender/simulation/intern/implicit_blender.c +++ b/source/blender/simulation/intern/implicit_blender.c @@ -40,7 +40,7 @@ # include "BKE_collision.h" # include "BKE_effect.h" -# include "BPH_mass_spring.h" +# include "SIM_mass_spring.h" # ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wtype-limits" @@ -679,7 +679,7 @@ typedef struct Implicit_Data { fmatrix3x3 *P, *Pinv; /* pre-conditioning matrix */ } Implicit_Data; -Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings) +Implicit_Data *SIM_mass_spring_solver_create(int numverts, int numsprings) { Implicit_Data *id = (Implicit_Data *)MEM_callocN(sizeof(Implicit_Data), "implicit vecmat"); @@ -707,7 +707,7 @@ Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings) return id; } -void BPH_mass_spring_solver_free(Implicit_Data *id) +void SIM_mass_spring_solver_free(Implicit_Data *id) { del_bfmatrix(id->tfm); del_bfmatrix(id->A); @@ -924,8 +924,8 @@ static int cg_filtered(lfVector *ldV, del_lfvector(s); // printf("W/O conjgrad_loopcount: %d\n", conjgrad_loopcount); - result->status = conjgrad_loopcount < conjgrad_looplimit ? BPH_SOLVER_SUCCESS : - BPH_SOLVER_NO_CONVERGENCE; + result->status = conjgrad_loopcount < conjgrad_looplimit ? SIM_SOLVER_SUCCESS : + SIM_SOLVER_NO_CONVERGENCE; result->iterations = conjgrad_loopcount; result->error = bnorm2 > 0.0f ? sqrtf(delta_new / bnorm2) : 0.0f; @@ -1139,7 +1139,7 @@ static int cg_filtered_pre(lfVector *dv, } # endif -bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSolverResult *result) +bool SIM_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSolverResult *result) { unsigned int numverts = data->dFdV[0].vcount; @@ -1173,10 +1173,10 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol del_lfvector(dFdXmV); - return result->status == BPH_SOLVER_SUCCESS; + return result->status == SIM_SOLVER_SUCCESS; } -bool BPH_mass_spring_solve_positions(Implicit_Data *data, float dt) +bool SIM_mass_spring_solve_positions(Implicit_Data *data, float dt) { int numverts = data->M[0].vcount; @@ -1186,20 +1186,20 @@ bool BPH_mass_spring_solve_positions(Implicit_Data *data, float dt) return true; } -void BPH_mass_spring_apply_result(Implicit_Data *data) +void SIM_mass_spring_apply_result(Implicit_Data *data) { int numverts = data->M[0].vcount; cp_lfvector(data->X, data->Xnew, numverts); cp_lfvector(data->V, data->Vnew, numverts); } -void BPH_mass_spring_set_vertex_mass(Implicit_Data *data, int index, float mass) +void SIM_mass_spring_set_vertex_mass(Implicit_Data *data, int index, float mass) { unit_m3(data->M[index].m); mul_m3_fl(data->M[index].m, mass); } -void BPH_mass_spring_set_rest_transform(Implicit_Data *data, int index, float tfm[3][3]) +void SIM_mass_spring_set_rest_transform(Implicit_Data *data, int index, float tfm[3][3]) { # ifdef CLOTH_ROOT_FRAME copy_m3_m3(data->tfm[index].m, tfm); @@ -1209,7 +1209,7 @@ void BPH_mass_spring_set_rest_transform(Implicit_Data *data, int index, float tf # endif } -void BPH_mass_spring_set_motion_state(Implicit_Data *data, +void SIM_mass_spring_set_motion_state(Implicit_Data *data, int index, const float x[3], const float v[3]) @@ -1218,17 +1218,17 @@ void BPH_mass_spring_set_motion_state(Implicit_Data *data, world_to_root_v3(data, index, data->V[index], v); } -void BPH_mass_spring_set_position(Implicit_Data *data, int index, const float x[3]) +void SIM_mass_spring_set_position(Implicit_Data *data, int index, const float x[3]) { world_to_root_v3(data, index, data->X[index], x); } -void BPH_mass_spring_set_velocity(Implicit_Data *data, int index, const float v[3]) +void SIM_mass_spring_set_velocity(Implicit_Data *data, int index, const float v[3]) { world_to_root_v3(data, index, data->V[index], v); } -void BPH_mass_spring_get_motion_state(struct Implicit_Data *data, +void SIM_mass_spring_get_motion_state(struct Implicit_Data *data, int index, float x[3], float v[3]) @@ -1241,39 +1241,39 @@ void BPH_mass_spring_get_motion_state(struct Implicit_Data *data, } } -void BPH_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3]) +void SIM_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3]) { root_to_world_v3(data, index, x, data->X[index]); } -void BPH_mass_spring_get_velocity(struct Implicit_Data *data, int index, float v[3]) +void SIM_mass_spring_get_velocity(struct Implicit_Data *data, int index, float v[3]) { root_to_world_v3(data, index, v, data->V[index]); } -void BPH_mass_spring_get_new_position(struct Implicit_Data *data, int index, float x[3]) +void SIM_mass_spring_get_new_position(struct Implicit_Data *data, int index, float x[3]) { root_to_world_v3(data, index, x, data->Xnew[index]); } -void BPH_mass_spring_set_new_position(struct Implicit_Data *data, int index, const float x[3]) +void SIM_mass_spring_set_new_position(struct Implicit_Data *data, int index, const float x[3]) { world_to_root_v3(data, index, data->Xnew[index], x); } -void BPH_mass_spring_get_new_velocity(struct Implicit_Data *data, int index, float v[3]) +void SIM_mass_spring_get_new_velocity(struct Implicit_Data *data, int index, float v[3]) { root_to_world_v3(data, index, v, data->Vnew[index]); } -void BPH_mass_spring_set_new_velocity(struct Implicit_Data *data, int index, const float v[3]) +void SIM_mass_spring_set_new_velocity(struct Implicit_Data *data, int index, const float v[3]) { world_to_root_v3(data, index, data->Vnew[index], v); } /* -------------------------------- */ -static int BPH_mass_spring_add_block(Implicit_Data *data, int v1, int v2) +static int SIM_mass_spring_add_block(Implicit_Data *data, int v1, int v2) { int s = data->M[0].vcount + data->num_blocks; /* index from array start */ BLI_assert(s < data->M[0].vcount + data->M[0].scount); @@ -1291,7 +1291,7 @@ static int BPH_mass_spring_add_block(Implicit_Data *data, int v1, int v2) return s; } -void BPH_mass_spring_clear_constraints(Implicit_Data *data) +void SIM_mass_spring_clear_constraints(Implicit_Data *data) { int i, numverts = data->S[0].vcount; for (i = 0; i < numverts; i++) { @@ -1300,14 +1300,14 @@ void BPH_mass_spring_clear_constraints(Implicit_Data *data) } } -void BPH_mass_spring_add_constraint_ndof0(Implicit_Data *data, int index, const float dV[3]) +void SIM_mass_spring_add_constraint_ndof0(Implicit_Data *data, int index, const float dV[3]) { zero_m3(data->S[index].m); world_to_root_v3(data, index, data->z[index], dV); } -void BPH_mass_spring_add_constraint_ndof1( +void SIM_mass_spring_add_constraint_ndof1( Implicit_Data *data, int index, const float c1[3], const float c2[3], const float dV[3]) { float m[3][3], p[3], q[3], u[3], cmat[3][3]; @@ -1328,7 +1328,7 @@ void BPH_mass_spring_add_constraint_ndof1( add_v3_v3(data->z[index], u); } -void BPH_mass_spring_add_constraint_ndof2(Implicit_Data *data, +void SIM_mass_spring_add_constraint_ndof2(Implicit_Data *data, int index, const float c1[3], const float dV[3]) @@ -1346,7 +1346,7 @@ void BPH_mass_spring_add_constraint_ndof2(Implicit_Data *data, add_v3_v3(data->z[index], u); } -void BPH_mass_spring_clear_forces(Implicit_Data *data) +void SIM_mass_spring_clear_forces(Implicit_Data *data) { int numverts = data->M[0].vcount; zero_lfvector(data->F, numverts); @@ -1356,7 +1356,7 @@ void BPH_mass_spring_clear_forces(Implicit_Data *data) data->num_blocks = 0; } -void BPH_mass_spring_force_reference_frame(Implicit_Data *data, +void SIM_mass_spring_force_reference_frame(Implicit_Data *data, int index, const float acceleration[3], const float omega[3], @@ -1411,7 +1411,7 @@ void BPH_mass_spring_force_reference_frame(Implicit_Data *data, # endif } -void BPH_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, const float g[3]) +void SIM_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, const float g[3]) { /* force = mass * acceleration (in this case: gravity) */ float f[3]; @@ -1421,7 +1421,7 @@ void BPH_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, c add_v3_v3(data->F[index], f); } -void BPH_mass_spring_force_drag(Implicit_Data *data, float drag) +void SIM_mass_spring_force_drag(Implicit_Data *data, float drag) { int i, numverts = data->M[0].vcount; for (i = 0; i < numverts; i++) { @@ -1436,7 +1436,7 @@ void BPH_mass_spring_force_drag(Implicit_Data *data, float drag) } } -void BPH_mass_spring_force_extern( +void SIM_mass_spring_force_extern( struct Implicit_Data *data, int i, const float f[3], float dfdx[3][3], float dfdv[3][3]) { float tf[3], tdfdx[3][3], tdfdv[3][3]; @@ -1465,7 +1465,7 @@ static float calc_nor_area_tri(float nor[3], /* XXX does not support force jacobians yet, since the effector system does not provide them either */ -void BPH_mass_spring_force_face_wind( +void SIM_mass_spring_force_face_wind( Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3]) { const float effector_scale = 0.02f; @@ -1505,7 +1505,7 @@ void BPH_mass_spring_force_face_wind( madd_v3_v3fl(data->F[v3], nor, base_force + force[2]); } -void BPH_mass_spring_force_face_extern( +void SIM_mass_spring_force_face_extern( Implicit_Data *data, int v1, int v2, int v3, const float (*forcevec)[3]) { const float effector_scale = 0.02f; @@ -1536,20 +1536,20 @@ void BPH_mass_spring_force_face_extern( } } -float BPH_tri_tetra_volume_signed_6x(Implicit_Data *data, int v1, int v2, int v3) +float SIM_tri_tetra_volume_signed_6x(Implicit_Data *data, int v1, int v2, int v3) { /* The result will be 6x the volume */ return volume_tri_tetrahedron_signed_v3_6x(data->X[v1], data->X[v2], data->X[v3]); } -float BPH_tri_area(struct Implicit_Data *data, int v1, int v2, int v3) +float SIM_tri_area(struct Implicit_Data *data, int v1, int v2, int v3) { float nor[3]; return calc_nor_area_tri(nor, data->X[v1], data->X[v2], data->X[v3]); } -void BPH_mass_spring_force_pressure(Implicit_Data *data, +void SIM_mass_spring_force_pressure(Implicit_Data *data, int v1, int v2, int v3, @@ -1617,7 +1617,7 @@ static void edge_wind_vertex(const float dir[3], mul_v3_v3fl(f, wind, density * cross_section); } -void BPH_mass_spring_force_edge_wind( +void SIM_mass_spring_force_edge_wind( Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float (*winvec)[3]) { float win[3], dir[3], length; @@ -1635,7 +1635,7 @@ void BPH_mass_spring_force_edge_wind( add_v3_v3(data->F[v2], f); } -void BPH_mass_spring_force_vertex_wind(Implicit_Data *data, +void SIM_mass_spring_force_vertex_wind(Implicit_Data *data, int v, float UNUSED(radius), const float (*winvec)[3]) @@ -1766,7 +1766,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data, BLI_INLINE void apply_spring( Implicit_Data *data, int i, int j, const float f[3], float dfdx[3][3], float dfdv[3][3]) { - int block_ij = BPH_mass_spring_add_block(data, i, j); + int block_ij = SIM_mass_spring_add_block(data, i, j); add_v3_v3(data->F[i], f); sub_v3_v3(data->F[j], f); @@ -1780,7 +1780,7 @@ BLI_INLINE void apply_spring( sub_m3_m3m3(data->dFdV[block_ij].m, data->dFdV[block_ij].m, dfdv); } -bool BPH_mass_spring_force_spring_linear(Implicit_Data *data, +bool SIM_mass_spring_force_spring_linear(Implicit_Data *data, int i, int j, float restlen, @@ -1841,7 +1841,7 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data, } /* See "Stable but Responsive Cloth" (Choi, Ko 2005) */ -bool BPH_mass_spring_force_spring_bending( +bool SIM_mass_spring_force_spring_bending( Implicit_Data *data, int i, int j, float restlen, float kb, float cb) { float extent[3], length, dir[3], vel[3]; @@ -1948,7 +1948,7 @@ BLI_INLINE void spring_angle(Implicit_Data *data, /* Angular springs roughly based on the bending model proposed by Baraff and Witkin in "Large Steps * in Cloth Simulation". */ -bool BPH_mass_spring_force_spring_angular(Implicit_Data *data, +bool SIM_mass_spring_force_spring_angular(Implicit_Data *data, int i, int j, int *i_a, @@ -2169,7 +2169,7 @@ BLI_INLINE void spring_hairbend_estimate_dfdv(Implicit_Data *data, /* Angular spring that pulls the vertex toward the local target * See "Artistic Simulation of Curly Hair" (Pixar technical memo #12-03a) */ -bool BPH_mass_spring_force_spring_bending_hair(Implicit_Data *data, +bool SIM_mass_spring_force_spring_bending_hair(Implicit_Data *data, int i, int j, int k, @@ -2184,9 +2184,9 @@ bool BPH_mass_spring_force_spring_bending_hair(Implicit_Data *data, const float vecnull[3] = {0.0f, 0.0f, 0.0f}; - int block_ij = BPH_mass_spring_add_block(data, i, j); - int block_jk = BPH_mass_spring_add_block(data, j, k); - int block_ik = BPH_mass_spring_add_block(data, i, k); + int block_ij = SIM_mass_spring_add_block(data, i, j); + int block_jk = SIM_mass_spring_add_block(data, j, k); + int block_ik = SIM_mass_spring_add_block(data, i, k); world_to_root_v3(data, j, goal, target); @@ -2318,7 +2318,7 @@ bool BPH_mass_spring_force_spring_bending_hair(Implicit_Data *data, return true; } -bool BPH_mass_spring_force_spring_goal(Implicit_Data *data, +bool SIM_mass_spring_force_spring_goal(Implicit_Data *data, int i, const float goal_x[3], const float goal_v[3], diff --git a/source/blender/simulation/intern/implicit_eigen.cpp b/source/blender/simulation/intern/implicit_eigen.cpp index 58538c13116..15b9e30e32a 100644 --- a/source/blender/simulation/intern/implicit_eigen.cpp +++ b/source/blender/simulation/intern/implicit_eigen.cpp @@ -78,7 +78,7 @@ extern "C" { # include "BKE_effect.h" # include "BKE_global.h" -# include "BPH_mass_spring.h" +# include "SIM_mass_spring.h" } typedef float Scalar; @@ -460,20 +460,20 @@ struct Implicit_Data { lMatrixCtor iS; /* filtering matrix for constraints */ }; -Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings) +Implicit_Data *SIM_mass_spring_solver_create(int numverts, int numsprings) { Implicit_Data *id = new Implicit_Data(numverts); return id; } -void BPH_mass_spring_solver_free(Implicit_Data *id) +void SIM_mass_spring_solver_free(Implicit_Data *id) { if (id) { delete id; } } -int BPH_mass_spring_solver_numvert(Implicit_Data *id) +int SIM_mass_spring_solver_numvert(Implicit_Data *id) { if (id) { return id->numverts; @@ -511,7 +511,7 @@ BLI_INLINE void root_to_world_m3(Implicit_Data *data, int index, float r[3][3], /* ================================ */ -bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSolverResult *result) +bool SIM_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSolverResult *result) { # ifdef USE_EIGEN_CORE typedef ConjugateGradient solver_t; @@ -566,16 +566,16 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol switch (cg.info()) { case Eigen::Success: - result->status = BPH_SOLVER_SUCCESS; + result->status = SIM_SOLVER_SUCCESS; break; case Eigen::NoConvergence: - result->status = BPH_SOLVER_NO_CONVERGENCE; + result->status = SIM_SOLVER_NO_CONVERGENCE; break; case Eigen::InvalidInput: - result->status = BPH_SOLVER_INVALID_INPUT; + result->status = SIM_SOLVER_INVALID_INPUT; break; case Eigen::NumericalIssue: - result->status = BPH_SOLVER_NUMERICAL_ISSUE; + result->status = SIM_SOLVER_NUMERICAL_ISSUE; break; } @@ -585,7 +585,7 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol return cg.info() == Eigen::Success; } -bool BPH_mass_spring_solve_positions(Implicit_Data *data, float dt) +bool SIM_mass_spring_solve_positions(Implicit_Data *data, float dt) { data->Xnew = data->X + data->Vnew * dt; return true; @@ -593,13 +593,13 @@ bool BPH_mass_spring_solve_positions(Implicit_Data *data, float dt) /* ================================ */ -void BPH_mass_spring_apply_result(Implicit_Data *data) +void SIM_mass_spring_apply_result(Implicit_Data *data) { data->X = data->Xnew; data->V = data->Vnew; } -void BPH_mass_spring_set_vertex_mass(Implicit_Data *data, int index, float mass) +void SIM_mass_spring_set_vertex_mass(Implicit_Data *data, int index, float mass) { float m[3][3]; copy_m3_m3(m, I); @@ -607,7 +607,7 @@ void BPH_mass_spring_set_vertex_mass(Implicit_Data *data, int index, float mass) data->iM.add(index, index, m); } -void BPH_mass_spring_set_rest_transform(Implicit_Data *data, int index, float tfm[3][3]) +void SIM_mass_spring_set_rest_transform(Implicit_Data *data, int index, float tfm[3][3]) { # ifdef CLOTH_ROOT_FRAME copy_m3_m3(data->tfm[index], tfm); @@ -617,7 +617,7 @@ void BPH_mass_spring_set_rest_transform(Implicit_Data *data, int index, float tf # endif } -void BPH_mass_spring_set_motion_state(Implicit_Data *data, +void SIM_mass_spring_set_motion_state(Implicit_Data *data, int index, const float x[3], const float v[3]) @@ -626,17 +626,17 @@ void BPH_mass_spring_set_motion_state(Implicit_Data *data, world_to_root_v3(data, index, data->V.v3(index), v); } -void BPH_mass_spring_set_position(Implicit_Data *data, int index, const float x[3]) +void SIM_mass_spring_set_position(Implicit_Data *data, int index, const float x[3]) { world_to_root_v3(data, index, data->X.v3(index), x); } -void BPH_mass_spring_set_velocity(Implicit_Data *data, int index, const float v[3]) +void SIM_mass_spring_set_velocity(Implicit_Data *data, int index, const float v[3]) { world_to_root_v3(data, index, data->V.v3(index), v); } -void BPH_mass_spring_get_motion_state(struct Implicit_Data *data, +void SIM_mass_spring_get_motion_state(struct Implicit_Data *data, int index, float x[3], float v[3]) @@ -649,22 +649,22 @@ void BPH_mass_spring_get_motion_state(struct Implicit_Data *data, } } -void BPH_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3]) +void SIM_mass_spring_get_position(struct Implicit_Data *data, int index, float x[3]) { root_to_world_v3(data, index, x, data->X.v3(index)); } -void BPH_mass_spring_get_new_velocity(Implicit_Data *data, int index, float v[3]) +void SIM_mass_spring_get_new_velocity(Implicit_Data *data, int index, float v[3]) { root_to_world_v3(data, index, v, data->V.v3(index)); } -void BPH_mass_spring_set_new_velocity(Implicit_Data *data, int index, const float v[3]) +void SIM_mass_spring_set_new_velocity(Implicit_Data *data, int index, const float v[3]) { world_to_root_v3(data, index, data->V.v3(index), v); } -void BPH_mass_spring_clear_constraints(Implicit_Data *data) +void SIM_mass_spring_clear_constraints(Implicit_Data *data) { int numverts = data->numverts; for (int i = 0; i < numverts; i++) { @@ -673,14 +673,14 @@ void BPH_mass_spring_clear_constraints(Implicit_Data *data) } } -void BPH_mass_spring_add_constraint_ndof0(Implicit_Data *data, int index, const float dV[3]) +void SIM_mass_spring_add_constraint_ndof0(Implicit_Data *data, int index, const float dV[3]) { data->iS.sub(index, index, I); world_to_root_v3(data, index, data->z.v3(index), dV); } -void BPH_mass_spring_add_constraint_ndof1( +void SIM_mass_spring_add_constraint_ndof1( Implicit_Data *data, int index, const float c1[3], const float c2[3], const float dV[3]) { float m[3][3], p[3], q[3], u[3], cmat[3][3]; @@ -701,7 +701,7 @@ void BPH_mass_spring_add_constraint_ndof1( add_v3_v3(data->z.v3(index), u); } -void BPH_mass_spring_add_constraint_ndof2(Implicit_Data *data, +void SIM_mass_spring_add_constraint_ndof2(Implicit_Data *data, int index, const float c1[3], const float dV[3]) @@ -719,14 +719,14 @@ void BPH_mass_spring_add_constraint_ndof2(Implicit_Data *data, add_v3_v3(data->z.v3(index), u); } -void BPH_mass_spring_clear_forces(Implicit_Data *data) +void SIM_mass_spring_clear_forces(Implicit_Data *data) { data->F.setZero(); data->dFdX.setZero(); data->dFdV.setZero(); } -void BPH_mass_spring_force_reference_frame(Implicit_Data *data, +void SIM_mass_spring_force_reference_frame(Implicit_Data *data, int index, const float acceleration[3], const float omega[3], @@ -781,7 +781,7 @@ void BPH_mass_spring_force_reference_frame(Implicit_Data *data, # endif } -void BPH_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, const float g[3]) +void SIM_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, const float g[3]) { /* force = mass * acceleration (in this case: gravity) */ float f[3]; @@ -791,7 +791,7 @@ void BPH_mass_spring_force_gravity(Implicit_Data *data, int index, float mass, c add_v3_v3(data->F.v3(index), f); } -void BPH_mass_spring_force_drag(Implicit_Data *data, float drag) +void SIM_mass_spring_force_drag(Implicit_Data *data, float drag) { int numverts = data->numverts; for (int i = 0; i < numverts; i++) { @@ -806,7 +806,7 @@ void BPH_mass_spring_force_drag(Implicit_Data *data, float drag) } } -void BPH_mass_spring_force_extern( +void SIM_mass_spring_force_extern( struct Implicit_Data *data, int i, const float f[3], float dfdx[3][3], float dfdv[3][3]) { float tf[3], tdfdx[3][3], tdfdv[3][3]; @@ -835,7 +835,7 @@ static float calc_nor_area_tri(float nor[3], /* XXX does not support force jacobians yet, * since the effector system does not provide them either. */ -void BPH_mass_spring_force_face_wind( +void SIM_mass_spring_force_face_wind( Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3]) { const float effector_scale = 0.02f; @@ -856,7 +856,7 @@ void BPH_mass_spring_force_face_wind( madd_v3_v3fl(data->F.v3(v3), nor, factor * dot_v3v3(win, nor)); } -void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, const float (*winvec)[3]) +void SIM_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, const float (*winvec)[3]) { const float effector_scale = 0.01; float win[3], dir[3], nor[3], length; @@ -1000,7 +1000,7 @@ BLI_INLINE void apply_spring( data->idFdV.sub(j, i, dfdv); } -bool BPH_mass_spring_force_spring_linear(Implicit_Data *data, +bool SIM_mass_spring_force_spring_linear(Implicit_Data *data, int i, int j, float restlen, @@ -1063,7 +1063,7 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data, } /* See "Stable but Responsive Cloth" (Choi, Ko 2005) */ -bool BPH_mass_spring_force_spring_bending(Implicit_Data *data, +bool SIM_mass_spring_force_spring_bending(Implicit_Data *data, int i, int j, float restlen, @@ -1293,7 +1293,7 @@ BLI_INLINE void spring_angbend_estimate_dfdv(Implicit_Data *data, /* Angular spring that pulls the vertex toward the local target * See "Artistic Simulation of Curly Hair" (Pixar technical memo #12-03a) */ -bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data, +bool SIM_mass_spring_force_spring_bending_angular(Implicit_Data *data, int i, int j, int k, @@ -1444,7 +1444,7 @@ bool BPH_mass_spring_force_spring_bending_angular(Implicit_Data *data, return true; } -bool BPH_mass_spring_force_spring_goal(Implicit_Data *data, +bool SIM_mass_spring_force_spring_goal(Implicit_Data *data, int i, const float goal_x[3], const float goal_v[3], |