Blender V4.5
BKE_rigidbody.h File Reference

API for Blender-side Rigid Body stuff. More...

#include "BKE_lib_query.hh"

Go to the source code of this file.

Macros

Utility Macros
#define RBO_GET_MASS(rbo)
#define RBO_GET_MARGIN(rbo)

Functions

Memory Management
void BKE_rigidbody_free_world (struct Scene *scene)
void BKE_rigidbody_free_object (struct Object *ob, struct RigidBodyWorld *rbw)
void BKE_rigidbody_free_constraint (struct Object *ob)
void BKE_rigidbody_object_copy (struct Main *bmain, struct Object *ob_dst, const struct Object *ob_src, int flag)
Setup
struct RigidBodyWorldBKE_rigidbody_create_world (struct Scene *scene)
struct RigidBodyObBKE_rigidbody_create_object (struct Scene *scene, struct Object *ob, short type)
struct RigidBodyConBKE_rigidbody_create_constraint (struct Scene *scene, struct Object *ob, short type)
void BKE_rigidbody_objects_collection_validate (struct Main *bmain, struct Scene *scene, struct RigidBodyWorld *rbw)
void BKE_rigidbody_constraints_collection_validate (struct Scene *scene, struct RigidBodyWorld *rbw)
void BKE_rigidbody_main_collection_object_add (struct Main *bmain, struct Collection *collection, struct Object *object)
struct RigidBodyWorldBKE_rigidbody_world_copy (struct RigidBodyWorld *rbw, int flag)
void BKE_rigidbody_world_groups_relink (struct RigidBodyWorld *rbw)
void BKE_rigidbody_world_init_runtime (struct RigidBodyWorld *rbw)
struct rbDynamicsWorldBKE_rigidbody_world_physics (struct RigidBodyWorld *rbw)
void BKE_rigidbody_validate_sim_world (struct Scene *scene, struct RigidBodyWorld *rbw, bool rebuild)
void BKE_rigidbody_calc_volume (struct Object *ob, float *r_vol)
void BKE_rigidbody_calc_center_of_mass (struct Object *ob, float r_center[3])
Utilities
struct RigidBodyWorldBKE_rigidbody_get_world (struct Scene *scene)
bool BKE_rigidbody_add_object (struct Main *bmain, struct Scene *scene, struct Object *ob, int type, struct ReportList *reports)
void BKE_rigidbody_ensure_local_object (struct Main *bmain, struct Object *ob)
void BKE_rigidbody_remove_object (struct Main *bmain, struct Scene *scene, struct Object *ob, bool free_us)
void BKE_rigidbody_remove_constraint (struct Main *bmain, struct Scene *scene, struct Object *ob, bool free_us)
Simulation
void BKE_rigidbody_aftertrans_update (struct Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle)
void BKE_rigidbody_sync_transforms (struct RigidBodyWorld *rbw, struct Object *ob, float ctime)
bool BKE_rigidbody_check_sim_running (struct RigidBodyWorld *rbw, float ctime)
bool BKE_rigidbody_is_affected_by_simulation (struct Object *ob)
void BKE_rigidbody_cache_reset (struct RigidBodyWorld *rbw)
void BKE_rigidbody_rebuild_world (struct Depsgraph *depsgraph, struct Scene *scene, float ctime)
void BKE_rigidbody_do_simulation (struct Depsgraph *depsgraph, struct Scene *scene, float ctime)
Depsgraph evaluation
void BKE_rigidbody_rebuild_sim (struct Depsgraph *depsgraph, struct Scene *scene)
void BKE_rigidbody_eval_simulation (struct Depsgraph *depsgraph, struct Scene *scene)
void BKE_rigidbody_object_sync_transforms (struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob)

Iterator

typedef void(*) RigidbodyWorldIDFunc(struct RigidBodyWorld *rbw, struct ID **idpoin, void *userdata, LibraryForeachIDCallbackFlag cb_flag)
void BKE_rigidbody_world_id_loop (struct RigidBodyWorld *rbw, RigidbodyWorldIDFunc func, void *userdata)

Detailed Description

API for Blender-side Rigid Body stuff.

Definition in file BKE_rigidbody.h.

Macro Definition Documentation

◆ RBO_GET_MARGIN

#define RBO_GET_MARGIN ( rbo)
Value:
(((rbo)->flag & RBO_FLAG_USE_MARGIN || (rbo)->shape == RB_SHAPE_CONVEXH || \
(rbo)->shape == RB_SHAPE_TRIMESH || (rbo)->shape == RB_SHAPE_CONE) ? \
((rbo)->margin) : \
(0.04f))
@ RBO_FLAG_USE_MARGIN
@ RB_SHAPE_CONVEXH
@ RB_SHAPE_TRIMESH
@ RB_SHAPE_CONE

Get collision margin for Rigid Body Object, triangle mesh and cone shapes cannot embed margin, convex hull always uses custom margin.

Definition at line 186 of file BKE_rigidbody.h.

◆ RBO_GET_MASS

#define RBO_GET_MASS ( rbo)
Value:
(((rbo) && (((rbo)->type == RBO_TYPE_PASSIVE) || ((rbo)->flag & RBO_FLAG_KINEMATIC) || \
((rbo)->flag & RBO_FLAG_DISABLED))) ? \
(0.0f) : \
((rbo)->mass))
@ RBO_TYPE_PASSIVE
@ RBO_FLAG_KINEMATIC
@ RBO_FLAG_DISABLED

Get mass of Rigid Body Object to supply to RigidBody simulators.

Definition at line 177 of file BKE_rigidbody.h.

Typedef Documentation

◆ RigidbodyWorldIDFunc

typedef void(*) RigidbodyWorldIDFunc(struct RigidBodyWorld *rbw, struct ID **idpoin, void *userdata, LibraryForeachIDCallbackFlag cb_flag)

Callback format for performing operations on ID-pointers for rigid-body world.

Definition at line 58 of file BKE_rigidbody.h.

Function Documentation

◆ BKE_rigidbody_add_object()

bool BKE_rigidbody_add_object ( struct Main * bmain,
struct Scene * scene,
struct Object * ob,
int type,
struct ReportList * reports )

◆ BKE_rigidbody_aftertrans_update()

void BKE_rigidbody_aftertrans_update ( struct Object * ob,
float loc[3],
float rot[3],
float quat[4],
float rotAxis[3],
float rotAngle )

Used when canceling transforms - return rigidbody and object to initial states.

Definition at line 2345 of file rigidbody.cc.

References BKE_rigidbody_aftertrans_update(), and rot.

Referenced by BKE_rigidbody_aftertrans_update(), and blender::ed::transform::special_aftertrans_update__object().

◆ BKE_rigidbody_cache_reset()

void BKE_rigidbody_cache_reset ( struct RigidBodyWorld * rbw)

Definition at line 2353 of file rigidbody.cc.

References BKE_rigidbody_cache_reset().

Referenced by BKE_rigidbody_cache_reset(), and BKE_rigidbody_object_copy().

◆ BKE_rigidbody_calc_center_of_mass()

void BKE_rigidbody_calc_center_of_mass ( struct Object * ob,
float r_center[3] )

Definition at line 2308 of file rigidbody.cc.

References BKE_rigidbody_calc_center_of_mass(), and zero_v3().

Referenced by BKE_rigidbody_calc_center_of_mass().

◆ BKE_rigidbody_calc_volume()

void BKE_rigidbody_calc_volume ( struct Object * ob,
float * r_vol )

Helper function to calculate volume of rigid-body object.

TODO: allow a parameter to specify method used to calculate this?

Definition at line 2302 of file rigidbody.cc.

References BKE_rigidbody_calc_volume().

Referenced by BKE_rigidbody_calc_volume(), and rigidbody_objects_calc_mass_exec().

◆ BKE_rigidbody_check_sim_running()

bool BKE_rigidbody_check_sim_running ( struct RigidBodyWorld * rbw,
float ctime )

◆ BKE_rigidbody_constraints_collection_validate()

void BKE_rigidbody_constraints_collection_validate ( struct Scene * scene,
struct RigidBodyWorld * rbw )

◆ BKE_rigidbody_create_constraint()

struct RigidBodyCon * BKE_rigidbody_create_constraint ( struct Scene * scene,
struct Object * ob,
short type )

Add rigid body constraint to the specified object.

Definition at line 2325 of file rigidbody.cc.

References BKE_rigidbody_create_constraint().

Referenced by BKE_rigidbody_create_constraint(), and ED_rigidbody_constraint_add().

◆ BKE_rigidbody_create_object()

struct RigidBodyOb * BKE_rigidbody_create_object ( struct Scene * scene,
struct Object * ob,
short type )

Add rigid body settings to the specified object.

Definition at line 2321 of file rigidbody.cc.

References BKE_rigidbody_create_object().

Referenced by BKE_rigidbody_create_object().

◆ BKE_rigidbody_create_world()

struct RigidBodyWorld * BKE_rigidbody_create_world ( struct Scene * scene)

Set up RigidBody world.

Create Blender-side settings data - physics objects not initialized yet.

Definition at line 2312 of file rigidbody.cc.

References BKE_rigidbody_create_world().

Referenced by BKE_rigidbody_create_world(), and rigidbody_world_add_exec().

◆ BKE_rigidbody_do_simulation()

void BKE_rigidbody_do_simulation ( struct Depsgraph * depsgraph,
struct Scene * scene,
float ctime )

Run RigidBody simulation for the specified physics world.

Definition at line 2355 of file rigidbody.cc.

References BKE_rigidbody_do_simulation().

Referenced by BKE_rigidbody_do_simulation(), and BKE_rigidbody_eval_simulation().

◆ BKE_rigidbody_ensure_local_object()

void BKE_rigidbody_ensure_local_object ( struct Main * bmain,
struct Object * ob )

◆ BKE_rigidbody_eval_simulation()

void BKE_rigidbody_eval_simulation ( struct Depsgraph * depsgraph,
struct Scene * scene )

◆ BKE_rigidbody_free_constraint()

void BKE_rigidbody_free_constraint ( struct Object * ob)

Free rigid-body constraint and simulation instance.

Definition at line 215 of file rigidbody.cc.

References BKE_rigidbody_free_constraint(), MEM_freeN(), RigidBodyCon::physics_constraint, RB_constraint_delete(), and Object::rigidbody_constraint.

Referenced by BKE_rigidbody_free_constraint(), and object_free_data().

◆ BKE_rigidbody_free_object()

◆ BKE_rigidbody_free_world()

◆ BKE_rigidbody_get_world()

struct RigidBodyWorld * BKE_rigidbody_get_world ( struct Scene * scene)

Get RigidBody world for the given scene, creating one if needed

Parameters
sceneScene to find active Rigid Body world for.

Definition at line 2329 of file rigidbody.cc.

References BKE_rigidbody_get_world().

Referenced by BKE_rigidbody_get_world(), ED_rigidbody_constraint_add(), and rigidbody_con_add_exec().

◆ BKE_rigidbody_is_affected_by_simulation()

◆ BKE_rigidbody_main_collection_object_add()

void BKE_rigidbody_main_collection_object_add ( struct Main * bmain,
struct Collection * collection,
struct Object * object )

Ensure object added to collection gets RB data if that collection is a RB one.

Definition at line 2358 of file rigidbody.cc.

References BKE_rigidbody_main_collection_object_add().

Referenced by BKE_rigidbody_main_collection_object_add(), and collection_object_add().

◆ BKE_rigidbody_object_copy()

void BKE_rigidbody_object_copy ( struct Main * bmain,
struct Object * ob_dst,
const struct Object * ob_src,
int flag )

◆ BKE_rigidbody_object_sync_transforms()

void BKE_rigidbody_object_sync_transforms ( struct Depsgraph * depsgraph,
struct Scene * scene,
struct Object * ob )

◆ BKE_rigidbody_objects_collection_validate()

void BKE_rigidbody_objects_collection_validate ( struct Main * bmain,
struct Scene * scene,
struct RigidBodyWorld * rbw )

Ensure newly set collections' objects all have required data.

Definition at line 2356 of file rigidbody.cc.

References BKE_rigidbody_objects_collection_validate().

Referenced by BKE_rigidbody_objects_collection_validate(), and do_versions_after_linking_280().

◆ BKE_rigidbody_rebuild_sim()

void BKE_rigidbody_rebuild_sim ( struct Depsgraph * depsgraph,
struct Scene * scene )

◆ BKE_rigidbody_rebuild_world()

void BKE_rigidbody_rebuild_world ( struct Depsgraph * depsgraph,
struct Scene * scene,
float ctime )

Rebuild rigid body world.

NOTE: this needs to be called before frame update to work correctly.

Definition at line 2354 of file rigidbody.cc.

References BKE_rigidbody_rebuild_world().

Referenced by BKE_rigidbody_rebuild_sim(), and BKE_rigidbody_rebuild_world().

◆ BKE_rigidbody_remove_constraint()

void BKE_rigidbody_remove_constraint ( struct Main * bmain,
struct Scene * scene,
struct Object * ob,
bool free_us )

◆ BKE_rigidbody_remove_object()

void BKE_rigidbody_remove_object ( struct Main * bmain,
struct Scene * scene,
struct Object * ob,
bool free_us )

◆ BKE_rigidbody_sync_transforms()

void BKE_rigidbody_sync_transforms ( struct RigidBodyWorld * rbw,
struct Object * ob,
float ctime )

Sync rigid body and object transformations.

Definition at line 2344 of file rigidbody.cc.

References BKE_rigidbody_sync_transforms().

Referenced by BKE_rigidbody_object_sync_transforms(), BKE_rigidbody_sync_transforms(), and object_where_is_calc_ex().

◆ BKE_rigidbody_validate_sim_world()

void BKE_rigidbody_validate_sim_world ( struct Scene * scene,
struct RigidBodyWorld * rbw,
bool rebuild )

'validate' (i.e. make new or replace old) Physics-Engine objects. Create physics sim world given RigidBody world settings

Note
this does NOT update object references that the scene uses, in case those aren't ready yet!

Definition at line 2300 of file rigidbody.cc.

References BKE_rigidbody_validate_sim_world().

Referenced by BKE_rigidbody_validate_sim_world().

◆ BKE_rigidbody_world_copy()

struct RigidBodyWorld * BKE_rigidbody_world_copy ( struct RigidBodyWorld * rbw,
int flag )

Copy.

Definition at line 2316 of file rigidbody.cc.

References BKE_rigidbody_world_copy().

Referenced by BKE_rigidbody_world_copy(), and scene_copy_data().

◆ BKE_rigidbody_world_groups_relink()

void BKE_rigidbody_world_groups_relink ( struct RigidBodyWorld * rbw)

◆ BKE_rigidbody_world_id_loop()

◆ BKE_rigidbody_world_init_runtime()

void BKE_rigidbody_world_init_runtime ( struct RigidBodyWorld * rbw)

◆ BKE_rigidbody_world_physics()