pure-cpp 1.0.0
A C++ physics simulation benchmark comparing performance with Python implementations
Model::Space Class Reference

Class describing a space in which move several bodies. More...

#include <space.hpp>

Collaboration diagram for Model::Space:
Collaboration graph

Public Member Functions

 Space ()
 Default constructor. More...
 
 Space (const Configuration::SimulationConfig &config)
 Initialise the space. More...
 
 ~Space ()
 Destructor to clean up OpenMP locks. More...
 
std::size_t n () const
 Number of bodies getter. More...
 
BodyProxy body (std::size_t i)
 Get a proxy to the i-th body. More...
 
ConstBodyProxy body (std::size_t i) const
 Get a const proxy to the i-th body. More...
 
double getPreviousTimeStep () const
 Get the time step used in the last completed simulation frame. More...
 
void computeDynamics (std::size_t iteration)
 Computes one full step of the simulation. More...
 
std::tuple< double, double, double > calculateSystemEnergy () const
 Calculates the kinetic and potential energy of the system. More...
 
std::tuple< Vector3dVec, QuaterniondVec > getAllBodyTransforms () const
 Retrieves the current positions and orientations of all bodies. More...
 
std::tuple< Vector3dVec, QuaterniondVec, Vector3dVec, Vector3dVec > getDataForDisplay () const
 Retrieves all data required for display for all bodies. More...
 
void printProfilingReport () const
 
double getG () const
 Get the universal gravitational constant. More...
 
void setG (double g)
 Set the universal gravitational constant. More...
 
double getEpsilon () const
 Get the numerical precision threshold. More...
 
void setEpsilon (double eps)
 Set the numerical precision threshold. More...
 
double getCoeffRestitution () const
 Get the coefficient of restitution. More...
 
void setCoeffRestitution (double e)
 Set the coefficient of restitution. More...
 
double getCoeffFriction () const
 Get the coefficient of kinetic friction. More...
 
void setCoeffFriction (double mu)
 Set the coefficient of kinetic friction. More...
 
double getCoeffStaticFriction () const
 Get the coefficient of static friction. More...
 
void setCoeffStaticFriction (double mu_s)
 Set the coefficient of static friction. More...
 
double getLinearDamping () const
 Get the linear damping factor. More...
 
void setLinearDamping (double damping)
 Set the linear damping factor. More...
 
double getAngularDamping () const
 Get the angular damping factor. More...
 
void setAngularDamping (double damping)
 Set the angular damping factor. More...
 
double getTimeStep () const
 Get the current time step. More...
 
void setTimeStep (double dt)
 Set the current time step. More...
 
double getPositionalCorrectionFactor () const
 Get the positional correction factor. More...
 
void setPositionalCorrectionFactor (double factor)
 Set the positional correction factor. More...
 
bool isDiagnosticsEnabled () const
 Check if diagnostics are enabled. More...
 
void setDiagnosticsEnabled (bool enabled)
 Enable or disable diagnostics. More...
 
BodiesgetBodiesForTest ()
 Provides direct access to the Bodies container for testing. More...
 
std::optional< CollisionContextcreateCollisionContext (BodyProxy &b1, BodyProxy &b2)
 Factory method to create a CollisionContext if two bodies are colliding. More...
 
std::tuple< Vector3d, double, double > applyRestitutionImpulse (CollisionContext &ctx)
 Calculates and applies the normal impulse (restitution) for a collision. More...
 
Vector3d applyFrictionImpulse (const CollisionContext &ctx, double jn, const Vector3d &impulseN)
 Calculates the tangential (frictional) impulse for a collision. More...
 
void colorGraph (const std::vector< std::vector< std::size_t > > &graph)
 A greedy graph colouring algorithm to assign a colour (integer) to each body such that no two adjacent bodies (i.e., colliding bodies) share the same colour. More...
 

Private Member Functions

void handleCollision (BodyProxy &b1, BodyProxy &b2)
 Handles collision detection and response between two bodies. More...
 
void initializeBodies (std::size_t n, double dens, unsigned int seed)
 Initialises the bodies in the simulation with random properties. More...
 
void resolveInterpenetration (const CollisionContext &ctx)
 Resolves interpenetration by moving bodies apart along the collision normal. More...
 
double getEffectiveMass (const CollisionContext &ctx, const Vector3d &direction_vec)
 Calculates the effective mass of two colliding bodies in a given direction. More...
 
void logSystemEnergy (std::size_t iteration)
 Logs system energy and checks for instability if diagnostics are enabled. More...
 
void buildCollisionGraph ()
 Builds the collision graph using broad-phase and narrow-phase detection. More...
 
void resolveCollisions ()
 Resolves all detected collisions using graph colouring. More...
 
void applyGravity ()
 Calculates and applies gravitational forces to all bodies. More...
 
void updateAdaptiveTimeStep ()
 Determines the optimal time step for the next frame based on current velocities and accelerations. More...
 
void applyDamping ()
 Applies linear and angular damping to all bodies. More...
 

Private Attributes

double dt_
 Time step (in s). More...
 
double previous_dt_
 Previous time step (in s). More...
 
double G_
 Universal gravitational constant (in m³ / kg /s²). More...
 
double epsilon_
 Numerical precision threshold. More...
 
double coeffRestitution_
 Coefficient of restitution for collisions. More...
 
double coeffFriction_
 Coefficient of kinetic (sliding) friction. More...
 
double coeffStaticFriction_
 Coefficient of static friction. More...
 
double positionalCorrectionFactor_
 The percentage of overlap to correct in each frame. More...
 
double linearDamping_
 Damping factor for linear velocity. More...
 
double angularDamping_
 Damping factor for angular velocity. More...
 
bool diagnosticsEnabled_
 Flag indicating if diagnostic output is enabled. More...
 
std::size_t logFreq_
 Frequency of energy log output (every N iterations). More...
 
Bodies bodies_
 SoA container for all bodies in the simulation. More...
 
std::unique_ptr< KDTreekdTree_
 k-d tree for broad-phase collision detection. More...
 
std::vector< std::vector< std::size_t > > collisionGraph_
 Adjacency list for the collision graph. More...
 
std::vector< int > colors_
 Stores the colour of each body for parallel collision processing. More...
 
std::vector< omp_lock_t > graphLocks_
 OpenMP locks for thread-safe collision graph updates. More...
 
std::vector< std::vector< std::pair< std::size_t, std::size_t > > > thread_local_collision_pairs_
 Thread-local storage for collision pairs found during broad-phase. This reduces lock contention on the global collisionGraph_ during parallel processing. More...
 
double lastTotalEnergy_ = std::numeric_limits<double>::infinity()
 The total energy from the previous logged step. More...
 
double cached_max_radius_ = 0.0
 Cached maximum radius for collision detection optimization. This is recalculated only when bodies are added/removed, not every frame. More...
 
double profIntegration_ = 0.0
 Time spent in integration steps. More...
 
double profCollisionGraph_ = 0.0
 Time spent in collision graph building. More...
 
double profCollisionResponse_ = 0.0
 Time spent in collision response. More...
 
double profForceCalculation_ = 0.0
 Time spent in force calculation. More...
 

Friends

class ::SpaceTest
 

Detailed Description

Class describing a space in which move several bodies.

Definition at line 89 of file space.hpp.

Constructor & Destructor Documentation

◆ Space() [1/2]

Model::Space::Space ( )
inline

Default constructor.

Definition at line 96 of file space.hpp.

◆ Space() [2/2]

Model::Space::Space ( const Configuration::SimulationConfig &  config)
explicit

Initialise the space.

Parameters
configThe simulation configuration object containing all simulation parameters.

Definition at line 39 of file space.cpp.

Here is the call graph for this function:

◆ ~Space()

Model::Space::~Space ( )

Destructor to clean up OpenMP locks.

Definition at line 202 of file space.cpp.

Member Function Documentation

◆ applyDamping()

void Model::Space::applyDamping ( )
private

Applies linear and angular damping to all bodies.

This method applies velocity damping to reduce energy over time, which helps stabilize the simulation and prevent numerical explosions.

Definition at line 994 of file space.cpp.

◆ applyFrictionImpulse()

Model::Vector3d Model::Space::applyFrictionImpulse ( const CollisionContext ctx,
double  jn,
const Vector3d &  impulseN 
)

Calculates the tangential (frictional) impulse for a collision.

This method is part of the internal collision handling API and is exposed to tests for unit testing collision logic.

Parameters
ctxThe collision context.
jnThe magnitude of the normal impulse, used for the friction limit.
impulseNThe normal impulse vector.
Returns
The friction impulse vector.
Note
This method is public but intended for testing only.

Definition at line 548 of file space.cpp.

Here is the call graph for this function:

◆ applyGravity()

void Model::Space::applyGravity ( )
private

Calculates and applies gravitational forces to all bodies.

Definition at line 1085 of file space.cpp.

◆ applyRestitutionImpulse()

std::tuple< Model::Vector3d, double, double > Model::Space::applyRestitutionImpulse ( CollisionContext ctx)

Calculates and applies the normal impulse (restitution) for a collision.

This method is part of the internal collision handling API and is exposed to tests for unit testing collision logic.

Parameters
ctxThe collision context.
Returns
A tuple containing the total impulse vector, its magnitude, and the magnitude of the bias impulse component.
Note
This method is public but intended for testing only.

Definition at line 523 of file space.cpp.

◆ body() [1/2]

BodyProxy Model::Space::body ( std::size_t  i)
inline

Get a proxy to the i-th body.

Parameters
iBody index.
Returns
A mutable proxy object for the i-th body.

Definition at line 123 of file space.hpp.

◆ body() [2/2]

ConstBodyProxy Model::Space::body ( std::size_t  i) const
inline

Get a const proxy to the i-th body.

Parameters
iBody index.
Returns
A const proxy object for the i-th body.

Definition at line 132 of file space.hpp.

◆ buildCollisionGraph()

void Model::Space::buildCollisionGraph ( )
private

Builds the collision graph using broad-phase and narrow-phase detection.

This method implements a two-phase collision detection algorithm to efficiently identify all colliding body pairs in the simulation. The result is stored in collisionGraph_, where collisionGraph_[i] contains the indices of all bodies colliding with body i.

Algorithm Overview
The algorithm uses a two-phase approach:

Phase 1: Broad-Phase Detection (Spatial Acceleration)

  • Rebuilds the k-d tree with current body positions
  • For each body, performs a radius search to find all bodies within a safe distance (body radius + maximum body radius in system)
  • Uses thread-local storage to collect candidate pairs in parallel
  • Complexity: O(N log N) where N is the number of bodies

Phase 2: Narrow-Phase Detection (Exact Collision Test)

  • For each candidate pair from Phase 1, performs an exact collision test using distance and radius comparison
  • Only pairs that actually overlap are added to the collision graph
  • Complexity: O(C) where C is the number of candidate pairs
Example
Consider a system with 3 bodies:
Body 0: position (0, 0, 0), radius 1.0
Body 1: position (1.5, 0, 0), radius 1.0 // Overlaps with body 0
Body 2: position (5, 0, 0), radius 1.0 // No collision

After execution:

collisionGraph_[0] = {1} // Body 0 collides with body 1
collisionGraph_[1] = {0} // Body 1 collides with body 0
collisionGraph_[2] = {} // Body 2 has no collisions
std::vector< std::vector< std::size_t > > collisionGraph_
Adjacency list for the collision graph.
Definition: space.hpp:608
Thread Safety
This method is fully parallelized using OpenMP:
  • Broad-phase searches are performed in parallel using thread-local storage to avoid race conditions
  • Candidate pairs are collected per-thread and merged sequentially after parallel execution
  • The final collision graph is built sequentially from thread-local results
Performance Optimizations
  • Maximum radius is cached and only recalculated when bodies are added/removed (not every frame)
  • Results vectors are pre-allocated to avoid repeated allocations
  • k-d tree is rebuilt each frame to reflect position changes
  • Thread-local storage minimizes lock contention
Note
This method is called once per simulation step in computeDynamics().
The collision graph is undirected: if body i collides with j, then j appears in collisionGraph_[i] and i appears in collisionGraph_[j].

Definition at line 821 of file space.cpp.

◆ calculateSystemEnergy()

std::tuple< double, double, double > Model::Space::calculateSystemEnergy ( ) const

Calculates the kinetic and potential energy of the system.

Returns
A tuple containing:
  1. Translational Kinetic Energy
  2. Rotational Kinetic Energy
  3. Potential Energy

Definition at line 443 of file space.cpp.

◆ colorGraph()

void Model::Space::colorGraph ( const std::vector< std::vector< std::size_t > > &  graph)

A greedy graph colouring algorithm to assign a colour (integer) to each body such that no two adjacent bodies (i.e., colliding bodies) share the same colour.

This method implements a parallel greedy graph colouring algorithm used to partition collision pairs into independent sets. Bodies with the same colour can have their collisions resolved in parallel without conflicts.

Algorithm Overview
The algorithm uses an iterative approach with two passes per iteration:
  • Pass 1: Each body (in parallel) assigns itself the smallest available colour not used by any of its neighbours.
  • Pass 2: Detect conflicts where adjacent bodies share the same colour (can occur due to race conditions in parallel execution).

The algorithm iterates until no conflicts remain.

Example
Consider a collision graph with 4 bodies:
graph[0] = {1, 2} // Body 0 collides with bodies 1 and 2
graph[1] = {0, 3} // Body 1 collides with bodies 0 and 3
graph[2] = {0} // Body 2 collides with body 0
graph[3] = {1} // Body 3 collides with body 1

After colouring, a possible result is:

colors[0] = 0 // Bodies 0 and 3 can be processed in parallel
colors[1] = 1 // Body 1 can be processed alone
colors[2] = 1 // Bodies 1 and 2 can be processed in parallel
colors[3] = 0 // (same as body 0)
Thread Safety
This method uses OpenMP locks to synchronize access to the shared colors_ vector. Reads of neighbour colours are protected by locks to avoid data races, while writes are minimal and lock-protected.
Parameters
graphThe collision graph where graph[i] contains indices of bodies colliding with i. The graph should be undirected (if body i collides with j, then j should appear in graph[i] and i in graph[j]).
Note
This method is public but intended for testing only.
The algorithm is guaranteed to terminate as conflicts decrease with each iteration (worst-case: O(N) iterations for N bodies).

Definition at line 700 of file space.cpp.

◆ computeDynamics()

void Model::Space::computeDynamics ( std::size_t  iteration)

Computes one full step of the simulation.

This method orchestrates the main simulation loop, including:

  1. Advancing positions and velocities (Velocity Verlet).
  2. Detecting and resolving collisions.
  3. Calculating new forces (gravity).
    Parameters
    iterationThe current simulation iteration number.

Definition at line 908 of file space.cpp.

◆ createCollisionContext()

std::optional< Model::CollisionContext > Model::Space::createCollisionContext ( BodyProxy b1,
BodyProxy b2 
)

Factory method to create a CollisionContext if two bodies are colliding.

This method is part of the internal collision handling API and is exposed to tests for unit testing collision logic.

Parameters
b1First body.
b2Second body.
Returns
A CollisionContext object if a collision occurs, otherwise std::nullopt.
Note
This method is public but intended for testing only.

Definition at line 642 of file space.cpp.

Here is the call graph for this function:

◆ getAllBodyTransforms()

std::tuple< Model::Vector3dVec, Model::QuaterniondVec > Model::Space::getAllBodyTransforms ( ) const

Retrieves the current positions and orientations of all bodies.

Returns
A tuple containing a vector of positions and a vector of quaternions.

Definition at line 384 of file space.cpp.

◆ getAngularDamping()

double Model::Space::getAngularDamping ( ) const
inline

Get the angular damping factor.

Returns
The angular damping factor.

Definition at line 268 of file space.hpp.

◆ getBodiesForTest()

Bodies & Model::Space::getBodiesForTest ( )
inline

Provides direct access to the Bodies container for testing.

Returns
A reference to the internal Bodies object.
Note
This method is public but intended for testing only. Access is controlled via the friend declaration.

Definition at line 329 of file space.hpp.

◆ getCoeffFriction()

double Model::Space::getCoeffFriction ( ) const
inline

Get the coefficient of kinetic friction.

Returns
The coefficient of kinetic friction.

Definition at line 228 of file space.hpp.

◆ getCoeffRestitution()

double Model::Space::getCoeffRestitution ( ) const
inline

Get the coefficient of restitution.

Returns
The coefficient of restitution.

Definition at line 214 of file space.hpp.

◆ getCoeffStaticFriction()

double Model::Space::getCoeffStaticFriction ( ) const
inline

Get the coefficient of static friction.

Returns
The coefficient of static friction.

Definition at line 240 of file space.hpp.

◆ getDataForDisplay()

std::tuple< Model::Vector3dVec, Model::QuaterniondVec, Model::Vector3dVec, Model::Vector3dVec > Model::Space::getDataForDisplay ( ) const

Retrieves all data required for display for all bodies.

Returns
A tuple containing vectors of positions, quaternions, torques, and angular accelerations.

Definition at line 400 of file space.cpp.

◆ getEffectiveMass()

double Model::Space::getEffectiveMass ( const CollisionContext ctx,
const Vector3d &  direction_vec 
)
private

Calculates the effective mass of two colliding bodies in a given direction.

Parameters
ctxThe collision context.
direction_vecThe direction vector (e.g., normal or tangent).
Returns
The scalar effective mass.

Definition at line 507 of file space.cpp.

Here is the call graph for this function:

◆ getEpsilon()

double Model::Space::getEpsilon ( ) const
inline

Get the numerical precision threshold.

Returns
The epsilon value.

Definition at line 202 of file space.hpp.

◆ getG()

double Model::Space::getG ( ) const
inline

Get the universal gravitational constant.

Returns
The gravitational constant G.

Definition at line 190 of file space.hpp.

◆ getLinearDamping()

double Model::Space::getLinearDamping ( ) const
inline

Get the linear damping factor.

Returns
The linear damping factor.

Definition at line 256 of file space.hpp.

◆ getPositionalCorrectionFactor()

double Model::Space::getPositionalCorrectionFactor ( ) const
inline

Get the positional correction factor.

Returns
The positional correction factor.

Definition at line 294 of file space.hpp.

◆ getPreviousTimeStep()

double Model::Space::getPreviousTimeStep ( ) const
inline

Get the time step used in the last completed simulation frame.

Returns
The previous time step value.

Definition at line 140 of file space.hpp.

◆ getTimeStep()

double Model::Space::getTimeStep ( ) const
inline

Get the current time step.

Returns
The current time step value.

Definition at line 282 of file space.hpp.

◆ handleCollision()

void Model::Space::handleCollision ( BodyProxy b1,
BodyProxy b2 
)
private

Handles collision detection and response between two bodies.

Parameters
b1A proxy to the first body in the collision.
b2A proxy to the second body in the collision.

Definition at line 664 of file space.cpp.

Here is the call graph for this function:

◆ initializeBodies()

void Model::Space::initializeBodies ( std::size_t  n,
double  dens,
unsigned int  seed 
)
private

Initialises the bodies in the simulation with random properties.

Parameters
nThe number of bodies to create.
densThe density of the bodies.
seedThe seed for random number generation.

Definition at line 209 of file space.cpp.

Here is the caller graph for this function:

◆ isDiagnosticsEnabled()

bool Model::Space::isDiagnosticsEnabled ( ) const
inline

Check if diagnostics are enabled.

Returns
True if diagnostics are enabled, false otherwise.

Definition at line 310 of file space.hpp.

◆ logSystemEnergy()

void Model::Space::logSystemEnergy ( std::size_t  iteration)
private

Logs system energy and checks for instability if diagnostics are enabled.

Parameters
iterationThe current simulation iteration number.

Definition at line 788 of file space.cpp.

◆ n()

std::size_t Model::Space::n ( ) const
inline

Number of bodies getter.

Returns
The number of bodies in the space.

Definition at line 114 of file space.hpp.

Here is the call graph for this function:

◆ printProfilingReport()

void Model::Space::printProfilingReport ( ) const

Definition at line 416 of file space.cpp.

◆ resolveCollisions()

void Model::Space::resolveCollisions ( )
private

Resolves all detected collisions using graph colouring.

Definition at line 966 of file space.cpp.

◆ resolveInterpenetration()

void Model::Space::resolveInterpenetration ( const CollisionContext ctx)
private

Resolves interpenetration by moving bodies apart along the collision normal.

Definition at line 485 of file space.cpp.

Here is the call graph for this function:

◆ setAngularDamping()

void Model::Space::setAngularDamping ( double  damping)
inline

Set the angular damping factor.

Parameters
dampingThe new angular damping factor (typically in [0, 1]).

Definition at line 276 of file space.hpp.

◆ setCoeffFriction()

void Model::Space::setCoeffFriction ( double  mu)
inline

Set the coefficient of kinetic friction.

Parameters
muThe new coefficient of kinetic friction.

Definition at line 234 of file space.hpp.

◆ setCoeffRestitution()

void Model::Space::setCoeffRestitution ( double  e)
inline

Set the coefficient of restitution.

Parameters
eThe new coefficient of restitution (typically in [0, 1]).

Definition at line 222 of file space.hpp.

◆ setCoeffStaticFriction()

void Model::Space::setCoeffStaticFriction ( double  mu_s)
inline

Set the coefficient of static friction.

Parameters
mu_sThe new coefficient of static friction.

Definition at line 248 of file space.hpp.

◆ setDiagnosticsEnabled()

void Model::Space::setDiagnosticsEnabled ( bool  enabled)
inline

Enable or disable diagnostics.

Parameters
enabledTrue to enable diagnostics, false to disable.

Definition at line 318 of file space.hpp.

◆ setEpsilon()

void Model::Space::setEpsilon ( double  eps)
inline

Set the numerical precision threshold.

Parameters
epsThe new epsilon value.

Definition at line 208 of file space.hpp.

◆ setG()

void Model::Space::setG ( double  g)
inline

Set the universal gravitational constant.

Parameters
gThe new gravitational constant value.

Definition at line 196 of file space.hpp.

◆ setLinearDamping()

void Model::Space::setLinearDamping ( double  damping)
inline

Set the linear damping factor.

Parameters
dampingThe new linear damping factor (typically in [0, 1]).

Definition at line 262 of file space.hpp.

◆ setPositionalCorrectionFactor()

void Model::Space::setPositionalCorrectionFactor ( double  factor)
inline

Set the positional correction factor.

Parameters
factorThe new positional correction factor.

Definition at line 302 of file space.hpp.

◆ setTimeStep()

void Model::Space::setTimeStep ( double  dt)
inline

Set the current time step.

Parameters
dtThe new time step value.

Definition at line 288 of file space.hpp.

◆ updateAdaptiveTimeStep()

void Model::Space::updateAdaptiveTimeStep ( )
private

Determines the optimal time step for the next frame based on current velocities and accelerations.

Definition at line 1005 of file space.cpp.

Friends And Related Function Documentation

◆ ::SpaceTest

friend class ::SpaceTest
friend

Definition at line 93 of file space.hpp.

Member Data Documentation

◆ angularDamping_

double Model::Space::angularDamping_
private

Damping factor for angular velocity.

Definition at line 593 of file space.hpp.

◆ bodies_

Bodies Model::Space::bodies_
private

SoA container for all bodies in the simulation.

Definition at line 602 of file space.hpp.

◆ cached_max_radius_

double Model::Space::cached_max_radius_ = 0.0
mutableprivate

Cached maximum radius for collision detection optimization. This is recalculated only when bodies are added/removed, not every frame.

Definition at line 633 of file space.hpp.

◆ coeffFriction_

double Model::Space::coeffFriction_
private

Coefficient of kinetic (sliding) friction.

Definition at line 581 of file space.hpp.

◆ coeffRestitution_

double Model::Space::coeffRestitution_
private

Coefficient of restitution for collisions.

Definition at line 578 of file space.hpp.

◆ coeffStaticFriction_

double Model::Space::coeffStaticFriction_
private

Coefficient of static friction.

Definition at line 584 of file space.hpp.

◆ collisionGraph_

std::vector<std::vector<std::size_t> > Model::Space::collisionGraph_
private

Adjacency list for the collision graph.

Definition at line 608 of file space.hpp.

◆ colors_

std::vector<int> Model::Space::colors_
private

Stores the colour of each body for parallel collision processing.

Definition at line 614 of file space.hpp.

◆ diagnosticsEnabled_

bool Model::Space::diagnosticsEnabled_
private

Flag indicating if diagnostic output is enabled.

Definition at line 596 of file space.hpp.

◆ dt_

double Model::Space::dt_
private

Time step (in s).

Definition at line 566 of file space.hpp.

◆ epsilon_

double Model::Space::epsilon_
private

Numerical precision threshold.

Definition at line 575 of file space.hpp.

◆ G_

double Model::Space::G_
private

Universal gravitational constant (in m³ / kg /s²).

Definition at line 572 of file space.hpp.

◆ graphLocks_

std::vector<omp_lock_t> Model::Space::graphLocks_
private

OpenMP locks for thread-safe collision graph updates.

Definition at line 617 of file space.hpp.

◆ kdTree_

std::unique_ptr<KDTree> Model::Space::kdTree_
private

k-d tree for broad-phase collision detection.

Definition at line 605 of file space.hpp.

◆ lastTotalEnergy_

double Model::Space::lastTotalEnergy_ = std::numeric_limits<double>::infinity()
private

The total energy from the previous logged step.

Definition at line 628 of file space.hpp.

◆ linearDamping_

double Model::Space::linearDamping_
private

Damping factor for linear velocity.

Definition at line 590 of file space.hpp.

◆ logFreq_

std::size_t Model::Space::logFreq_
private

Frequency of energy log output (every N iterations).

Definition at line 599 of file space.hpp.

◆ positionalCorrectionFactor_

double Model::Space::positionalCorrectionFactor_
private

The percentage of overlap to correct in each frame.

Definition at line 587 of file space.hpp.

◆ previous_dt_

double Model::Space::previous_dt_
private

Previous time step (in s).

Definition at line 569 of file space.hpp.

◆ profCollisionGraph_

double Model::Space::profCollisionGraph_ = 0.0
mutableprivate

Time spent in collision graph building.

Definition at line 642 of file space.hpp.

◆ profCollisionResponse_

double Model::Space::profCollisionResponse_ = 0.0
mutableprivate

Time spent in collision response.

Definition at line 645 of file space.hpp.

◆ profForceCalculation_

double Model::Space::profForceCalculation_ = 0.0
mutableprivate

Time spent in force calculation.

Definition at line 648 of file space.hpp.

◆ profIntegration_

double Model::Space::profIntegration_ = 0.0
mutableprivate

Time spent in integration steps.

Definition at line 639 of file space.hpp.

◆ thread_local_collision_pairs_

std::vector<std::vector<std::pair<std::size_t, std::size_t> > > Model::Space::thread_local_collision_pairs_
private

Thread-local storage for collision pairs found during broad-phase. This reduces lock contention on the global collisionGraph_ during parallel processing.

Definition at line 625 of file space.hpp.


The documentation for this class was generated from the following files: