Blender  V3.3
BKE_rigidbody.h File Reference

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

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_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, int 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 180 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
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type

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

Definition at line 171 of file BKE_rigidbody.h.

Typedef Documentation

◆ RigidbodyWorldIDFunc

typedef void(* RigidbodyWorldIDFunc) (struct RigidBodyWorld *rbw, struct ID **idpoin, void *userdata, int 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 
)

Definition at line 2333 of file rigidbody.c.

References BKE_report(), and RPT_ERROR.

Referenced by ED_rigidbody_object_add().

◆ 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 2348 of file rigidbody.c.

Referenced by special_aftertrans_update__object().

◆ BKE_rigidbody_cache_reset()

void BKE_rigidbody_cache_reset ( struct RigidBodyWorld rbw)

Definition at line 2356 of file rigidbody.c.

◆ BKE_rigidbody_calc_center_of_mass()

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

Definition at line 2296 of file rigidbody.c.

References zero_v3().

◆ 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 2290 of file rigidbody.c.

Referenced by rigidbody_objects_calc_mass_exec().

◆ BKE_rigidbody_check_sim_running()

bool BKE_rigidbody_check_sim_running ( struct RigidBodyWorld rbw,
float  ctime 
)

Definition at line 2352 of file rigidbody.c.

Referenced by ObjectToTransData(), and special_aftertrans_update__object().

◆ BKE_rigidbody_constraints_collection_validate()

void BKE_rigidbody_constraints_collection_validate ( struct Scene scene,
struct RigidBodyWorld rbw 
)

Definition at line 2368 of file rigidbody.c.

Referenced by do_versions_after_linking_280().

◆ 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 2320 of file rigidbody.c.

References NULL.

Referenced by 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 2316 of file rigidbody.c.

References NULL.

◆ 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 2300 of file rigidbody.c.

References NULL.

Referenced by 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 2362 of file rigidbody.c.

Referenced by 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 193 of file rigidbody.c.

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

Referenced by object_free_data().

◆ BKE_rigidbody_free_object()

void BKE_rigidbody_free_object ( struct Object ob,
struct RigidBodyWorld rbw 
)

◆ BKE_rigidbody_free_world()

void BKE_rigidbody_free_world ( struct Scene scene)

◆ 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 2324 of file rigidbody.c.

References NULL.

Referenced by ED_rigidbody_constraint_add(), and rigidbody_con_add_exec().

◆ BKE_rigidbody_is_affected_by_simulation()

bool BKE_rigidbody_is_affected_by_simulation ( struct Object ob)

◆ 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 2371 of file rigidbody.c.

Referenced by 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 
)

Referenced by object_copy_data().

◆ 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 2365 of file rigidbody.c.

Referenced by 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 2359 of file rigidbody.c.

Referenced by BKE_rigidbody_rebuild_sim().

◆ 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 
)

Definition at line 2339 of file rigidbody.c.

Referenced by BKE_scene_remove_rigidbody_object(), and ED_rigidbody_object_remove().

◆ 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 2345 of file rigidbody.c.

Referenced by BKE_rigidbody_object_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 2286 of file rigidbody.c.

◆ BKE_rigidbody_world_copy()

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

Copy.

Definition at line 2304 of file rigidbody.c.

References NULL.

Referenced by scene_copy_data().

◆ BKE_rigidbody_world_groups_relink()

void BKE_rigidbody_world_groups_relink ( struct RigidBodyWorld rbw)

Definition at line 2308 of file rigidbody.c.

Referenced by BKE_scene_groups_relink().

◆ BKE_rigidbody_world_id_loop()

void BKE_rigidbody_world_id_loop ( struct RigidBodyWorld rbw,
RigidbodyWorldIDFunc  func,
void userdata 
)

Definition at line 2311 of file rigidbody.c.

Referenced by scene_foreach_id().