Blender V4.3
cloth.cc File Reference
#include "MEM_guardedalloc.h"
#include "DNA_cloth_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_linklist.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
#include "BKE_bvhutils.hh"
#include "BKE_cloth.hh"
#include "BKE_customdata.hh"
#include "BKE_effect.h"
#include "BKE_global.hh"
#include "BKE_lib_id.hh"
#include "BKE_mesh.hh"
#include "BKE_modifier.hh"
#include "BKE_pointcache.h"
#include "SIM_mass_spring.h"

Go to the source code of this file.

Classes

struct  BendSpringRef
 

Functions

static void cloth_to_object (Object *ob, ClothModifierData *clmd, float(*vertexCos)[3])
 
static void cloth_from_mesh (ClothModifierData *clmd, const Object *ob, Mesh *mesh)
 
static bool cloth_from_object (Object *ob, ClothModifierData *clmd, Mesh *mesh, float framenr, int first)
 
static void cloth_apply_vgroup (ClothModifierData *clmd, Mesh *mesh)
 
static BVHTreebvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon)
 
void bvhtree_update_from_cloth (ClothModifierData *clmd, bool moving, bool self)
 
void cloth_clear_cache (Object *ob, ClothModifierData *clmd, float framenr)
 
static bool do_init_cloth (Object *ob, ClothModifierData *clmd, Mesh *result, int framenr)
 
static int do_step_cloth (Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, Mesh *result, int framenr)
 
void clothModifier_do (ClothModifierData *clmd, Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *mesh, float(*vertexCos)[3])
 
void cloth_free_modifier (ClothModifierData *clmd)
 
void cloth_free_modifier_extern (ClothModifierData *clmd)
 
int cloth_uses_vgroup (ClothModifierData *clmd)
 
static float cloth_shrink_factor (ClothModifierData *clmd, ClothVertex *verts, int i1, int i2)
 
Spring Network Building Implementation
static void cloth_update_springs (ClothModifierData *clmd)
 
static void cloth_update_verts (Object *ob, ClothModifierData *clmd, Mesh *mesh)
 
static void cloth_update_spring_lengths (ClothModifierData *clmd, Mesh *mesh)
 
static bool cloth_build_springs (ClothModifierData *clmd, Mesh *mesh)
 
BLI_INLINE void spring_verts_ordered_set (ClothSpring *spring, int v0, int v1)
 
static void cloth_free_edgelist (LinkNodePair *edgelist, uint mvert_num)
 
static void cloth_free_errorsprings (Cloth *cloth, LinkNodePair *edgelist, BendSpringRef *spring_ref)
 
BLI_INLINE void cloth_bend_poly_dir (ClothVertex *verts, int i, int j, const int *inds, int len, float r_dir[3])
 
static float cloth_spring_angle (ClothVertex *verts, int i, int j, int *i_a, int *i_b, int len_a, int len_b)
 
static void cloth_hair_update_bending_targets (ClothModifierData *clmd)
 
static void cloth_hair_update_bending_rest_targets (ClothModifierData *clmd)
 
static Meshcloth_make_rest_mesh (ClothModifierData *clmd, Mesh *mesh)
 
BLI_INLINE void cross_identity_v3 (float r[3][3], const float v[3])
 
BLI_INLINE void madd_m3_m3fl (float r[3][3], const float m[3][3], float f)
 
void cloth_parallel_transport_hair_frame (float mat[3][3], const float dir_old[3], const float dir_new[3])
 
static bool cloth_add_shear_bend_spring (ClothModifierData *clmd, LinkNodePair *edgelist, const blender::Span< int > corner_verts, const blender::OffsetIndices< int > faces, int i, int j, int k)
 
BLI_INLINE bool cloth_bend_set_poly_vert_array (int **poly, int len, const int *corner_verts)
 
static bool find_internal_spring_target_vertex (BVHTreeFromMesh *treedata, const blender::Span< blender::float3 > vert_normals, uint v_idx, RNG *rng, float max_length, float max_diversion, bool check_normal, int *r_tar_v_idx)
 

Function Documentation

◆ bvhtree_build_from_cloth()

static BVHTree * bvhtree_build_from_cloth ( ClothModifierData * clmd,
float epsilon )
static

◆ bvhtree_update_from_cloth()

void bvhtree_update_from_cloth ( ClothModifierData * clmd,
bool moving,
bool self )

◆ cloth_add_shear_bend_spring()

◆ cloth_apply_vgroup()

◆ cloth_bend_poly_dir()

BLI_INLINE void cloth_bend_poly_dir ( ClothVertex * verts,
int i,
int j,
const int * inds,
int len,
float r_dir[3] )

Definition at line 925 of file cloth.cc.

References len, madd_v3_v3fl(), normal_tri_v3(), and verts.

Referenced by cloth_spring_angle().

◆ cloth_bend_set_poly_vert_array()

BLI_INLINE bool cloth_bend_set_poly_vert_array ( int ** poly,
int len,
const int * corner_verts )

Definition at line 1358 of file cloth.cc.

References len, and MEM_mallocN.

Referenced by cloth_build_springs().

◆ cloth_build_springs()

static bool cloth_build_springs ( ClothModifierData * clmd,
Mesh * mesh )
static

Definition at line 1452 of file cloth.cc.

References ClothSpring::ang_stiffness, ClothSimSettings::avg_spring_len, ClothSimSettings::bending_model, BKE_bvhtree_from_mesh_get(), BKE_id_free(), BLI_assert, BLI_linklist_prepend(), BLI_rng_free(), BLI_rng_new_srandom(), BVHTREE_FROM_CORNER_TRIS, cloth_add_shear_bend_spring(), cloth_bend_set_poly_vert_array(), CLOTH_BENDING_ANGULAR, CLOTH_BENDING_LINEAR, cloth_free_edgelist(), cloth_free_errorsprings(), cloth_hair_update_bending_rest_targets(), cloth_make_rest_mesh(), cloth_shrink_factor(), CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH, CLOTH_SIMSETTINGS_FLAG_INTERNAL_SPRINGS, CLOTH_SIMSETTINGS_FLAG_INTERNAL_SPRINGS_NORMAL, CLOTH_SIMSETTINGS_FLAG_SEW, cloth_spring_angle(), CLOTH_SPRING_TYPE_BENDING, CLOTH_SPRING_TYPE_BENDING_HAIR, CLOTH_SPRING_TYPE_INTERNAL, CLOTH_SPRING_TYPE_SEWING, CLOTH_SPRING_TYPE_STRUCTURAL, ClothModifierData::clothObject, blender::bke::LooseGeomCache::count, BendSpringRef::face, find_internal_spring_target_vertex(), ClothSimSettings::flags, ClothSpring::flags, float, free_bvhtree_from_mesh(), G, Mesh::id, ClothSpring::ij, BendSpringRef::index, ClothSimSettings::internal_spring_max_diversion, ClothSimSettings::internal_spring_max_length, blender::bke::LooseGeomCache::is_loose_bits, ClothSpring::kl, ClothSpring::la, ClothSpring::lb, len_v3v3(), ClothSpring::lin_stiffness, LinkNode::link, LinkNodePair::list, MEM_callocN, MEM_freeN(), MEM_SAFE_FREE, mesh, ClothSpring::mn, LinkNode::next, ClothSpring::pa, ClothSpring::pb, printf, ClothSpring::restang, ClothSpring::restlen, ClothSimSettings::shapekey_rest, ClothModifierData::sim_parms, size(), BendSpringRef::spring, spring_verts_ordered_set(), and ClothSpring::type.

Referenced by cloth_from_object().

◆ cloth_clear_cache()

◆ cloth_free_edgelist()

static void cloth_free_edgelist ( LinkNodePair * edgelist,
uint mvert_num )
static

Definition at line 887 of file cloth.cc.

References BLI_linklist_free(), and MEM_freeN().

Referenced by cloth_build_springs(), and cloth_free_errorsprings().

◆ cloth_free_errorsprings()

static void cloth_free_errorsprings ( Cloth * cloth,
LinkNodePair * edgelist,
BendSpringRef * spring_ref )
static

◆ cloth_free_modifier()

◆ cloth_free_modifier_extern()

◆ cloth_from_mesh()

◆ cloth_from_object()

◆ cloth_hair_update_bending_rest_targets()

◆ cloth_hair_update_bending_targets()

◆ cloth_make_rest_mesh()

static Mesh * cloth_make_rest_mesh ( ClothModifierData * clmd,
Mesh * mesh )
static

Definition at line 1162 of file cloth.cc.

References BKE_mesh_copy_for_eval(), ClothModifierData::clothObject, Cloth::verts, and verts.

Referenced by cloth_build_springs().

◆ cloth_parallel_transport_hair_frame()

void cloth_parallel_transport_hair_frame ( float mat[3][3],
const float dir_old[3],
const float dir_new[3] )

◆ cloth_shrink_factor()

◆ cloth_spring_angle()

static float cloth_spring_angle ( ClothVertex * verts,
int i,
int j,
int * i_a,
int * i_b,
int len_a,
int len_b )
static

◆ cloth_to_object()

static void cloth_to_object ( Object * ob,
ClothModifierData * clmd,
float(*) vertexCos[3] )
static

Copies the deformed vertices to the object.

Definition at line 571 of file cloth.cc.

References ClothModifierData::clothObject, copy_v3_v3(), invert_m4_m4(), mul_m4_v3(), and Object::runtime.

Referenced by clothModifier_do().

◆ cloth_update_spring_lengths()

◆ cloth_update_springs()

◆ cloth_update_verts()

static void cloth_update_verts ( Object * ob,
ClothModifierData * clmd,
Mesh * mesh )
static

Definition at line 1147 of file cloth.cc.

References ClothModifierData::clothObject, copy_v3_v3(), mul_m4_v3(), Cloth::verts, and verts.

Referenced by do_step_cloth().

◆ cloth_uses_vgroup()

◆ clothModifier_do()

◆ cross_identity_v3()

BLI_INLINE void cross_identity_v3 ( float r[3][3],
const float v[3] )

Definition at line 1238 of file cloth.cc.

References v, and zero_m3().

◆ do_init_cloth()

◆ do_step_cloth()

◆ find_internal_spring_target_vertex()

◆ madd_m3_m3fl()

BLI_INLINE void madd_m3_m3fl ( float r[3][3],
const float m[3][3],
float f )

Definition at line 1249 of file cloth.cc.

◆ spring_verts_ordered_set()

BLI_INLINE void spring_verts_ordered_set ( ClothSpring * spring,
int v0,
int v1 )

Definition at line 875 of file cloth.cc.

References ClothSpring::ij, and ClothSpring::kl.

Referenced by cloth_add_shear_bend_spring(), and cloth_build_springs().