Skip to content

novaphy.Contacts

Device-resident structure-of-arrays contact aggregate produced by CollisionPipeline / Model.collide and consumed by solvers.

Allocate through a pipeline when you need contacts sized for collision:

pipeline = novaphy.CollisionPipeline(model, broad_phase="sap")
contacts = pipeline.contacts()
pipeline.collide(state, contacts)
solver.step(state, state, control, contacts, dt)

model.contacts() also returns an empty aggregate, but does not run collision or pre-size buffers by itself.

Counts and Capacity

Field / Method Description
contact_counters Two-slot counter array: rigid count, soft-point count.
rigid_contact_max Allocated rigid contact capacity.
soft_contact_max Allocated soft-point contact capacity.
rigid_contact_count Single-element list containing rigid_count().
soft_contact_count Single-element list containing soft_count().
rigid_count() Number of active rigid contacts.
soft_count() Number of active soft-point contacts.
empty() True when both active counts are zero.
__len__() rigid_count() + soft_count().

Rigid Contact Columns

Rigid contacts are exposed as parallel arrays. Active entries occupy 0:contacts.rigid_count().

Field Description
rigid_contact_point_id Contact feature / persistence id.
rigid_contact_shape0, rigid_contact_shape1 Shape indices for the two sides.
rigid_contact_body0, rigid_contact_body1 Resolved body indices; -1 denotes world.
rigid_contact_point0, rigid_contact_point1 Contact anchors on each side.
rigid_contact_position World-space midpoint used by row solvers.
rigid_contact_offset0, rigid_contact_offset1 Body-frame finite-thickness offsets.
rigid_contact_normal World normal from side 0 toward side 1.
rigid_contact_margin0, rigid_contact_margin1 Effective margin / radius per side.
rigid_contact_penetration Solver-facing penetration depth.
rigid_contact_restitution Combined restitution coefficient.
rigid_contact_accumulated_normal_impulse Warm-start normal impulse.
rigid_contact_accumulated_tangent_impulse0, rigid_contact_accumulated_tangent_impulse1 Warm-start tangent impulses.
rigid_contact_impulse Solver-written world impulse vector.
rigid_contact_adhesion Adhesion coefficient / cache allocated with rigid contact storage.
rigid_contact_torsional_friction Torsional friction coefficient / cache allocated with rigid contact storage.
rigid_contact_rolling_friction Rolling friction coefficient / cache allocated with rigid contact storage.
rigid_contact_tids Writer thread / debug ids.

Optional rigid columns are None unless their matching allocation flag is enabled:

Field Enabled By
rigid_contact_stiffness, rigid_contact_damping, rigid_contact_friction per_contact_shape_properties=True
rigid_contact_match_index contact_matching=True
rigid_contact_new_indices, rigid_contact_broken_indices contact_report=True

Soft-Point Contact Columns

Particle / soft-point contacts against rigid shapes use the soft_contact_* columns. Active entries occupy 0:contacts.soft_count().

Field Description
soft_contact_particle Particle / vertex index.
soft_contact_shape Rigid collider shape index.
soft_contact_body_pos World contact position on the rigid side.
soft_contact_body_vel World rigid-side contact velocity.
soft_contact_normal World normal from point toward rigid shape.
soft_contact_tids Writer thread / debug ids.

Fluid solvers consume this channel through apply_particle_coupling_contacts and apply_particle_contact_reactions.

Optional Force Channel

force is None unless requested through Model.request_contact_attributes("force") or assigned explicitly. When allocated, it stores [force, torque] rows.

Methods

Method Description
reserve_rigid(capacity, per_contact_shape_properties=False, contact_matching=False, contact_report=False, device=Device.cpu()) Allocate rigid contact arrays.
reserve_soft(capacity, device=Device.cpu()) Allocate soft-point contact arrays.
ensure_rigid_capacity(capacity) Grow rigid contact storage if needed.
clear(bump_generation=True) Reset active counts and optionally increment contact_generation.

See Also