|
Blender V5.0
|
#include <algorithm>#include <cmath>#include <cstdlib>#include <cstring>#include "CLG_log.h"#include "MEM_guardedalloc.h"#include "DNA_collection_types.h"#include "DNA_curve_types.h"#include "DNA_lattice_types.h"#include "DNA_mesh_types.h"#include "DNA_meshdata_types.h"#include "DNA_object_force_types.h"#include "DNA_object_types.h"#include "DNA_scene_types.h"#include "BLI_ghash.h"#include "BLI_listbase.h"#include "BLI_math_geom.h"#include "BLI_math_matrix.h"#include "BLI_math_vector.h"#include "BLI_threads.h"#include "BLI_time.h"#include "BLI_utildefines.h"#include "BKE_collision.h"#include "BKE_curve.hh"#include "BKE_customdata.hh"#include "BKE_deform.hh"#include "BKE_effect.h"#include "BKE_global.hh"#include "BKE_layer.hh"#include "BKE_mesh.hh"#include "BKE_modifier.hh"#include "BKE_pointcache.h"#include "BKE_scene.hh"#include "BKE_softbody.h"#include "DEG_depsgraph.hh"#include "DEG_depsgraph_query.hh"Go to the source code of this file.
Classes | |
| struct | BodySpring |
| struct | BodyFace |
| struct | ReferenceVert |
| struct | ReferenceState |
| struct | SBScratch |
| struct | SB_thread_context |
| struct | CCDF_MinMax |
| struct | ccd_Mesh |
Macros | |
| #define | MID_PRESERVE 1 |
| #define | SOFTGOALSNAP 0.999f |
| #define | HEUNWARNLIMIT 1 /* 500 would be fine i think for detecting severe *stiff* stuff */ |
| #define | BSF_INTERSECT 1 /* edge intersects collider face */ |
| #define | SBF_DOFUZZY 1 /* Body-point do fuzzy. */ |
| #define | SBF_OUTOFCOLLISION 2 /* Body-point does not collide. */ |
| #define | BFF_INTERSECT 1 /* collider edge intrudes face. */ |
| #define | BFF_CLOSEVERT 2 /* collider vertex repulses face. */ |
Enumerations | |
| enum | type_spring { SB_EDGE = 1 , SB_BEND = 2 , SB_STIFFQUAD = 3 , SB_HANDLE = 4 } |
Functions | |
| static void | free_softbody_intern (SoftBody *sb) |
| static float | sb_grav_force_scale (Object *) |
| static float | sb_fric_force_scale (Object *) |
| static float | sb_time_scale (Object *ob) |
| static float | _final_goal (Object *ob, BodyPoint *bp) |
| static float | _final_mass (Object *ob, BodyPoint *bp) |
| static ccd_Mesh * | ccd_mesh_make (Object *ob) |
| static void | ccd_mesh_update (Object *ob, ccd_Mesh *pccd_M) |
| static void | ccd_mesh_free (ccd_Mesh *ccdm) |
| static void | ccd_build_deflector_hash_single (GHash *hash, Object *ob) |
| static void | ccd_build_deflector_hash (Depsgraph *depsgraph, Collection *collection, Object *vertexowner, GHash *hash) |
| static void | ccd_update_deflector_hash_single (GHash *hash, Object *ob) |
| static void | ccd_update_deflector_hash (Depsgraph *depsgraph, Collection *collection, Object *vertexowner, GHash *hash) |
| static int | count_mesh_quads (Mesh *mesh) |
| static void | add_mesh_quad_diag_springs (Object *ob) |
| static void | add_2nd_order_roller (Object *ob, float, int *counter, int addsprings) |
| static void | add_2nd_order_springs (Object *ob, float stiffness) |
| static void | add_bp_springlist (BodyPoint *bp, int springID) |
| static void | build_bps_springlist (Object *ob) |
| static void | calculate_collision_balls (Object *ob) |
| static void | renew_softbody (Object *ob, int totpoint, int totspring) |
| static void | free_softbody_baked (SoftBody *sb) |
| static void | free_scratch (SoftBody *sb) |
| static int | query_external_colliders (Depsgraph *depsgraph, Collection *collection) |
| static int | sb_detect_aabb_collisionCached (float[3], Object *vertexowner, float) |
| static int | sb_detect_face_pointCached (const float face_v1[3], const float face_v2[3], const float face_v3[3], float *damp, float force[3], Object *vertexowner, float time) |
| static int | sb_detect_face_collisionCached (const float face_v1[3], const float face_v2[3], const float face_v3[3], float *damp, float force[3], Object *vertexowner, float time) |
| static void | scan_for_ext_face_forces (Object *ob, float timenow) |
| static int | sb_detect_edge_collisionCached (const float edge_v1[3], const float edge_v2[3], float *damp, float force[3], Object *vertexowner, float time) |
| static void | _scan_for_ext_spring_forces (Scene *scene, Object *ob, float timenow, int ifirst, int ilast, ListBase *effectors) |
| static void * | exec_scan_for_ext_spring_forces (void *data) |
| static void | sb_sfesf_threads_run (Depsgraph *depsgraph, Scene *scene, Object *ob, float timenow, int totsprings, int *ptr_to_break_func(void)) |
| static int | choose_winner (float *w, float *pos, float *a, float *b, float *c, float *ca, float *cb, float *cc) |
| static int | sb_detect_vertex_collisionCached (float opco[3], float facenormal[3], float *damp, float force[3], Object *vertexowner, float time, float vel[3], float *intrusion) |
| static int | sb_deflect_face (Object *ob, float *actpos, float *facenormal, float *force, float *cf, float time, float *vel, float *intrusion) |
| static void | sb_spring_force (Object *ob, int bpi, BodySpring *bs, float iks, float) |
| static int | _softbody_calc_forces_slice_in_a_thread (Scene *scene, Object *ob, float forcetime, float timenow, int ifirst, int ilast, int *ptr_to_break_func(void), ListBase *effectors, int do_deflector, float fieldfactor, float windfactor) |
| static void * | exec_softbody_calc_forces (void *data) |
| static void | sb_cf_threads_run (Scene *scene, Object *ob, float forcetime, float timenow, int totpoint, int *ptr_to_break_func(void), ListBase *effectors, int do_deflector, float fieldfactor, float windfactor) |
| static void | softbody_calc_forces (Depsgraph *depsgraph, Scene *scene, Object *ob, float forcetime, float timenow) |
| static void | softbody_apply_forces (Object *ob, float forcetime, int mode, float *err, int mid_flags) |
| static void | softbody_restore_prev_step (Object *ob) |
| static void | softbody_apply_goalsnap (Object *ob) |
| static void | apply_spring_memory (Object *ob) |
| static void | interpolate_exciter (Object *ob, int timescale, int time) |
| static void | springs_from_mesh (Object *ob) |
| static void | mesh_to_softbody (Object *ob) |
| static void | mesh_faces_to_scratch (Object *ob) |
| static void | reference_to_scratch (Object *ob) |
| static float | globallen (float *v1, float *v2, Object *ob) |
| static void | makelatticesprings (Lattice *lt, BodySpring *bs, int dostiff, Object *ob) |
| static void | lattice_to_softbody (Object *ob) |
| static void | curve_surf_to_softbody (Object *ob) |
| static void | softbody_to_object (Object *ob, float(*vertexCos)[3], int numVerts, int local) |
| static void | sb_new_scratch (SoftBody *sb) |
| SoftBody * | sbNew () |
| void | sbFree (Object *ob) |
| void | sbFreeSimulation (SoftBody *sb) |
| void | sbObjectToSoftbody (Object *ob) |
| static bool | object_has_edges (const Object *ob) |
| void | sbSetInterruptCallBack (int(*f)()) |
| static void | softbody_update_positions (Object *ob, SoftBody *sb, float(*vertexCos)[3], int numVerts) |
| void | SB_estimate_transform (Object *ob, float lloc[3], float lrot[3][3], float lscale[3][3]) |
| static void | softbody_reset (Object *ob, SoftBody *sb, float(*vertexCos)[3], int numVerts) |
| static void | softbody_step (Depsgraph *depsgraph, Scene *scene, Object *ob, SoftBody *sb, float dtime) |
| static void | sbStoreLastFrame (Depsgraph *depsgraph, Object *object, float framenr) |
| void | sbObjectStep (Depsgraph *depsgraph, Scene *scene, Object *ob, float cfra, float(*vertexCos)[3], int numVerts) |
Variables | |
| static CLG_LogRef | LOG = {"physics.softbody"} |
| static int(* | SB_localInterruptCallBack )() = nullptr |
| static float | SoftHeunTol = 1.0f |
| static const int | CCD_SAFETY = 190561 |
| #define BFF_CLOSEVERT 2 /* collider vertex repulses face. */ |
Definition at line 144 of file softbody.cc.
Referenced by scan_for_ext_face_forces().
| #define BFF_INTERSECT 1 /* collider edge intrudes face. */ |
Definition at line 143 of file softbody.cc.
Referenced by scan_for_ext_face_forces().
| #define BSF_INTERSECT 1 /* edge intersects collider face */ |
Definition at line 137 of file softbody.cc.
Referenced by _scan_for_ext_spring_forces(), and _softbody_calc_forces_slice_in_a_thread().
| #define HEUNWARNLIMIT 1 /* 500 would be fine i think for detecting severe *stiff* stuff */ |
Definition at line 135 of file softbody.cc.
Referenced by softbody_step().
| #define MID_PRESERVE 1 |
Definition at line 129 of file softbody.cc.
Referenced by softbody_apply_forces(), and softbody_step().
| #define SBF_DOFUZZY 1 /* Body-point do fuzzy. */ |
Definition at line 140 of file softbody.cc.
Referenced by _softbody_calc_forces_slice_in_a_thread(), softbody_apply_forces(), and softbody_step().
| #define SBF_OUTOFCOLLISION 2 /* Body-point does not collide. */ |
Definition at line 141 of file softbody.cc.
Referenced by _softbody_calc_forces_slice_in_a_thread(), and curve_surf_to_softbody().
| #define SOFTGOALSNAP 0.999f |
Definition at line 131 of file softbody.cc.
| enum type_spring |
| Enumerator | |
|---|---|
| SB_EDGE | |
| SB_BEND | |
| SB_STIFFQUAD | |
| SB_HANDLE | |
Definition at line 77 of file softbody.cc.
Definition at line 207 of file softbody.cc.
References CLOG_ERROR, fabsf, BodyPoint::goal, LOG, SoftBody::maxgoal, SoftBody::mingoal, OB_SB_GOAL, pow, Object::soft, and Object::softflag.
Referenced by _softbody_calc_forces_slice_in_a_thread(), interpolate_exciter(), softbody_apply_forces(), and softbody_apply_goalsnap().
Definition at line 228 of file softbody.cc.
References CLOG_ERROR, LOG, BodyPoint::mass, SoftBody::nodemass, and Object::soft.
Referenced by _softbody_calc_forces_slice_in_a_thread(), reference_to_scratch(), and softbody_apply_forces().
|
static |
Definition at line 1428 of file softbody.cc.
References add_v3_v3(), add_v3_v3v3(), SoftBody::aeroedge, BKE_effectors_apply(), SoftBody::bpoint, BSF_INTERSECT, SoftBody::bspring, BodySpring::cf, SoftBody::choke, dot_v3v3(), SoftBody::effector_weights, BodySpring::ext_force, fabsf, BodySpring::flag, madd_v3_v3fl(), mid_v3_v3v3(), mul_v3_fl(), normalize_v3(), OB_SB_AERO_ANGLE, OB_SB_EDGECOLL, pd_point_from_soft(), BodyPoint::pos, pos, project_v3_v3v3(), sb_detect_edge_collisionCached(), SB_EDGE, Object::soft, Object::softflag, BodySpring::springtype, sub_v3_v3(), sub_v3_v3v3(), SoftBody::totspring, BodySpring::v1, BodySpring::v2, and BodyPoint::vec.
Referenced by exec_scan_for_ext_spring_forces().
|
static |
Definition at line 1947 of file softbody.cc.
References _final_goal(), _final_mass(), add_v3_v3(), add_v3_v3v3(), SoftBody::aeroedge, b, SoftBody::balldamp, SoftBody::ballstiff, BKE_effectors_apply(), SoftBody::bpoint, BSF_INTERSECT, SoftBody::bspring, BodySpring::cf, BodyPoint::choke, SoftBody::choke, BodyPoint::choke2, CLOG_ERROR, BodyPoint::colball, copy_v3_v3(), distance(), SoftBody::effector_weights, ELEM, BodySpring::ext_force, fabsf, BodySpring::flag, PhysicsSettings::flag, SBScratch::flag, BodyPoint::force, EffectorWeights::global_gravity, SoftBody::goalfrict, SoftBody::goalspring, PhysicsSettings::gravity, SoftBody::inspring, BodyPoint::loc_flag, LOG, madd_v3_v3fl(), SoftBody::mediafrict, mid_v3_v3v3(), mul_v3_fl(), BodyPoint::nofsprings, normalize_v3(), OB_SB_EDGECOLL, OB_SB_EDGES, OB_SB_GOAL, OB_SB_SELF, BodyPoint::origE, BodyPoint::origS, BodyPoint::origT, pd_point_from_soft(), PHYS_GLOBAL_GRAVITY, Scene::physics_settings, BodyPoint::pos, printf, sb_deflect_face(), sb_fric_force_scale(), sb_grav_force_scale(), sb_spring_force(), SBF_DOFUZZY, SBF_OUTOFCOLLISION, SoftBody::scratch, Object::soft, Object::softflag, SOFTGOALSNAP, BodyPoint::springs, sub_v3_v3v3(), SoftBody::totpoint, UNUSED_VARS, BodySpring::v1, BodySpring::v2, and BodyPoint::vec.
Referenced by exec_softbody_calc_forces().
Definition at line 621 of file softbody.cc.
References b, SoftBody::bpoint, SoftBody::bspring, CLOG_ERROR, LOG, BodyPoint::nofsprings, SB_BEND, Object::soft, BodyPoint::springs, BodySpring::springtype, SoftBody::totpoint, SoftBody::totspring, BodySpring::v1, and BodySpring::v2.
Referenced by add_2nd_order_springs().
Definition at line 685 of file softbody.cc.
References add_2nd_order_roller(), SoftBody::bspring, MEM_calloc_arrayN(), MEM_freeN(), Object::soft, and SoftBody::totspring.
Referenced by mesh_to_softbody().
|
static |
Definition at line 708 of file softbody.cc.
References MEM_calloc_arrayN(), MEM_freeN(), BodyPoint::nofsprings, and BodyPoint::springs.
Referenced by build_bps_springlist().
|
static |
Definition at line 580 of file softbody.cc.
References SoftBody::bspring, count_mesh_quads(), Object::data, faces, Mesh::faces_num, MEM_recallocN, SB_STIFFQUAD, Object::soft, BodySpring::springtype, SoftBody::totspring, BodySpring::v1, and BodySpring::v2.
Referenced by mesh_to_softbody().
|
static |
Definition at line 2583 of file softbody.cc.
References b, SoftBody::bpoint, SoftBody::bspring, l, BodySpring::len, len_v3v3(), SoftBody::plastic, BodyPoint::pos, Object::soft, SoftBody::totspring, BodySpring::v1, and BodySpring::v2.
Referenced by softbody_step().
|
static |
Do this once when sb is build it is O(N^2) so scanning for springs every iteration is too expensive.
Definition at line 731 of file softbody.cc.
References add_bp_springlist(), b, SoftBody::bpoint, SoftBody::bspring, MEM_freeN(), Object::soft, BodyPoint::springs, SoftBody::totpoint, SoftBody::totspring, BodySpring::v1, and BodySpring::v2.
Referenced by curve_surf_to_softbody(), lattice_to_softbody(), and mesh_to_softbody().
|
static |
Definition at line 760 of file softbody.cc.
References b, SoftBody::bpoint, SoftBody::bspring, BodyPoint::colball, SoftBody::colball, float, BodySpring::len, max, max_ff(), min, min_ff(), BodyPoint::nofsprings, SB_EDGE, SoftBody::sbc_mode, SBC_MODE_AVG, SBC_MODE_AVGMINMAX, SBC_MODE_MANUAL, SBC_MODE_MAX, SBC_MODE_MIN, Object::soft, BodyPoint::springs, BodySpring::springtype, and SoftBody::totpoint.
Referenced by curve_surf_to_softbody(), lattice_to_softbody(), and mesh_to_softbody().
|
static |
Definition at line 505 of file softbody.cc.
References BKE_collision_objects_create(), BKE_collision_objects_free(), ccd_build_deflector_hash_single(), depsgraph, eModifierType_Collision, hash, i, OB_MESH, and Object::type.
Referenced by softbody_step().
Definition at line 490 of file softbody.cc.
References BLI_ghash_ensure_p(), ccd_mesh_make(), PartDeflect::deflect, hash, and Object::pd.
Referenced by ccd_build_deflector_hash().
|
static |
Definition at line 476 of file softbody.cc.
References CCD_SAFETY, MEM_freeN(), ccd_Mesh::mima, ccd_Mesh::safety, ccd_Mesh::vert_positions, ccd_Mesh::vert_positions_prev, and ccd_Mesh::vert_tris.
Referenced by free_scratch().
Definition at line 271 of file softbody.cc.
References ccd_Mesh::bbmax, ccd_Mesh::bbmin, BKE_modifiers_findby_type(), CCD_SAFETY, eModifierType_Collision, i, max_ff(), CCDF_MinMax::maxx, CCDF_MinMax::maxy, CCDF_MinMax::maxz, MEM_dupallocN(), MEM_malloc_arrayN(), MEM_mallocN(), ccd_Mesh::mima, min_ff(), CCDF_MinMax::minx, CCDF_MinMax::miny, CCDF_MinMax::minz, ccd_Mesh::mvert_num, CollisionModifierData::mvert_num, Object::pd, PartDeflect::pdef_sbift, PartDeflect::pdef_sboft, ccd_Mesh::safety, ccd_Mesh::tri_num, CollisionModifierData::tri_num, v, ccd_Mesh::vert_positions, ccd_Mesh::vert_positions_prev, ccd_Mesh::vert_tris, CollisionModifierData::vert_tris, and CollisionModifierData::xnew.
Referenced by ccd_build_deflector_hash_single().
Definition at line 357 of file softbody.cc.
References ccd_Mesh::bbmax, ccd_Mesh::bbmin, BKE_modifiers_findby_type(), eModifierType_Collision, i, max_ff(), MEM_dupallocN(), MEM_freeN(), ccd_Mesh::mima, min_ff(), ccd_Mesh::mvert_num, CollisionModifierData::mvert_num, Object::pd, PartDeflect::pdef_sbift, PartDeflect::pdef_sboft, ccd_Mesh::tri_num, CollisionModifierData::tri_num, v, ccd_Mesh::vert_positions, ccd_Mesh::vert_positions_prev, and CollisionModifierData::xnew.
Referenced by ccd_update_deflector_hash_single().
|
static |
Definition at line 542 of file softbody.cc.
References BKE_collision_objects_create(), BKE_collision_objects_free(), ccd_update_deflector_hash_single(), depsgraph, eModifierType_Collision, hash, i, OB_MESH, and Object::type.
Referenced by softbody_step().
Definition at line 529 of file softbody.cc.
References BLI_ghash_lookup(), ccd_mesh_update(), PartDeflect::deflect, hash, and Object::pd.
Referenced by ccd_update_deflector_hash().
|
static |
Definition at line 1580 of file softbody.cc.
References b, copy_v3_v3(), dot_v3v3(), fabsf, pos, and w().
Referenced by sb_detect_vertex_collisionCached().
|
static |
Definition at line 568 of file softbody.cc.
References faces, i, result, and size().
Referenced by add_mesh_quad_diag_springs().
|
static |
Definition at line 2963 of file softbody.cc.
References BKE_nurbList_verts_count(), BLI_listbase_count(), SoftBody::bpoint, SoftBody::bspring, build_bps_springlist(), calculate_collision_balls(), Object::data, globallen(), BodyPoint::goal, BodySpring::len, LISTBASE_FOREACH, Curve::nurb, OB_CURVES_LEGACY, OB_SB_EDGES, OB_SB_GOAL, OB_SB_SELF, renew_softbody(), SB_EDGE, SB_HANDLE, SBF_OUTOFCOLLISION, Object::soft, Object::softflag, BodySpring::springtype, Object::type, BodySpring::v1, BodySpring::v2, BezTriple::vec, BPoint::vec, BezTriple::weight, and BPoint::weight.
Referenced by sbObjectStep().
|
static |
Definition at line 1503 of file softbody.cc.
References _scan_for_ext_spring_forces(), data, SB_thread_context::effectors, SB_thread_context::ifirst, SB_thread_context::ilast, SB_thread_context::ob, SB_thread_context::scene, and SB_thread_context::timenow.
Referenced by sb_sfesf_threads_run().
|
static |
Definition at line 2171 of file softbody.cc.
References _softbody_calc_forces_slice_in_a_thread(), data, SB_thread_context::do_deflector, SB_thread_context::effectors, SB_thread_context::fieldfactor, SB_thread_context::forcetime, SB_thread_context::ifirst, SB_thread_context::ilast, SB_thread_context::ob, SB_thread_context::scene, SB_thread_context::timenow, and SB_thread_context::windfactor.
Referenced by sb_cf_threads_run().
|
static |
Definition at line 878 of file softbody.cc.
References BLI_ghash_free(), SBScratch::bodyface, ccd_mesh_free(), SBScratch::colliderhash, ReferenceState::ivert, MEM_freeN(), SBScratch::Ref, and SoftBody::scratch.
Referenced by free_softbody_intern(), and softbody_reset().
|
static |
Definition at line 864 of file softbody.cc.
References SoftBody::keys, MEM_freeN(), MEM_SAFE_FREE, and SoftBody::totkey.
Referenced by free_softbody_intern().
|
static |
Definition at line 900 of file softbody.cc.
References SoftBody::bpoint, SoftBody::bspring, free_scratch(), free_softbody_baked(), MEM_freeN(), BodyPoint::springs, SoftBody::totpoint, and SoftBody::totspring.
Referenced by renew_softbody(), sbFree(), sbFreeSimulation(), and sbObjectToSoftbody().
helper function to get proper spring length when object is re-scaled
Definition at line 2810 of file softbody.cc.
References copy_v3_v3(), len_v3v3(), mul_m4_v3(), and v2.
Referenced by curve_surf_to_softbody(), and makelatticesprings().
|
static |
Definition at line 2607 of file softbody.cc.
References _final_goal(), SoftBody::bpoint, float, BodyPoint::origE, BodyPoint::origS, BodyPoint::origT, Object::soft, SOFTGOALSNAP, SoftBody::totpoint, and BodyPoint::vec.
Referenced by softbody_step().
|
static |
Definition at line 2900 of file softbody.cc.
References BKE_defvert_find_weight(), BKE_id_defgroup_name_index(), BLI_assert, SoftBody::bpoint, SoftBody::bspring, build_bps_springlist(), calculate_collision_balls(), Object::data, Lattice::def, SoftBody::defgoal, Lattice::dvert, BodyPoint::goal, Lattice::id, makelatticesprings(), BodyPoint::mass, SoftBody::namedVG_Mass, SoftBody::namedVG_Spring_K, OB_SB_EDGES, OB_SB_GOAL, OB_SB_QUADS, OB_SB_SELF, Lattice::pntsu, Lattice::pntsv, Lattice::pntsw, renew_softbody(), Object::soft, Object::softflag, BodyPoint::springweight, SoftBody::vertgroup, and BPoint::weight.
Referenced by sbObjectStep().
|
static |
Definition at line 2820 of file softbody.cc.
References Lattice::def, globallen(), BodySpring::len, Lattice::pntsu, Lattice::pntsv, Lattice::pntsw, SB_BEND, SB_EDGE, BodySpring::springtype, v, BodySpring::v1, BodySpring::v2, and w().
Referenced by lattice_to_softbody().
|
static |
Definition at line 2757 of file softbody.cc.
References SBScratch::bodyface, SBScratch::bodyface_num, blender::bke::mesh::corner_tris_calc(), Mesh::corners_num, Object::data, BodyFace::ext_force, Mesh::faces_num, BodyFace::flag, MEM_malloc_arrayN(), poly_to_tri_count(), SoftBody::scratch, Object::soft, BodyFace::v1, BodyFace::v2, BodyFace::v3, and zero_v3().
Referenced by softbody_reset().
|
static |
Definition at line 2671 of file softbody.cc.
References add_2nd_order_springs(), add_mesh_quad_diag_springs(), BKE_defvert_find_weight(), BKE_id_defgroup_name_index(), BLI_assert, SoftBody::bpoint, SoftBody::bspring, build_bps_springlist(), calculate_collision_balls(), Object::data, SoftBody::defgoal, Mesh::edges_num, BodyPoint::goal, i, Mesh::id, blender::Span< T >::index_range(), blender::Span< T >::is_empty(), BodyPoint::mass, SoftBody::namedVG_Mass, SoftBody::namedVG_Spring_K, OB_SB_EDGES, OB_SB_GOAL, OB_SB_QUADS, OB_SB_SELF, renew_softbody(), SB_EDGE, SoftBody::secondspring, Object::soft, Object::softflag, springs_from_mesh(), BodySpring::springtype, BodyPoint::springweight, BodySpring::v1, BodySpring::v2, SoftBody::vertgroup, and Mesh::verts_num.
Referenced by sbObjectStep().
|
static |
Definition at line 3196 of file softbody.cc.
References Object::data, OB_LATTICE, OB_MESH, and Object::type.
Referenced by sbObjectStep().
|
static |
Definition at line 961 of file softbody.cc.
References BKE_collision_objects_create(), BKE_collision_objects_free(), depsgraph, and eModifierType_Collision.
Referenced by softbody_calc_forces().
|
static |
Definition at line 2784 of file softbody.cc.
References _final_mass(), add_v3_v3(), SoftBody::bpoint, ReferenceState::com, copy_v3_v3(), ReferenceState::ivert, MEM_malloc_arrayN(), mul_v3_fl(), BodyPoint::pos, ReferenceVert::pos, SBScratch::Ref, SoftBody::scratch, Object::soft, and SoftBody::totpoint.
Referenced by softbody_reset().
|
static |
Definition at line 813 of file softbody.cc.
References SoftBody::bpoint, SoftBody::bspring, BodyPoint::choke, BodyPoint::choke2, BodyPoint::colball, SoftBody::defgoal, free_softbody_intern(), BodyPoint::frozen, BodyPoint::goal, i, BodyPoint::loc_flag, BodyPoint::mass, MEM_malloc_arrayN(), BodyPoint::nofsprings, OB_SB_GOAL, sbNew(), Object::soft, Object::softflag, BodyPoint::springs, BodyPoint::springweight, SoftBody::totpoint, and SoftBody::totspring.
Referenced by curve_surf_to_softbody(), lattice_to_softbody(), mesh_to_softbody(), and sbObjectStep().
|
static |
Definition at line 2188 of file softbody.cc.
References BKE_scene_num_threads(), BLI_threadpool_end(), BLI_threadpool_init(), BLI_threadpool_insert(), SB_thread_context::do_deflector, SB_thread_context::effectors, exec_softbody_calc_forces(), SB_thread_context::fieldfactor, SB_thread_context::forcetime, i, SB_thread_context::ifirst, SB_thread_context::ilast, left, MEM_calloc_arrayN(), MEM_freeN(), SB_thread_context::nr, SB_thread_context::ob, SB_thread_context::scene, SB_thread_context::timenow, SB_thread_context::tot, UNUSED_VARS, and SB_thread_context::windfactor.
Referenced by softbody_calc_forces().
|
static |
Definition at line 1803 of file softbody.cc.
References copy_v3_v3(), and sb_detect_vertex_collisionCached().
Referenced by _softbody_calc_forces_slice_in_a_thread().
Definition at line 973 of file softbody.cc.
References SBScratch::aabbmax, SBScratch::aabbmin, ccd_Mesh::bbmax, ccd_Mesh::bbmin, BLI_ghashIterator_done(), BLI_ghashIterator_free(), BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), BLI_ghashIterator_new(), BLI_ghashIterator_step(), CLOG_ERROR, SBScratch::colliderhash, copy_v3_v3(), PartDeflect::deflect, hash, LOG, Object::pd, SoftBody::scratch, and Object::soft.
Referenced by softbody_calc_forces().
|
static |
Definition at line 1313 of file softbody.cc.
References ccd_Mesh::bbmax, ccd_Mesh::bbmin, BLI_ghashIterator_done(), BLI_ghashIterator_free(), BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), BLI_ghashIterator_new(), BLI_ghashIterator_step(), CLOG_ERROR, SBScratch::colliderhash, copy_v3_v3(), cross_v3_v3v3(), PartDeflect::deflect, dot_v3v3(), float, hash, isect_line_segment_tri_v3(), len_v3v3(), LOG, madd_v3_v3fl(), CCDF_MinMax::maxx, CCDF_MinMax::maxy, CCDF_MinMax::maxz, ccd_Mesh::mima, min_ff(), minmax_v3v3_v3(), CCDF_MinMax::minx, CCDF_MinMax::miny, CCDF_MinMax::minz, mul_v3_fl(), normalize_v3(), Object::pd, PartDeflect::pdef_sbdamp, SoftBody::scratch, Object::soft, sub_v3_v3v3(), ccd_Mesh::tri_num, v2, ccd_Mesh::vert_positions, ccd_Mesh::vert_positions_prev, and ccd_Mesh::vert_tris.
Referenced by _scan_for_ext_spring_forces().
|
static |
Definition at line 1129 of file softbody.cc.
References ccd_Mesh::bbmax, ccd_Mesh::bbmin, BLI_ghashIterator_done(), BLI_ghashIterator_free(), BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), BLI_ghashIterator_new(), BLI_ghashIterator_step(), CLOG_ERROR, SBScratch::colliderhash, copy_v3_v3(), cross_v3_v3v3(), PartDeflect::deflect, float, hash, isect_line_segment_tri_v3(), LOG, madd_v3_v3fl(), max_fff(), CCDF_MinMax::maxx, CCDF_MinMax::maxy, CCDF_MinMax::maxz, ccd_Mesh::mima, min_fff(), CCDF_MinMax::minx, CCDF_MinMax::miny, CCDF_MinMax::minz, mul_v3_fl(), normalize_v3(), Object::pd, PartDeflect::pdef_sbdamp, SoftBody::scratch, Object::soft, sub_v3_v3v3(), ccd_Mesh::tri_num, ccd_Mesh::vert_positions, ccd_Mesh::vert_positions_prev, and ccd_Mesh::vert_tris.
Referenced by scan_for_ext_face_forces().
|
static |
Definition at line 1030 of file softbody.cc.
References ccd_Mesh::bbmax, ccd_Mesh::bbmin, BLI_ghashIterator_done(), BLI_ghashIterator_free(), BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), BLI_ghashIterator_new(), BLI_ghashIterator_step(), CLOG_ERROR, SBScratch::colliderhash, copy_v3_v3(), cross_v3_v3v3(), PartDeflect::deflect, dot_v3v3(), expf, fabsf, float, hash, isect_point_tri_prism_v3(), LOG, madd_v3_v3fl(), max_fff(), min_fff(), mul_v3_fl(), ccd_Mesh::mvert_num, normalize_v3(), Object::pd, PartDeflect::pdef_sbdamp, PartDeflect::pdef_sboft, SoftBody::scratch, Object::soft, sub_v3_v3(), sub_v3_v3v3(), ccd_Mesh::vert_positions, and ccd_Mesh::vert_positions_prev.
Referenced by scan_for_ext_face_forces().
|
static |
Definition at line 1611 of file softbody.cc.
References add_v3_v3(), ccd_Mesh::bbmax, ccd_Mesh::bbmin, BLI_ghashIterator_done(), BLI_ghashIterator_free(), BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), BLI_ghashIterator_new(), BLI_ghashIterator_step(), choose_winner(), CLOG_ERROR, SBScratch::colliderhash, copy_v3_v3(), cross_v3_v3v3(), PartDeflect::deflect, dot_v3v3(), exp, float, hash, isect_point_tri_prism_v3(), LOG, madd_v3_v3fl(), CCDF_MinMax::maxx, CCDF_MinMax::maxy, CCDF_MinMax::maxz, ccd_Mesh::mima, CCDF_MinMax::minx, CCDF_MinMax::miny, CCDF_MinMax::minz, mul_v3_fl(), normalize_v3(), normalize_v3_v3(), Object::pd, PartDeflect::pdef_sbdamp, PartDeflect::pdef_sbift, PartDeflect::pdef_sboft, SoftBody::scratch, Object::soft, sub_v3_v3v3(), ccd_Mesh::tri_num, ccd_Mesh::vert_positions, ccd_Mesh::vert_positions_prev, and ccd_Mesh::vert_tris.
Referenced by sb_deflect_face().
A precise position vector denoting the motion of the center of mass give a rotation/scale matrix using averaging method, that's why estimate and not calculate see: this is kind of reverse engineering: having to states of a point cloud and recover what happened our advantage here we know the identity of the vertex there are others methods giving other results.
| ob | Any object that can do soft-body e.g. mesh, lattice, curve. |
| lloc | Output of the calculated location (or NULL). |
| lrot | Output of the calculated rotation (or NULL). |
| lscale | Output for the calculated scale (or NULL). |
For velocity & 2nd order stuff see: vcloud_estimate_transform_v3.
Definition at line 3238 of file softbody.cc.
References SoftBody::bpoint, copy_m3_m3(), copy_v3_v3(), float, ReferenceState::ivert, SoftBody::lcom, SoftBody::lrot, SoftBody::lscale, MEM_calloc_arrayN(), MEM_freeN(), BodyPoint::pos, ReferenceVert::pos, SBScratch::Ref, SoftBody::scratch, Object::soft, SoftBody::totpoint, and vcloud_estimate_transform_v3().
Referenced by softbody_reset(), and softbody_to_object().
Re-scaling unit of drag [1 / sec] to somehow reasonable put it to a function here, so we can add user options later without touching simulation code.
Definition at line 169 of file softbody.cc.
Referenced by _softbody_calc_forces_slice_in_a_thread(), and sb_spring_force().
Since unit of g is [m/sec^2] and F = mass * g we re-scale unit mass of node to 1 gram put it to a function here, so we can add user options later without touching simulation code.
Definition at line 160 of file softbody.cc.
Referenced by _softbody_calc_forces_slice_in_a_thread().
|
static |
Definition at line 3090 of file softbody.cc.
References SBScratch::aabbmax, SBScratch::aabbmin, BLI_ghash_ptr_new(), SBScratch::bodyface, SBScratch::bodyface_num, SBScratch::colliderhash, ReferenceState::ivert, MEM_callocN(), SBScratch::Ref, and SoftBody::scratch.
Referenced by sbNew(), and softbody_reset().
|
static |
Definition at line 1511 of file softbody.cc.
References BKE_effectors_create(), BKE_effectors_free(), BKE_scene_num_threads(), BLI_threadpool_end(), BLI_threadpool_init(), BLI_threadpool_insert(), depsgraph, SB_thread_context::do_deflector, SoftBody::effector_weights, SB_thread_context::effectors, exec_scan_for_ext_spring_forces(), SB_thread_context::fieldfactor, SB_thread_context::forcetime, i, SB_thread_context::ifirst, SB_thread_context::ilast, left, MEM_calloc_arrayN(), MEM_freeN(), SB_thread_context::nr, SB_thread_context::ob, SB_thread_context::scene, Object::soft, SB_thread_context::timenow, SB_thread_context::tot, UNUSED_VARS, and SB_thread_context::windfactor.
Referenced by softbody_calc_forces().
|
static |
Definition at line 1866 of file softbody.cc.
References SoftBody::bpoint, CLOG_WARN, distance(), dot_v3v3(), BodyPoint::force, SoftBody::infrict, SoftBody::inpush, SoftBody::inspring, BodySpring::len, LOG, madd_v3_v3fl(), normalize_v3(), BodyPoint::pos, SB_BEND, SB_EDGE, sb_fric_force_scale(), SB_HANDLE, SB_STIFFQUAD, SoftBody::secondspring, SoftBody::shearstiff, Object::soft, BodySpring::springtype, BodyPoint::springweight, sub_v3_v3v3(), BodySpring::v1, BodySpring::v2, and BodyPoint::vec.
Referenced by _softbody_calc_forces_slice_in_a_thread().
Defining the frames to real time relation.
Definition at line 177 of file softbody.cc.
References SoftBody::physics_speed, and Object::soft.
Referenced by softbody_apply_forces().
| void sbFree | ( | struct Object * | ob | ) |
Frees internal data and soft-body itself.
Definition at line 3159 of file softbody.cc.
References BKE_ptcache_free_list(), SoftBody::effector_weights, free_softbody_intern(), Object::id, ID_TAG_COPIED_ON_EVAL, MEM_freeN(), SoftBody_Shared::pointcache, SoftBody_Shared::ptcaches, SoftBody::shared, Object::soft, and ID::tag.
Referenced by BKE_object_free_softbody(), object_free_data(), and blender::ed::object::object_modifier_remove().
| void sbFreeSimulation | ( | struct SoftBody * | sb | ) |
Frees simulation data to reset simulation.
Definition at line 3184 of file softbody.cc.
References free_softbody_intern().
Referenced by BKE_ptcache_id_reset().
| SoftBody * sbNew | ( | void | ) |
Allocates and initializes general main data.
Definition at line 3107 of file softbody.cc.
References SoftBody::balldamp, SoftBody::ballstiff, BKE_effector_add_weights(), BKE_ptcache_add(), SoftBody::choke, SoftBody::colball, SoftBody::defgoal, SoftBody::effector_weights, SoftBody::fuzzyness, SoftBody::goalfrict, SoftBody::goalspring, SoftBody::grav, SoftBody::infrict, SoftBody::inpush, SoftBody::inspring, SoftBody::last_frame, SoftBody::maxgoal, SoftBody::maxloops, SoftBody::mediafrict, MEM_callocN(), MINFRAME, SoftBody::mingoal, SoftBody::minloops, SoftBody::nodemass, SoftBody::physics_speed, SoftBody_Shared::pointcache, SoftBody_Shared::ptcaches, SoftBody::rklimit, sb_new_scratch(), SoftBody::sbc_mode, SBSO_OLDERR, SoftBody::shared, SoftBody::shearstiff, and SoftBody::solverflags.
Referenced by blender::ed::object::modifier_add(), and renew_softbody().
| void sbObjectStep | ( | struct Depsgraph * | depsgraph, |
| struct Scene * | scene, | ||
| struct Object * | ob, | ||
| float | cfra, | ||
| float(*) | vertexCos[3], | ||
| int | numVerts ) |
Do one simulation step, reading and writing vertex locs from given array.
Definition at line 3504 of file softbody.cc.
References BKE_ptcache_id_from_softbody(), BKE_ptcache_id_reset(), BKE_ptcache_id_time(), BKE_ptcache_invalidate(), BKE_ptcache_read(), BKE_ptcache_validate(), BKE_ptcache_write(), SoftBody::bpoint, SoftBody::bspring, curve_surf_to_softbody(), DEG_is_active(), depsgraph, PointCache::flag, PointCache::last_exact, SoftBody::last_frame, lattice_to_softbody(), SoftBody::local, mesh_to_softbody(), OB_CURVES_LEGACY, OB_LATTICE, OB_MESH, OB_SB_EDGES, OB_SURF, object_has_edges(), SoftBody_Shared::pointcache, PTCACHE_BAKED, PTCACHE_OUTDATED, PTCACHE_READ_EXACT, PTCACHE_READ_INTERPOLATED, PTCACHE_READ_OLD, PTCACHE_REDO_NEEDED, PTCACHE_RESET_OUTDATED, Scene::r, renew_softbody(), sbStoreLastFrame(), SoftBody::shared, PointCache::simframe, Object::soft, softbody_reset(), softbody_step(), softbody_to_object(), softbody_update_positions(), Object::softflag, RenderData::subframe, SoftBody::totpoint, and Object::type.
Referenced by deform_verts().
| void sbObjectToSoftbody | ( | struct Object * | ob | ) |
Makes totally fresh start situation, resets time.
Definition at line 3189 of file softbody.cc.
References free_softbody_intern(), and Object::soft.
| void sbSetInterruptCallBack | ( | int(* | f )(void) | ) |
Soft-body global visible functions. Links the soft-body module to a 'test for Interrupt' function, pass NULL to clear the callback.
Definition at line 3208 of file softbody.cc.
References SB_localInterruptCallBack.
Definition at line 3494 of file softbody.cc.
References DEG_get_original(), DEG_is_active(), depsgraph, SoftBody::last_frame, and Object::soft.
Referenced by sbObjectStep().
Definition at line 1241 of file softbody.cc.
References BFF_CLOSEVERT, BFF_INTERSECT, SBScratch::bodyface, SBScratch::bodyface_num, SoftBody::bpoint, BodyPoint::choke2, BodyFace::ext_force, BodyFace::flag, BodyPoint::force, madd_v3_v3fl(), max_ff(), min_ff(), BodyPoint::pos, sb_detect_face_collisionCached(), sb_detect_face_pointCached(), SoftBody::scratch, Object::soft, BodyFace::v1, BodyFace::v2, BodyFace::v3, and zero_v3().
Referenced by softbody_calc_forces().
|
static |
So here is:
(v)' = a(cceleration) =
sum(F_springs)/m + gravitation + some friction forces + more forces.
The ( ... )' operator denotes derivate respective time.
The euler step for velocity then becomes:
v(t + dt) = v(t) + a(t) * dt
Definition at line 2317 of file softbody.cc.
References _final_goal(), _final_mass(), SBScratch::aabbmax, SBScratch::aabbmin, add_v3_v3(), SoftBody::bpoint, BodyPoint::choke, BodyPoint::choke2, copy_v3_v3(), dot_v3v3(), fabsf, BodyPoint::force, BodyPoint::frozen, SoftBody::fuzzyness, BodyPoint::loc_flag, max_ff(), MID_PRESERVE, min_ff(), minmax_v3v3_v3(), mul_v3_fl(), SoftBody::nodemass, BodyPoint::pos, BodyPoint::prevdv, BodyPoint::prevdx, BodyPoint::prevpos, BodyPoint::prevvec, sb_time_scale(), SBF_DOFUZZY, SBSO_OLDERR, SoftBody::scratch, Object::soft, SOFTGOALSNAP, SoftBody::solverflags, SoftBody::totpoint, and BodyPoint::vec.
Referenced by softbody_step().
|
static |
Care for body-points taken out of the 'ordinary' solver step because they are screwed to goal by bolts they just need to move along with the goal in time we need to adjust them on sub frame timing in solver so now when frame is done .. put them to the position at the end of frame.
Definition at line 2569 of file softbody.cc.
References _final_goal(), SoftBody::bpoint, copy_v3_v3(), BodyPoint::origT, BodyPoint::pos, BodyPoint::prevpos, Object::soft, SOFTGOALSNAP, and SoftBody::totpoint.
Referenced by softbody_step().
|
static |
Definition at line 2257 of file softbody.cc.
References SoftBody::aeroedge, BKE_effectors_create(), BKE_effectors_free(), SoftBody::bspring, SoftBody::collision_group, depsgraph, SoftBody::effector_weights, OB_SB_EDGECOLL, OB_SB_EDGES, OB_SB_FACECOLL, OB_SB_SELF, query_external_colliders(), sb_cf_threads_run(), sb_detect_aabb_collisionCached(), sb_sfesf_threads_run(), scan_for_ext_face_forces(), Object::soft, Object::softflag, SoftBody::totpoint, and SoftBody::totspring.
Referenced by softbody_step().
Definition at line 3281 of file softbody.cc.
References SoftBody::bpoint, copy_v3_v3(), free_scratch(), SoftBody::lcom, SoftBody::lrot, SoftBody::lscale, mesh_faces_to_scratch(), mul_m4_v3(), SBScratch::needstobuildcollider, OB_CURVES_LEGACY, OB_LATTICE, OB_MESH, OB_SB_FACECOLL, OB_SURF, BodyPoint::origE, BodyPoint::origS, BodyPoint::origT, BodyPoint::pos, BodyPoint::prevdv, BodyPoint::prevdx, BodyPoint::prevpos, BodyPoint::prevvec, reference_to_scratch(), SB_estimate_transform(), sb_new_scratch(), SoftBody::scratch, Object::softflag, Object::type, unit_m3(), BodyPoint::vec, and zero_v3().
Referenced by sbObjectStep().
|
static |
Definition at line 2477 of file softbody.cc.
References SoftBody::bpoint, copy_v3_v3(), BodyPoint::pos, BodyPoint::prevpos, BodyPoint::prevvec, Object::soft, SoftBody::totpoint, and BodyPoint::vec.
Referenced by softbody_step().
|
static |
Definition at line 3343 of file softbody.cc.
References apply_spring_memory(), BLI_time_now_seconds(), ccd_build_deflector_hash(), ccd_update_deflector_hash(), CLOG_ERROR, SBScratch::colliderhash, SoftBody::collision_group, depsgraph, fabsf, SBScratch::flag, G, G_DEBUG, HEUNWARNLIMIT, Object::id, interpolate_exciter(), LOG, max_ff(), SoftBody::maxloops, MID_PRESERVE, min_ff(), SoftBody::minloops, ID::name, SBScratch::needstobuildcollider, SoftBody::plastic, printf, SoftBody::rklimit, SB_localInterruptCallBack, SBF_DOFUZZY, SBSO_MONITOR, SoftBody::scratch, softbody_apply_forces(), softbody_apply_goalsnap(), softbody_calc_forces(), softbody_restore_prev_step(), SoftHeunTol, SoftBody::solver_ID, and SoftBody::solverflags.
Referenced by sbObjectStep().
Definition at line 3067 of file softbody.cc.
References SoftBody::bpoint, copy_v3_v3(), invert_m4_m4(), SoftBody::lcom, SoftBody::lrot, SoftBody::lscale, mul_m4_v3(), BodyPoint::pos, Object::runtime, SB_estimate_transform(), SBSO_ESTIMATEIPO, Object::soft, and SoftBody::solverflags.
Referenced by sbObjectStep().
|
static |
Definition at line 3213 of file softbody.cc.
References SoftBody::bpoint, copy_v3_v3(), mul_m4_v3(), BodyPoint::origE, BodyPoint::origS, and BodyPoint::origT.
Referenced by sbObjectStep().
|
static |
Definition at line 2636 of file softbody.cc.
References SoftBody::bpoint, SoftBody::bspring, copy_v3_v3(), Object::data, BodySpring::len, len_v3v3(), mul_m4_v3(), BodyPoint::origS, Object::soft, SoftBody::springpreload, SoftBody::totspring, BodySpring::v1, BodySpring::v2, and Mesh::verts_num.
Referenced by mesh_to_softbody().
|
static |
Definition at line 253 of file softbody.cc.
Referenced by ccd_mesh_free(), and ccd_mesh_make().
|
static |
variables on the UI for now
float mediafrict; friction to env float nodemass; softbody mass of *vertex* float grav; softbody amount of gravitation to apply float goalspring; softbody goal springs float goalfrict; softbody goal springs friction float mingoal; quick limits for goal float maxgoal; float inspring; softbody inner springs float infrict; softbody inner springs friction
Definition at line 70 of file softbody.cc.
|
static |
Definition at line 73 of file softbody.cc.
Referenced by sbSetInterruptCallBack(), and softbody_step().
|
static |
Definition at line 147 of file softbody.cc.
Referenced by softbody_step().