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

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...

#include <nudge.h>

Public Attributes

UserData32Bit user
 
float aabb_center [3]
 
float aabb_half_extents [3]
 
float com_offset [3]
 
float aabb_enlarged_radius
 
union { 
 
   int16_t   aux_bodies [NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES
 
   union { 
 
      int32_t   i32 [NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES/2] 
 
      uint32_t   u32 [NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES/2] 
 
      int16_t   i16 [NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES
 
      uint16_t   u16 [NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES
 
      int8_t   i8 [NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES *2] 
 
      uint8_t   u8 [NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES *2] 
 
   }   sk_user 
 
};  
 

Detailed Description

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.

Note
User custom field injection is allowed by the two definitions NUDGE_BODYINFO_STRUCT_EXTRA_FIELDS and NUDGE_BODYINFO_STRUCT_EXTRA_PADDING; the best place to do so is in a nudge config header file (setting its name in the project-scope definition: NUDGE_USER_CFG_FILE_NAME)
It's possible to remove the default (per-body) UserData32Bit user field of this struct using the definition NUDGE_BODYINFO_STRUCT_NO_USER_DATA, and the 'aux_bodies[...] array / sk_user struct' by setting the NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES definition to zero

Member Data Documentation

◆ user

UserData32Bit nudge::BodyInfo::user

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

◆ aabb_center

float nudge::BodyInfo::aabb_center[3]

[read-only; unused by nudge.h] the axis aligned bounding box center of the body; note that the com_offset has not been stripped from it (it must be summed to strip it from aabb_center)

◆ aabb_half_extents

float nudge::BodyInfo::aabb_half_extents[3]

[read-only; unused by nudge.h] the axis aligned bounding box half extents of the body (it does not depend on com_offset)

◆ com_offset

float nudge::BodyInfo::com_offset[3]

[read-only] the center of mass offset of the body (it's only used in the calculate_graphic_transform_xxx(...) functions)

◆ aabb_enlarged_radius

float nudge::BodyInfo::aabb_enlarged_radius

[read-only] this radius is the sum of |com_offset|+|aabb_half_extents|, so that it can be used only with the body's transform position (no transform orientation required)

◆ aux_bodies

int16_t nudge::BodyInfo::aux_bodies[NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES]

user data that by default can be used for dynamic bodies ONLY, and that are reset to -1 every frame (but only for dynamic bodies in the c->active_bodies list); they can be used to store body indices, since they are currently in the [0,8192) range

◆ i32

int32_t nudge::BodyInfo::i32[NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES/2]

user data that can be used for static and kinematic bodies only (and only one of its array variants)

◆ u32

uint32_t nudge::BodyInfo::u32[NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES/2]

user data that can be used for static and kinematic bodies only (and only one of its array variants)

◆ i16

int16_t nudge::BodyInfo::i16[NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES]

user data that can be used for static and kinematic bodies only (and only one of its array variants)

◆ u16

uint16_t nudge::BodyInfo::u16[NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES]

user data that can be used for static and kinematic bodies only (and only one of its array variants)

◆ i8

int8_t nudge::BodyInfo::i8[NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES *2]

user data that can be used for static and kinematic bodies only (and only one of its array variants)

◆ u8

uint8_t nudge::BodyInfo::u8[NUDGE_BODYINFO_STRUCT_NUM_AUX_BODIES *2]

user data that can be used for static and kinematic bodies only (and only one of its array variants)

◆ [union]

union { ... } nudge::BodyInfo::sk_user

user data that by default can be used for static and kinematic bodies ONLY (and only one of the available array variants); using c->global_data.flags and/or per-body c->bodies.filters[body].flags we can use this field for dynamic bodies too, at the expense of the "aux_bodies" field

◆ [union]

union { ... } nudge::BodyInfo

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