Add Chromium-only Blender WebEngine parity work

This commit is contained in:
mes123456
2026-08-12 04:47:48 -04:00
commit 9fd26010f6
18225 changed files with 11622124 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
# SPDX-FileCopyrightText: 2014 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
set(INC
.
intern
../makesrna
)
set(INC_SYS
)
set(SRC
intern/SIM_mass_spring.cc
intern/hair_volume.cc
intern/implicit_blender.cc
intern/implicit_eigen.cc
intern/ConstrainedConjugateGradient.h
intern/eigen_utils.h
intern/implicit.h
SIM_mass_spring.h
)
set(LIB
PRIVATE bf::blenkernel
PRIVATE bf::blenlib
PRIVATE bf::depsgraph
PRIVATE bf::dna
PRIVATE bf::functions
PRIVATE bf::imbuf
PRIVATE bf::intern::guardedalloc
PRIVATE bf::nodes
PRIVATE bf::dependencies::eigen
)
blender_add_lib(bf_simulation "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -0,0 +1,44 @@
/* SPDX-FileCopyrightText: Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup sim
*/
#pragma once
#include "DNA_listBase.h"
namespace blender {
struct ClothModifierData;
struct Depsgraph;
struct EffectorCache;
struct Implicit_Data;
struct Object;
enum eMassSpringSolverStatus {
SIM_SOLVER_SUCCESS = (1 << 0),
SIM_SOLVER_NUMERICAL_ISSUE = (1 << 1),
SIM_SOLVER_NO_CONVERGENCE = (1 << 2),
SIM_SOLVER_INVALID_INPUT = (1 << 3),
};
struct Implicit_Data *SIM_mass_spring_solver_create(int numverts, int numsprings);
void SIM_mass_spring_solver_free(struct Implicit_Data *id);
int SIM_mass_spring_solver_numvert(struct Implicit_Data *id);
int SIM_cloth_solver_init(struct Object *ob, struct ClothModifierData *clmd);
void SIM_mass_spring_set_implicit_vertex_mass(struct Implicit_Data *data, int index, float mass);
void SIM_cloth_solver_free(struct ClothModifierData *clmd);
int SIM_cloth_solve(struct Depsgraph *depsgraph,
struct Object *ob,
float frame,
struct ClothModifierData *clmd,
ListBaseT<EffectorCache> *effectors);
void SIM_cloth_solver_set_positions(struct ClothModifierData *clmd);
void SIM_cloth_solver_set_volume(struct ClothModifierData *clmd);
} // namespace blender

View File

@@ -0,0 +1,317 @@
/* SPDX-FileCopyrightText: Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup sim
*/
#include <Eigen/Core>
#include <Eigen/IterativeLinearSolvers>
#include <Eigen/Sparse>
class ConstrainedConjugateGradient;
namespace blender::Eigen {
namespace internal {
/**
* \internal Low-level conjugate gradient algorithm
* \param mat: The matrix A
* \param rhs: The right hand side vector b
* \param x: On input and initial solution, on output the computed solution.
* \param precond: A preconditioner being able to efficiently solve for an
* approximation of Ax=b (regardless of b)
* \param iters: On input the max number of iteration,
* on output the number of performed iterations.
* \param tol_error: On input the tolerance error,
* on output an estimation of the relative error.
*/
template<typename MatrixType,
typename Rhs,
typename Dest,
typename FilterMatrixType,
typename Preconditioner>
EIGEN_DONT_INLINE void constrained_conjugate_gradient(const MatrixType &mat,
const Rhs &rhs,
Dest &x,
const FilterMatrixType &filter,
const Preconditioner &precond,
int &iters,
typename Dest::RealScalar &tol_error)
{
using std::abs;
using std::sqrt;
using RealScalar = typename Dest::RealScalar;
using Scalar = typename Dest::Scalar;
using VectorType = Matrix<Scalar, Dynamic, 1>;
RealScalar tol = tol_error;
int maxIters = iters;
int n = mat.cols();
VectorType residual = filter * (rhs - mat * x); /* initial residual */
RealScalar rhsNorm2 = (filter * rhs).squaredNorm();
if (rhsNorm2 == 0) {
/* XXX TODO: set constrained result here. */
x.setZero();
iters = 0;
tol_error = 0;
return;
}
RealScalar threshold = tol * tol * rhsNorm2;
RealScalar residualNorm2 = residual.squaredNorm();
if (residualNorm2 < threshold) {
iters = 0;
tol_error = sqrt(residualNorm2 / rhsNorm2);
return;
}
VectorType p(n);
p = filter * precond.solve(residual); /* initial search direction */
VectorType z(n), tmp(n);
RealScalar absNew = numext::real(
residual.dot(p)); /* The square of the absolute value of `r` scaled by `invM`. */
int i = 0;
while (i < maxIters) {
tmp.noalias() = filter * (mat * p); /* The bottleneck of the algorithm. */
Scalar alpha = absNew / p.dot(tmp); /* The amount we travel on direction. */
x += alpha * p; /* Update solution. */
residual -= alpha * tmp; /* Update residue. */
residualNorm2 = residual.squaredNorm();
if (residualNorm2 < threshold) {
break;
}
z = precond.solve(residual); /* Approximately solve for `A z = residual`. */
RealScalar absOld = absNew;
absNew = numext::real(residual.dot(z)); /* Update the absolute value of `r`. */
/* Calculate the Gram-Schmidt value used to create the new search direction. */
RealScalar beta = absNew / absOld;
p = filter * (z + beta * p); /* Update search direction. */
i++;
}
tol_error = sqrt(residualNorm2 / rhsNorm2);
iters = i;
}
} // namespace internal
#if 0 /* unused */
template<typename MatrixType> struct MatrixFilter {
MatrixFilter() : m_cmat(NULL) {}
MatrixFilter(const MatrixType &cmat) : m_cmat(&cmat) {}
void setMatrix(const MatrixType &cmat)
{
m_cmat = &cmat;
}
template<typename VectorType> void apply(VectorType v) const
{
v = (*m_cmat) * v;
}
protected:
const MatrixType *m_cmat;
};
#endif
template<typename _MatrixType,
int _UpLo = Lower,
typename _FilterMatrixType = _MatrixType,
typename _Preconditioner = DiagonalPreconditioner<typename _MatrixType::Scalar>>
namespace internal
{
template<typename _MatrixType, int _UpLo, typename _FilterMatrixType, typename _Preconditioner>
struct traits<
ConstrainedConjugateGradient<_MatrixType, _UpLo, _FilterMatrixType, _Preconditioner>> {
using MatrixType = _MatrixType;
using FilterMatrixType = _FilterMatrixType;
using Preconditioner = _Preconditioner;
};
} // namespace internal
/** \ingroup IterativeLinearSolvers_Module
* \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 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
* or Upper. Default is Lower.
* \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
* maximal number of iterations and NumTraits<Scalar>::epsilon() for the tolerance.
*
* This class can be used as the direct solver classes. Here is a typical usage example:
* \code
* int n = 10000;
* VectorXd x(n), b(n);
* SparseMatrix<double> A(n,n);
* // fill A and b
* ConjugateGradient<SparseMatrix<double> > cg;
* cg.compute(A);
* x = cg.solve(b);
* std::cout << "#iterations: " << cg.iterations() << std::endl;
* std::cout << "estimated error: " << cg.error() << std::endl;
* // update b, and solve again
* x = cg.solve(b);
* \endcode
*
* By default the iterations start with x=0 as an initial guess of the solution.
* One can control the start using the solveWithGuess() method. Here is a step by
* step execution example starting with a random guess and printing the evolution
* of the estimated error:
* * \code
* x = VectorXd::Random(n);
* cg.setMaxIterations(1);
* int i = 0;
* do {
* x = cg.solveWithGuess(b,x);
* std::cout << i << " : " << cg.error() << std::endl;
* ++i;
* } while (cg.info()!=Success && i<100);
* \endcode
* Note that such a step by step execution is slightly slower.
*
* \sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner
*/
template<typename _MatrixType, int _UpLo, typename _FilterMatrixType, typename _Preconditioner>
class ConstrainedConjugateGradient
: public IterativeSolverBase<
ConstrainedConjugateGradient<_MatrixType, _UpLo, _FilterMatrixType, _Preconditioner>> {
using Base = IterativeSolverBase<ConstrainedConjugateGradient>;
using Base::m_error;
using Base::m_info;
using Base::m_isInitialized;
using Base::m_iterations;
using Base::mp_matrix;
public:
using MatrixType = _MatrixType;
using Scalar = typename MatrixType::Scalar;
using Index = typename MatrixType::Index;
using RealScalar = typename MatrixType::RealScalar;
using FilterMatrixType = _FilterMatrixType;
using Preconditioner = _Preconditioner;
enum { UpLo = _UpLo };
/** Default constructor. */
ConstrainedConjugateGradient() : Base() {}
/**
* Initialize the solver with matrix \a A for further \c Ax=b solving.
*
* This constructor is a shortcut for the default constructor followed
* by a call to compute().
*
* \warning this class stores a reference to the matrix A as well as some
* precomputed values that depend on it. Therefore, if \a A is changed
* this class becomes invalid. Call compute() to update it with the new
* matrix A, or modify a copy of A.
*/
ConstrainedConjugateGradient(const MatrixType &A) : Base(A) {}
~ConstrainedConjugateGradient() = default;
FilterMatrixType &filter()
{
return m_filter;
}
const FilterMatrixType &filter() const
{
return m_filter;
}
/**
* \returns the solution x of \f$ A x = b \f$ using the current decomposition of A
* \a x0 as an initial solution.
*
* \sa compute()
*/
template<typename Rhs, typename Guess>
internal::solve_retval_with_guess<ConstrainedConjugateGradient, Rhs, Guess> solveWithGuess(
const MatrixBase<Rhs> &b, const Guess &x0) const
{
eigen_assert(m_isInitialized && "ConjugateGradient is not initialized.");
eigen_assert(
Base::rows() == b.rows() &&
"ConjugateGradient::solve(): invalid number of rows of the right hand side matrix b");
return internal::solve_retval_with_guess<ConstrainedConjugateGradient, Rhs, Guess>(
*this, b.derived(), x0);
}
/** \internal */
template<typename Rhs, typename Dest> void _solveWithGuess(const Rhs &b, Dest &x) const
{
m_iterations = Base::maxIterations();
m_error = Base::m_tolerance;
for (int j = 0; j < b.cols(); j++) {
m_iterations = Base::maxIterations();
m_error = Base::m_tolerance;
typename Dest::ColXpr xj(x, j);
internal::constrained_conjugate_gradient(mp_matrix->template selfadjointView<UpLo>(),
b.col(j),
xj,
m_filter,
Base::m_preconditioner,
m_iterations,
m_error);
}
m_isInitialized = true;
m_info = m_error <= Base::m_tolerance ? Success : NoConvergence;
}
/** \internal */
template<typename Rhs, typename Dest> void _solve(const Rhs &b, Dest &x) const
{
x.setOnes();
_solveWithGuess(b, x);
}
protected:
FilterMatrixType m_filter;
};
namespace internal {
template<typename _MatrixType, int _UpLo, typename _Filter, typename _Preconditioner, typename Rhs>
struct solve_retval<ConstrainedConjugateGradient<_MatrixType, _UpLo, _Filter, _Preconditioner>,
Rhs>
: solve_retval_base<ConstrainedConjugateGradient<_MatrixType, _UpLo, _Filter, _Preconditioner>,
Rhs> {
using Dec = ConstrainedConjugateGradient<_MatrixType, _UpLo, _Filter, _Preconditioner>;
EIGEN_MAKE_SOLVE_HELPERS(Dec, Rhs)
template<typename Dest> void evalTo(Dest &dst) const
{
dec()._solve(rhs(), dst);
}
};
} // end namespace internal
} // namespace blender::Eigen

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,213 @@
/* SPDX-FileCopyrightText: Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup sim
*/
#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic push
/* XXX suppress verbose warnings in eigen */
# pragma GCC diagnostic ignored "-Wlogical-op"
#endif
#include <Eigen/Sparse>
#include <Eigen/src/Core/util/DisableStupidWarnings.h>
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
#include "implicit.h"
namespace blender {
using Scalar = float;
/* slightly extended Eigen vector class
* with conversion to/from plain C float array
*/
class Vector3 : public Eigen::Vector3f {
public:
using ctype = float *;
Vector3() = default;
Vector3(const ctype &v)
{
for (int k = 0; k < 3; k++) {
coeffRef(k) = v[k];
}
}
Vector3 &operator=(const ctype &v)
{
for (int k = 0; k < 3; k++) {
coeffRef(k) = v[k];
}
return *this;
}
operator ctype()
{
return data();
}
};
/* slightly extended Eigen matrix class
* with conversion to/from plain C float array
*/
class Matrix3 : public Eigen::Matrix3f {
public:
using ctype = float (*)[3];
Matrix3() = default;
Matrix3(const ctype &v)
{
for (int k = 0; k < 3; k++) {
for (int l = 0; l < 3; l++) {
coeffRef(l, k) = v[k][l];
}
}
}
Matrix3 &operator=(const ctype &v)
{
for (int k = 0; k < 3; k++) {
for (int l = 0; l < 3; l++) {
coeffRef(l, k) = v[k][l];
}
}
return *this;
}
operator ctype()
{
return reinterpret_cast<ctype>(data());
}
};
using lVector = Eigen::VectorXf;
/* Extension of dense Eigen vectors,
* providing 3-float block access for `blenlib` math functions
*/
class lVector3f : public Eigen::VectorXf {
public:
using base_t = Eigen::VectorXf;
lVector3f() = default;
template<typename T> lVector3f &operator=(T rhs)
{
base_t::operator=(rhs);
return *this;
}
float *v3(int vertex)
{
return &coeffRef(3 * vertex);
}
const float *v3(int vertex) const
{
return &coeffRef(3 * vertex);
}
};
using Triplet = Eigen::Triplet<Scalar>;
using TripletList = std::vector<Triplet>;
using lMatrix = Eigen::SparseMatrix<Scalar>;
/* Constructor type that provides more convenient handling of Eigen triplets
* for efficient construction of sparse 3x3 block matrices.
* This should be used for building lMatrix instead of writing to such lMatrix directly (which is
* very inefficient). After all elements have been defined using the set() method, the actual
* matrix can be filled using construct().
*/
struct lMatrix3fCtor {
lMatrix3fCtor() = default;
void reset()
{
m_trips.clear();
}
void reserve(int numverts)
{
/* reserve for diagonal entries */
m_trips.reserve(numverts * 9);
}
void add(int i, int j, const Matrix3 &m)
{
i *= 3;
j *= 3;
for (int k = 0; k < 3; k++) {
for (int l = 0; l < 3; l++) {
m_trips.emplace_back(i + k, j + l, m.coeff(l, k));
}
}
}
void sub(int i, int j, const Matrix3 &m)
{
i *= 3;
j *= 3;
for (int k = 0; k < 3; k++) {
for (int l = 0; l < 3; l++) {
m_trips.emplace_back(i + k, j + l, -m.coeff(l, k));
}
}
}
void construct(lMatrix &m)
{
m.setFromTriplets(m_trips.begin(), m_trips.end());
m_trips.clear();
}
private:
TripletList m_trips;
};
using ConjugateGradient =
Eigen::ConjugateGradient<lMatrix, Eigen::Lower, Eigen::DiagonalPreconditioner<Scalar>>;
using Eigen::ComputationInfo;
BLI_INLINE void print_lvector(const lVector3f &v)
{
for (int i = 0; i < v.rows(); i++) {
if (i > 0 && i % 3 == 0) {
printf("\n");
}
printf("%f,\n", v[i]);
}
}
BLI_INLINE void print_lmatrix(const lMatrix &m)
{
for (int j = 0; j < m.rows(); j++) {
if (j > 0 && j % 3 == 0) {
printf("\n");
}
for (int i = 0; i < m.cols(); i++) {
if (i > 0 && i % 3 == 0) {
printf(" ");
}
implicit_print_matrix_elem(m.coeff(j, i));
}
printf("\n");
}
}
} // namespace blender

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,279 @@
/* SPDX-FileCopyrightText: Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup sim
*/
#include "BLI_compiler_compat.h"
#include <cstdio>
namespace blender {
// #define IMPLICIT_SOLVER_EIGEN
#define IMPLICIT_SOLVER_BLENDER
#define CLOTH_ROOT_FRAME /* enable use of root frame coordinate transform */
#define CLOTH_FORCE_GRAVITY
#define CLOTH_FORCE_DRAG
#define CLOTH_FORCE_SPRING_STRUCTURAL
#define CLOTH_FORCE_SPRING_SHEAR
#define CLOTH_FORCE_SPRING_BEND
// #define CLOTH_FORCE_SPRING_GOAL /* UNUSED. */
// #define CLOTH_FORCE_EFFECTORS /* UNUSED. */
// #define IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
// #define IMPLICIT_ENABLE_EIGEN_DEBUG
struct Implicit_Data;
struct ImplicitSolverResult {
int status;
int iterations;
float error;
};
BLI_INLINE void implicit_print_matrix_elem(float v)
{
printf("%-8.3f", v);
}
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 tfm[3][3]);
void SIM_mass_spring_set_motion_state(struct Implicit_Data *data,
int index,
const float x[3],
const float v[3]);
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 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 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 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 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 SIM_mass_spring_add_constraint_ndof2(struct Implicit_Data *data,
int index,
const float c1[3],
const float dV[3]);
bool SIM_mass_spring_solve_velocities(struct Implicit_Data *data,
float dt,
struct ImplicitSolverResult *result);
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 SIM_mass_spring_clear_forces(struct Implicit_Data *data);
/**
* 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.
*/
void SIM_mass_spring_force_gravity(struct Implicit_Data *data,
int index,
float mass,
const float g[3]);
/**
* Global drag force (velocity damping).
*/
void SIM_mass_spring_force_drag(struct Implicit_Data *data, float drag);
/**
* 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).
*/
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 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 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 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 SIM_mass_spring_force_spring_linear(struct Implicit_Data *data,
int i,
int j,
float restlen,
float stiffness_tension,
float damping_tension,
float stiffness_compression,
float damping_compression,
bool resist_compress,
bool new_compress,
float clamp_force);
/**
* Angular spring force between two polygons.
*/
bool SIM_mass_spring_force_spring_angular(struct Implicit_Data *data,
int i,
int j,
int *i_a,
int *i_b,
int len_a,
int len_b,
float restang,
float stiffness,
float damping);
/**
* 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.
*/
bool SIM_mass_spring_force_spring_bending_hair(struct Implicit_Data *data,
int i,
int j,
int k,
const float target[3],
float stiffness,
float damping);
/**
* Global goal spring.
*/
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 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 SIM_mass_spring_force_pressure(struct Implicit_Data *data,
int v1,
int v2,
int v3,
float common_pressure,
const float *vertex_pressure,
const float weights[3]);
/* ======== Hair Volumetric Forces ======== */
struct HairGrid;
#define MAX_HAIR_GRID_RES 256
struct HairGrid *SIM_hair_volume_create_vertex_grid(float cellsize,
const float gmin[3],
const float gmax[3]);
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 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],
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 SIM_hair_volume_normalize_vertex_grid(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 SIM_hair_volume_vertex_grid_filter_box(struct HairVertexGrid *grid, int kernel_size);
#endif
void SIM_hair_volume_grid_interpolate(struct HairGrid *grid,
const float x[3],
float *density,
float velocity[3],
float velocity_smooth[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 SIM_hair_volume_grid_velocity(
struct HairGrid *grid, const float x[3], const float v[3], float fluid_factor, float r_v[3]);
/**
* 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"
* (McAdams, Selle 2009)
*/
void SIM_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]);
} // namespace blender

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff