Clamp DynamicRigidBody.density in the setter


QPhysicsCommandSetDensity::execute() computed a clamped density and, on
non-positive input, warned "Clamping density" but then returned before
ever calling updateMassAndInertia() -- so the warned-about clamp was
never applied and the body's mass/inertia silently kept its previous
value.

Rather than fix the clamp in the deferred command, move it into
DynamicRigidBody::setDensity() itself, matching the pattern used for
the joint limit properties (qBound() directly in the setter, no
warning): density is documented as Range: (0, inf], but the setter
never actually enforced that, so density() could return a value that
was never what got applied to the physics body. The deferred command
now just applies the already-valid value.

Adds a regression test with massMode: CustomDensity and density: 0,
asserting the property reads back as clamped instead of 0.

Pick-to: 6.12 6.11 6.8
Change-Id: Id8b0914fa71603bf5308f1c977bdd2ba1b89b763
Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io>
commit409441cbaffe8e466b5bfb16cea080b83fea2a97
parent02254340bfbbb7e3956a43d3afecf36826694cdc
authorJonas Karlsson <jonas.karlsson@qt.io>
committerJonas Karlsson <jonas.karlsson@qt.io>
commit timeWed, 12 Aug 2026 06:24:48 +0000