SubShape Class

An additional collision shape attached to the same Box2D body as a PhysicsBodyComponent. Chain shapes are not supported as sub-shapes.

public sealed class SubShape

Inheritance System.Object → SubShape

Properties
CategoryBits Raw category bitmask override for this sub-shape. When non-zero, overrides the single-bit mask derived from Layer (i.e. 1UL << Layer). When null, falls back to Layer-derived bits or the owning body's CategoryBits. Takes effect immediately on a live body via a lightweight filter update.
CollisionMask Collision mask override for this sub-shape. When null, inherits Brine2D.ECS.Components.PhysicsBodyComponent.CollisionMask from the owning body. Takes effect immediately on a live body via a lightweight filter update.
EnableHitEvents Whether hit events (OnCollisionHit) are enabled for this sub-shape. When null, inherits EnableHitEvents from the owning body. Changes on a live body apply immediately.
Friction Surface friction for this sub-shape (0–1). When null, inherits SurfaceFriction from the owning body. Changes on a live body apply immediately via a lightweight material update.
GroupIndex Box2D collision group index for this sub-shape. Overrides the owning body's GroupIndex for this shape only. Positive = always collide with same group, negative = never collide, 0 = use category/mask bits (default).
IsTrigger When true, this sub-shape acts as a sensor: it fires trigger events but generates no collision response. Changing this on a live body applies immediately via a lightweight sensor-events toggle — no full rebuild is required.
Layer Collision layer override for this sub-shape (0–63). When null, inherits Brine2D.ECS.Components.PhysicsBodyComponent.Layer from the owning body. Takes effect immediately on a live body via a lightweight filter update.
MarkOwnerShouldCollideChanged Invoked when ShouldCollide transitions between null and non-null. Wired by the owning PhysicsBodyComponent to propagate changes into the system's filter-active count.
MarkOwnerTriggerDirty Invoked when IsTrigger changes on a live body sub-shape. Wired by the owning PhysicsBodyComponent to propagate the change into the system's sub-shape trigger handler.
Restitution Restitution (bounciness) for this sub-shape (0–1). When null, inherits Restitution from the owning body. Changes on a live body apply immediately via a lightweight material update.
ShouldCollide Per-sub-shape collision filter. When set, called for every candidate contact pair involving this sub-shape — return false to prevent the pair from colliding. The first parameter is the other PhysicsBodyComponent. The second is the specific SubShape on that body involved in the contact, or null when the other body's primary shape or a chain segment is the candidate. The callback is invoked from the Box2D broad-phase on the simulation thread — keep it allocation-free.
Methods
UpdateDefinition(ShapeDefinition) Updates the geometry of this sub-shape. When the body is live and the new definition is the same shape type as the current one, the change is applied via a lightweight B2.ShapeSet* call. When the shape type changes, a full body rebuild is triggered. Chain shapes are not supported.