times

operator fun <E : Shape, Kinetic> E.times(bounce: Bounce): E

Shape * Bounce => Shape
Returns this entity bounced off the violated edge: velocity reflected when the entity approaches the edge, geometry landed clear of the penetration either way.

The receiver resolves bounce's penetration relative to the collider's motion. Approach is decided raw: the entity reflects only when its velocity relative to Bounce.colliderVelocity runs against Penetration.normal — (velocity - colliderVelocity) dot normal < 0. On approach, the geometry translates by twice Penetration.depth along the normal — the penetration happened one depth ago along the normal and the reflected continuation lands one depth clear — and the Kinetic.velocity of the result is the relative velocity mirrored across the violated edge's carrier with the collider's velocity restored: the normal component of the relative velocity flips, the tangential component rides through. Against the default zero-direction collider this is exactly the world-frame reflection off a static edge.

A receding or grazing contact — relative velocity with no component against the normal — reflects nothing: the geometry translates by one Penetration.depth along the normal, resolving the penetration, and the velocity rides through untouched. The relative gate is what keeps the dynamics sound against a moving collider: motion of the collider manufactures fresh contacts step after step, and each one resolves as a push — never as a second reflection of an entity already moving away. The receiver itself is untouched in both lanes: the velocity is written only on the returned copy, so a binding captured before the bounce keeps its pre-bounce velocity, and the result is the receiver's own class through its copy hook. entity *= bounce(penetration) spells the bounce — the rebind replaces the entity with its bounced value.

Receiver

The entity to bounce — a Shape carrying the Kinetic trait.

Return

The bounced entity, as the receiver's class.

Parameters

bounce

The bounce to apply.

Type Parameters

E

The receiver's type, preserved in the result.

Throws

when the landing lands two consecutive vertices of a polygon receiver rounded-coincident at the SCALE quantum.

when the landing lands two consecutive vertices of a polyline receiver rounded-coincident at the SCALE quantum.