Nudge Physics
A single file, header-only 3D physics library
Loading...
Searching...
No Matches
Main Functions

Set of functions regarding stepping the simulation and getting the body transforms back. More...

Functions

unsigned nudge::pre_simulation_step (context_t *c, double elapsedSecondsFromLastCall)
 Mandatory function that must be called once per frame.
 
void nudge::simulation_step (context_t *c)
 Mandatory function that must be called once per frame.
 
float * nudge::calculate_graphic_transform_for_body (context_t *c, unsigned body, float *pModelMatrix16Out)
 Function that can be used to calculate the smoothed 16-float column-major model matrix of a single body.
 
void nudge::calculate_graphic_transforms (context_t *c, float *pModelMatricesOut, unsigned modelMatrixStrideInFloatUnits, int loopActiveBodiesOnly=0)
 Function that can be used to calculate the smoothed 16-float column-major model matrices of all the bodies together.
 

Detailed Description

Set of functions regarding stepping the simulation and getting the body transforms back.

Function Documentation

◆ pre_simulation_step()

unsigned nudge::pre_simulation_step ( context_t c,
double  elapsedSecondsFromLastCall 
)

Mandatory function that must be called once per frame.

Parameters
cthe nudge context
elapsedSecondsFromLastCalltime tn seconds elapsed from last call
Returns
the number of simulation substeps (i.e. physic frame substeps) that will be executed in the next simulation_step(...) call

◆ simulation_step()

void nudge::simulation_step ( context_t c)

Mandatory function that must be called once per frame.

Parameters
cthe nudge context
Note
It's the main function of the whole library

◆ calculate_graphic_transform_for_body()

float * nudge::calculate_graphic_transform_for_body ( context_t c,
unsigned  body,
float *  pModelMatrix16Out 
)

Function that can be used to calculate the smoothed 16-float column-major model matrix of a single body.

Parameters
cthe nudge context
bodythe input body index
pModelMatrix16Outthe output smoothed 16-float column-major model matrix
Returns
the same as pModelMatrix16Out (for chaining the call only)
Note
This function must be used after calling simulation_step(...), and the returned matrix inglobes the center of mass offset if present (so that no offset operation is required on the user-side in most cases)

◆ calculate_graphic_transforms()

void nudge::calculate_graphic_transforms ( context_t c,
float *  pModelMatricesOut,
unsigned  modelMatrixStrideInFloatUnits,
int  loopActiveBodiesOnly = 0 
)

Function that can be used to calculate the smoothed 16-float column-major model matrices of all the bodies together.

Parameters
cthe nudge context
pModelMatricesOuta pointer to the output c->bodies.count*modelMatrixStrideInFloatUnits floats that represent the returned smoothed 16-float column-major model matrices of this function
modelMatrixStrideInFloatUnitsstride (in number of floats) between two 16-float matrices inside the pModelMatricesOut array (it must be at least 16)
loopActiveBodiesOnly(experimental) if not zero, it only updates bodies present in the c->active_bodies list, i.e. not all the output matrices are updated (not recommended)
Note
This function must be used after calling simulation_step(...), and the returned matrices inglobe the center of mass offsets if present (so that no offset operation is required on the user-side in most cases)