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

Set of functions regarding the nudge context, and in general the program startup and shutdown functions. More...

Functions

void nudge::show_info ()
 Displays basic info at program startup; very important call to detect the SIMD configuration of the program.
 
void nudge::init_context_with (context_t *c, unsigned MAX_NUM_BOXES, unsigned MAX_NUM_SPHERES)
 Mandatory function to be called at program startup.
 
void nudge::init_context (context_t *c)
 Mandatory function to be called at program startup.
 
void nudge::destroy_context (context_t *c)
 Mandatory function to be called at program exit.
 
void nudge::restart_context (context_t *c)
 Optional function that restarts a valid context, preserving the simulation settings and the allocated memory.
 
void nudge::save_context (FILE *f, const context_t *c)
 Saves the nudge context.
 
void nudge::load_context (FILE *f, context_t *c)
 Loads a saved nudge context.
 

Detailed Description

Set of functions regarding the nudge context, and in general the program startup and shutdown functions.

Function Documentation

◆ show_info()

void nudge::show_info ( )

Displays basic info at program startup; very important call to detect the SIMD configuration of the program.

◆ init_context_with()

void nudge::init_context_with ( context_t c,
unsigned  MAX_NUM_BOXES,
unsigned  MAX_NUM_SPHERES 
)

Mandatory function to be called at program startup.

Parameters
cthe nudge context; best practice is to clear its memory before calling this function
MAX_NUM_BOXESthe max number of box colliders (i.e. box collision shapes) that can be used in the library (each physic body can contain one or more colliders and each collider is owned by a single physic body)
MAX_NUM_SPHERESthe max number of sphere colliders (i.e. sphere collision shapes) that can be used in the library (each physic body can contain one or more colliders and each collider is owned by a single physic body)
Note
It must be MAX_NUM_BOXES+MAX_NUM_SPHERES<=8192

◆ init_context()

void nudge::init_context ( context_t c)

Mandatory function to be called at program startup.

Parameters
cthe nudge context; best practice is to clear its memory before calling this function
Note
It sets MAX_NUM_BOXES and MAX_NUM_SPHERES to some default value (see init_context_with(...))

◆ destroy_context()

void nudge::destroy_context ( context_t c)

Mandatory function to be called at program exit.

Parameters
cthe nudge context
Note
After this call init_context(...) and init_context_with(...) can be called again, but restart_context(...) can't

◆ restart_context()

void nudge::restart_context ( context_t c)

Optional function that restarts a valid context, preserving the simulation settings and the allocated memory.

Parameters
ca valid nudge context that must be inited with init_context(...) or init_context_with(...)
Note
This function is faster than calling in sequence destroy_context(...) and init_context(...) (no deallocations/allocations)
If you want to restart the simulation frame/substep counters, please manually set: c->simulation_params.num_frames=0;c->simulation_params.num_total_substeps=0;

◆ save_context()

void nudge::save_context ( FILE *  f,
const context_t c 
)

Saves the nudge context.

Parameters
fthe output file
cthe input context
Note
Experimental feature
Available only when NUDGE_NO_STDIO is not defined

◆ load_context()

void nudge::load_context ( FILE *  f,
context_t c 
)

Loads a saved nudge context.

Parameters
fthe input file
cthe output (inited) context
Note
Experimental feature, currently c must have a compatible c->MAX_NUM_BOXES and c->MAX_NUM_SPHERES to work (and user pointers must of course be handled by the user)
Currently it just asserts on failing
Available only when NUDGE_NO_STDIO is not defined