Blender  V3.3
Functions | Variables
SIM_mass_spring.cpp File Reference
#include "MEM_guardedalloc.h"
#include "DNA_cloth_types.h"
#include "DNA_meshdata_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.h"
#include "BLI_utildefines.h"
#include "BKE_cloth.h"
#include "BKE_collision.h"
#include "BKE_effect.h"
#include "SIM_mass_spring.h"
#include "implicit.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"

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 MVertTri *vt, 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 *UNUSED(ob), 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 *UNUSED(ob), ClothModifierData *clmd, float(*initial_cos)[3], float UNUSED(step), float dt)
 
BLI_INLINE void cloth_calc_spring_force (ClothModifierData *clmd, ClothSpring *s)
 
static void hair_get_boundbox (ClothModifierData *clmd, float gmin[3], float gmax[3])
 
static void cloth_calc_force (Scene *scene, ClothModifierData *clmd, float UNUSED(frame), 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()

static void cloth_calc_average_acceleration ( ClothModifierData clmd,
float  dt 
)
static

◆ cloth_calc_average_pressure()

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

◆ cloth_calc_force()

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

Definition at line 566 of file SIM_mass_spring.cpp.

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, ClothVertex::flags, ClothSpring::flags, ClothSimSettings::flags, float(), ClothSimSettings::fluid_density, EffectorWeights::global_gravity, ClothVertex::goal, ClothSimSettings::goalfrict, ClothSimSettings::goalspring, PhysicsSettings::gravity, ClothModifierData::hairdata, if(), ClothSpring::ij, Cloth::implicit, Cloth::initial_mesh_volume, interp_v3_v3v3(), is_zero_v3(), ClothSpring::kl, ClothVertex::mass, MEM_callocN, MEM_freeN, MEM_mallocN, 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, scene, 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, time, ClothSimSettings::time_scale, Cloth::tri, MVertTri::tri, ClothSpring::type, ClothSimSettings::uniform_pressure_force, v, Cloth::verts, x, ClothVertex::xconst, and ClothVertex::xold.

Referenced by SIM_cloth_solve().

◆ cloth_calc_helper_forces()

static int UNUSED_FUNCTION() cloth_calc_helper_forces ( Object UNUSEDob,
ClothModifierData clmd,
float(*)  initial_cos[3],
float   UNUSEDstep,
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 274 of file SIM_mass_spring.cpp.

References add_v3_v3(), Freestyle::c, CLOTH_SPRING_TYPE_SHEAR, CLOTH_SPRING_TYPE_STRUCTURAL, copy_v3_v3(), KDL::cos(), e, ELEM, float(), ClothVertex::goal, if(), ClothSpring::ij, ClothSpring::kl, l, len, len_squared_v3v3(), len_v3v3(), ClothVertex::mass, MEM_callocN, MEM_freeN, mul_v3_fl(), Cloth::mvert_num, node, normalize_v3(), ClothSpring::restlen, Cloth::springs, steps, sub_v3_v3v3(), ClothVertex::tv, ClothVertex::tx, ClothSpring::type, v1, v2, and Cloth::verts.

◆ cloth_calc_pressure_gradient()

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

◆ cloth_calc_rest_volume()

static float cloth_calc_rest_volume ( ClothModifierData clmd)
static

◆ cloth_calc_spring_force()

BLI_INLINE void cloth_calc_spring_force ( ClothModifierData clmd,
ClothSpring s 
)

Definition at line 358 of file SIM_mass_spring.cpp.

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, 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, ClothSpring::flags, ClothSimSettings::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()

static float cloth_calc_volume ( ClothModifierData clmd)
static

◆ cloth_clear_result()

static void cloth_clear_result ( ClothModifierData clmd)
static

◆ cloth_continuum_add_hair_segments()

static 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()

static void cloth_continuum_fill_grid ( HairGrid grid,
Cloth cloth 
)
static

◆ cloth_continuum_step()

static void cloth_continuum_step ( ClothModifierData clmd,
float  dt 
)
static

◆ cloth_count_nondiag_blocks()

static 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()

static bool cloth_get_pressure_weights ( ClothModifierData clmd,
const MVertTri vt,
float r_weights 
)
static

◆ cloth_record_result()

static void cloth_record_result ( ClothModifierData clmd,
ImplicitSolverResult result,
float  dt 
)
static

◆ cloth_setup_constraints()

static void cloth_setup_constraints ( ClothModifierData clmd)
static

◆ cloth_solve_collisions()

static void cloth_solve_collisions ( Depsgraph depsgraph,
Object ob,
ClothModifierData clmd,
float  step,
float  dt 
)
static

◆ hair_get_boundbox()

static void hair_get_boundbox ( ClothModifierData clmd,
float  gmin[3],
float  gmax[3] 
)
static

◆ hair_spring_next()

BLI_INLINE LinkNode* hair_spring_next ( LinkNode spring_link)

◆ SIM_cloth_solve()

int SIM_cloth_solve ( Depsgraph depsgraph,
Object ob,
float  frame,
ClothModifierData clmd,
ListBase effectors 
)

◆ SIM_cloth_solver_free()

void SIM_cloth_solver_free ( ClothModifierData clmd)

◆ SIM_cloth_solver_init()

int SIM_cloth_solver_init ( Object UNUSEDob,
ClothModifierData clmd 
)

◆ SIM_cloth_solver_set_positions()

void SIM_cloth_solver_set_positions ( ClothModifierData clmd)

◆ 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 200 of file SIM_mass_spring.cpp.

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 31 of file SIM_mass_spring.cpp.

Referenced by SIM_cloth_solver_set_positions().