Blender V5.0
SIM_mass_spring.cc File Reference
#include "MEM_guardedalloc.h"
#include "DNA_cloth_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_linklist.h"
#include "BLI_math_geom.h"
#include "BLI_math_vector.h"
#include "BLI_math_vector.hh"
#include "BLI_utildefines.h"
#include "BKE_cloth.hh"
#include "BKE_collision.h"
#include "BKE_effect.h"
#include "SIM_mass_spring.h"
#include "implicit.h"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"

Go to the source code of this file.

Functions

static int cloth_count_nondiag_blocks (Cloth *cloth)
static bool cloth_get_pressure_weights (ClothModifierData *clmd, const blender::int3 &vert_tri, float *r_weights)
static void cloth_calc_pressure_gradient (ClothModifierData *clmd, const float gradient_vector[3], float *r_vertex_pressure)
static float cloth_calc_volume (ClothModifierData *clmd)
static float cloth_calc_rest_volume (ClothModifierData *clmd)
static float cloth_calc_average_pressure (ClothModifierData *clmd, const float *vertex_pressure)
int SIM_cloth_solver_init (Object *, ClothModifierData *clmd)
void SIM_mass_spring_set_implicit_vertex_mass (Implicit_Data *data, int index, float mass)
void SIM_cloth_solver_free (ClothModifierData *clmd)
void SIM_cloth_solver_set_positions (ClothModifierData *clmd)
void SIM_cloth_solver_set_volume (ClothModifierData *clmd)
static void cloth_setup_constraints (ClothModifierData *clmd)
static int UNUSED_FUNCTION cloth_calc_helper_forces (Object *, ClothModifierData *clmd, float(*initial_cos)[3], float, float dt)
BLI_INLINE void cloth_calc_spring_force (ClothModifierData *clmd, ClothSpring *s)
static void hair_get_boundbox (ClothModifierData *clmd, blender::float3 &gmin, blender::float3 &gmax)
static void cloth_calc_force (Scene *scene, ClothModifierData *clmd, float, ListBase *effectors, float time)
BLI_INLINE void cloth_get_grid_location (Implicit_Data *data, float cell_scale, const float cell_offset[3], int index, float x[3], float v[3])
BLI_INLINE LinkNodehair_spring_next (LinkNode *spring_link)
static LinkNodecloth_continuum_add_hair_segments (HairGrid *grid, const float cell_scale, const float cell_offset[3], Cloth *cloth, LinkNode *spring_link)
static void cloth_continuum_fill_grid (HairGrid *grid, Cloth *cloth)
static void cloth_continuum_step (ClothModifierData *clmd, float dt)
static void cloth_calc_average_acceleration (ClothModifierData *clmd, float dt)
static void cloth_solve_collisions (Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, float step, float dt)
static void cloth_clear_result (ClothModifierData *clmd)
static void cloth_record_result (ClothModifierData *clmd, ImplicitSolverResult *result, float dt)
int SIM_cloth_solve (Depsgraph *depsgraph, Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors)

Variables

static float I3 [3][3] = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}

Function Documentation

◆ cloth_calc_average_acceleration()

◆ cloth_calc_average_pressure()

float cloth_calc_average_pressure ( ClothModifierData * clmd,
const float * vertex_pressure )
static

◆ cloth_calc_force()

void cloth_calc_force ( Scene * scene,
ClothModifierData * clmd,
float ,
ListBase * effectors,
float time )
static

Definition at line 566 of file SIM_mass_spring.cc.

References Cloth::average_acceleration, ClothSimSettings::avg_spring_len, BKE_effectors_apply(), CLAMP_MAX, cloth_calc_average_pressure(), cloth_calc_pressure_gradient(), cloth_calc_spring_force(), cloth_calc_volume(), cloth_get_pressure_weights(), CLOTH_SIMSETTINGS_FLAG_PRESSURE, CLOTH_SIMSETTINGS_FLAG_PRESSURE_VOL, CLOTH_SPRING_FLAG_DEACTIVATE, CLOTH_SPRING_TYPE_STRUCTURAL, CLOTH_VERT_FLAG_PINNED, ClothModifierData::clothObject, copy_v3_v3(), ClothSimSettings::Cvi, data, ClothSimSettings::effector_weights, fabs(), PhysicsSettings::flag, ClothSimSettings::flags, ClothSpring::flags, ClothVertex::flags, float, ClothSimSettings::fluid_density, EffectorWeights::global_gravity, ClothVertex::goal, ClothSimSettings::goalfrict, ClothSimSettings::goalspring, PhysicsSettings::gravity, ClothModifierData::hairdata, i, ClothSpring::ij, Cloth::implicit, Cloth::initial_mesh_volume, interp_v3_v3v3(), is_zero_v3(), ClothSpring::kl, ClothVertex::mass, MEM_calloc_arrayN(), MEM_freeN(), MEM_malloc_arrayN(), mul_v3_fl(), mul_v3_v3fl(), Cloth::mvert_num, LinkNode::next, pd_point_from_loc(), PHYS_GLOBAL_GRAVITY, Scene::physics_settings, ClothSimSettings::pressure_factor, Cloth::primitive_num, ClothHairData::radius, SIM_mass_spring_force_drag(), SIM_mass_spring_force_edge_wind(), SIM_mass_spring_force_face_extern(), SIM_mass_spring_force_face_wind(), SIM_mass_spring_force_gravity(), SIM_mass_spring_force_pressure(), SIM_mass_spring_force_spring_goal(), SIM_mass_spring_force_vertex_wind(), SIM_mass_spring_get_motion_state(), ClothModifierData::sim_parms, Cloth::springs, sub_v3_v3(), sub_v3_v3v3(), ClothSimSettings::target_volume, ClothSimSettings::time_scale, ClothSpring::type, ClothSimSettings::uniform_pressure_force, v, Cloth::vert_tris, Cloth::verts, x, ClothVertex::xconst, and ClothVertex::xold.

Referenced by SIM_cloth_solve().

◆ cloth_calc_helper_forces()

int UNUSED_FUNCTION cloth_calc_helper_forces ( Object * ,
ClothModifierData * clmd,
float(*) initial_cos[3],
float ,
float dt )
static

Computes where the cloth would be if it were subject to perfectly stiff edges (edge distance constraints) in a lagrangian solver. Then add forces to help guide the implicit solver to that state. This function is called after collisions.

Definition at line 276 of file SIM_mass_spring.cc.

References add_v3_v3(), cloth_calc_helper_forces(), CLOTH_SPRING_TYPE_SHEAR, CLOTH_SPRING_TYPE_STRUCTURAL, copy_v3_v3(), cos, e, ELEM, float, ClothVertex::goal, i, ClothSpring::ij, ClothSpring::kl, l, len, len_squared_v3v3(), len_v3v3(), LinkNode::link, ClothVertex::mass, MEM_calloc_arrayN(), MEM_freeN(), mul_v3_fl(), Cloth::mvert_num, LinkNode::next, normalize_v3(), ClothSpring::restlen, Cloth::springs, sub_v3_v3v3(), ClothVertex::tv, ClothVertex::tx, ClothSpring::type, v2, and Cloth::verts.

Referenced by cloth_calc_helper_forces().

◆ cloth_calc_pressure_gradient()

void cloth_calc_pressure_gradient ( ClothModifierData * clmd,
const float gradient_vector[3],
float * r_vertex_pressure )
static

◆ cloth_calc_rest_volume()

◆ cloth_calc_spring_force()

BLI_INLINE void cloth_calc_spring_force ( ClothModifierData * clmd,
ClothSpring * s )

Definition at line 355 of file SIM_mass_spring.cc.

References ClothSpring::ang_stiffness, ClothSimSettings::avg_spring_len, ClothSimSettings::bending, ClothSimSettings::bending_damping, ClothSimSettings::bending_model, BKE_sim_debug_data_add_dot, BKE_sim_debug_data_add_line, BKE_sim_debug_data_add_vector, BLI_assert, BLI_INLINE, CLOTH_BENDING_ANGULAR, CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS, CLOTH_SPRING_FLAG_NEEDED, CLOTH_SPRING_TYPE_BENDING, CLOTH_SPRING_TYPE_BENDING_HAIR, CLOTH_SPRING_TYPE_INTERNAL, CLOTH_SPRING_TYPE_SEWING, CLOTH_SPRING_TYPE_SHEAR, CLOTH_SPRING_TYPE_STRUCTURAL, ClothModifierData::clothObject, ClothSimSettings::compression, ClothSimSettings::compression_damp, copy_v3_v3(), data, fabsf, ClothSimSettings::flags, ClothSpring::flags, ClothSpring::ij, Cloth::implicit, ClothSimSettings::internal_compression, ClothSimSettings::internal_tension, ClothSpring::kl, ClothSpring::la, ClothSpring::lb, ClothSpring::lin_stiffness, ClothSimSettings::max_bend, ClothSimSettings::max_compression, ClothSimSettings::max_internal_compression, ClothSimSettings::max_internal_tension, ClothSimSettings::max_sewing, ClothSimSettings::max_shear, ClothSimSettings::max_tension, ClothSpring::mn, ClothSpring::pa, ClothSpring::pb, ClothSpring::restang, ClothSpring::restlen, ClothSimSettings::shear, ClothSimSettings::shear_damp, SIM_mass_spring_force_spring_angular(), SIM_mass_spring_force_spring_bending(), SIM_mass_spring_force_spring_bending_hair(), SIM_mass_spring_force_spring_linear(), SIM_mass_spring_get_motion_state(), ClothModifierData::sim_parms, ClothSpring::target, ClothSimSettings::tension, ClothSimSettings::tension_damp, ClothSpring::type, and v.

Referenced by cloth_calc_force().

◆ cloth_calc_volume()

◆ cloth_clear_result()

◆ cloth_continuum_add_hair_segments()

LinkNode * cloth_continuum_add_hair_segments ( HairGrid * grid,
const float cell_scale,
const float cell_offset[3],
Cloth * cloth,
LinkNode * spring_link )
static

◆ cloth_continuum_fill_grid()

◆ cloth_continuum_step()

◆ cloth_count_nondiag_blocks()

int cloth_count_nondiag_blocks ( Cloth * cloth)
static

◆ cloth_get_grid_location()

BLI_INLINE void cloth_get_grid_location ( Implicit_Data * data,
float cell_scale,
const float cell_offset[3],
int index,
float x[3],
float v[3] )

◆ cloth_get_pressure_weights()

◆ cloth_record_result()

◆ cloth_setup_constraints()

◆ cloth_solve_collisions()

◆ hair_get_boundbox()

◆ hair_spring_next()

◆ SIM_cloth_solve()

◆ SIM_cloth_solver_free()

void SIM_cloth_solver_free ( ClothModifierData * clmd)

◆ SIM_cloth_solver_init()

◆ SIM_cloth_solver_set_positions()

◆ SIM_cloth_solver_set_volume()

void SIM_cloth_solver_set_volume ( ClothModifierData * clmd)

◆ SIM_mass_spring_set_implicit_vertex_mass()

void SIM_mass_spring_set_implicit_vertex_mass ( Implicit_Data * data,
int index,
float mass )

Definition at line 202 of file SIM_mass_spring.cc.

References data, and SIM_mass_spring_set_vertex_mass().

Referenced by do_step_cloth(), and SIM_cloth_solver_init().

Variable Documentation

◆ I3

float I3[3][3] = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}
static

Definition at line 33 of file SIM_mass_spring.cc.

Referenced by SIM_cloth_solver_set_positions().