group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
RigidBody Struct Reference

Dynamic-body state shared across the force, impulse, and (Phase 7+) constraint-solver paths. More...

#include <RigidBody.hpp>

Public Attributes

float invMass = 1.0f / 80.0f
 Inverse mass.
glm::mat3 localInvInertia {0.0f}
 Local-space inverse inertia tensor.
glm::mat3 invInertiaWorld {0.0f}
 World-space inverse inertia tensor.
glm::vec3 forceAccum {0.0f}
 Continuous force accumulator. Integrated as dv += F * dt * invMass.
glm::vec3 impulseAccum {0.0f}
 Instantaneous impulse accumulator.
glm::vec3 torqueAccum {0.0f}
 Continuous torque accumulator (Phase 7).
glm::vec3 angImpulseAccum {0.0f}
 Instantaneous angular-impulse accumulator (Phase 7).
float linearDamping = 0.0f
 Per-frame linear damping factor.
float angularDamping = 0.05f
 Per-frame angular damping factor (Phase 7).
bool isAsleep = false
 Sleep state (Phase 12). Sleeping bodies skip integration.
uint16_t sleepCounter = 0
 Frames since the body's energy dropped below the sleep threshold (Phase 12).

Detailed Description

Dynamic-body state shared across the force, impulse, and (Phase 7+) constraint-solver paths.

Lifecycle. Accumulators (forceAccum, impulseAccum, torqueAccum, angImpulseAccum) are written by forces::apply* helpers throughout a tick, drained into velocity / angularVelocity by forces::integrateAccumulators at tick start, and then cleared.

Member Data Documentation

◆ angImpulseAccum

glm::vec3 RigidBody::angImpulseAccum {0.0f}

Instantaneous angular-impulse accumulator (Phase 7).

◆ angularDamping

float RigidBody::angularDamping = 0.05f

Per-frame angular damping factor (Phase 7).

◆ forceAccum

glm::vec3 RigidBody::forceAccum {0.0f}

Continuous force accumulator. Integrated as dv += F * dt * invMass.

◆ impulseAccum

glm::vec3 RigidBody::impulseAccum {0.0f}

Instantaneous impulse accumulator.

Integrated as dv += J * invMass (no dt — impulses are pre-integrated forces).

◆ invInertiaWorld

glm::mat3 RigidBody::invInertiaWorld {0.0f}

World-space inverse inertia tensor.

Computed each tick by Phase 7's integration step as R * localInvInertia * R^T (where R is the body's rotation matrix). Phase 6 leaves this at identity since no rotation is integrated yet.

◆ invMass

float RigidBody::invMass = 1.0f / 80.0f

Inverse mass.

0 = static / kinematic (infinite mass — applied forces have no effect). Defaults to 1 / 80 kg ≈ 0.0125 — a typical human-sized character mass.

◆ isAsleep

bool RigidBody::isAsleep = false

Sleep state (Phase 12). Sleeping bodies skip integration.

◆ linearDamping

float RigidBody::linearDamping = 0.0f

Per-frame linear damping factor.

velocity *= (1 - damping*dt). 0 = no damping. Useful for atmospheric drag on projectiles.

◆ localInvInertia

glm::mat3 RigidBody::localInvInertia {0.0f}

Local-space inverse inertia tensor.

Diagonal-only suffices for the box / capsule / sphere shapes we currently support; off-diagonal terms are zero. Phase 7 will refresh invInertiaWorld each frame from this and the body's orientation.

◆ sleepCounter

uint16_t RigidBody::sleepCounter = 0

Frames since the body's energy dropped below the sleep threshold (Phase 12).

◆ torqueAccum

glm::vec3 RigidBody::torqueAccum {0.0f}

Continuous torque accumulator (Phase 7).


The documentation for this struct was generated from the following file: