Blender Physics constraint implementation sources
The following files contain the implementation of the rigid bodies:


properties_physics_rigidbody.py: UI panels in the physics tab for the Rigid Body
properties_physics_rigidbody_constraint.py: UI panels in the physics tab for the Rigid Body Constraint
rna_rigidbody.c: RNA properties for the rigid bodies.
rigidbody.c: Initialization, copying, validating and freeing data structures for rigid body simulation. Functions for calculating volumes, mass, convex hull. Running and managing the simulation.
rigidbody_world.c: Implements operators that can be called from Python that are related to the rigid body world.
rigidbody_constraint.c: Implements operators that can be called from Python that are related to the rigid body constraint.
rigidbody_object.c: Implements operators that can be called from Python that are related to the rigid body object.
rb_bullet_api.cpp: Wrapper for Bullet Physics functions. 


For the parts of code that use the Bullet Physics, search for the WITH_BULLET macro.



Setting the properties and executing the rigid body simulation are separate operations. 

Adding a rigid body simulation to an object in the UI results in call to ED_rigidbody_object_add (rigidbody_object.c) which in turn calls BKE_rigidbody_add_object (rigidbody.c). This functions creates the rigid body world by calling rigidbody_add_object_to_scene() (rigidbody.c) in case it doesn't exist and allocates the memory for RigidBodyOb through BKE_rigidbody_create_object() (rigidbody.c) and assigns default values.

For instance the mass property is displayed in the PHYSICS_PT_rigid_body_settings panel (properties_physics_rigidbody.py). It references the RNA property defined in rna_rigidbody.c which calls rna_RigidBodyOb_mass_set() when a new value is assigned through the UI. This stores the value in RigidBodyOb of the object and updates the state of the Bullet Physics through RB_body_set_mass() (rb_bullet_api.cpp).

Adding a rigid body constraint results in a call to ED_rigidbody_constraint_add() (rigidbody_constraint.c). A constraint collection is created if it doesn't already exist. The constraint is created through BKE_rigidbody_create_constraint (rigidbody.c) and added to the constraint collection through BKE_collection_object_add() (rigidbody.c).

When starting the simulation it executes the function BKE_rigidbody_eval_simulation (deg_builder_nodes.cc) which calls BKE_rigidbody_do_simulation (rigidbody.c). It uses the properties for the world, objects and constraints that were previously assigned.



The explanation of the call stack is a simplification of all the operations that happen during configuration and simulation. They are meant as an overview for where certain steps can be found in the code and not a complete explanation of the performed operations.