Nudge Physics
A single file, header-only 3D physics library
Loading...
Searching...
No Matches
nudge::context_t Struct Reference

Main struct of the library. More...

#include <nudge.h>

Public Attributes

Arena arena
 
BodyData bodies
 
ColliderData colliders
 
ContactData contact_data
 
ContactCache contact_cache
 
ActiveBodies active_bodies
 
KinematicData kinematic_data
 
GlobalData global_data
 
SimulationParams simulation_params
 
const unsigned MAX_NUM_BOXES
 
const unsigned MAX_NUM_SPHERES
 
const unsigned MAX_NUM_BODIES
 
UserData64Bit user
 

Detailed Description

Main struct of the library.

Note
It should be initialized at program startup (see init_context_with(...) or init_context(...))
It should be destroyed at program exit (see destroy_context(...))

Member Data Documentation

◆ arena

Arena nudge::context_t::arena

[internal usage]

◆ bodies

BodyData nudge::context_t::bodies

accessor to the main physics data of the library

◆ colliders

ColliderData nudge::context_t::colliders

accessor to the (global) collider (i.e. collision shape) (box and sphere) arrays. These arrays can be reordered by nudge, but their 'tags' are unique and are automatically assigned and preserved (please NEVER touch them); it's NOT safe to store array indices in colliders.boxes or collider.spheres! Always use c->bodies.infos[body].first_box_index and c->bodies.infos[body].num_boxes instead (same for spheres)

◆ contact_data

ContactData nudge::context_t::contact_data

accessor to the array of contacts, so that users can understand if a body is in contact with another. Please note that only dynamic non-sleeping bodies are guaranteed to report all their contacts every frame AFAIK

◆ contact_cache

ContactCache nudge::context_t::contact_cache

accessor to the persistent (across frames) CachedContactImpulses that are used to implement warmstarting (used to slightly improved stacking AFAIK); users should simply ignore it

◆ active_bodies

ActiveBodies nudge::context_t::active_bodies

accessor to an array of active bodies. AFAICU this array has something to do with bodies that have contacts between them (however for some strange reason even sleeping bodies can be in the list). I personally prefer using the official c->bodies array (more robust and thrustable)

◆ kinematic_data

KinematicData nudge::context_t::kinematic_data

accessor to the KinematicData::key_frames array and the KinematicData::animations array that can be used to move kinamatic bodies in an automatic way

◆ global_data

GlobalData nudge::context_t::global_data

accessor to some global fields that don't fit the SimulationParams category

◆ simulation_params

SimulationParams nudge::context_t::simulation_params

accessor to some global fields that deal with the physic simulation, such as the simulation time_step, the max_num_substeps, sleeping thresholds, damping factors, etc.

◆ MAX_NUM_BOXES

const unsigned nudge::context_t::MAX_NUM_BOXES

fixed value of the max number of box colliders that can be used in the simulation;

See also
init_context_with(...); it must be: c->MAX_NUM_BOXES+c->MAX_NUM_SPHERES<8192 (the limitation seems to arise from the broadphase management)

◆ MAX_NUM_SPHERES

const unsigned nudge::context_t::MAX_NUM_SPHERES

fixed value of the max number of sphere colliders that can be used in the simulation;

See also
init_context_with(...); it must be: c->MAX_NUM_BOXES+c->MAX_NUM_SPHERES<8192 (the limitation seems to arise from the broadphase management)

◆ MAX_NUM_BODIES

const unsigned nudge::context_t::MAX_NUM_BODIES

fixed value that should always be equal to: MAX_NUM_BOXES+MAX_NUM_SPHERES; this value is only reachable when a single collider per body is used

◆ user

UserData64Bit nudge::context_t::user

user data: a per-context user space in 11 different variable names that share the same space, so that ONLY one of them must be chosen and used


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