Blender V4.3
SIM_mass_spring.cc File Reference
#include <algorithm>
#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()

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 ,
ListBase * effectors,
float time )
static

Definition at line 570 of file SIM_mass_spring.cc.

References 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, ClothSimSettings::effector_weights, fabs(), ClothSimSettings::flags, ClothSpring::flags, ClothVertex::flags, float, ClothSimSettings::fluid_density, EffectorWeights::global_gravity, ClothVertex::goal, ClothSimSettings::goalfrict, ClothSimSettings::goalspring, ClothModifierData::hairdata, ClothSpring::ij, interp_v3_v3v3(), is_zero_v3(), ClothSpring::kl, ClothVertex::mass, MEM_callocN, MEM_freeN(), MEM_mallocN, mul_v3_fl(), mul_v3_v3fl(), pd_point_from_loc(), PHYS_GLOBAL_GRAVITY, ClothSimSettings::pressure_factor, 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, sub_v3_v3(), sub_v3_v3v3(), ClothSimSettings::target_volume, ClothSimSettings::time_scale, ClothSpring::type, ClothSimSettings::uniform_pressure_force, v, ClothVertex::xconst, and ClothVertex::xold.

Referenced by SIM_cloth_solve().

◆ cloth_calc_helper_forces()

static 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 278 of file SIM_mass_spring.cc.

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

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

◆ cloth_calc_spring_force()

◆ cloth_calc_volume()

◆ cloth_clear_result()

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

◆ cloth_continuum_step()

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

◆ cloth_record_result()

◆ cloth_setup_constraints()

static void cloth_setup_constraints ( ClothModifierData * clmd)
static

◆ cloth_solve_collisions()

◆ hair_get_boundbox()

static void hair_get_boundbox ( ClothModifierData * clmd,
blender::float3 & gmin,
blender::float3 & gmax )
static

◆ 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 204 of file SIM_mass_spring.cc.

References 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 35 of file SIM_mass_spring.cc.

Referenced by SIM_cloth_solver_set_positions().