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:
authorClément Foucault <foucault.clem@gmail.com>2022-01-26 22:25:16 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-01-26 22:27:16 +0300
commitaf87b6d8cb75d9d625378dee25d726a0d55f75c6 (patch)
treeb400a9a7e8d63dc2e60c45e988e969798c066d3b /source/blender/simulation
parent42d2c96d4cceab46de8eebf30497e7399a2998e0 (diff)
parent57dfec79f4ab1ceeb8c5f6049aa03e779e7871c0 (diff)
Merge branch 'master' into draw-viewport-data
# Conflicts: # source/blender/draw/DRW_engine_types.h # source/blender/draw/intern/draw_manager.c # source/blender/draw/intern/draw_manager.h # source/blender/draw/intern/draw_manager_profiling.c # source/blender/draw/intern/draw_manager_text.h # source/blender/draw/intern/draw_texture_pool.cc # source/blender/draw/intern/draw_texture_pool.h # source/blender/draw/intern/draw_view_data.cc # source/blender/draw/intern/draw_view_data.h # source/blender/editors/space_view3d/view3d_draw.c # source/blender/gpu/GPU_texture.h # source/blender/gpu/GPU_viewport.h # source/blender/gpu/intern/gpu_shader_create_info_private.hh # source/blender/gpu/intern/gpu_viewport.c
Diffstat (limited to 'source/blender/simulation')
-rw-r--r--source/blender/simulation/intern/ConstrainedConjugateGradient.h8
-rw-r--r--source/blender/simulation/intern/SIM_mass_spring.cpp5
-rw-r--r--source/blender/simulation/intern/hair_volume.cpp12
-rw-r--r--source/blender/simulation/intern/implicit.h65
-rw-r--r--source/blender/simulation/intern/implicit_blender.c18
5 files changed, 69 insertions, 39 deletions
diff --git a/source/blender/simulation/intern/ConstrainedConjugateGradient.h b/source/blender/simulation/intern/ConstrainedConjugateGradient.h
index c5a2827a09f..d4d6057cd4c 100644
--- a/source/blender/simulation/intern/ConstrainedConjugateGradient.h
+++ b/source/blender/simulation/intern/ConstrainedConjugateGradient.h
@@ -164,13 +164,13 @@ struct traits<
* \brief A conjugate gradient solver for sparse self-adjoint problems with additional constraints
*
* This class allows to solve for A.x = b sparse linear problems using a conjugate gradient
- * algorithm. The sparse matrix A must be selfadjoint. The vectors x and b can be either dense or
+ * algorithm. The sparse matrix A must be self-adjoint. The vectors x and b can be either dense or
* sparse.
*
- * \tparam _MatrixType the type of the sparse matrix A, can be a dense or a sparse matrix.
- * \tparam _UpLo the triangular part that will be used for the computations. It can be Lower
+ * \tparam _MatrixType: the type of the sparse matrix A, can be a dense or a sparse matrix.
+ * \tparam _UpLo: the triangular part that will be used for the computations. It can be Lower
* or Upper. Default is Lower.
- * \tparam _Preconditioner the type of the preconditioner. Default is DiagonalPreconditioner
+ * \tparam _Preconditioner: the type of the pre-conditioner. Default is #DiagonalPreconditioner
*
* The maximal number of iterations and tolerance value can be controlled via the
* setMaxIterations() and setTolerance() methods. The defaults are the size of the problem for the
diff --git a/source/blender/simulation/intern/SIM_mass_spring.cpp b/source/blender/simulation/intern/SIM_mass_spring.cpp
index f9a22276363..73b287b4233 100644
--- a/source/blender/simulation/intern/SIM_mass_spring.cpp
+++ b/source/blender/simulation/intern/SIM_mass_spring.cpp
@@ -625,7 +625,7 @@ static void cloth_calc_force(
}
#endif
- /* cloth_calc_volume_force(clmd); */
+ // cloth_calc_volume_force(clmd);
#ifdef CLOTH_FORCE_DRAG
SIM_mass_spring_force_drag(data, drag);
@@ -1295,8 +1295,7 @@ int SIM_cloth_solve(
BKE_sim_debug_data_clear_category("collision");
if (!clmd->solver_result) {
- clmd->solver_result = (ClothSolverResult *)MEM_callocN(sizeof(ClothSolverResult),
- "cloth solver result");
+ clmd->solver_result = MEM_cnew<ClothSolverResult>("cloth solver result");
}
cloth_clear_result(clmd);
diff --git a/source/blender/simulation/intern/hair_volume.cpp b/source/blender/simulation/intern/hair_volume.cpp
index 348c8683be9..f9b61fe9942 100644
--- a/source/blender/simulation/intern/hair_volume.cpp
+++ b/source/blender/simulation/intern/hair_volume.cpp
@@ -633,9 +633,6 @@ 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 SIM_hair_volume_add_segment(HairGrid *grid,
const float UNUSED(x1[3]),
const float UNUSED(v1[3]),
@@ -649,6 +646,9 @@ void SIM_hair_volume_add_segment(HairGrid *grid,
const float UNUSED(dir2[3]),
const float UNUSED(dir3[3]))
{
+ /* XXX simplified test implementation using a series of discrete sample along the segment,
+ * instead of finding the closest point for all affected grid vertices. */
+
const float radius = 1.5f;
const float dist_scale = grid->inv_cellsize;
@@ -842,8 +842,8 @@ bool SIM_hair_volume_solve_divergence(HairGrid *grid,
}
/* Main Poisson equation system:
- * This is derived from the discretezation of the Poisson equation
- * div(grad(p)) = div(v)
+ * This is derived from the discretization of the Poisson equation:
+ * `div(grad(p)) = div(v)`
*
* The finite difference approximation yields the linear equation system described here:
* https://en.wikipedia.org/wiki/Discrete_Poisson_equation
@@ -1160,7 +1160,7 @@ HairGrid *SIM_hair_volume_create_vertex_grid(float cellsize,
}
size = hair_grid_size(res);
- grid = (HairGrid *)MEM_callocN(sizeof(HairGrid), "hair grid");
+ grid = MEM_cnew<HairGrid>("hair grid");
grid->res[0] = res[0];
grid->res[1] = res[1];
grid->res[2] = res[2];
diff --git a/source/blender/simulation/intern/implicit.h b/source/blender/simulation/intern/implicit.h
index a8693c61018..c8eab94d315 100644
--- a/source/blender/simulation/intern/implicit.h
+++ b/source/blender/simulation/intern/implicit.h
@@ -80,7 +80,8 @@ void SIM_mass_spring_get_motion_state(struct Implicit_Data *data,
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 */
+/* Access to modified motion state during solver step. */
+
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]);
@@ -106,44 +107,64 @@ bool SIM_mass_spring_solve_velocities(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 */
+/**
+ * Clear the force vector at the beginning of the time step.
+ */
void SIM_mass_spring_clear_forces(struct Implicit_Data *data);
-/* Fictitious forces introduced by moving coordinate systems */
+/**
+ * Fictitious forces introduced by moving coordinate systems.
+ */
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 */
+/**
+ * Simple uniform gravity force.
+ */
void SIM_mass_spring_force_gravity(struct Implicit_Data *data,
int index,
float mass,
const float g[3]);
-/* Global drag force (velocity damping) */
+/**
+ * Global drag force (velocity damping).
+ */
void SIM_mass_spring_force_drag(struct Implicit_Data *data, float drag);
-/* Custom external force */
+/**
+ * Custom external force.
+ */
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) */
+/**
+ * Wind force, acting on a face (only generates pressure from the normal component).
+ */
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. */
+/**
+ * Arbitrary per-unit-area vector force field acting on a face..
+ */
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 */
+/**
+ * Wind force, acting on an edge.
+ */
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 */
+/**
+ * Wind force, acting on a vertex.
+ */
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 */
+/**
+ * Linear spring force between two points.
+ */
bool SIM_mass_spring_force_spring_linear(struct Implicit_Data *data,
int i,
int j,
@@ -155,7 +176,9 @@ bool SIM_mass_spring_force_spring_linear(struct Implicit_Data *data,
bool resist_compress,
bool new_compress,
float clamp_force);
-/* Angular spring force between two polygons */
+/**
+ * Angular spring force between two polygons.
+ */
bool SIM_mass_spring_force_spring_angular(struct Implicit_Data *data,
int i,
int j,
@@ -166,10 +189,14 @@ bool SIM_mass_spring_force_spring_angular(struct Implicit_Data *data,
float restang,
float stiffness,
float damping);
-/* Bending force, forming a triangle at the base of two structural springs */
+/**
+ * Bending force, forming a triangle at the base of two structural springs.
+ */
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 */
+/**
+ * Angular bending force based on local target vectors.
+ */
bool SIM_mass_spring_force_spring_bending_hair(struct Implicit_Data *data,
int i,
int j,
@@ -177,7 +204,9 @@ bool SIM_mass_spring_force_spring_bending_hair(struct Implicit_Data *data,
const float target[3],
float stiffness,
float damping);
-/* Global goal spring */
+/**
+ * Global goal spring.
+ */
bool SIM_mass_spring_force_spring_goal(struct Implicit_Data *data,
int i,
const float goal_x[3],
@@ -242,13 +271,15 @@ void SIM_hair_volume_grid_interpolate(struct HairGrid *grid,
float density_gradient[3],
float velocity_gradient[3][3]);
-/* Effect of fluid simulation grid on velocities.
+/**
+ * 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 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,
+/**
+ * WARNING: expressing grid effects on velocity as a force is not very stable,
* due to discontinuities in interpolated values!
* Better use hybrid approaches such as described in
* "Detail Preserving Continuum Simulation of Straight Hair"
diff --git a/source/blender/simulation/intern/implicit_blender.c b/source/blender/simulation/intern/implicit_blender.c
index ad903e9da4a..95bf59101e6 100644
--- a/source/blender/simulation/intern/implicit_blender.c
+++ b/source/blender/simulation/intern/implicit_blender.c
@@ -830,7 +830,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z,
s_prev = s;
s = dot_lfvector(r, r, numverts);
- /* d = r+d*(s/s_prev); */
+ // d = r+d*(s/s_prev);
add_lfvector_lfvectorS(d, r, d, (s / s_prev), numverts);
filter(d, S);
@@ -1475,11 +1475,12 @@ static float calc_nor_area_tri(float nor[3],
return normalize_v3(nor) / 2.0f;
}
-/* XXX does not support force jacobians yet, since the effector system does not provide them either
- */
void SIM_mass_spring_force_face_wind(
Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3])
{
+ /* XXX does not support force jacobians yet,
+ * since the effector system does not provide them either. */
+
const float effector_scale = 0.02f;
const int vs[3] = {v1, v2, v3};
float win[3], nor[3], area;
@@ -1854,10 +1855,11 @@ bool SIM_mass_spring_force_spring_linear(Implicit_Data *data,
return true;
}
-/* See "Stable but Responsive Cloth" (Choi, Ko 2005) */
bool SIM_mass_spring_force_spring_bending(
Implicit_Data *data, int i, int j, float restlen, float kb, float cb)
{
+ /* See "Stable but Responsive Cloth" (Choi, Ko 2005). */
+
float extent[3], length, dir[3], vel[3];
/* calculate elongation */
@@ -1959,8 +1961,6 @@ BLI_INLINE void spring_angle(Implicit_Data *data,
sub_v3_v3(r_vel_b, vel_e);
}
-/* Angular springs roughly based on the bending model proposed by Baraff and Witkin in "Large Steps
- * in Cloth Simulation". */
bool SIM_mass_spring_force_spring_angular(Implicit_Data *data,
int i,
int j,
@@ -2179,9 +2179,6 @@ 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 SIM_mass_spring_force_spring_bending_hair(Implicit_Data *data,
int i,
int j,
@@ -2190,6 +2187,9 @@ bool SIM_mass_spring_force_spring_bending_hair(Implicit_Data *data,
float stiffness,
float damping)
{
+ /* Angular springs roughly based on the bending model proposed by Baraff and Witkin in
+ * "Large Steps in Cloth Simulation". */
+
float goal[3];
float fj[3], fk[3];
float dfj_dxi[3][3], dfj_dxj[3][3], dfk_dxi[3][3], dfk_dxj[3][3], dfk_dxk[3][3];