@@ -119,17 +119,35 @@ impl Default for BodyDesc {
119119 }
120120}
121121
122+ /// Coupling mode between GPU and CPU physics simulations.
123+ ///
124+ /// Determines how rigid body state is synchronized between GPU and CPU representations.
122125#[ derive( Copy , Clone , Debug , PartialEq , Eq , Default ) ]
123126pub enum BodyCoupling {
127+ /// One-way coupling: CPU -> GPU only.
128+ ///
129+ /// The GPU reads body state from CPU but doesn't write back. The body is treated
130+ /// as kinematic from the GPU's perspective (zero mass).
124131 OneWay ,
132+ /// Two-way coupling: CPU <-> GPU.
133+ ///
134+ /// The GPU both reads from and writes to the body state. The body is fully dynamic
135+ /// with its mass properties applied on the GPU.
125136 #[ default]
126137 TwoWays ,
127138}
128139
140+ /// Associates a Rapier rigid body with a collider for GPU simulation.
141+ ///
142+ /// Defines which Rapier rigid body and collider pair should be included in the
143+ /// GPU simulation and how they should be coupled.
129144#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
130145pub struct BodyCouplingEntry {
146+ /// Handle to the Rapier rigid body
131147 pub body : RigidBodyHandle ,
148+ /// Handle to the Rapier collider attached to this body
132149 pub collider : ColliderHandle ,
150+ /// Coupling mode (one-way or two-way synchronization)
133151 pub mode : BodyCoupling ,
134152}
135153
@@ -144,6 +162,26 @@ impl<B: Backend> GpuBodySet<B> {
144162 self . len
145163 }
146164
165+ /// Create a GPU body set from Rapier bodies and colliders.
166+ ///
167+ /// Converts Rapier rigid bodies and their associated colliders into GPU-compatible
168+ /// representations. The coupling entries determine which body-collider pairs are
169+ /// included and how they synchronize with the CPU simulation.
170+ ///
171+ /// # Arguments
172+ /// * `backend` - The GPU backend to allocate buffers on
173+ /// * `bodies` - The Rapier rigid body set
174+ /// * `colliders` - The Rapier collider set
175+ /// * `coupling` - List of body-collider pairs to include with their coupling modes
176+ ///
177+ /// # Returns
178+ /// A new `GpuBodySet` containing GPU representations of the specified bodies
179+ ///
180+ /// # Errors
181+ /// Returns an error if GPU buffer allocation fails
182+ ///
183+ /// # Panics
184+ /// Panics if a collider has an unsupported shape type
147185 pub fn from_rapier (
148186 backend : & B ,
149187 bodies : & RigidBodySet ,
@@ -276,18 +314,34 @@ impl<B: Backend> GpuBodySet<B> {
276314 & self . shapes
277315 }
278316
317+ /// GPU storage buffer containing world-space vertices for complex shapes.
318+ ///
319+ /// Contains vertices for polylines and trimeshes in world-space coordinates.
320+ /// Updated when body poses change.
279321 pub fn shapes_vertex_buffers ( & self ) -> & GpuTensor < Point < f32 > , B > {
280322 & self . shapes_vertex_buffers
281323 }
282324
325+ /// GPU storage buffer containing local-space vertices for complex shapes.
326+ ///
327+ /// Contains vertices for polylines and trimeshes in body-local coordinates.
328+ /// These are the original untransformed vertices.
283329 pub fn shapes_local_vertex_buffers ( & self ) -> & GpuTensor < Point < f32 > , B > {
284330 & self . shapes_local_vertex_buffers
285331 }
286332
333+ /// GPU storage buffer mapping each vertex to its collider ID.
334+ ///
335+ /// For each vertex in the vertex buffers, stores which collider (body index) it belongs to.
336+ /// Used for collision detection and response.
287337 pub fn shapes_vertex_collider_id ( & self ) -> & GpuTensor < u32 , B > {
288338 & self . shapes_vertex_collider_id
289339 }
290340
341+ /// CPU copy of shape data for all bodies.
342+ ///
343+ /// Returns a slice containing the [`GpuShape`] for each body in the set.
344+ /// Primarily used for convenience in particle-based simulations.
291345 pub fn shapes_data ( & self ) -> & [ GpuShape ] {
292346 & self . shapes_data
293347 }
0 commit comments