@@ -174,24 +174,25 @@ class PhysicsBoxState internal constructor(
174174 /* *
175175 * Queues a linear impulse for the body associated with [key].
176176 *
177- * Units are interpreted by the runtime (typically physics units).
177+ * Impulse components are expressed in container pixels (Px) and converted internally
178+ * to physics impulse units by the runtime [dev.zinchenko.physicsbox.units.PhysicsUnits].
178179 *
179180 * @param key Body key used in `Modifier.physicsBody(key = ...)`.
180- * @param impulseX Impulse X component.
181- * @param impulseY Impulse Y component.
181+ * @param impulseXPx Impulse X component in container pixels (Px) .
182+ * @param impulseYPx Impulse Y component in container pixels (Px) .
182183 * @param wake Whether to wake the body if the backend supports sleeping.
183184 */
184185 fun enqueueImpulse (
185186 key : Any ,
186- impulseX : Float ,
187- impulseY : Float ,
187+ impulseXPx : Float ,
188+ impulseYPx : Float ,
188189 wake : Boolean = true,
189190 ) {
190191 enqueueCommand(
191192 PhysicsCommand .EnqueueImpulse (
192193 key = key,
193- impulseX = impulseX ,
194- impulseY = impulseY ,
194+ impulseXPx = impulseXPx ,
195+ impulseYPx = impulseYPx ,
195196 wake = wake,
196197 ),
197198 )
@@ -200,12 +201,13 @@ class PhysicsBoxState internal constructor(
200201 /* *
201202 * Queues a linear velocity update for the body associated with [key].
202203 *
203- * Units are interpreted by the runtime (some implementations may treat these as physics units,
204- * others as pixel units; prefer runtime-specific helpers if available).
204+ * Velocity components are expressed in container pixels per second (Px/s) and converted
205+ * internally to meters per second by the runtime
206+ * [dev.zinchenko.physicsbox.units.PhysicsUnits].
205207 *
206208 * @param key Body key used in `Modifier.physicsBody(key = ...)`.
207- * @param velocityX Velocity X component.
208- * @param velocityY Velocity Y component.
209+ * @param velocityX Velocity X component in container pixels per second (Px/s) .
210+ * @param velocityY Velocity Y component in container pixels per second (Px/s) .
209211 */
210212 fun enqueueVelocity (
211213 key : Any ,
@@ -215,8 +217,8 @@ class PhysicsBoxState internal constructor(
215217 enqueueCommand(
216218 PhysicsCommand .EnqueueVelocity (
217219 key = key,
218- velocityX = velocityX,
219- velocityY = velocityY,
220+ velocityXPxPerSec = velocityX,
221+ velocityYPxPerSec = velocityY,
220222 ),
221223 )
222224 }
@@ -278,10 +280,6 @@ class PhysicsBoxState internal constructor(
278280 callbacksByKey.remove(key)
279281 }
280282
281- internal fun dispatchCollisionToBody (event : CollisionEvent ) {
282- callbacksByKey[event.selfKey]?.onCollision?.invoke(event)
283- }
284-
285283 internal fun dispatchDragToBody (event : DragEvent ) {
286284 val callbacks = callbacksByKey[event.key] ? : return
287285 when (event.phase) {
@@ -290,10 +288,6 @@ class PhysicsBoxState internal constructor(
290288 DragPhase .End , DragPhase .Cancel -> callbacks.onDragEnd?.invoke(event)
291289 }
292290 }
293-
294- internal fun dispatchSleepToBody (key : Any , isSleeping : Boolean ) {
295- callbacksByKey[key]?.onSleepChanged?.invoke(isSleeping)
296- }
297291}
298292
299293/* *
0 commit comments