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

Set of helper functions that just wrap existing functions. More...

Functions

unsigned nudge::extra::add_compound_prism (context_t *c, float mass, float radius, float hheight, unsigned num_lateral_faces=0, const Transform *T=NULL, AxisEnum axis=AXIS_Y, const float comOffset[3]=NULL)
 Adds a new body to the simulation with a compound collider that represents a prism of 4 or more lateral faces.
 
unsigned nudge::extra::add_compound_prism (context_t *c, float mass, float radius, float hheight, unsigned num_lateral_faces, const float *mMatrix16WithoutScaling, AxisEnum axis=AXIS_Y, const float comOffset[3]=NULL)
 
unsigned nudge::extra::add_compound_cylinder (context_t *c, float mass, float radius, float hheight, const Transform *T=NULL, AxisEnum axis=AXIS_Y, unsigned num_boxes=0, unsigned num_spheres=0, const float comOffset[3]=NULL, float box_lateral_side_shrinking=-1.f)
 Adds a new body to the simulation with a compound collider that represents a cylinder.
 
unsigned nudge::extra::add_compound_cylinder (context_t *c, float mass, float radius, float hheight, const float *mMatrix16WithoutScaling, AxisEnum axis=AXIS_Y, unsigned num_boxes=0, unsigned num_spheres=0, const float comOffset[3]=NULL, float box_lateral_side_shrinking=-1.f)
 
unsigned nudge::extra::add_compound_capsule (context_t *c, float mass, float radius, float hheight, const Transform *T=NULL, AxisEnum axis=AXIS_Y, unsigned num_boxes=1, unsigned num_spheres=3, const float comOffset[3]=NULL, float box_lateral_side_shrinking=-1.f)
 Adds a new body to the simulation with a compound collider that represents a capsule.
 
unsigned nudge::extra::add_compound_capsule (context_t *c, float mass, float radius, float hheight, const float *mMatrix16WithoutScaling, AxisEnum axis=AXIS_Y, unsigned num_boxes=1, unsigned num_spheres=3, const float comOffset[3]=NULL, float box_lateral_side_shrinking=-1.f)
 
unsigned nudge::extra::add_compound_hollow_cylinder (context_t *c, float mass, float min_radius, float max_radius, float hheight, const Transform *T=NULL, AxisEnum axis=AXIS_Y, unsigned num_boxes=8, const float comOffset[3]=NULL)
 Adds a new body to the simulation with a compound collider that represents the hollow lateral surface of a cylinder.
 
unsigned nudge::extra::add_compound_hollow_cylinder (context_t *c, float mass, float min_radius, float max_radius, float hheight, const float *mMatrix16WithoutScaling, AxisEnum axis=AXIS_Y, unsigned num_boxes=8, const float comOffset[3]=NULL)
 
unsigned nudge::extra::add_compound_torus (context_t *c, float mass, float radius, float inner_radius, const Transform *T=NULL, AxisEnum axis=AXIS_Y, unsigned num_boxes=8, const float comOffset[3]=NULL)
 Adds a new body to the simulation with a compound collider that represents a torus.
 
unsigned nudge::extra::add_compound_torus (context_t *c, float mass, float radius, float inner_radius, const float *mMatrix16WithoutScaling, AxisEnum axis=AXIS_Y, unsigned num_boxes=8, const float comOffset[3]=NULL)
 
unsigned nudge::extra::add_compound_cone (context_t *c, float mass, float radius, float hheight, const Transform *T=NULL, AxisEnum axis=AXIS_Y, unsigned num_boxes=0, unsigned num_spheres=0, const float comOffset[3]=NULL)
 Adds a new body to the simulation with a compound collider that represents an approximated cone.
 
unsigned nudge::extra::add_compound_cone (context_t *c, float mass, float radius, float hheight, const float *mMatrix16WithoutScaling, AxisEnum axis=AXIS_Y, unsigned num_boxes=0, unsigned num_spheres=0, const float comOffset[3]=NULL)
 
unsigned nudge::extra::add_compound_staircase (context_t *c, float mass, float hdepth, float hheight, float hlength, unsigned num_steps=15, const Transform *T=NULL, int orientation_in_0_3=0, const float comOffset[3]=NULL)
 Adds a new body to the simulation with a compound collider that represents a staircase; please note that the inertia is not calculated (or even approximated) correctly (only relevant when used as dynamic body)
 
unsigned nudge::extra::add_compound_staircase (context_t *c, float mass, float hdepth, float hheight, float hlength, unsigned num_steps, const float *mMatrix16WithoutScaling, int orientation_in_0_3=0, const float comOffset[3]=NULL)
 

Detailed Description

Set of helper functions that just wrap existing functions.

Function Documentation

◆ add_compound_prism() [1/2]

unsigned nudge::extra::add_compound_prism ( context_t c,
float  mass,
float  radius,
float  hheight,
unsigned  num_lateral_faces = 0,
const Transform T = NULL,
AxisEnum  axis = AXIS_Y,
const float  comOffset[3] = NULL 
)

Adds a new body to the simulation with a compound collider that represents a prism of 4 or more lateral faces.

Parameters
cthe nudge context
masspositive => dynamic; 0 => static; negative => kinematic (where the absolute value will be used as mass internally)
radiusthe radius of the cylinder inscribed into the prism (the prism covers all the inscribed cylinder); please use (radius*cosf(M_PI/num_lateral_faces)) as radius for a prism that is entirely covered by the cylinder of radius: radius
hheightthe half height of the prism
num_lateral_facesthe number of lateral faces of the prism (must be >=4)
Ta pointer to a Transform
axisone of the AXIS_X,AXIS_Y,AXIS_Z values
comOffsetan optional array of 3 floats that determines the center of mass offset of the body
Returns
the body index, or NUDGE_INVALID_BODY_ID if not enough colliders can be added, or if the input arguments are not supported
Note
This function is just a wrapper around the add_compound(...) function
This function consumes at most 'num_lateral_faces' boxes
This function can return NUDGE_INVALID_BODY_ID even if there are enough colliders (unlike add_compound(...))

◆ add_compound_prism() [2/2]

unsigned nudge::extra::add_compound_prism ( context_t c,
float  mass,
float  radius,
float  hheight,
unsigned  num_lateral_faces,
const float *  mMatrix16WithoutScaling,
AxisEnum  axis = AXIS_Y,
const float  comOffset[3] = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
mMatrix16WithoutScalinga pointer to a 4x4 column-major matrix with only translation and rotation

◆ add_compound_cylinder() [1/2]

unsigned nudge::extra::add_compound_cylinder ( context_t c,
float  mass,
float  radius,
float  hheight,
const Transform T = NULL,
AxisEnum  axis = AXIS_Y,
unsigned  num_boxes = 0,
unsigned  num_spheres = 0,
const float  comOffset[3] = NULL,
float  box_lateral_side_shrinking = -1.f 
)

Adds a new body to the simulation with a compound collider that represents a cylinder.

Parameters
cthe nudge context
masspositive => dynamic; 0 => static; negative => kinematic (where the absolute value will be used as mass internally)
radiusthe radius of the cylinder
hheightthe half height of the cylinder
Ta pointer to a Transform
axisone of the AXIS_X,AXIS_Y,AXIS_Z values
num_boxesthe number of boxes to consume (0 is replaced by some predefined value)
num_spheresthe number of spheres to consume (0 is replaced by some predefined value)
comOffsetan optional array of 3 floats that determines the center of mass offset of the body
box_lateral_side_shrinkingconstant to tune how much the lateral half size of the box(es) is smaller than radius of the spheres (default value of -1 is replaced by some predefined value)
Returns
the body index, or NUDGE_INVALID_BODY_ID if not enough colliders can be added, or if the input arguments are not supported
Note
This function is just a wrapper around the add_compound(...) function
This function can return NUDGE_INVALID_BODY_ID even if there are enough colliders (unlike add_compound(...))

◆ add_compound_cylinder() [2/2]

unsigned nudge::extra::add_compound_cylinder ( context_t c,
float  mass,
float  radius,
float  hheight,
const float *  mMatrix16WithoutScaling,
AxisEnum  axis = AXIS_Y,
unsigned  num_boxes = 0,
unsigned  num_spheres = 0,
const float  comOffset[3] = NULL,
float  box_lateral_side_shrinking = -1.f 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
mMatrix16WithoutScalinga pointer to a 4x4 column-major matrix with only translation and rotation

◆ add_compound_capsule() [1/2]

unsigned nudge::extra::add_compound_capsule ( context_t c,
float  mass,
float  radius,
float  hheight,
const Transform T = NULL,
AxisEnum  axis = AXIS_Y,
unsigned  num_boxes = 1,
unsigned  num_spheres = 3,
const float  comOffset[3] = NULL,
float  box_lateral_side_shrinking = -1.f 
)

Adds a new body to the simulation with a compound collider that represents a capsule.

Parameters
cthe nudge context
masspositive => dynamic; 0 => static; negative => kinematic (where the absolute value will be used as mass internally)
radiusthe radius of the capsule
hheightthe half height of the cylinder that compose the capsule (if it's zero, then the capsule becomes a sphere)
Ta pointer to a Transform
axisone of the AXIS_X,AXIS_Y,AXIS_Z values
num_boxesthe number of boxes to consume (0 is replaced by some predefined value)
num_spheresthe number of spheres to consume (0 is replaced by some predefined value)
comOffsetan optional array of 3 floats that determines the center of mass offset of the body
box_lateral_side_shrinkingconstant to tune how much the lateral half size of the box(es) is smaller than radius of the spheres (default value of -1 is replaced by some predefined value)
Returns
the body index, or NUDGE_INVALID_BODY_ID if not enough colliders can be added, or if the input arguments are not supported
Note
This function is just a wrapper around the add_compound(...) function
This function can return NUDGE_INVALID_BODY_ID even if there are enough colliders (unlike add_compound(...))

◆ add_compound_capsule() [2/2]

unsigned nudge::extra::add_compound_capsule ( context_t c,
float  mass,
float  radius,
float  hheight,
const float *  mMatrix16WithoutScaling,
AxisEnum  axis = AXIS_Y,
unsigned  num_boxes = 1,
unsigned  num_spheres = 3,
const float  comOffset[3] = NULL,
float  box_lateral_side_shrinking = -1.f 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
mMatrix16WithoutScalinga pointer to a 4x4 column-major matrix with only translation and rotation

◆ add_compound_hollow_cylinder() [1/2]

unsigned nudge::extra::add_compound_hollow_cylinder ( context_t c,
float  mass,
float  min_radius,
float  max_radius,
float  hheight,
const Transform T = NULL,
AxisEnum  axis = AXIS_Y,
unsigned  num_boxes = 8,
const float  comOffset[3] = NULL 
)

Adds a new body to the simulation with a compound collider that represents the hollow lateral surface of a cylinder.

Parameters
cthe nudge context
masspositive => dynamic; 0 => static; negative => kinematic (where the absolute value will be used as mass internally)
min_radiusthe minimum radius that starts at the center of the cylinder
max_radiusthe maximum radius that starts at the center of the cylinder (the whole depth is: max_radius - min_radius)
hheightthe half height of the cylinder
Ta pointer to a Transform
axisone of the AXIS_X,AXIS_Y,AXIS_Z values
num_boxesthe number of boxes to consume (0 is replaced by some predefined value)
comOffsetan optional array of 3 floats that determines the center of mass offset of the body
Returns
the body index, or NUDGE_INVALID_BODY_ID if not enough colliders can be added, or if the input arguments are not supported
Note
This function is just a wrapper around the add_compound(...) function
This function can return NUDGE_INVALID_BODY_ID even if there are enough colliders (unlike add_compound(...))

◆ add_compound_hollow_cylinder() [2/2]

unsigned nudge::extra::add_compound_hollow_cylinder ( context_t c,
float  mass,
float  min_radius,
float  max_radius,
float  hheight,
const float *  mMatrix16WithoutScaling,
AxisEnum  axis = AXIS_Y,
unsigned  num_boxes = 8,
const float  comOffset[3] = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
mMatrix16WithoutScalinga pointer to a 4x4 column-major matrix with only translation and rotation

◆ add_compound_torus() [1/2]

unsigned nudge::extra::add_compound_torus ( context_t c,
float  mass,
float  radius,
float  inner_radius,
const Transform T = NULL,
AxisEnum  axis = AXIS_Y,
unsigned  num_boxes = 8,
const float  comOffset[3] = NULL 
)

Adds a new body to the simulation with a compound collider that represents a torus.

Parameters
cthe nudge context
masspositive => dynamic; 0 => static; negative => kinematic (where the absolute value will be used as mass internally)
radiusthe radius that starts at the origin of the shape and ends in the middle of the rotational donut-like solid
inner_radiusthe internal radius of the donut-like solid (so that maximum_radius = radius + inner_radius represent the maximum radius of the shape, starting at its origin)
Ta pointer to a Transform
axisone of the AXIS_X,AXIS_Y,AXIS_Z values
num_boxesthe number of boxes to consume (0 is replaced by some predefined value)
comOffsetan optional array of 3 floats that determines the center of mass offset of the body
Returns
the body index, or NUDGE_INVALID_BODY_ID if not enough colliders can be added, or if the input arguments are not supported
Note
This function is just a wrapper around the add_compound(...) function
This function can return NUDGE_INVALID_BODY_ID even if there are enough colliders (unlike add_compound(...))

◆ add_compound_torus() [2/2]

unsigned nudge::extra::add_compound_torus ( context_t c,
float  mass,
float  radius,
float  inner_radius,
const float *  mMatrix16WithoutScaling,
AxisEnum  axis = AXIS_Y,
unsigned  num_boxes = 8,
const float  comOffset[3] = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
mMatrix16WithoutScalinga pointer to a 4x4 column-major matrix with only translation and rotation

◆ add_compound_cone() [1/2]

unsigned nudge::extra::add_compound_cone ( context_t c,
float  mass,
float  radius,
float  hheight,
const Transform T = NULL,
AxisEnum  axis = AXIS_Y,
unsigned  num_boxes = 0,
unsigned  num_spheres = 0,
const float  comOffset[3] = NULL 
)

Adds a new body to the simulation with a compound collider that represents an approximated cone.

Parameters
cthe nudge context
masspositive => dynamic; 0 => static; negative => kinematic (where the absolute value will be used as mass internally)
radiusthe radius of the cone
hheightthe half height of the cone
Ta pointer to a Transform
axisone of the AXIS_X,AXIS_Y,AXIS_Z values
num_boxesthe number of boxes to consume (0 is replaced by some predefined value)
num_spheresthe number of spheres to consume (0 is replaced by some predefined value)
comOffsetan optional array of 3 floats that determines the center of mass offset of the body
Returns
the body index, or NUDGE_INVALID_BODY_ID if not enough colliders can be added
Note
This function is just a wrapper around the add_compound(...) function
The constructed shape is a raw approximatation, and the comOffset itself should not be at zero by default in a cone

◆ add_compound_cone() [2/2]

unsigned nudge::extra::add_compound_cone ( context_t c,
float  mass,
float  radius,
float  hheight,
const float *  mMatrix16WithoutScaling,
AxisEnum  axis = AXIS_Y,
unsigned  num_boxes = 0,
unsigned  num_spheres = 0,
const float  comOffset[3] = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
mMatrix16WithoutScalinga pointer to a 4x4 column-major matrix with only translation and rotation

◆ add_compound_staircase() [1/2]

unsigned nudge::extra::add_compound_staircase ( context_t c,
float  mass,
float  hdepth,
float  hheight,
float  hlength,
unsigned  num_steps = 15,
const Transform T = NULL,
int  orientation_in_0_3 = 0,
const float  comOffset[3] = NULL 
)

Adds a new body to the simulation with a compound collider that represents a staircase; please note that the inertia is not calculated (or even approximated) correctly (only relevant when used as dynamic body)

Parameters
cthe nudge context
masspositive => dynamic; 0 => static; negative => kinematic (where the absolute value will be used as mass internally)
hdepththe half depth of the staircase
hheightthe half height of the staircase
hlengththe half length of the staircase
num_stepsthe number of the steps and of the boxes to consume (0 is replaced by some predefined value)
Ta pointer to a Transform
orientation_in_0_3the height of the staircase is always aligned to AXIS_Y: if orientation_in_0_3==0 the front of the staircase is along +AXIS_Z; successive values rotate it of 90 degrees clockwise
comOffsetan optional array of 3 floats that determines the center of mass offset of the body
Returns
the body index, or NUDGE_INVALID_BODY_ID if not enough colliders can be added
Note
This function is just a wrapper around the add_compound(...) function
When mass is positive, the inertia is calculated using the shape axis aligned bounding box (i.e. it's wrong)

◆ add_compound_staircase() [2/2]

unsigned nudge::extra::add_compound_staircase ( context_t c,
float  mass,
float  hdepth,
float  hheight,
float  hlength,
unsigned  num_steps,
const float *  mMatrix16WithoutScaling,
int  orientation_in_0_3 = 0,
const float  comOffset[3] = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
mMatrix16WithoutScalinga pointer to a 4x4 column-major matrix with only translation and rotation