bevy_xpbd icon indicating copy to clipboard operation
bevy_xpbd copied to clipboard

Read only methods of `RigidBodyForces` are not implemented for `ForcesReadOnlyItem`

Open Dzejkop opened this issue 2 months ago • 1 comments

Methods such as accumulated_linear_acceleration are only implemented for the ForcesItem type, as a result one must always use a mutable reference to query data even if non-mutable access would suffice.

I'm thinking splitting RigidBodyForces into RigidBodyForces & RigidBodyForcesReadOnly where RigidBodyForces: RigidBodyForcesReadOnly and then implementing RigidBodyForcesReadOnly for ForcesIteamReadOnly should do the trick.

I'm down to handle it myself just wanted to check if there are other plans for this code or you'd prefer a different solution.

Dzejkop avatar Oct 09 '25 18:10 Dzejkop

That seems fine as a solution. Originally, I would have preferred if the read-only variant didn't even exist (afaik not easily doable with QueryData), since it feels a bit footgunny to me; Forces is intended more for applying forces, not reading them. But I suppose the read-only version may be useful for some scenarios too

Jondolf avatar Oct 11 '25 15:10 Jondolf