pub struct SkinnedInstanceDesc<'a> {
pub mesh: &'a SkinnedMesh,
pub material: usize,
pub transform: Mat4,
pub bounds: Option<Aabb>,
}Expand description
Where a skinned object is, and what it draws: InstanceDesc with a
SkinnedMesh where the description’s mesh index would be.
The mesh is a reservation rather than an index because a skinned draw is not
only a mesh — it also names a run of the vertex pool the skinning dispatch
fills, and which of the reservation’s two runs that is changes every frame.
ForwardRenderer::begin_skinned_frame is what keeps it current, so nothing
here carries a parity.
Fields§
§mesh: &'a SkinnedMeshThe region this object is drawn out of, from
ForwardRenderer::reserve_skinned.
material: usizeWhich SceneDesc::materials row it shades through, exactly as
InstanceDesc::material.
transform: Mat4Where it is: a model matrix, on InstanceDesc::transform’s terms.
The joints are not in it — a palette carries each joint’s global
transform times its inverse bind matrix, and this is what puts the
deformed mesh in the world. See
SkinRange::palette.
bounds: Option<Aabb>A model-space box around every pose this object will be drawn in
until it is next set, in the space transform
carries into the world — or None, which keeps it in every cull.
None is the safe default and the costly one. The region’s source
mesh’s box is its bind pose, which says nothing about where a skinning
dispatch moves the vertices, so an object without a box of its own is
drawn by every camera and every shadow map wherever it is. With one, the
frustum culls, the occlusion culls and the shadow cache’s footprints
test it exactly as they test a rigid mesh’s box. The box has to
contain every vertex the palette can put anywhere: a cull that finds
it outside drops the whole object, so a box that misses part of a pose
can make an object vanish while that part is on screen.
ForwardRenderer::set_skinned_bounds moves it each frame, for a pose
— a ragdoll — that travels far from the object’s origin.
Every corner must be finite and min must not exceed max on any
axis. An inverted or non-finite box is refused rather than written,
because the culls would read it as a box nothing reaches and drop the
object everywhere — see InstancePoolError::InvalidBounds.