Blender
V3.3
|
#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_edgehash.h"
#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "BKE_bvhutils.h"
#include "BKE_cloth.h"
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_lib_id.h"
#include "BKE_mesh.h"
#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_pointcache.h"
#include "SIM_mass_spring.h"
Go to the source code of this file.
Classes | |
struct | BendSpringRef |
Typedefs | |
typedef struct BendSpringRef | BendSpringRef |
typedef struct BendSpringRef BendSpringRef |
|
static |
Definition at line 64 of file cloth.c.
References BLI_bvhtree_balance(), BLI_bvhtree_insert(), BLI_bvhtree_new(), ClothModifierData::clothObject, copy_v3_v3(), Cloth::edges, blender::robust_pred::epsilon, ClothModifierData::hairdata, NULL, Cloth::primitive_num, Cloth::tri, MVertTri::tri, v1, v2, Cloth::verts, and verts.
Referenced by cloth_from_object().
void bvhtree_update_from_cloth | ( | ClothModifierData * | clmd, |
bool | moving, | ||
bool | self | ||
) |
Definition at line 118 of file cloth.c.
References BLI_assert, BLI_bvhtree_update_node(), BLI_bvhtree_update_tree(), Cloth::bvhselftree, Cloth::bvhtree, ClothModifierData::clothObject, copy_v3_v3(), Cloth::edges, ClothModifierData::hairdata, NULL, Cloth::primitive_num, ret, Cloth::tri, MVertTri::tri, v1, v2, Cloth::verts, and verts.
Referenced by cloth_bvh_collision().
|
static |
Definition at line 1276 of file cloth.c.
References ClothSpring::ang_stiffness, ClothVertex::bend_stiff, ClothSimSettings::bending_model, BLI_linklist_append(), BLI_linklist_prepend(), CLOTH_BENDING_ANGULAR, cloth_shrink_factor(), cloth_spring_angle(), CLOTH_SPRING_TYPE_BENDING, CLOTH_SPRING_TYPE_SHEAR, ClothModifierData::clothObject, ClothSpring::ij, ClothSpring::kl, ClothSpring::la, ClothSpring::lb, len_v3v3(), ClothSpring::lin_stiffness, MPoly::loopstart, MEM_callocN, MEM_mallocN, ClothSpring::mn, ClothSpring::pa, ClothSpring::pb, ClothSpring::restang, ClothSpring::restlen, ClothVertex::shear_stiff, ClothModifierData::sim_parms, spring_verts_ordered_set(), Cloth::springs, MPoly::totloop, ClothSpring::type, v, MLoop::v, Cloth::verts, x, ClothVertex::xrest, and y.
Referenced by cloth_build_springs().
|
static |
Applies a vertex group as specified by type.
Definition at line 607 of file cloth.c.
References CD_MDEFORMVERT, cloth_uses_vgroup(), CLOTH_VERT_FLAG_NOOBJCOLL, CLOTH_VERT_FLAG_NOSELFCOLL, CLOTH_VERT_FLAG_PINNED, ClothModifierData::clothObject, ClothModifierData::coll_parms, CustomData_get(), MDeformWeight::def_nr, ClothSimSettings::defgoal, MDeformVert::dw, mesh, pow4f(), ClothModifierData::sim_parms, SOFTGOALSNAP, Mesh::totvert, MDeformVert::totweight, Mesh::vdata, Cloth::verts, verts, ClothSimSettings::vgroup_bend, ClothSimSettings::vgroup_intern, ClothSimSettings::vgroup_mass, ClothCollSettings::vgroup_objcol, ClothSimSettings::vgroup_pressure, ClothCollSettings::vgroup_selfcol, ClothSimSettings::vgroup_shear, ClothSimSettings::vgroup_shrink, ClothSimSettings::vgroup_struct, and MDeformWeight::weight.
Referenced by cloth_from_object(), and do_step_cloth().
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 929 of file cloth.c.
References len, madd_v3_v3fl(), normal_tri_v3(), verts, and x.
Referenced by cloth_spring_angle().
BLI_INLINE bool cloth_bend_set_poly_vert_array | ( | int ** | poly, |
int | len, | ||
const MLoop * | mloop | ||
) |
Definition at line 1359 of file cloth.c.
References len, MEM_mallocN, and MLoop::v.
Referenced by cloth_build_springs().
|
static |
Definition at line 1453 of file cloth.c.
References ClothSpring::ang_stiffness, ClothVertex::avg_spring_len, ClothSimSettings::avg_spring_len, ClothVertex::bend_stiff, ClothSimSettings::bending_model, BKE_bvhtree_from_mesh_get(), BKE_id_free(), BLI_assert, BLI_edgeset_add(), BLI_edgeset_free(), BLI_edgeset_haskey(), BLI_edgeset_insert(), BLI_edgeset_new(), BLI_edgeset_new_ex(), BLI_linklist_prepend(), BLI_rng_free(), BLI_rng_new_srandom(), BVHTREE_FROM_LOOPTRI, 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, MLoop::e, Cloth::edgeset, find_internal_spring_target_vertex(), ClothSpring::flags, ClothSimSettings::flags, float(), free_bvhtree_from_mesh(), G, Mesh::id, if(), ClothSpring::ij, BendSpringRef::index, ClothSimSettings::internal_spring_max_diversion, ClothSimSettings::internal_spring_max_length, ClothVertex::internal_stiff, ClothSpring::kl, ClothSpring::la, ClothSpring::lb, len_v3v3(), ClothSpring::lin_stiffness, LinkNode::link, ME_LOOSEEDGE, Mesh::medge, MEM_callocN, MEM_freeN, MEM_SAFE_FREE, mesh, Mesh::mloop, ClothSpring::mn, Mesh::mpoly, LinkNode::next, NULL, Cloth::numsprings, ClothSpring::pa, ClothSpring::pb, BendSpringRef::polys, ClothSpring::restang, ClothSpring::restlen, Cloth::sew_edge_graph, ClothSimSettings::shapekey_rest, ClothModifierData::sim_parms, BendSpringRef::spring, ClothVertex::spring_count, spring_verts_ordered_set(), Cloth::springs, ClothVertex::struct_stiff, Mesh::totedge, Mesh::totpoly, Mesh::totvert, ClothSpring::type, v, v1, v2, Cloth::verts, and ClothVertex::xrest.
Referenced by cloth_from_object().
void cloth_clear_cache | ( | Object * | ob, |
ClothModifierData * | clmd, | ||
float | framenr | ||
) |
Definition at line 198 of file cloth.c.
References BKE_ptcache_id_clear(), BKE_ptcache_id_from_cloth(), PTCacheID::cache, PointCache::edit, Object::mode, OB_MODE_PARTICLE_EDIT, and PTCACHE_CLEAR_AFTER.
|
static |
Definition at line 888 of file cloth.c.
References BLI_linklist_free(), MEM_freeN, and NULL.
Referenced by cloth_build_springs(), and cloth_free_errorsprings().
|
static |
Definition at line 899 of file cloth.c.
References BLI_edgeset_free(), BLI_linklist_free(), cloth_free_edgelist(), Cloth::edgeset, LinkNode::link, MEM_freeN, MEM_SAFE_FREE, Cloth::mvert_num, LinkNode::next, NULL, ClothSpring::pa, ClothSpring::pb, and Cloth::springs.
Referenced by cloth_build_springs().
void cloth_free_modifier | ( | struct ClothModifierData * | clmd | ) |
Frees all.
Definition at line 421 of file cloth.c.
References BLI_bvhtree_free(), BLI_edgeset_free(), BLI_linklist_free(), Cloth::bvhselftree, Cloth::bvhtree, ClothModifierData::clothObject, Cloth::edgeset, LinkNode::link, MEM_freeN, MEM_SAFE_FREE, Cloth::mvert_num, LinkNode::next, NULL, Cloth::numsprings, ClothSpring::pa, ClothSpring::pb, Cloth::sew_edge_graph, SIM_cloth_solver_free(), Cloth::springs, Cloth::tri, and Cloth::verts.
Referenced by BKE_ptcache_id_reset(), cloth_from_mesh(), cloth_from_object(), free_hair(), and hair_step().
void cloth_free_modifier_extern | ( | struct ClothModifierData * | clmd | ) |
Frees all.
Definition at line 491 of file cloth.c.
References BLI_bvhtree_free(), BLI_edgeset_free(), BLI_linklist_free(), Cloth::bvhselftree, Cloth::bvhtree, ClothModifierData::clothObject, Cloth::edgeset, G, G_DEBUG_SIMDATA, LinkNode::link, MEM_freeN, MEM_SAFE_FREE, Cloth::mvert_num, LinkNode::next, NULL, Cloth::numsprings, ClothSpring::pa, ClothSpring::pb, Cloth::sew_edge_graph, SIM_cloth_solver_free(), Cloth::springs, Cloth::tri, and Cloth::verts.
Referenced by freeData().
|
static |
Definition at line 825 of file cloth.c.
References BKE_mesh_runtime_looptri_ensure(), BKE_mesh_runtime_verttri_from_looptri(), BKE_modifier_set_error(), cloth_free_modifier(), ClothModifierData::clothObject, Cloth::edges, ClothModifierData::hairdata, MLoopTri_Store::len, Mesh_Runtime::looptris, Mesh::medge, MEM_callocN, MEM_freeN, MEM_mallocN, mesh, Mesh::mloop, ClothModifierData::modifier, Cloth::mvert_num, NULL, Cloth::primitive_num, Mesh::runtime, Cloth::springs, Mesh::totedge, Mesh::totvert, Cloth::tri, and Cloth::verts.
Referenced by cloth_from_object().
|
static |
Referenced by do_init_cloth().
|
static |
Definition at line 712 of file cloth.c.
References BKE_modifier_set_error(), Cloth::bvhselftree, Cloth::bvhtree, bvhtree_build_from_cloth(), CD_CLOTH_ORCO, cloth_apply_vgroup(), cloth_build_springs(), cloth_free_modifier(), cloth_from_mesh(), CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH, ClothModifierData::clothObject, MVert::co, ClothModifierData::coll_parms, copy_v3_v3(), CustomData_get_layer(), ClothSimSettings::defgoal, Cloth::edgeset, ClothCollSettings::epsilon, ClothSimSettings::flags, float(), G, G_DEBUG_SIMDATA, ClothSimSettings::mass, MEM_callocN, mesh, ClothModifierData::modifier, mul_m4_v3(), mul_v3_fl(), Mesh::mvert, NULL, Cloth::numsprings, Object::obmat, Cloth::old_solver_type, ClothCollSettings::selfepsilon, Cloth::sew_edge_graph, ClothSimSettings::shapekey_rest, SIM_cloth_solver_init(), SIM_cloth_solver_set_positions(), ClothModifierData::sim_parms, Cloth::springs, Mesh::totvert, Mesh::vdata, Cloth::verts, verts, and ClothSimSettings::vgroup_mass.
|
static |
Definition at line 1024 of file cloth.c.
References cloth_parallel_transport_hair_frame(), CLOTH_SPRING_TYPE_BENDING_HAIR, ClothModifierData::clothObject, copy_m3_m3(), copy_v3_v3(), ClothModifierData::hairdata, ClothSpring::ij, ClothSpring::kl, LinkNode::link, ClothSpring::mn, mul_transposed_m3_v3(), LinkNode::next, normalize_v3(), NULL, ClothHairData::rest_target, ClothHairData::rot, Cloth::springs, sub_v3_v3v3(), ClothSpring::type, Cloth::verts, and ClothVertex::xrest.
Referenced by cloth_build_springs().
|
static |
Definition at line 966 of file cloth.c.
References cloth_parallel_transport_hair_frame(), CLOTH_SPRING_TYPE_BENDING_HAIR, ClothModifierData::clothObject, copy_m3_m3(), copy_v3_v3(), ClothModifierData::hairdata, ClothSpring::ij, ClothSpring::kl, LinkNode::link, ClothSpring::mn, mul_v3_fl(), mul_v3_m3v3(), LinkNode::next, normalize_v3(), NULL, ClothHairData::rest_target, ClothSpring::restlen, ClothHairData::rot, Cloth::springs, sub_v3_v3v3(), ClothSpring::target, ClothSpring::type, Cloth::verts, and ClothVertex::x.
Referenced by cloth_update_springs().
|
static |
Definition at line 1164 of file cloth.c.
References BKE_mesh_copy_for_eval(), BKE_mesh_tag_coords_changed(), ClothModifierData::clothObject, copy_v3_v3(), mesh, Mesh::mvert, Mesh::totvert, Cloth::verts, and verts.
Referenced by cloth_build_springs().
void cloth_parallel_transport_hair_frame | ( | float | mat[3][3], |
const float | dir_old[3], | ||
const float | dir_new[3] | ||
) |
Definition at line 1262 of file cloth.c.
References mul_m3_m3m3(), rot, and rotation_between_vecs_to_mat3().
Referenced by cloth_hair_update_bending_rest_targets(), and cloth_hair_update_bending_targets().
|
static |
Definition at line 698 of file cloth.c.
References i1, ClothSimSettings::shrink_max, ClothSimSettings::shrink_min, ClothModifierData::sim_parms, sqrtf, and verts.
Referenced by cloth_add_shear_bend_spring(), cloth_build_springs(), and cloth_update_spring_lengths().
|
static |
Definition at line 942 of file cloth.c.
References atan2f, cloth_bend_poly_dir(), KDL::cos(), cross_v3_v3v3(), dot_v3v3(), normalize_v3(), KDL::sin(), sub_v3_v3v3(), and verts.
Referenced by cloth_add_shear_bend_spring(), cloth_build_springs(), and cloth_update_spring_lengths().
|
static |
Copies the deformed vertices to the object.
Definition at line 577 of file cloth.c.
References ClothModifierData::clothObject, copy_v3_v3(), Object::imat, invert_m4_m4(), mul_m4_v3(), Cloth::mvert_num, Object::obmat, Cloth::verts, and ClothVertex::x.
Referenced by clothModifier_do().
|
static |
Definition at line 1180 of file cloth.c.
References ClothVertex::avg_spring_len, ClothSimSettings::avg_spring_len, cloth_shrink_factor(), cloth_spring_angle(), CLOTH_SPRING_TYPE_BENDING, CLOTH_SPRING_TYPE_INTERNAL, CLOTH_SPRING_TYPE_SEWING, CLOTH_SPRING_TYPE_SHEAR, CLOTH_SPRING_TYPE_STRUCTURAL, ClothModifierData::clothObject, float(), ClothSpring::ij, ClothSpring::kl, ClothSpring::la, ClothSpring::lb, len_v3v3(), LinkNode::link, mesh, LinkNode::next, ClothSpring::pa, ClothSpring::pb, ClothSpring::restang, ClothSpring::restlen, ClothModifierData::sim_parms, ClothVertex::spring_count, Cloth::springs, Mesh::totvert, ClothSpring::type, Cloth::verts, and ClothVertex::xrest.
Referenced by do_step_cloth().
|
static |
Definition at line 1080 of file cloth.c.
References ALMOST_ZERO, ClothSpring::ang_stiffness, ClothVertex::bend_stiff, ClothSimSettings::bending_model, ClothHairData::bending_stiffness, CLOTH_BENDING_ANGULAR, cloth_hair_update_bending_targets(), CLOTH_SPRING_FLAG_DEACTIVATE, CLOTH_SPRING_TYPE_BENDING, CLOTH_SPRING_TYPE_BENDING_HAIR, CLOTH_SPRING_TYPE_GOAL, CLOTH_SPRING_TYPE_INTERNAL, CLOTH_SPRING_TYPE_SHEAR, CLOTH_SPRING_TYPE_STRUCTURAL, CLOTH_VERT_FLAG_PINNED, ClothModifierData::clothObject, ClothVertex::flags, ClothSpring::flags, ClothVertex::goal, ClothModifierData::hairdata, ClothSpring::ij, ClothVertex::internal_stiff, ClothSpring::kl, ClothSpring::lin_stiffness, LinkNode::link, LinkNode::next, NULL, ClothVertex::shear_stiff, ClothModifierData::sim_parms, Cloth::springs, ClothVertex::struct_stiff, ClothSpring::type, v1, v2, and Cloth::verts.
Referenced by do_step_cloth().
|
static |
Definition at line 1150 of file cloth.c.
References ClothModifierData::clothObject, MVert::co, copy_v3_v3(), mesh, mul_m4_v3(), Mesh::mvert, Object::obmat, Mesh::totvert, Cloth::verts, and verts.
Referenced by do_step_cloth().
int cloth_uses_vgroup | ( | ClothModifierData * | clmd | ) |
Definition at line 593 of file cloth.c.
References CLOTH_COLLSETTINGS_FLAG_ENABLED, CLOTH_COLLSETTINGS_FLAG_SELF, ClothModifierData::coll_parms, ClothCollSettings::flags, ClothModifierData::sim_parms, ClothSimSettings::vgroup_bend, ClothSimSettings::vgroup_intern, ClothSimSettings::vgroup_mass, ClothCollSettings::vgroup_objcol, ClothSimSettings::vgroup_pressure, ClothCollSettings::vgroup_selfcol, ClothSimSettings::vgroup_shrink, and ClothSimSettings::vgroup_struct.
Referenced by cloth_apply_vgroup(), and requiredDataMask().
void clothModifier_do | ( | ClothModifierData * | clmd, |
Depsgraph * | depsgraph, | ||
Scene * | scene, | ||
Object * | ob, | ||
Mesh * | mesh, | ||
float(*) | vertexCos[3] | ||
) |
Definition at line 314 of file cloth.c.
References BKE_ptcache_id_from_cloth(), BKE_ptcache_id_reset(), BKE_ptcache_id_time(), BKE_ptcache_invalidate(), BKE_ptcache_read(), BKE_ptcache_validate(), BKE_ptcache_write(), cloth_to_object(), ClothModifierData::clothObject, DEG_get_ctime(), depsgraph, do_init_cloth(), do_step_cloth(), PointCache::flag, PointCache::last_exact, Cloth::last_frame, mesh, Cloth::mvert_num, ClothModifierData::point_cache, PTCACHE_BAKED, PTCACHE_OUTDATED, PTCACHE_READ_EXACT, PTCACHE_READ_INTERPOLATED, PTCACHE_READ_OLD, PTCACHE_REDO_NEEDED, PTCACHE_RESET_OUTDATED, Scene::r, ClothSimSettings::reset, scene, SIM_cloth_solver_set_positions(), ClothModifierData::sim_parms, PointCache::simframe, RenderData::subframe, ClothSimSettings::time_scale, ClothSimSettings::timescale, and Mesh::totvert.
Referenced by deformVerts(), and do_hair_dynamics().
BLI_INLINE void cross_identity_v3 | ( | float | r[3][3], |
const float | v[3] | ||
) |
|
static |
Definition at line 212 of file cloth.c.
References BKE_modifier_set_error(), BKE_ptcache_invalidate(), cloth_from_object(), CLOTH_SIMSETTINGS_FLAG_PRESSURE, CLOTH_SIMSETTINGS_FLAG_PRESSURE_VOL, ClothModifierData::clothObject, ClothSimSettings::dt, ClothSimSettings::flags, Cloth::last_frame, MINFRAME, ClothModifierData::modifier, NULL, ClothModifierData::point_cache, result, SIM_cloth_solver_set_positions(), SIM_cloth_solver_set_volume(), ClothModifierData::sim_parms, and ClothSimSettings::stepsPerFrame.
Referenced by clothModifier_do().
|
static |
Definition at line 247 of file cloth.c.
References BKE_effectors_create(), BKE_effectors_free(), cloth_apply_vgroup(), CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH, cloth_update_spring_lengths(), cloth_update_springs(), cloth_update_verts(), ClothModifierData::clothObject, MVert::co, copy_v3_v3(), depsgraph, ClothSimSettings::effector_weights, ClothSimSettings::flags, Cloth::implicit, ClothSimSettings::mass, mul_m4_v3(), Cloth::mvert_num, NULL, Object::obmat, result, ret, ClothSimSettings::shrink_min, SIM_cloth_solve(), SIM_mass_spring_set_implicit_vertex_mass(), ClothModifierData::sim_parms, Cloth::verts, verts, and ClothSimSettings::vgroup_shrink.
Referenced by clothModifier_do().
|
static |
Definition at line 1376 of file cloth.c.
References add_v3_v3(), BLI_bvhtree_ray_cast(), BLI_rng_get_float(), BVHTreeRayHit::co, MVert::co, copy_v3_v3(), BVHTreeRayHit::dist, dot_v3v3(), BVHTreeRayHit::index, len, len_v3v3(), BVHTreeFromMesh::loop, BVHTreeFromMesh::looptri, mul_v3_fl(), negate_v3_v3(), BVHTreeRayHit::no, normalize_v3(), NULL, offset, BVHTreeFromMesh::raycast_callback, KDL::sin(), BVHTreeFromMesh::tree, MLoopTri::tri, MLoop::v, BVHTreeFromMesh::vert, and BVHTreeFromMesh::vert_normals.
Referenced by cloth_build_springs().
BLI_INLINE void madd_m3_m3fl | ( | float | r[3][3], |
const float | m[3][3], | ||
float | f | ||
) |
BLI_INLINE void spring_verts_ordered_set | ( | ClothSpring * | spring, |
int | v0, | ||
int | v1 | ||
) |
Definition at line 876 of file cloth.c.
References ClothSpring::ij, ClothSpring::kl, and v1.
Referenced by cloth_add_shear_bend_spring(), and cloth_build_springs().