Nudge Physics
A single file, header-only 3D physics library
Loading...
Searching...
No Matches
nudge.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <stdarg.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  nudge::Arena
 The Arena struct used internally. More...
 
union  nudge::UserData64Bit
 Storage struct for user data (by default used inside context_t): a per-context 64-bit user space in 11 different variable names that share the same space, so that ONLY one of them must be chosen and used. More...
 
union  nudge::UserData32Bit
 Storage struct for user data (by default used inside BodyInfo): a per-body 32-bit user space in 7 different variable names that share the same space, so that ONLY one of them must be chosen and used. More...
 
struct  nudge::Transform
 The Transform struct. More...
 
struct  nudge::BodyProperties
 The BodyProperties struct. More...
 
struct  nudge::BodyMomentum
 The BodyMomentum struct. More...
 
struct  nudge::SphereCollider
 The SphereCollider struct. More...
 
struct  nudge::BoxCollider
 The BoxCollider struct. More...
 
struct  nudge::Contact
 The Contact struct. More...
 
struct  nudge::BodyPair
 The BodyPair struct. More...
 
struct  nudge::ContactData
 The ContactData class. More...
 
struct  nudge::ColliderData
 This struct is used to access all the colliders in the physic world. More...
 
struct  nudge::BodyFilter
 The BodyFilter struct. More...
 
struct  nudge::BodyLayout
 Per-body struct that contains the indices of the body colliders inside ColliderData::boxes and ColliderData::spheres. More...
 
struct  nudge::BodyInfo
 The BodyInfo struct contains some read-only graphic properties of the body (e.g. axis aligned bounding box and center of mass offset), and plenty of per-body user available space, handy to bind user-side structs to a nudge physic body. More...
 
struct  nudge::BodyData
 The main struct contained in context_t: it exposes every per-body data in the simulation, except collisions. More...
 
struct  nudge::BodyConnections
 [unused] The BodyConnections struct is actually just sketched in nudge (it was intended to add custom constraints) More...
 
struct  nudge::CachedContactImpulse
 The CachedContactImpulse struct. More...
 
struct  nudge::ContactCache
 The ContactCache struct contains the CachedContactImpulse and persists across frames. More...
 
struct  nudge::ActiveBodies
 The ActiveBodies struct. More...
 
struct  nudge::KinematicData
 The KinematicData is composed by two arrays: an array of global key frames and an array of animations. Each animation owns a (kinematic) body index and a range of key frames. More...
 
struct  nudge::KinematicData::Animation
 The Animation class. Each animation owns a (kinematic) body index and a range of key frames. More...
 
struct  nudge::SimulationParams
 The SimulationParams struct. More...
 
struct  nudge::GlobalData
 The GlobalData struct inglobes global fields that could not fit in the SimulationParams struct. More...
 
struct  nudge::context_t
 Main struct of the library. More...
 

Namespaces

namespace  nudge
 
namespace  nudge::extra
 

Macros

#define NUDGE_STATIC_ASSERT(X)   NUDGE_STATIC_ASSERT_WITH_MESSAGE((X), "") /*never used in nudge.h*/
 
#define NUDGE_POINTER_SIZE   (0)
 
#define NUDGE_COLLISION_MASK_TYPE   uint8_t
 
#define NUDGE_FLAG_MASK_TYPE   uint16_t
 
#define NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES   (2)
 
#define NUDGE_INVALID_BODY_ID   (32767)
 
#define M_PIOVER180   ((float)(3.14159265358979323846/180.0))
 
#define M_180OVERPI   ((float)(180.0/3.14159265358979323846))
 
#define M_DEG2RAD(X)   ((X)*(float)M_PIOVER180)
 
#define M_RAD2DEG(X)   ((X)*(float)M_180OVERPI)
 
#define NUDGE_DEFAULT_SIMULATION_TIMESTEP   (1.0/60.0)
 
#define NUDGE_DEFAULT_MAX_NUM_SIMULATION_SUBSTEPS   (2)
 
#define NUDGE_DEFAULT_NUM_SIMULATION_ITERATIONS   (5)
 
#define NUDGE_DEFAULT_DAMPING_LINEAR   (0.25f)
 
#define NUDGE_DEFAULT_DAMPING_ANGULAR   (0.25f)
 
#define NUDGE_DEFAULT_SLEEPING_THRESHOLD_LINEAR_VELOCITY_SQUARED   (1e-2f)
 
#define NUDGE_DEFAULT_SLEEPING_THRESHOLD_ANGULAR_VELOCITY_SQUARED   (1e-1f)
 
#define NUDGE_DEFAULT_PENETRATION_ALLOWED_AMOUNT   (1e-3f)
 
#define NUDGE_DEFAULT_PENETRATION_BIAS_FACTOR   (2.0f)
 

Typedefs

typedef NUDGE_COLLISION_MASK_TYPE nudge::CollisionMask
 The unsigned type used for the COLLISION_GROUP_ flags; it defaults to uint8_t (i.e. 8 groups available) if C++11 is supported and NUDGE_USE_INT32_ENUMS is not defined, and to uint32_t otherwise (i.e. 32 groups available)
 
typedef NUDGE_FLAG_MASK_TYPE nudge::FlagMask
 The unsigned type used for the BF_ flags; it defaults to uint16_t (i.e. 16 flags available) if C++11 is supported and NUDGE_USE_INT32_ENUMS is not defined, and to uint32_t otherwise (i.e. 32 flags available)
 

Enumerations

enum  nudge::CollisionMaskEnum : CollisionMask {
  nudge::COLLISION_GROUP_DEFAULT = 1<<0 , nudge::COLLISION_GROUP_A = 1<<1 , nudge::COLLISION_GROUP_B = 1<<2 , nudge::COLLISION_GROUP_C = 1<<3 ,
  nudge::COLLISION_GROUP_D = 1<<4 , nudge::COLLISION_GROUP_E = 1<<5 , nudge::COLLISION_GROUP_F = 1<<6 , nudge::COLLISION_GROUP_G = 1<<7 ,
  nudge::COLLISION_GROUP_ALL = (CollisionMask)(-1)
}
 The CollisionMaskEnum enum. More...
 
enum  nudge::BodyFlagEnum : FlagMask {
  nudge::BF_HAS_COM_OFFSET = 1<<0 , nudge::BF_IS_DISABLED = 1<<1 , nudge::BF_IS_REMOVED = 1<<2 , nudge::BF_IS_DISABLED_OR_REMOVED = BF_IS_DISABLED|BF_IS_REMOVED ,
  nudge::BF_IS_STATIC = 1<<3 , nudge::BF_IS_KINEMATIC = 1<<4 , nudge::BF_IS_DYNAMIC = 1<<5 , nudge::BF_NEVER_SLEEPING = 1<<6 ,
  nudge::BF_HAS_DIFFERENT_GRAVITY_MODE = 1<<7 , nudge::BF_HAS_DIFFERENT_AUX_BODIES_RESET_MODE = 1<<8 , nudge::BF_IS_CHARACTER = 1<<9 , nudge::BF_IS_PLATFORM = 1<<10 ,
  nudge::BF_IS_SENSOR = 1<<11 , nudge::BF_IS_FRUSTUM_CULLED = 1<<12 , nudge::BF_IS_DISABLED_OR_REMOVED_OR_FRUSTUM_CULLED = BF_IS_DISABLED_OR_REMOVED|BF_IS_FRUSTUM_CULLED , nudge::BF_IS_STATIC_OR_KINEMATIC = BF_IS_STATIC|BF_IS_KINEMATIC ,
  nudge::BF_IS_STATIC_OR_DYNAMIC = BF_IS_STATIC|BF_IS_DYNAMIC , nudge::BF_IS_KINEMATIC_OR_DYNAMIC = BF_IS_KINEMATIC|BF_IS_DYNAMIC , nudge::BF_IS_STATIC_OR_KINEMATIC_OR_DYNAMIC = BF_IS_STATIC|BF_IS_KINEMATIC|BF_IS_DYNAMIC , nudge::BF_IS_STATIC_OR_KINEMATIC_OR_DISABLED_OR_REMOVED = BF_IS_STATIC_OR_KINEMATIC|BF_IS_DISABLED_OR_REMOVED
}
 The BodyFlagEnum enum. More...
 
enum  nudge::GlobalDataMaskEnum { nudge::GF_USE_GLOBAL_GRAVITY = 1<<0 , nudge::GF_DONT_RESET_AUX_BODIES = 1<<1 }
 The GlobalDataMaskEnum enum. More...
 
enum  nudge::AxisEnum { nudge::AXIS_X =0 , nudge::AXIS_Y =1 , nudge::AXIS_Z =2 }
 The AxisEnum enum. 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.
 
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.
 
unsigned nudge::add_box (context_t *c, float mass, float hsizex, float hsizey, float hsizez, const Transform *T=NULL, const float comOffset[3]=NULL)
 Adds a new body to the simulation with a single box collider.
 
unsigned nudge::add_box (context_t *c, float mass, float hsizex, float hsizey, float hsizez, const float *mMatrix16WithoutScaling, const float comOffset[3]=NULL)
 
unsigned nudge::add_sphere (context_t *c, float mass, float radius, const Transform *T=NULL, const float comOffset[3]=NULL)
 Adds a new body to the simulation with a single sphere collider.
 
unsigned nudge::add_sphere (context_t *c, float mass, float radius, const float *mMatrix16WithoutScaling, const float comOffset[3]=NULL)
 
unsigned nudge::add_compound (context_t *c, float mass, float inertia[3], unsigned num_boxes, const float *hsizeTriplets, const Transform *boxOffsetTransforms, unsigned num_spheres, const float *radii, const Transform *sphereOffsetTransforms, const Transform *T=NULL, const float comOffset[3]=NULL, float *centerMeshAndRetrieveOldCenter3Out=NULL)
 Adds a new body to the simulation with a compound collider made up of num_boxes box colliders and num_spheres sphere colliders.
 
unsigned nudge::add_compound (context_t *c, float mass, float inertia[3], unsigned num_boxes, const float *hsizeTriplets, const float *boxOffsetMatrices16WithoutScaling, unsigned num_spheres, const float *radii, const float *sphereOffsetMatrices16WithoutScaling, const float *mMatrix16WithoutScaling=NULL, const float comOffset[3]=NULL, float *centerMeshAndRetrieveOldCenter3Out=NULL)
 
unsigned nudge::add_clone (context_t *c, unsigned body_to_clone, float mass, const Transform *T=NULL, float scale_factor=1.f, const float newComOffsetInPreScaledUnits[3]=NULL)
 [Experimental] Adds a new body to the simulation cloning an existing body
 
unsigned nudge::add_clone (context_t *c, unsigned body_to_clone, float mass, const float *mMatrix16WithoutScaling, float scale_factor=1.f, const float newComOffsetInPreScaledUnits[3]=NULL)
 
void nudge::remove_body (context_t *c, unsigned body)
 Removes a body from the simulation.
 
uint32_t nudge::colliders_get_num_remaining_boxes (context_t *c)
 Return the number of box colliders that can still be added to the physic world.
 
uint32_t nudge::colliders_get_num_remaining_spheres (context_t *c)
 Return the number of sphere colliders that can still be added to the physic world.
 
int nudge::can_add_box (context_t *c)
 
int nudge::can_add_sphere (context_t *c)
 
int nudge::can_add_compound (context_t *c, unsigned num_boxes, unsigned num_spheres)
 
int nudge::can_add_clone (context_t *c, unsigned body_to_clone)
 
unsigned nudge::get_next_add_body_index (context_t *c)
 Allows to peek the body index that is going to be returned in next add_xxx(...) call.
 
void nudge::body_recalculate_bounding_box (context_t *c, uint32_t body)
 Recalculates the bounding box of the body (BodyInfo::aabb_center and BodyInfo::aabb_extents)
 
void nudge::body_change_motion_state (nudge::context_t *c, unsigned body, nudge::FlagMask new_motion_state, float mass_fallback=1.f)
 [Experimental] Changes the body motion state (i.e. the BF_IS_STATIC_OR_KINEMATIC_OR_DYNAMIC group of body flags)
 
void nudge::body_scale (nudge::context_t *c, unsigned body, float scale_factor, float mass_scale_factor=0.f)
 [Experimental] Uniformly scales the specified body incrementally
 
float * nudge::body_get_velocity (context_t *c, uint32_t body)
 Gets the pointer to the body linear velocity (3-floats)
 
float * nudge::body_get_angular_velocity (context_t *c, uint32_t body)
 Gets the pointer to the body angular velocity (3-floats)
 
float * nudge::body_get_position (context_t *c, uint32_t body)
 Gets the pointer to the body position (3-floats vector)
 
float * nudge::body_get_orientation (context_t *c, uint32_t body)
 Gets the pointer to the body orientation (4-floats quaternion in {x,y,z,w} format)
 
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)
 
void nudge::body_set_collision_group_and_mask (context_t *c, uint32_t body, CollisionMask single_collision_group_body_belongs_to, CollisionMask collision_group_mask_body_can_collide_with=COLLISION_GROUP_ALL)
 Sets the body collision group (a single value of COLLISION_GROUP_) and mask (a combination of COLLISION_GROUP_ values)
 
CollisionMasknudge::body_get_collision_group (context_t *c, uint32_t body)
 Gets the body collision group (a single value of COLLISION_GROUP_)
 
CollisionMasknudge::body_get_collision_mask (context_t *c, uint32_t body)
 Gets the body collision mask (a combination of COLLISION_GROUP_ values)
 
FlagMasknudge::body_get_flags (context_t *c, uint32_t body)
 Shortcut that returns a pointer to the body flags (a combination of BF_ enums)
 
void nudge::kinematic_data_reserve_key_frames (KinematicData *kd, size_t new_size)
 Reserves additional space for KinematicData key frames.
 
void nudge::kinematic_data_reserve_animations (KinematicData *kd, size_t new_size)
 Reserves additional space for KinematicData animations.
 
int nudge::log (const char *format,...)
 Logging function used by the library. It defaults to printf.
 
int nudge::flush (void)
 Flushes the log. It defaults to fflush(NUDGE_LOG_FILE_PTR)
 
void nudge::contact_data_find_colliders (const context_t *c, unsigned contact_data_index, int16_t *box_collider_index_for_body_a, int16_t *sphere_collider_index_for_body_a, int16_t *box_collider_index_for_body_b, int16_t *sphere_collider_index_for_body_b, int use_relative_values_for_output_indices=0)
 Find out which collider belonging to body_a and body_b is involved in the collision determined by a ContactData index.
 
Transformnudge::Mat4WithoutScalingToTransform (Transform *Tout, const float *matrix16WithoutScaling)
 Converts a column-major 16-floats matrix without any scaling applied to a nudge::Transform.
 
Transform nudge::Mat4WithoutScalingToTransform (const float *matrix16WithoutScaling)
 Converts a column-major 16-floats matrix without any scaling applied to a nudge::Transform.
 
float * nudge::TransformToMat4 (float *matrix16Out, const Transform *T)
 Converts a nudge::Transform to a column-major 16-floats matrix.
 
void nudge::TransformAssignToBody (context_t *c, unsigned body, Transform newT, float deltaTime, int16_t aux_body=-1)
 Assigns a new Transform to a body, and sets its linear and angular velocities based on the differences between the new transform and the old one: this is essential when manually moving bodies by changing their transform.
 
void nudge::TransformAdvanceBodyFromVelocities (context_t *c, unsigned body, float deltaTime)
 Advances the body's transform based on its linear and angular velocities.
 
Transform nudge::TransformSlerp (Transform T0, Transform T1, float time)
 Applies (spherical) lerp between T0 and T1.
 
Transform nudge::TransformMul (Transform T0, Transform T1)
 Multiplies two transforms.
 
void nudge::nm_QuatAdvance (float *__restrict qOut4, const float *__restrict q4, const float *__restrict angVel3, float halfTimeStep)
 Advances a quaternion given an angular velocity and a (small) time step.
 
float * nudge::nm_QuatFromMat4 (float *__restrict result4, const float *__restrict m16)
 Turns the 3x3 submatrix of a 16-floats column-major matrix (without scaling applied) into a quaternion.
 
float * nudge::nm_Mat4SetRotationFromQuat (float *__restrict result16, const float *__restrict q4)
 Replaces the 3x3 submatrix of a 16-floats column-major matrix with the 3x3 matrix representing the given quaternion.
 
float * nudge::nm_QuatFromMat3 (float *__restrict result4, const float *__restrict m9)
 Turns the 3x3 9-floats column-major rotation matrix (without scaling applied) into a quaternion.
 
float * nudge::nm_Mat3FromQuat (float *__restrict result9, const float *__restrict q4)
 Converts the given quaternion the a 3x3 9-floats column-major rotation matrix.
 
void nudge::nm_QuatGetAngularVelocity (float *__restrict angVel3, const float *newQuat4, const float *oldQuat4, float halfTimeStep)
 Given an old and a new quaternion and a small time step, it calculates the angular velocities.
 
float * nudge::nm_QuatSlerp (float *__restrict result4, const float *__restrict a4, const float *__restrict b4, float slerpTime_In_0_1, int normalizeResult4AfterLerp)
 Performs a spherical lerp between two quaternions (in 4-floats format)
 
float * nudge::nm_QuatMul (float *qOut4, const float *a4, const float *b4)
 Multiplies two 4-floats quaternions.
 
void nudge::nm_QuatNormalize (float *__restrict q4)
 normalizes a 4-floats quaternion in place
 
float * nudge::nm_QuatFromAngleAxis (float *__restrict qOut4, float rfAngle, float rkAxisX, float rkAxisY, float rkAxisZ)
 Generates a 4-floats quaternion based on an orientation arouns an axis.
 
void nudge::nm_QuatToAngleAxis (const float *__restrict q4, float *__restrict rfAngleOut1, float *__restrict rkAxisOut3)
 Calculates the angle-axis representation of the given 4-float quaternion.
 
float nudge::nm_Vec3Normalize (float *__restrict v3)
 Normalizes a 3-floats vector in place.
 
float nudge::nm_Vec3Normalized (float *__restrict v3Out, const float *__restrict v3)
 Get a normalizes copy of an input 3-floats vector.
 
float nudge::nm_Vec3Dot (const float *__restrict a3, const float *__restrict b3)
 Computes the dot product between two 3-floats vectors.
 
float * nudge::nm_Vec3Cross (float *__restrict vOut3, const float *__restrict a3, const float *__restrict b3)
 Computes the cross product between two 3-floats vectors.
 
float * nudge::nm_QuatMulVec3 (float *__restrict vOut3, const float *__restrict q4, const float *__restrict vIn3)
 Transforms a 3-floats vector by a 4-floats quaternion.
 
float * nudge::nm_QuatGetAxis (float *__restrict vOut3, const float *__restrict q4, float axisX, float axisY, float axisZ)
 Transforms a particular axis from the input quaternion space to word space.
 
float * nudge::nm_QuatGetAxisX (float *__restrict axisOut3, const float *__restrict q4)
 
float * nudge::nm_QuatGetAxisY (float *__restrict axisOut3, const float *__restrict q4)
 
float * nudge::nm_QuatGetAxisZ (float *__restrict axisOut3, const float *__restrict q4)
 
float * nudge::nm_QuatRotate (float *__restrict qInOut4, float angle, float axisX, float axisY, float axisZ)
 Rotates an input 4-floats unit quaternion by an angle in radians around a specified axis.
 
float * nudge::nm_Mat4Mul (float *result16, const float *ml16, const float *mr16)
 Multiplies two column-major 16-floats 4x4 matrices.
 
void nudge::calculate_box_inertia (float result[3], float mass, float hsizex, float hsizey, float hsizez, const float comOffset[3]=NULL)
 
void nudge::calculate_sphere_inertia (float result[3], float mass, float radius, const float comOffset[3]=NULL, bool hollow=false)
 
void nudge::calculate_cylinder_inertia (float result[3], float mass, float radius, float halfHeight, AxisEnum upAxis=AXIS_Y, const float comOffset[3]=NULL)
 
void nudge::calculate_capsule_inertia (float result[3], float mass, float radius, float halfCylinderHeight, AxisEnum upAxis=AXIS_Y, const float comOffset[3]=NULL)
 
void nudge::calculate_torus_inertia (float result[3], float mass, float majorRadius, float minorRadius, AxisEnum upAxis=AXIS_Y, const float comOffset[3]=NULL)
 
void nudge::calculate_hollow_cylinder_inertia (float result[3], float mass, float R, float r, float halfHeight, AxisEnum upAxis=AXIS_Y, const float comOffset[3]=NULL)
 
void nudge::calculate_cone_inertia (float result[3], float mass, float radius, float halfHeight, AxisEnum upAxis=AXIS_Y, const float comOffset[3]=NULL)
 
void nudge::calculate_box_inertia_inverse (float result[3], float mass, float hsizex, float hsizey, float hsizez, const float comOffset[3]=NULL)
 
void nudge::calculate_sphere_inertia_inverse (float result[3], float mass, float radius, const float comOffset[3]=NULL, bool hollow=false)
 
void nudge::calculate_cylinder_inertia_inverse (float result[3], float mass, float radius, float halfHeight, AxisEnum upAxis=AXIS_Y, const float comOffset[3]=NULL)
 
void nudge::calculate_capsule_inertia_inverse (float result[3], float mass, float radius, float halfCylinderHeight, AxisEnum upAxis=AXIS_Y, const float comOffset[3]=NULL)
 
void nudge::calculate_torus_inertia_inverse (float result[3], float mass, float majorRadius, float minorRadius, AxisEnum upAxis=AXIS_Y, const float comOffset[3]=NULL)
 
void nudge::calculate_hollow_cylinder_inertia_inverse (float result[3], float mass, float R, float r, float halfHeight, AxisEnum upAxis=AXIS_Y, const float comOffset[3]=NULL)
 
void nudge::calculate_cone_inertia_inverse (float result[3], float mass, float radius, float halfHeight, AxisEnum upAxis=AXIS_Y, const float comOffset[3]=NULL)
 

Macro Definition Documentation

◆ NUDGE_STATIC_ASSERT

#define NUDGE_STATIC_ASSERT (   X)    NUDGE_STATIC_ASSERT_WITH_MESSAGE((X), "") /*never used in nudge.h*/

◆ NUDGE_POINTER_SIZE

#define NUDGE_POINTER_SIZE   (0)

◆ NUDGE_COLLISION_MASK_TYPE

#define NUDGE_COLLISION_MASK_TYPE   uint8_t

◆ NUDGE_FLAG_MASK_TYPE

#define NUDGE_FLAG_MASK_TYPE   uint16_t

◆ NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES

#define NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES   (2)

◆ NUDGE_INVALID_BODY_ID

#define NUDGE_INVALID_BODY_ID   (32767)

Value of a body index in an invalid state

◆ M_PIOVER180

#define M_PIOVER180   ((float)(3.14159265358979323846/180.0))

◆ M_180OVERPI

#define M_180OVERPI   ((float)(180.0/3.14159265358979323846))

◆ M_DEG2RAD

#define M_DEG2RAD (   X)    ((X)*(float)M_PIOVER180)

◆ M_RAD2DEG

#define M_RAD2DEG (   X)    ((X)*(float)M_180OVERPI)

◆ NUDGE_DEFAULT_SIMULATION_TIMESTEP

#define NUDGE_DEFAULT_SIMULATION_TIMESTEP   (1.0/60.0)

◆ NUDGE_DEFAULT_MAX_NUM_SIMULATION_SUBSTEPS

#define NUDGE_DEFAULT_MAX_NUM_SIMULATION_SUBSTEPS   (2)

◆ NUDGE_DEFAULT_NUM_SIMULATION_ITERATIONS

#define NUDGE_DEFAULT_NUM_SIMULATION_ITERATIONS   (5)

◆ NUDGE_DEFAULT_DAMPING_LINEAR

#define NUDGE_DEFAULT_DAMPING_LINEAR   (0.25f)

◆ NUDGE_DEFAULT_DAMPING_ANGULAR

#define NUDGE_DEFAULT_DAMPING_ANGULAR   (0.25f)

◆ NUDGE_DEFAULT_SLEEPING_THRESHOLD_LINEAR_VELOCITY_SQUARED

#define NUDGE_DEFAULT_SLEEPING_THRESHOLD_LINEAR_VELOCITY_SQUARED   (1e-2f)

◆ NUDGE_DEFAULT_SLEEPING_THRESHOLD_ANGULAR_VELOCITY_SQUARED

#define NUDGE_DEFAULT_SLEEPING_THRESHOLD_ANGULAR_VELOCITY_SQUARED   (1e-1f)

◆ NUDGE_DEFAULT_PENETRATION_ALLOWED_AMOUNT

#define NUDGE_DEFAULT_PENETRATION_ALLOWED_AMOUNT   (1e-3f)

◆ NUDGE_DEFAULT_PENETRATION_BIAS_FACTOR

#define NUDGE_DEFAULT_PENETRATION_BIAS_FACTOR   (2.0f)