Blender
V3.3
|
#include <math.h>
#include <stdlib.h>
#include <string.h>
#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.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BKE_collection.h"
#include "BKE_collision.h"
#include "BKE_curve.h"
#include "BKE_deform.h"
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_layer.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_pointcache.h"
#include "BKE_scene.h"
#include "BKE_softbody.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "PIL_time.h"
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 /* Bodypoint do fuzzy. */ |
#define | SBF_OUTOFCOLLISION 2 /* Bodypoint does not collide. */ |
#define | BFF_INTERSECT 1 /* collider edge intrudes face. */ |
#define | BFF_CLOSEVERT 2 /* collider vertex repulses face. */ |
Typedefs | |
typedef struct BodySpring | BodySpring |
typedef struct BodyFace | BodyFace |
typedef struct ReferenceVert | ReferenceVert |
typedef struct ReferenceState | ReferenceState |
typedef struct SBScratch | SBScratch |
typedef struct SB_thread_context | SB_thread_context |
typedef struct ccdf_minmax | ccdf_minmax |
typedef struct ccd_Mesh | ccd_Mesh |
Enumerations | |
enum | type_spring { SB_EDGE = 1 , SB_BEND = 2 , SB_STIFFQUAD = 3 , SB_HANDLE = 4 } |
Variables | |
static CLG_LogRef | LOG = {"bke.softbody"} |
static int(* | SB_localInterruptCallBack )(void) = NULL |
static float | SoftHeunTol = 1.0f |
static const int | CCD_SAFETY = 190561 |
#define BFF_CLOSEVERT 2 /* collider vertex repulses face. */ |
Definition at line 141 of file softbody.c.
#define BFF_INTERSECT 1 /* collider edge intrudes face. */ |
Definition at line 140 of file softbody.c.
#define BSF_INTERSECT 1 /* edge intersects collider face */ |
Definition at line 134 of file softbody.c.
#define HEUNWARNLIMIT 1 /* 500 would be fine i think for detecting severe *stiff* stuff */ |
Definition at line 132 of file softbody.c.
#define MID_PRESERVE 1 |
Definition at line 126 of file softbody.c.
#define SBF_DOFUZZY 1 /* Bodypoint do fuzzy. */ |
Definition at line 137 of file softbody.c.
#define SBF_OUTOFCOLLISION 2 /* Bodypoint does not collide. */ |
Definition at line 138 of file softbody.c.
#define SOFTGOALSNAP 0.999f |
Definition at line 128 of file softbody.c.
typedef struct BodySpring BodySpring |
typedef struct ccdf_minmax ccdf_minmax |
typedef struct ReferenceState ReferenceState |
typedef struct ReferenceVert ReferenceVert |
typedef struct SB_thread_context SB_thread_context |
enum type_spring |
Enumerator | |
---|---|
SB_EDGE | |
SB_BEND | |
SB_STIFFQUAD | |
SB_HANDLE |
Definition at line 74 of file softbody.c.
Definition at line 204 of file softbody.c.
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 225 of file softbody.c.
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 1424 of file softbody.c.
References Freestyle::a, 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(), NULL, OB_SB_AERO_ANGLE, OB_SB_EDGECOLL, pd_point_from_soft(), BodyPoint::pos, pos, project_v3_v3v3(), sb_detect_edge_collisionCached(), SB_EDGE, scene, 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 1943 of file softbody.c.
References _final_goal(), _final_mass(), add_v3_v3(), add_v3_v3v3(), SoftBody::aeroedge, usdtokens::b(), SoftBody::balldamp, SoftBody::ballstiff, BKE_effectors_apply(), SoftBody::bpoint, BSF_INTERSECT, SoftBody::bspring, Freestyle::c, BodySpring::cf, BodyPoint::choke, SoftBody::choke, BodyPoint::choke2, CLOG_ERROR, BodyPoint::colball, copy_v3_v3(), blender::math::distance(), SoftBody::effector_weights, ELEM, BodySpring::ext_force, fabsf, BodySpring::flag, SBScratch::flag, PhysicsSettings::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(), NULL, 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, sb_deflect_face(), sb_fric_force_scale(), sb_grav_force_scale(), sb_spring_force(), SBF_DOFUZZY, SBF_OUTOFCOLLISION, scene, SoftBody::scratch, Object::soft, Object::softflag, SOFTGOALSNAP, BodyPoint::springs, sub_v3_v3v3(), SoftBody::totpoint, BodySpring::v1, BodySpring::v2, and BodyPoint::vec.
Referenced by exec_softbody_calc_forces().
|
static |
Definition at line 625 of file softbody.c.
References Freestyle::a, usdtokens::b(), SoftBody::bpoint, SoftBody::bspring, Freestyle::c, CLOG_ERROR, counter, LOG, BodyPoint::nofsprings, NULL, 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 689 of file softbody.c.
References add_2nd_order_roller(), SoftBody::bspring, counter, MEM_callocN, MEM_freeN, Object::soft, and SoftBody::totspring.
Referenced by mesh_to_softbody().
Definition at line 711 of file softbody.c.
References MEM_callocN, MEM_freeN, BodyPoint::nofsprings, NULL, and BodyPoint::springs.
Referenced by build_bps_springlist().
Definition at line 582 of file softbody.c.
References Freestyle::a, SoftBody::bspring, count_mesh_quads(), Object::data, MPoly::loopstart, MEM_recallocN, Mesh::mloop, Mesh::mpoly, SB_STIFFQUAD, Object::soft, BodySpring::springtype, MPoly::totloop, Mesh::totpoly, SoftBody::totspring, MLoop::v, BodySpring::v1, and BodySpring::v2.
Referenced by mesh_to_softbody().
Definition at line 2575 of file softbody.c.
References Freestyle::a, usdtokens::b(), SoftBody::bpoint, SoftBody::bspring, l, BodySpring::len, len_v3v3(), SoftBody::plastic, BodyPoint::pos, r, Object::soft, SoftBody::totspring, BodySpring::v1, and BodySpring::v2.
Referenced by softbody_step().
Do this once when sb is build it is O(N^2)
so scanning for springs every iteration is too expensive.
Definition at line 734 of file softbody.c.
References Freestyle::a, add_bp_springlist(), usdtokens::b(), SoftBody::bpoint, SoftBody::bspring, MEM_freeN, NULL, 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().
Definition at line 763 of file softbody.c.
References Freestyle::a, usdtokens::b(), SoftBody::bpoint, SoftBody::bspring, BodyPoint::colball, SoftBody::colball, float(), BodySpring::len, max, max_ff(), min, min_ff(), BodyPoint::nofsprings, NULL, 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 504 of file softbody.c.
References BKE_collision_objects_create(), BKE_collision_objects_free(), ccd_build_deflector_hash_single(), depsgraph, eModifierType_Collision, hash, OB_MESH, and Object::type.
Referenced by softbody_step().
Definition at line 489 of file softbody.c.
References BLI_ghash_ensure_p(), ccd_mesh_make(), PartDeflect::deflect, hash, and Object::pd.
Referenced by ccd_build_deflector_hash().
Definition at line 475 of file softbody.c.
References CCD_SAFETY, MEM_freeN, ccd_Mesh::mima, ccd_Mesh::mprevvert, ccd_Mesh::mvert, ccd_Mesh::safety, and ccd_Mesh::tri.
Referenced by free_scratch().
Definition at line 268 of file softbody.c.
References ccd_Mesh::bbmax, ccd_Mesh::bbmin, BKE_modifiers_findby_type(), CCD_SAFETY, MVert::co, eModifierType_Collision, max_ff(), ccdf_minmax::maxx, ccdf_minmax::maxy, ccdf_minmax::maxz, MEM_dupallocN, MEM_mallocN, ccd_Mesh::mima, min_ff(), ccdf_minmax::minx, ccdf_minmax::miny, ccdf_minmax::minz, ccd_Mesh::mprevvert, ccd_Mesh::mvert, ccd_Mesh::mvert_num, CollisionModifierData::mvert_num, NULL, Object::pd, PartDeflect::pdef_sbift, PartDeflect::pdef_sboft, ccd_Mesh::safety, ccd_Mesh::tri, MVertTri::tri, CollisionModifierData::tri, ccd_Mesh::tri_num, CollisionModifierData::tri_num, v, and CollisionModifierData::xnew.
Referenced by ccd_build_deflector_hash_single().
Definition at line 355 of file softbody.c.
References ccd_Mesh::bbmax, ccd_Mesh::bbmin, BKE_modifiers_findby_type(), MVert::co, eModifierType_Collision, max_ff(), ccdf_minmax::maxx, ccdf_minmax::maxy, ccdf_minmax::maxz, MEM_dupallocN, MEM_freeN, ccd_Mesh::mima, min_ff(), ccdf_minmax::minx, ccdf_minmax::miny, ccdf_minmax::minz, ccd_Mesh::mprevvert, ccd_Mesh::mvert, ccd_Mesh::mvert_num, CollisionModifierData::mvert_num, Object::pd, PartDeflect::pdef_sbift, PartDeflect::pdef_sboft, ccd_Mesh::tri, MVertTri::tri, ccd_Mesh::tri_num, CollisionModifierData::tri_num, v, and CollisionModifierData::xnew.
Referenced by ccd_update_deflector_hash_single().
|
static |
Definition at line 541 of file softbody.c.
References BKE_collision_objects_create(), BKE_collision_objects_free(), ccd_update_deflector_hash_single(), depsgraph, eModifierType_Collision, hash, OB_MESH, and Object::type.
Referenced by softbody_step().
Definition at line 528 of file softbody.c.
References BLI_ghash_lookup(), ccd_mesh_update(), PartDeflect::deflect, hash, and Object::pd.
Referenced by ccd_update_deflector_hash().
|
static |
Definition at line 1575 of file softbody.c.
References Freestyle::a, usdtokens::b(), Freestyle::c, copy_v3_v3(), dot_v3v3(), fabsf, pos, and w().
Referenced by sb_detect_vertex_collisionCached().
|
static |
Definition at line 567 of file softbody.c.
References Freestyle::a, Mesh::mpoly, result, MPoly::totloop, and Mesh::totpoly.
Referenced by add_mesh_quad_diag_springs().
Definition at line 2955 of file softbody.c.
References Freestyle::a, Nurb::bezt, BKE_nurbList_verts_count(), BLI_listbase_count(), Nurb::bp, SoftBody::bpoint, SoftBody::bspring, build_bps_springlist(), calculate_collision_balls(), Object::data, ListBase::first, globallen(), BodyPoint::goal, BodySpring::len, Nurb::next, Curve::nurb, OB_CURVES_LEGACY, OB_SB_EDGES, OB_SB_GOAL, OB_SB_SELF, Nurb::pntsv, 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().
Definition at line 1498 of file softbody.c.
References _scan_for_ext_spring_forces(), data, SB_thread_context::effectors, SB_thread_context::ifirst, SB_thread_context::ilast, NULL, SB_thread_context::ob, SB_thread_context::scene, and SB_thread_context::timenow.
Referenced by sb_sfesf_threads_run().
Definition at line 2165 of file softbody.c.
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, NULL, SB_thread_context::ob, SB_thread_context::scene, SB_thread_context::timenow, and SB_thread_context::windfactor.
Referenced by sb_cf_threads_run().
Definition at line 881 of file softbody.c.
References BLI_ghash_free(), SBScratch::bodyface, ccd_mesh_free(), SBScratch::colliderhash, ReferenceState::ivert, MEM_freeN, NULL, SBScratch::Ref, and SoftBody::scratch.
Referenced by free_softbody_intern(), and softbody_reset().
Definition at line 867 of file softbody.c.
References SoftBody::keys, MEM_freeN, MEM_SAFE_FREE, and SoftBody::totkey.
Referenced by free_softbody_intern().
Definition at line 903 of file softbody.c.
References Freestyle::a, SoftBody::bpoint, SoftBody::bspring, free_scratch(), free_softbody_baked(), MEM_freeN, NULL, BodyPoint::springs, SoftBody::totpoint, and SoftBody::totspring.
Referenced by renew_softbody(), sbFree(), sbFreeSimulation(), and sbObjectToSoftbody().
Definition at line 2802 of file softbody.c.
References copy_v3_v3(), len_v3v3(), mul_m4_v3(), Object::obmat, v1, and v2.
Referenced by curve_surf_to_softbody(), and makelatticesprings().
Definition at line 2599 of file softbody.c.
References _final_goal(), Freestyle::a, SoftBody::bpoint, float(), BodyPoint::origE, BodyPoint::origS, BodyPoint::origT, Object::soft, SOFTGOALSNAP, time, SoftBody::totpoint, and BodyPoint::vec.
Referenced by softbody_step().
Definition at line 2892 of file softbody.c.
References Freestyle::a, 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 2812 of file softbody.c.
References Lattice::def, globallen(), BodySpring::len, NULL, Lattice::pntsu, Lattice::pntsv, Lattice::pntsw, SB_BEND, SB_EDGE, BodySpring::springtype, v, BodySpring::v1, BodySpring::v2, and w().
Referenced by lattice_to_softbody().
Definition at line 2749 of file softbody.c.
References Freestyle::a, BKE_mesh_recalc_looptri(), SBScratch::bodyface, Object::data, BodyFace::ext_force, BodyFace::flag, MEM_freeN, MEM_mallocN, Mesh::mloop, Mesh::mpoly, Mesh::mvert, poly_to_tri_count(), SoftBody::scratch, Object::soft, SBScratch::totface, Mesh::totloop, Mesh::totpoly, MLoopTri::tri, MLoop::v, BodyFace::v1, BodyFace::v2, BodyFace::v3, and zero_v3().
Referenced by softbody_reset().
Definition at line 2662 of file softbody.c.
References Freestyle::a, 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::dvert, BodyPoint::goal, Mesh::id, BodyPoint::mass, Mesh::medge, 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, Mesh::totedge, Mesh::totvert, BodySpring::v1, MEdge::v1, BodySpring::v2, MEdge::v2, and SoftBody::vertgroup.
Referenced by sbObjectStep().
Definition at line 3185 of file softbody.c.
References Object::data, OB_LATTICE, OB_MESH, and Object::type.
Referenced by sbObjectStep().
|
static |
Definition at line 964 of file softbody.c.
References BKE_collision_objects_create(), BKE_collision_objects_free(), depsgraph, eModifierType_Collision, and NULL.
Referenced by softbody_calc_forces().
Definition at line 2776 of file softbody.c.
References _final_mass(), Freestyle::a, add_v3_v3(), SoftBody::bpoint, ReferenceState::com, copy_v3_v3(), ReferenceState::ivert, MEM_mallocN, mul_v3_fl(), BodyPoint::pos, ReferenceVert::pos, SBScratch::Ref, SoftBody::scratch, Object::soft, and SoftBody::totpoint.
Referenced by softbody_reset().
Definition at line 816 of file softbody.c.
References SoftBody::bpoint, SoftBody::bspring, BodyPoint::choke, BodyPoint::choke2, BodyPoint::colball, SoftBody::defgoal, free_softbody_intern(), BodyPoint::frozen, BodyPoint::goal, BodyPoint::loc_flag, BodyPoint::mass, MEM_mallocN, BodyPoint::nofsprings, NULL, 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 2182 of file softbody.c.
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, SB_thread_context::ifirst, SB_thread_context::ilast, left, MEM_callocN, MEM_freeN, SB_thread_context::nr, SB_thread_context::ob, SB_thread_context::scene, scene, blender::compositor::threads, SB_thread_context::timenow, SB_thread_context::tot, and SB_thread_context::windfactor.
Referenced by softbody_calc_forces().
|
static |
Definition at line 1798 of file softbody.c.
References copy_v3_v3(), sb_detect_vertex_collisionCached(), and time.
Referenced by _softbody_calc_forces_slice_in_a_thread().
|
static |
Definition at line 976 of file softbody.c.
References Freestyle::a, 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, NULL, Object::pd, SoftBody::scratch, and Object::soft.
Referenced by softbody_calc_forces().
|
static |
Definition at line 1311 of file softbody.c.
References Freestyle::a, 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, MVert::co, SBScratch::colliderhash, copy_v3_v3(), cross_v3_v3v3(), PartDeflect::deflect, dot_v3v3(), hash, i1, 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, ccd_Mesh::mprevvert, mul_v3_fl(), ccd_Mesh::mvert, normalize_v3(), NULL, Object::pd, PartDeflect::pdef_sbdamp, SoftBody::scratch, Object::soft, sub_v3_v3v3(), t, time, ccd_Mesh::tri, MVertTri::tri, ccd_Mesh::tri_num, v1, and v2.
Referenced by _scan_for_ext_spring_forces().
|
static |
Definition at line 1132 of file softbody.c.
References Freestyle::a, 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, MVert::co, SBScratch::colliderhash, copy_v3_v3(), cross_v3_v3v3(), PartDeflect::deflect, 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, ccd_Mesh::mprevvert, mul_v3_fl(), ccd_Mesh::mvert, normalize_v3(), NULL, Object::pd, PartDeflect::pdef_sbdamp, SoftBody::scratch, Object::soft, sub_v3_v3v3(), t, time, ccd_Mesh::tri, MVertTri::tri, and ccd_Mesh::tri_num.
Referenced by scan_for_ext_face_forces().
|
static |
Definition at line 1034 of file softbody.c.
References Freestyle::a, 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, hash, isect_point_tri_prism_v3(), LOG, madd_v3_v3fl(), max_fff(), min_fff(), ccd_Mesh::mprevvert, mul_v3_fl(), ccd_Mesh::mvert, ccd_Mesh::mvert_num, normalize_v3(), NULL, Object::pd, PartDeflect::pdef_sbdamp, PartDeflect::pdef_sboft, SoftBody::scratch, Object::soft, sub_v3_v3(), sub_v3_v3v3(), and time.
Referenced by scan_for_ext_face_forces().
|
static |
Definition at line 1606 of file softbody.c.
References Freestyle::a, 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, MVert::co, 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, ccd_Mesh::mprevvert, mul_v3_fl(), ccd_Mesh::mvert, normalize_v3(), normalize_v3_v3(), NULL, Object::pd, PartDeflect::pdef_sbdamp, PartDeflect::pdef_sbift, PartDeflect::pdef_sboft, SoftBody::scratch, Object::soft, sub_v3_v3v3(), time, ccd_Mesh::tri, MVertTri::tri, and ccd_Mesh::tri_num.
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 3227 of file softbody.c.
References Freestyle::a, SoftBody::bpoint, copy_m3_m3(), copy_v3_v3(), float(), ReferenceState::ivert, SoftBody::lcom, SoftBody::lrot, SoftBody::lscale, MEM_callocN, MEM_freeN, NULL, 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 166 of file softbody.c.
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 157 of file softbody.c.
Referenced by _softbody_calc_forces_slice_in_a_thread().
Definition at line 3082 of file softbody.c.
References SBScratch::aabbmax, SBScratch::aabbmin, BLI_ghash_ptr_new(), SBScratch::bodyface, SBScratch::colliderhash, ReferenceState::ivert, MEM_callocN, NULL, SBScratch::Ref, SoftBody::scratch, and SBScratch::totface.
Referenced by sbNew(), and softbody_reset().
|
static |
Definition at line 1506 of file softbody.c.
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, SB_thread_context::ifirst, SB_thread_context::ilast, left, MEM_callocN, MEM_freeN, SB_thread_context::nr, NULL, SB_thread_context::ob, SB_thread_context::scene, scene, Object::soft, blender::compositor::threads, SB_thread_context::timenow, SB_thread_context::tot, and SB_thread_context::windfactor.
Referenced by softbody_calc_forces().
|
static |
Definition at line 1861 of file softbody.c.
References SoftBody::bpoint, CLOG_WARN, blender::math::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 174 of file softbody.c.
References SoftBody::physics_speed, and Object::soft.
Referenced by softbody_apply_forces().
Frees internal data and soft-body itself.
Definition at line 3148 of file softbody.c.
References BKE_ptcache_free_list(), SoftBody::effector_weights, free_softbody_intern(), Object::id, LIB_TAG_COPIED_ON_WRITE, MEM_freeN, NULL, SoftBody_Shared::pointcache, SoftBody_Shared::ptcaches, SoftBody::shared, Object::soft, and ID::tag.
Referenced by BKE_object_free_softbody(), object_free_data(), and object_modifier_remove().
Frees simulation data to reset simulation.
Definition at line 3173 of file softbody.c.
References free_softbody_intern().
Referenced by BKE_ptcache_id_reset().
Allocates and initializes general main data.
Definition at line 3099 of file softbody.c.
References SoftBody::balldamp, SoftBody::ballstiff, BKE_effector_add_weights(), BKE_ptcache_add(), SoftBody::choke, SoftBody::colball, SoftBody::defgoal, SoftBody::effector_weights, 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, NULL, 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 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 3492 of file softbody.c.
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(), NULL, 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(), scene, 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 deformVerts().
Makes totally fresh start situation, resets time.
Definition at line 3178 of file softbody.c.
References free_softbody_intern(), and Object::soft.
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 3197 of file softbody.c.
References SB_localInterruptCallBack.
|
static |
Definition at line 3482 of file softbody.c.
References DEG_get_original_object(), DEG_is_active(), depsgraph, SoftBody::last_frame, and Object::soft.
Referenced by sbObjectStep().
Definition at line 1241 of file softbody.c.
References Freestyle::a, BFF_CLOSEVERT, BFF_INTERSECT, SBScratch::bodyface, 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, SBScratch::totface, 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 2310 of file softbody.c.
References _final_goal(), _final_mass(), Freestyle::a, SBScratch::aabbmax, SBScratch::aabbmin, add_v3_v3(), SoftBody::bpoint, BodyPoint::choke, BodyPoint::choke2, copy_v3_v3(), dot_v3v3(), err, 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().
Definition at line 2561 of file softbody.c.
References _final_goal(), Freestyle::a, 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 2251 of file softbody.c.
References SoftBody::aeroedge, BKE_effectors_create(), BKE_effectors_free(), SoftBody::bspring, SoftBody::collision_group, depsgraph, SoftBody::effector_weights, NULL, 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(), scene, Object::soft, Object::softflag, SoftBody::totpoint, and SoftBody::totspring.
Referenced by softbody_step().
|
static |
Definition at line 3269 of file softbody.c.
References Freestyle::a, SoftBody::bpoint, copy_v3_v3(), free_scratch(), SoftBody::lcom, SoftBody::lrot, SoftBody::lscale, mesh_faces_to_scratch(), mul_m4_v3(), SBScratch::needstobuildcollider, NULL, OB_CURVES_LEGACY, OB_LATTICE, OB_MESH, OB_SB_FACECOLL, OB_SURF, Object::obmat, 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().
Definition at line 2470 of file softbody.c.
References Freestyle::a, 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 3331 of file softbody.c.
References apply_spring_memory(), ccd_build_deflector_hash(), ccd_update_deflector_hash(), CLOG_ERROR, SBScratch::colliderhash, SoftBody::collision_group, depsgraph, err, 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, NULL, PIL_check_seconds_timer(), SoftBody::plastic, SoftBody::rklimit, SB_localInterruptCallBack, SBF_DOFUZZY, SBSO_MONITOR, scene, 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().
|
static |
Definition at line 3060 of file softbody.c.
References Freestyle::a, SoftBody::bpoint, copy_v3_v3(), Object::imat, invert_m4_m4(), SoftBody::lcom, SoftBody::lrot, SoftBody::lscale, mul_m4_v3(), Object::obmat, BodyPoint::pos, SB_estimate_transform(), SBSO_ESTIMATEIPO, Object::soft, and SoftBody::solverflags.
Referenced by sbObjectStep().
|
static |
Definition at line 3202 of file softbody.c.
References Freestyle::a, SoftBody::bpoint, copy_v3_v3(), mul_m4_v3(), Object::obmat, BodyPoint::origE, BodyPoint::origS, and BodyPoint::origT.
Referenced by sbObjectStep().
Definition at line 2628 of file softbody.c.
References Freestyle::a, SoftBody::bpoint, SoftBody::bspring, MVert::co, copy_v3_v3(), Object::data, BodySpring::len, len_v3v3(), mul_m4_v3(), Mesh::mvert, Object::obmat, BodyPoint::origS, Object::soft, SoftBody::springpreload, SoftBody::totspring, Mesh::totvert, BodySpring::v1, and BodySpring::v2.
Referenced by mesh_to_softbody().
|
static |
Definition at line 250 of file softbody.c.
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 67 of file softbody.c.
Referenced by _final_goal(), _final_mass(), _softbody_calc_forces_slice_in_a_thread(), add_2nd_order_roller(), sb_detect_aabb_collisionCached(), sb_detect_edge_collisionCached(), sb_detect_face_collisionCached(), sb_detect_face_pointCached(), sb_detect_vertex_collisionCached(), sb_spring_force(), and softbody_step().
Definition at line 70 of file softbody.c.
Referenced by sbSetInterruptCallBack(), and softbody_step().
|
static |
Definition at line 144 of file softbody.c.
Referenced by softbody_step().