9#include "math_functions.h"
13#define B3_DEFAULT_CATEGORY_BITS UINT64_MAX
14#define B3_DEFAULT_MASK_BITS UINT64_MAX
48typedef void b3DestroyDebugShapeCallback(
void* userShape,
void* userContext );
54typedef float b3FrictionCallback(
float frictionA, uint64_t userMaterialIdA,
float frictionB, uint64_t userMaterialIdB );
60typedef float b3RestitutionCallback(
float restitutionA, uint64_t userMaterialIdA,
float restitutionB, uint64_t userMaterialIdB );
116 int triangleIndex,
int childIndex,
void* context );
523typedef struct b3Profile
531 float prepareConstraints;
532 float integrateVelocities;
535 float integratePositions;
537 float applyRestitution;
552typedef struct b3Counters
561 int staticTreeHeight;
564 int satCacheHitCount;
568 int manifoldCounts[B3_CONTACT_MANIFOLD_COUNT_BUCKETS];
572 int awakeContactCount;
575 int recycledContactCount;
578 int distanceIterations;
579 int pushBackIterations;
1431#if defined( BOX3D_DOUBLE_PRECISION )
1606 b3_toiStateOverlapped,
1608 b3_toiStateSeparated
1667 b3_allocatedNode = 0x0001,
1668 b3_enlargedNode = 0x0002,
1669 b3_leafNode = 0x0004,
1715#define B3_DYNAMIC_TREE_VERSION 0x93EDAF889FD30B4Aull
1960#define B3_HULL_VERSION 0x9D4716CE3793900Eull
2078#define B3_MESH_VERSION 0xABD11AB62A6E886Dull
2083 b3_concaveEdge1 = 0x01,
2084 b3_concaveEdge2 = 0x02,
2085 b3_concaveEdge3 = 0x04,
2087 b3_inverseConcaveEdge1 = 0x10,
2088 b3_inverseConcaveEdge2 = 0x20,
2089 b3_inverseConcaveEdge3 = 0x40,
2091 b3_allConcaveEdges = b3_concaveEdge1 | b3_concaveEdge2 | b3_concaveEdge3,
2093 b3_flatEdge1 = b3_concaveEdge1 | b3_inverseConcaveEdge1,
2094 b3_flatEdge2 = b3_concaveEdge2 | b3_inverseConcaveEdge2,
2095 b3_flatEdge3 = b3_concaveEdge3 | b3_inverseConcaveEdge3,
2097 b3_allFlatEdges = b3_flatEdge1 | b3_flatEdge2 | b3_flatEdge3,
2253#define B3_HEIGHT_FIELD_HOLE 0xFF
2256#define B3_HEIGHT_FIELD_VERSION 0x8B18CBD138A6BC84ull
2403#define B3_COMPOUND_VERSION ( 0x830778DB07086EB4ull ^ B3_DYNAMIC_TREE_VERSION ^ B3_MESH_VERSION ^ B3_HULL_VERSION )
2407#define B3_MAX_COMPOUND_MESH_MATERIALS 4
2627 b3_closestPointsAxis,
2632 b3_manualEdgePairAxis,
2639 b3_featureTriangleFace,
2750 b3_colorAliceBlue = 0xF0F8FF,
2751 b3_colorAntiqueWhite = 0xFAEBD7,
2752 b3_colorAqua = 0x00FFFF,
2753 b3_colorAquamarine = 0x7FFFD4,
2754 b3_colorAzure = 0xF0FFFF,
2755 b3_colorBeige = 0xF5F5DC,
2756 b3_colorBisque = 0xFFE4C4,
2757 b3_colorBlack = 0x000000,
2758 b3_colorBlanchedAlmond = 0xFFEBCD,
2759 b3_colorBlue = 0x0000FF,
2760 b3_colorBlueViolet = 0x8A2BE2,
2761 b3_colorBrown = 0xA52A2A,
2762 b3_colorBurlywood = 0xDEB887,
2763 b3_colorCadetBlue = 0x5F9EA0,
2764 b3_colorChartreuse = 0x7FFF00,
2765 b3_colorChocolate = 0xD2691E,
2766 b3_colorCoral = 0xFF7F50,
2767 b3_colorCornflowerBlue = 0x6495ED,
2768 b3_colorCornsilk = 0xFFF8DC,
2769 b3_colorCrimson = 0xDC143C,
2770 b3_colorCyan = 0x00FFFF,
2771 b3_colorDarkBlue = 0x00008B,
2772 b3_colorDarkCyan = 0x008B8B,
2773 b3_colorDarkGoldenRod = 0xB8860B,
2774 b3_colorDarkGray = 0xA9A9A9,
2775 b3_colorDarkGreen = 0x006400,
2776 b3_colorDarkKhaki = 0xBDB76B,
2777 b3_colorDarkMagenta = 0x8B008B,
2778 b3_colorDarkOliveGreen = 0x556B2F,
2779 b3_colorDarkOrange = 0xFF8C00,
2780 b3_colorDarkOrchid = 0x9932CC,
2781 b3_colorDarkRed = 0x8B0000,
2782 b3_colorDarkSalmon = 0xE9967A,
2783 b3_colorDarkSeaGreen = 0x8FBC8F,
2784 b3_colorDarkSlateBlue = 0x483D8B,
2785 b3_colorDarkSlateGray = 0x2F4F4F,
2786 b3_colorDarkTurquoise = 0x00CED1,
2787 b3_colorDarkViolet = 0x9400D3,
2788 b3_colorDeepPink = 0xFF1493,
2789 b3_colorDeepSkyBlue = 0x00BFFF,
2790 b3_colorDimGray = 0x696969,
2791 b3_colorDodgerBlue = 0x1E90FF,
2792 b3_colorFireBrick = 0xB22222,
2793 b3_colorFloralWhite = 0xFFFAF0,
2794 b3_colorForestGreen = 0x228B22,
2795 b3_colorFuchsia = 0xFF00FF,
2796 b3_colorGainsboro = 0xDCDCDC,
2797 b3_colorGhostWhite = 0xF8F8FF,
2798 b3_colorGold = 0xFFD700,
2799 b3_colorGoldenRod = 0xDAA520,
2800 b3_colorGray = 0x808080,
2801 b3_colorGreen = 0x008000,
2802 b3_colorGreenYellow = 0xADFF2F,
2803 b3_colorHoneyDew = 0xF0FFF0,
2804 b3_colorHotPink = 0xFF69B4,
2805 b3_colorIndianRed = 0xCD5C5C,
2806 b3_colorIndigo = 0x4B0082,
2807 b3_colorIvory = 0xFFFFF0,
2808 b3_colorKhaki = 0xF0E68C,
2809 b3_colorLavender = 0xE6E6FA,
2810 b3_colorLavenderBlush = 0xFFF0F5,
2811 b3_colorLawnGreen = 0x7CFC00,
2812 b3_colorLemonChiffon = 0xFFFACD,
2813 b3_colorLightBlue = 0xADD8E6,
2814 b3_colorLightCoral = 0xF08080,
2815 b3_colorLightCyan = 0xE0FFFF,
2816 b3_colorLightGoldenRodYellow = 0xFAFAD2,
2817 b3_colorLightGray = 0xD3D3D3,
2818 b3_colorLightGreen = 0x90EE90,
2819 b3_colorLightPink = 0xFFB6C1,
2820 b3_colorLightSalmon = 0xFFA07A,
2821 b3_colorLightSeaGreen = 0x20B2AA,
2822 b3_colorLightSkyBlue = 0x87CEFA,
2823 b3_colorLightSlateGray = 0x778899,
2824 b3_colorLightSteelBlue = 0xB0C4DE,
2825 b3_colorLightYellow = 0xFFFFE0,
2826 b3_colorLime = 0x00FF00,
2827 b3_colorLimeGreen = 0x32CD32,
2828 b3_colorLinen = 0xFAF0E6,
2829 b3_colorMagenta = 0xFF00FF,
2830 b3_colorMaroon = 0x800000,
2831 b3_colorMediumAquaMarine = 0x66CDAA,
2832 b3_colorMediumBlue = 0x0000CD,
2833 b3_colorMediumOrchid = 0xBA55D3,
2834 b3_colorMediumPurple = 0x9370DB,
2835 b3_colorMediumSeaGreen = 0x3CB371,
2836 b3_colorMediumSlateBlue = 0x7B68EE,
2837 b3_colorMediumSpringGreen = 0x00FA9A,
2838 b3_colorMediumTurquoise = 0x48D1CC,
2839 b3_colorMediumVioletRed = 0xC71585,
2840 b3_colorMidnightBlue = 0x191970,
2841 b3_colorMintCream = 0xF5FFFA,
2842 b3_colorMistyRose = 0xFFE4E1,
2843 b3_colorMoccasin = 0xFFE4B5,
2844 b3_colorNavajoWhite = 0xFFDEAD,
2845 b3_colorNavy = 0x000080,
2846 b3_colorOldLace = 0xFDF5E6,
2847 b3_colorOlive = 0x808000,
2848 b3_colorOliveDrab = 0x6B8E23,
2849 b3_colorOrange = 0xFFA500,
2850 b3_colorOrangeRed = 0xFF4500,
2851 b3_colorOrchid = 0xDA70D6,
2852 b3_colorPaleGoldenRod = 0xEEE8AA,
2853 b3_colorPaleGreen = 0x98FB98,
2854 b3_colorPaleTurquoise = 0xAFEEEE,
2855 b3_colorPaleVioletRed = 0xDB7093,
2856 b3_colorPapayaWhip = 0xFFEFD5,
2857 b3_colorPeachPuff = 0xFFDAB9,
2858 b3_colorPeru = 0xCD853F,
2859 b3_colorPink = 0xFFC0CB,
2860 b3_colorPlum = 0xDDA0DD,
2861 b3_colorPowderBlue = 0xB0E0E6,
2862 b3_colorPurple = 0x800080,
2863 b3_colorRebeccaPurple = 0x663399,
2864 b3_colorRed = 0xFF0000,
2865 b3_colorRosyBrown = 0xBC8F8F,
2866 b3_colorRoyalBlue = 0x4169E1,
2867 b3_colorSaddleBrown = 0x8B4513,
2868 b3_colorSalmon = 0xFA8072,
2869 b3_colorSandyBrown = 0xF4A460,
2870 b3_colorSeaGreen = 0x2E8B57,
2871 b3_colorSeaShell = 0xFFF5EE,
2872 b3_colorSienna = 0xA0522D,
2873 b3_colorSilver = 0xC0C0C0,
2874 b3_colorSkyBlue = 0x87CEEB,
2875 b3_colorSlateBlue = 0x6A5ACD,
2876 b3_colorSlateGray = 0x708090,
2877 b3_colorSnow = 0xFFFAFA,
2878 b3_colorSpringGreen = 0x00FF7F,
2879 b3_colorSteelBlue = 0x4682B4,
2880 b3_colorTan = 0xD2B48C,
2881 b3_colorTeal = 0x008080,
2882 b3_colorThistle = 0xD8BFD8,
2883 b3_colorTomato = 0xFF6347,
2884 b3_colorTurquoise = 0x40E0D0,
2885 b3_colorViolet = 0xEE82EE,
2886 b3_colorWheat = 0xF5DEB3,
2887 b3_colorWhite = 0xFFFFFF,
2888 b3_colorWhiteSmoke = 0xF5F5F5,
2889 b3_colorYellow = 0xFFFF00,
2890 b3_colorYellowGreen = 0x9ACD32,
2892 b3_colorBox2DRed = 0xDC3132,
2893 b3_colorBox2DBlue = 0x30AEBF,
2894 b3_colorBox2DGreen = 0x8CC924,
2895 b3_colorBox2DYellow = 0xFFEE8C
2904 b3_debugMaterialDefault = 0,
2905 b3_debugMaterialMatte,
2906 b3_debugMaterialSoft,
2907 b3_debugMaterialDead,
2908 b3_debugMaterialGlossy,
2909 b3_debugMaterialMetallic
2916 return ( (uint32_t)rgb & 0x00FFFFFFu ) | ( (uint32_t)material << 24 );
bool isAwake
Is this body initially awake or sleeping?
Definition types.h:318
const char * name
Optional body name for debugging. Up to B3_BODY_NAME_LENGTH characters (including null termination).
Definition types.h:306
float gravityScale
Scale the gravity applied to this body. Non-dimensional.
Definition types.h:300
b3BodyType type
The body type: static, kinematic, or dynamic.
Definition types.h:270
void * userData
Use this to store application specific body data.
Definition types.h:309
float linearDamping
Linear damping is used to reduce the linear velocity.
Definition types.h:291
bool enableSleep
Set this flag to false if this body should never fall asleep.
Definition types.h:315
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:348
bool angularX
Prevent rotation around the x-axis.
Definition types.h:253
bool linearZ
Prevent translation along the z-axis.
Definition types.h:250
bool angularY
Prevent rotation around the y-axis.
Definition types.h:256
bool angularZ
Prevent rotation around the z-axis.
Definition types.h:259
bool isBullet
Treat this body as a high speed object that performs continuous collision detection against dynamic a...
Definition types.h:334
b3Pos position
The initial world position of the body.
Definition types.h:275
bool allowFastRotation
This allows this body to bypass rotational speed limits.
Definition types.h:341
float sleepThreshold
Sleep speed threshold, default is 0.05 meters per second.
Definition types.h:303
b3Vec3 angularVelocity
The initial angular velocity of the body. Radians per second.
Definition types.h:284
bool isEnabled
Used to disable a body. A disabled body does not move or collide.
Definition types.h:337
b3MotionLocks motionLocks
Motions locks to restrict linear and angular movement.
Definition types.h:312
bool linearX
Prevent translation along the x-axis.
Definition types.h:244
float angularDamping
Angular damping is used to reduce the angular velocity.
Definition types.h:297
b3Vec3 linearVelocity
The initial linear velocity of the body's origin. Usually in meters per second.
Definition types.h:281
bool enableContactRecycling
Enable contact recycling.
Definition types.h:345
bool linearY
Prevent translation along the y-axis.
Definition types.h:247
b3Quat rotation
The initial world rotation of the body.
Definition types.h:278
b3BodyType
The body simulation type.
Definition types.h:225
b3BodyDef b3DefaultBodyDef(void)
Use this to initialize your body definition.
@ b3_staticBody
zero mass, zero velocity, may be manually moved
Definition types.h:227
@ b3_bodyTypeCount
number of body types
Definition types.h:236
@ b3_dynamicBody
positive mass, velocity determined by forces, moved by solver
Definition types.h:233
@ b3_kinematicBody
zero mass, velocity set by user, moved by solver
Definition types.h:230
A body definition holds all the data needed to construct a rigid body.
Definition types.h:268
Motion locks to restrict the body movement.
Definition types.h:242
float radius
The radius of the hemispheres.
Definition types.h:1914
b3Vec3 center1
Local center of the first hemisphere.
Definition types.h:1908
b3Vec3 center2
Local center of the second hemisphere.
Definition types.h:1911
A solid capsule can be viewed as two hemispheres connected by a rectangle.
Definition types.h:1906
b3ShapeId shapeId
The shape id on the body.
Definition types.h:1842
b3Plane plane
Outward pointing plane.
Definition types.h:1803
float pushLimit
Setting this to FLT_MAX makes the plane as rigid as possible.
Definition types.h:1819
bool clipVelocity
Indicates if b3ClipVector should clip against this plane. Should be false for soft collision.
Definition types.h:1825
b3Plane plane
The collision plane between the mover and some shape.
Definition types.h:1815
b3PlaneResult result
The plane result.
Definition types.h:1845
float push
The push on the mover determined by b3SolvePlanes. Usually in meters.
Definition types.h:1822
b3Vec3 delta
The final relative translation.
Definition types.h:1832
b3Vec3 point
Closest point on the shape. May not be unique.
Definition types.h:1806
int iterationCount
The number of iterations used by the plane solver. For diagnostics.
Definition types.h:1835
bool b3MoverFilterFcn(b3ShapeId shapeId, void *context)
Used to filter shapes for shape casting character movers.
Definition types.h:1854
bool b3PlaneResultFcn(b3ShapeId shapeId, const b3PlaneResult *plane, int planeCount, void *context)
Used to collect collision planes for character movers.
Definition types.h:1850
Body plane result for movers.
Definition types.h:1840
These are collision planes that can be fed to b3SolvePlanes.
Definition types.h:1813
The plane between a character mover and a shape.
Definition types.h:1801
Result returned by b3SolvePlanes.
Definition types.h:1830
b3Vec3 anchorB
Location of the contact point relative to the bodyB center of mass in world space.
Definition types.h:2564
int triangleFlags
b3MeshEdgeFlags.
Definition types.h:2734
uint8_t indexB
Index of the feature on shape B.
Definition types.h:2665
uint8_t indexA
Index of the feature on shape A.
Definition types.h:2662
float baseSeparation
Cached separation used for contact recycling.
Definition types.h:2570
b3Vec3 normal
Local normal in frame A.
Definition types.h:2709
b3Vec3 rollingImpulse
Rolling resistance angular impulse.
Definition types.h:2612
b3FeaturePair pair
The feature pair for this point.
Definition types.h:2699
b3Vec3 anchorA
Location of the contact point relative to the bodyA center of mass in world space.
Definition types.h:2561
int i1
Vertex 1 index.
Definition types.h:2723
b3ManifoldPoint points[B3_MAX_MANIFOLD_POINTS]
The manifold points. There may be 1 to 4 valid points.
Definition types.h:2600
float squaredDistance
The squared distance of a sphere from a triangle. For ghost collision reduction.
Definition types.h:2728
int pointCount
The number of manifold points. Only bounded by the buffer capacity.
Definition types.h:2718
float normalImpulse
The impulse along the manifold normal vector.
Definition types.h:2574
uint8_t owner2
Outgoing type (either edge on shape A or shape B).
Definition types.h:2684
float totalNormalImpulse
The total normal impulse applied during sub-stepping.
Definition types.h:2578
b3TriangleFeature feature
The triangle feature involved.
Definition types.h:2731
int triangleIndex
Triangle index if one of the shapes is a mesh or height field.
Definition types.h:2589
float separation
The contact point separation. Negative for overlap.
Definition types.h:2696
uint32_t featureId
Local point for matching Uniquely identifies a contact point between two shapes.
Definition types.h:2586
b3Vec3 triangleNormal
The triangle normal.
Definition types.h:2712
uint8_t type
b3SeparatingFeature.
Definition types.h:2659
uint8_t hit
Was the cache re-used?
Definition types.h:2668
b3Vec3 point
Local point in frame A.
Definition types.h:2693
float separation
The separation of the contact point, negative if penetrating.
Definition types.h:2567
int i3
Vertex 3 index.
Definition types.h:2725
uint8_t owner1
Incoming type (either edge on shape A or shape B).
Definition types.h:2680
float twistImpulse
Central friction angular impulse (applied about the normal).
Definition types.h:2606
int triangleIndex
The triangle index when collide with a mesh or height-field.
Definition types.h:2702
b3Vec3 frictionImpulse
Central friction linear impulse.
Definition types.h:2609
int i2
Vertex 2 index.
Definition types.h:2724
int triangleIndex
The index of the triangle.
Definition types.h:2721
int pointCount
The number of contact points, will be 0 to 4.
Definition types.h:2615
uint8_t index2
Outgoing edge index (into associated shape array).
Definition types.h:2686
b3LocalManifoldPoint * points
The manifold points. From a point buffer.
Definition types.h:2715
bool persisted
Did this contact point exist in the previous step?
Definition types.h:2592
float separation
The separation when the cache is populated. Negative for overlap.
Definition types.h:2656
b3Vec3 normal
The unit normal vector in world space, points from shape A to shape B.
Definition types.h:2603
float normalVelocity
Relative normal velocity pre-solve.
Definition types.h:2582
uint8_t index1
Incoming edge index (into associated shape array).
Definition types.h:2682
b3SeparatingFeature
Cached separating axis feature.
Definition types.h:2621
b3TriangleFeature
Cached triangle feature.
Definition types.h:2637
@ b3_manualFaceAxisA
These are for testing.
Definition types.h:2630
@ b3_featureEdge3
v3-v1
Definition types.h:2646
@ b3_featureEdge1
v1-v2
Definition types.h:2642
@ b3_featureEdge2
v2-v3
Definition types.h:2644
Contact points are always the result of two edges intersecting.
Definition types.h:2678
A local manifold with no dynamic information. Used by b3Collide functions.
Definition types.h:2707
A local manifold point and normal in frame A.
Definition types.h:2691
A contact manifold describes the contact points between colliding shapes.
Definition types.h:2598
A manifold point is a contact point belonging to a contact manifold.
Definition types.h:2559
Separating axis test cache. Provides temporal acceleration of collision routines.
Definition types.h:2654
int hullCount
The number of hull instances.
Definition types.h:2444
int sharedMeshCount
The number of unique meshes. Diagnostic.
Definition types.h:2456
b3SurfaceMaterial material
Material properties.
Definition types.h:2370
b3CompoundSphereDef * spheres
Sphere instances.
Definition types.h:2396
b3Transform transform
The transform of this mesh instance.
Definition types.h:2495
const b3HullData * hull
Hull.
int materialOffset
Offset of the material array in bytes from the struct address.
Definition types.h:2429
uint64_t version
The compound version is always first.
Definition types.h:2417
int materialCount
The number of materials.
Definition types.h:2432
b3Capsule capsule
Capsule.
b3DynamicTree tree
Immutable dynamic tree. The tree node pointer must be fixed up using the node offset.
Definition types.h:2426
b3Vec3 scale
Local space non-uniform mesh scale. May have negative components.
Definition types.h:2353
int meshCount
Number of mesh instances.
Definition types.h:2393
int sharedHullCount
The number of unique hulls. Diagnostic.
Definition types.h:2447
b3SurfaceMaterial material
Material properties.
Definition types.h:2327
int capsuleCount
Number of capsules.
Definition types.h:2381
b3Transform transform
The transform of this hull instance.
Definition types.h:2482
const b3MeshData * meshData
Shared mesh.
Definition types.h:2347
int sphereCount
Number of spheres.
Definition types.h:2399
b3Transform transform
Transform of the shared mesh into compound local space.
Definition types.h:2350
b3Capsule capsule
Local capsule.
Definition types.h:2469
int sphereOffset
Offset of the sphere array in bytes from the struct address.
Definition types.h:2459
b3Vec3 scale
Non-uniform scale of this mesh instance.
Definition types.h:2498
b3Transform transform
Transform of the shared hull into compound local space.
Definition types.h:2337
b3SurfaceMaterial material
Material properties.
Definition types.h:2340
b3Capsule capsule
Local capsule.
Definition types.h:2324
int meshCount
The number of mesh instances.
Definition types.h:2453
int materialCount
Number of materials.
Definition types.h:2360
b3Sphere sphere
Local sphere.
Definition types.h:2367
int hullOffset
Offset of the hull instance array in bytes from the struct address.
Definition types.h:2441
int materialIndex
Index to a shared material.
Definition types.h:2514
const b3MeshData * meshData
Pointer to the unique shared mesh.
Definition types.h:2492
int capsuleOffset
Offset of the capsule array in bytes from the struct address.
Definition types.h:2435
b3CompoundCapsuleDef * capsules
Capsule instances.
Definition types.h:2378
int byteCount
The total number of bytes for this compound.
Definition types.h:2420
const b3HullData * hull
Shared hull.
Definition types.h:2334
int sphereCount
The number of spheres.
Definition types.h:2462
b3Sphere sphere
Local sphere.
Definition types.h:2511
int meshOffset
Offset of the mesh instance array in bytes from the struct address.
Definition types.h:2450
int capsuleCount
The number of capsules.
Definition types.h:2438
b3CompoundHullDef * hulls
Hulls instances.
Definition types.h:2384
int nodeOffset
Offset of the tree node array in bytes from the struct address.
Definition types.h:2423
int materialIndex
Index to a shared material.
Definition types.h:2472
b3CompoundMeshDef * meshes
Mesh instances.
Definition types.h:2390
const b3HullData * hull
Pointer to the unique shared hull.
Definition types.h:2479
int materialIndices[B3_MAX_COMPOUND_MESH_MATERIALS]
This is used to access the surface material from b3GetCompoundMaterials.
Definition types.h:2504
int materialIndex
Index to a shared material.
Definition types.h:2485
const b3SurfaceMaterial * materials
Material properties.
Definition types.h:2357
int hullCount
Number of hull instances.
Definition types.h:2387
bool b3CompoundQueryFcn(const b3CompoundData *compound, int childIndex, void *context)
Callback for compound overlap queries.
Definition types.h:2541
#define B3_MAX_COMPOUND_MESH_MATERIALS
Meshes used in compounds have limited space for materials.
Definition types.h:2407
A capsule that lives in a compound.
Definition types.h:2467
Definition for a capsule in a compound shape.
Definition types.h:2322
The runtime data for a compound shape.
Definition types.h:2415
Definition for creating a compound shape.
Definition types.h:2376
A hull that lives in a compound.
Definition types.h:2477
Definition for a convex hull in a compound shape.
Definition types.h:2332
A mesh with non-uniform scale that lives in a compound.
Definition types.h:2490
Definition for a triangle mesh in a compound shape.
Definition types.h:2345
A sphere that lives in a compound.
Definition types.h:2509
Definition for a sphere in a compound shape.
Definition types.h:2365
const b3Mesh * mesh
Mesh shape with scale.
const b3HullData * hull
Convex hull shape.
const b3Capsule * capsule
Capsule shape.
const b3Sphere * sphere
Sphere shape.
const b3HeightFieldData * heightField
Height-field shape.
const b3CompoundData * compound
Compound shape.
uint32_t b3MakeDebugColor(b3HexColor rgb, b3DebugMaterial material)
Pack an RGB color with a material preset for debug draw.
Definition types.h:2914
void * b3CreateDebugShapeCallback(const b3DebugShape *debugShape, void *userContext)
The user needs to be able to create debug draw shapes for multi-pass rendering to work efficiently.
Definition types.h:47
b3DebugMaterial
Debug draw material preset.
Definition types.h:2903
b3DebugDraw b3DefaultDebugDraw(void)
Create a debug draw struct with default values.
b3HexColor b3GetGraphColor(int index)
Get the visualization color assigned to a constraint graph color slot.
b3HexColor
These colors are used for debug draw and mostly match the named SVG colors.
Definition types.h:2749
float maxLength
Maximum length. Must be greater than or equal to the minimum length.
Definition types.h:679
float lowerSpringForce
The lower spring force controls how much tension it can sustain.
Definition types.h:661
bool enableSpring
Enable the distance constraint to behave like a spring.
Definition types.h:658
float dampingRatio
The spring linear damping ratio, non-dimensional.
Definition types.h:670
bool enableLimit
Enable/disable the joint limit.
Definition types.h:673
b3JointDef base
Base joint definition.
Definition types.h:651
bool enableMotor
Enable/disable the joint motor.
Definition types.h:682
float maxMotorForce
The maximum motor force, usually in newtons.
Definition types.h:685
float upperSpringForce
The upper spring force controls how much compression it can sustain.
Definition types.h:664
float hertz
The spring linear stiffness Hertz, cycles per second.
Definition types.h:667
float minLength
Minimum length. Clamped to a stable minimum value.
Definition types.h:676
float length
The rest length of this joint. Clamped to a stable minimum value.
Definition types.h:654
float motorSpeed
The desired motor speed, usually in meters per second.
Definition types.h:688
b3DistanceJointDef b3DefaultDistanceJointDef(void)
Use this to initialize your joint definition.
Distance joint definition.
Definition types.h:649
b3ShapeId visitorShapeId
The id of the shape that stopped touching the sensor shape.
Definition types.h:1073
b3JointEvent * jointEvents
Array of events.
Definition types.h:1242
b3ContactId contactId
The contact id.
Definition types.h:1255
b3ContactBeginTouchEvent * beginEvents
Array of begin touch events.
Definition types.h:1170
uint64_t userMaterialIdA
User material on shape A.
Definition types.h:1157
b3ContactId contactId
Id of the contact.
Definition types.h:1127
int hitCount
Number of hit events.
Definition types.h:1185
b3BodyId bodyId
The body id.
Definition types.h:1207
b3Vec3 normal
Normal vector pointing from shape A to shape B.
Definition types.h:1151
int beginCount
The number of begin touch events.
Definition types.h:1088
b3ShapeId shapeIdA
Id of the first shape.
Definition types.h:1135
b3BodyMoveEvent * moveEvents
Array of move events.
Definition types.h:1219
float approachSpeed
The speed the shapes are approaching. Always positive. Typically in meters per second.
Definition types.h:1154
b3ShapeId shapeIdA
Id of the first shape.
Definition types.h:1117
int endCount
Number of end touch events.
Definition types.h:1182
uint64_t userMaterialIdB
User material on shape B.
Definition types.h:1160
b3ShapeId shapeIdB
Id of the second shape.
Definition types.h:1101
int moveCount
Number of move events.
Definition types.h:1222
b3ContactId contactId
The transient contact id.
Definition types.h:1105
int count
Number of events.
Definition types.h:1245
int manifoldCount
The number of contact manifolds. For mesh and height-field collision there can be multiple manifolds.
Definition types.h:1268
int endCount
The number of end touch events.
Definition types.h:1091
b3ContactId contactId
Id of the contact.
Definition types.h:1143
b3Pos point
Point where the shapes hit at the beginning of the time step.
Definition types.h:1148
b3ShapeId sensorShapeId
The id of the sensor shape.
Definition types.h:1053
b3ShapeId shapeIdB
The second shape id.
Definition types.h:1261
b3SensorBeginTouchEvent * beginEvents
Array of sensor begin touch events.
Definition types.h:1082
void * userData
The body user data.
Definition types.h:1201
bool fellAsleep
Did the body fall asleep this time step?
Definition types.h:1210
b3ShapeId shapeIdA
The first shape id.
Definition types.h:1258
b3ShapeId shapeIdB
Id of the first shape.
Definition types.h:1122
b3SensorEndTouchEvent * endEvents
Array of sensor end touch events.
Definition types.h:1085
void * userData
The user data from the joint for convenience.
Definition types.h:1233
b3ShapeId shapeIdA
Id of the first shape.
Definition types.h:1098
b3ShapeId visitorShapeId
The id of the shape that began touching the sensor shape.
Definition types.h:1056
b3ShapeId shapeIdB
Id of the second shape.
Definition types.h:1138
b3ContactEndTouchEvent * endEvents
Array of end touch events.
Definition types.h:1173
b3WorldTransform transform
The body transform.
Definition types.h:1204
b3ContactHitEvent * hitEvents
Array of hit events.
Definition types.h:1176
b3ShapeId sensorShapeId
The id of the sensor shape.
Definition types.h:1068
const struct b3Manifold * manifolds
The contact manifold.
Definition types.h:1265
int beginCount
Number of begin touch events.
Definition types.h:1179
b3JointId jointId
The joint id.
Definition types.h:1230
Body events are buffered in the world and are available as event arrays after the time step is comple...
Definition types.h:1217
Body move events triggered when a body moves.
Definition types.h:1199
Joint events report joints that are awake and have a force and/or torque exceeding the threshold The ...
Definition types.h:1228
Joint events are buffered in the world and are available as event arrays after the time step is compl...
Definition types.h:1240
A begin-touch event is generated when a shape starts to overlap a sensor shape.
Definition types.h:1051
An end touch event is generated when a shape stops overlapping a sensor shape.
Definition types.h:1064
Sensor events are buffered in the world and are available as begin/end overlap event arrays after the...
Definition types.h:1080
b3JointDef base
Base joint definition.
Definition types.h:742
b3FilterJointDef b3DefaultFilterJointDef(void)
Use this to initialize your joint definition.
A filter joint is used to disable collision between two specific bodies.
Definition types.h:740
float mass
The shape mass.
Definition types.h:1870
b3Matrix3 inertia
The inertia tensor about the shape center of mass.
Definition types.h:1876
b3Vec3 center
The local center of mass position.
Definition types.h:1873
This holds the mass data computed for a shape.
Definition types.h:1868
bool clockwiseWinding
Use clock-wise winding. This effectively inverts the height-field along the y-axis.
Definition types.h:2249
int countZ
The number of grid lines along the z-axis.
Definition types.h:2236
int columnCount
The number of grid columns along the local x-axis.
Definition types.h:2287
float globalMinimumHeight
Global minimum and maximum heights used for quantization.
Definition types.h:2243
b3Vec3 scale
The height field scale. All components must be positive values.
Definition types.h:2230
int countX
The number of grid lines along the x-axis.
Definition types.h:2233
b3AABB aabb
The local axis-aligned bounding box.
Definition types.h:2272
bool clockwise
Triangle winding.
Definition types.h:2305
int flagsOffset
Offset of the flag array in bytes from the struct address.
Definition types.h:2302
float heightScale
The quantization scale.
Definition types.h:2281
int heightsOffset
Offset of the compressed height array in bytes from the struct address.
Definition types.h:2294
int byteCount
The total number of bytes for this height field.
Definition types.h:2266
uint8_t padding[3]
Explicit padding.
Definition types.h:2309
int rowCount
The number of grid rows along the local z-axis.
Definition types.h:2290
int materialOffset
Offset of the material index array in bytes from the struct address.
Definition types.h:2298
b3Vec3 scale
The overall scale.
Definition types.h:2284
float minHeight
The minimum y value.
Definition types.h:2275
float maxHeight
The maximum y value.
Definition types.h:2278
float * heights
Grid point heights count = countX * countZ.
Definition types.h:2222
uint8_t * materialIndices
Grid cell material A value of 0xFF is reserved for holes count = (countX - 1) * (countZ - 1).
Definition types.h:2227
float globalMaximumHeight
The maximum.
Definition types.h:2246
uint32_t hash
Hash of this height field (this field is zero when the hash is computed).
Definition types.h:2269
uint64_t version
Version must be first and match B3_HEIGHT_FIELD_VERSION.
Definition types.h:2263
A height field with compressed storage.
Definition types.h:2261
Data used to create a height field.
Definition types.h:2219
int planeOffset
Offset of the face plane array in bytes from the struct address.
Definition types.h:2015
int padding
Explicit padding.
Definition types.h:2019
b3AABB aabb
Axis-aligned box in local space.
Definition types.h:1976
int pointOffset
Offset of the point array in bytes from the struct address.
Definition types.h:2000
float innerRadius
The radius of the largest sphere at the center.
Definition types.h:1985
b3HullFace boxFaces[6]
Box faces.
Definition types.h:2030
int faceOffset
Offset of the face array in bytes from the struct address.
Definition types.h:2012
uint8_t edge
An arbitrary half-edge on this face.
Definition types.h:1956
b3Vec3 boxPoints[8]
Box points.
Definition types.h:2028
float volume
Volume, typically in m^3.
Definition types.h:1982
b3HullHalfEdge boxEdges[24]
Box half-edges.
Definition types.h:2029
int faceCount
The face count. Hulls faces are convex polygons.
Definition types.h:2009
int edgeCount
This is the half-edge count (double the edge count).
Definition types.h:2003
float surfaceArea
Surface area, typically in squared meters.
Definition types.h:1979
uint64_t version
Version must be first and match B3_HULL_VERSION.
Definition types.h:1967
b3Vec3 center
The local centroid.
Definition types.h:1988
uint8_t edge
A half-edge that has this vertex as the origin Can be used along with edge twins and winding order to...
Definition types.h:1932
uint8_t next
Next edge index CCW.
Definition types.h:1939
uint32_t hash
Hash of this hull (this field is zero when the hash is computed).
Definition types.h:1973
b3Plane boxPlanes[6]
Box face planes.
Definition types.h:2032
int vertexOffset
Offset of the vertex array in bytes from the struct address.
Definition types.h:1997
uint8_t padding[2]
Explicit padding, see b3HullData::padding.
Definition types.h:2031
b3HullVertex boxVertices[8]
Box vertices.
Definition types.h:2027
uint8_t twin
Twin edge index.
Definition types.h:1942
int byteCount
The total number of bytes for this hull.
Definition types.h:1970
b3HullData base
The embedded hull. So the offsets index into the arrays that follow.
Definition types.h:2026
uint8_t face
Face to the left of this edge.
Definition types.h:1948
b3Matrix3 centralInertia
The inertia tensor about the centroid.
Definition types.h:1991
uint8_t origin
index of origin vertex and point
Definition types.h:1945
int vertexCount
The vertex count.
Definition types.h:1994
int edgeOffset
Offset of the edge array in bytes from the struct address.
Definition types.h:2006
Efficient box hull.
Definition types.h:2024
A convex hull.
Definition types.h:1965
A hull face.
Definition types.h:1954
Half-edge for hull data structure.
Definition types.h:1937
A hull vertex.
Definition types.h:1928
Body id references a body instance. This should be treated as an opaque handle.
Definition id.h:45
Joint id references a joint instance. This should be treated as an opaque handle.
Definition id.h:61
Shape id references a shape instance. This should be treated as an opaque handle.
Definition id.h:53
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:641
float drawScale
Debug draw scale.
Definition types.h:635
void * userData
User data pointer.
Definition types.h:608
b3Transform localFrameB
The second local joint frame.
Definition types.h:620
float constraintHertz
Constraint hertz (advanced feature).
Definition types.h:629
b3BodyId bodyIdA
The first attached body.
Definition types.h:611
b3Transform localFrameA
The first local joint frame.
Definition types.h:617
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:638
float forceThreshold
Force threshold for joint events.
Definition types.h:623
float constraintDampingRatio
Constraint damping ratio (advanced feature).
Definition types.h:632
b3BodyId bodyIdB
The second attached body.
Definition types.h:614
float torqueThreshold
Torque threshold for joint events.
Definition types.h:626
b3JointType
Joint type enumeration.
Definition types.h:588
Base joint definition used by all joint types.
Definition types.h:606
b3Vec3 b3Pos
In single precision mode these types are the same.
Definition math_functions.h:90
b3Transform b3WorldTransform
In single precision mode these types are the same.
Definition math_functions.h:93
Axis aligned bounding box.
Definition math_functions.h:105
A 3x3 matrix.
Definition math_functions.h:99
A plane.
Definition math_functions.h:113
A quaternion.
Definition math_functions.h:58
A 3D vector.
Definition math_functions.h:41
uint32_t triangleCount
The number of triangles for this leaf node.
int nodeCount
The number of BVH nodes.
Definition types.h:2174
int materialOffset
Offset of the material array in bytes from the struct address.
Definition types.h:2189
int treeHeight
The height of the bounding volume hierarchy.
Definition types.h:2165
int byteCount
The total number of bytes for this mesh.
Definition types.h:2153
int vertexOffset
Offset of the vertex array in bytes from the struct address.
Definition types.h:2177
int triangleCount
The number of triangles.
Definition types.h:2186
uint32_t axis
Split axis. 0, 1, or 2.
float surfaceArea
Combined surface area of all triangles. Single-sided.
Definition types.h:2162
const b3MeshData * data
Immutable pointer to the mesh data.
Definition types.h:2202
bool identifyEdges
Compute triangle adjacency information using shared edges.
Definition types.h:2074
uint32_t childOffset
Offset of the second child node.
uint8_t * materialIndices
Triangle material index.
Definition types.h:2055
uint32_t type
Aligned with axis above and has value of 3 if this is a leaf.
uint32_t hash
Hash of this mesh (this field is zero when the hash is computed).
Definition types.h:2156
b3Vec3 scale
This scale may be non-uniform and have negative components.
Definition types.h:2206
int32_t index3
Index of vertex 3.
Definition types.h:2106
int32_t index1
Index of vertex 1.
Definition types.h:2104
b3Vec3 * vertices
Triangle vertices.
Definition types.h:2047
bool useMedianSplit
Use the median split instead of SAH to speed up mesh creation.
Definition types.h:2071
int nodeOffset
Offset of the node array in bytes from the struct address.
Definition types.h:2171
int triangleCount
The triangle count. Must be 1 or more.
Definition types.h:2064
int flagsOffset
Offset of the triangle flag array in bytes from the struct address.
Definition types.h:2195
uint64_t version
Version must be first.
Definition types.h:2150
int vertexCount
The number of vertices.
Definition types.h:2180
b3AABB bounds
Local axis-aligned box.
Definition types.h:2159
int32_t * indices
Triangle vertex indices. 3 for each triangle.
Definition types.h:2050
int triangleOffset
Offset of the triangle array in bytes from the struct address.
Definition types.h:2183
bool weldVertices
Optionally weld nearby vertices.
Definition types.h:2067
float weldTolerance
Tolerance for vertex welding in length units.
Definition types.h:2058
int vertexCount
The vertex count. Must be 3 or more.
Definition types.h:2061
int materialCount
The number of materials.
Definition types.h:2192
int32_t index2
Index of vertex 2.
Definition types.h:2105
int degenerateCount
The number of degenerate triangles. Diagnostic.
Definition types.h:2168
b3MeshEdgeFlags
Triangle mesh edge flags.
Definition types.h:2082
This allows mesh data to be re-used with different scales.
Definition types.h:2200
This is a sorted triangle collision bounding volume hierarchy.
Definition types.h:2148
This is used to create a re-usable collision mesh.
Definition types.h:2045
A mesh triangle.
Definition types.h:2103
float maxSpringTorque
Maximum spring torque in newton-meters.
Definition types.h:730
float maxVelocityTorque
The maximum motor torque in newton-meters.
Definition types.h:712
float angularHertz
Angular spring hertz for position control.
Definition types.h:724
float linearHertz
Linear spring hertz for position control.
Definition types.h:715
float maxSpringForce
Maximum spring force in newtons.
Definition types.h:721
b3JointDef base
Base joint definition.
Definition types.h:700
b3Vec3 linearVelocity
The desired linear velocity.
Definition types.h:703
float linearDampingRatio
Linear spring damping ratio.
Definition types.h:718
float angularDampingRatio
Angular spring damping ratio.
Definition types.h:727
float maxVelocityForce
The maximum motor force in newtons.
Definition types.h:706
b3Vec3 angularVelocity
The desired angular velocity.
Definition types.h:709
b3MotorJointDef b3DefaultMotorJointDef(void)
Use this to initialize your joint definition.
A motor joint is used to control the relative position and velocity between two bodies.
Definition types.h:698
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:758
float maxTorque
The maximum spring torque, typically in newton-meters.
Definition types.h:764
float dampingRatio
The spring damping ratio, non-dimensional.
Definition types.h:761
b3JointDef base
Base joint definition.
Definition types.h:755
b3ParallelJointDef b3DefaultParallelJointDef(void)
Use this to initialize your joint definition.
Parallel joint definition.
Definition types.h:753
bool enableLimit
Enable/disable the joint limit.
Definition types.h:795
float upperTranslation
The upper translation limit.
Definition types.h:801
float targetTranslation
The target translation for the joint in meters.
Definition types.h:792
b3JointDef base
Base joint definition.
Definition types.h:779
float maxMotorForce
The maximum motor force, typically in newtons.
Definition types.h:807
bool enableMotor
Enable/disable the joint motor.
Definition types.h:804
float lowerTranslation
The lower translation limit.
Definition types.h:798
bool enableSpring
Enable a linear spring along the prismatic joint axis.
Definition types.h:782
float dampingRatio
The spring damping ratio, non-dimensional.
Definition types.h:788
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:785
float motorSpeed
The desired motor speed, typically in meters per second.
Definition types.h:810
b3PrismaticJointDef b3DefaultPrismaticJointDef(void)
Use this to initialize your joint definition.
Prismatic joint definition.
Definition types.h:777
b3Vec3 normal
A to B normal in shape A's frame. Invalid if distance is zero.
Definition types.h:1555
b3ShapeProxy proxyB
The proxy for shape B.
Definition types.h:1540
b3Vec3 c1
Starting center of mass world position.
Definition types.h:1585
int nodeVisits
The number of BVH nodes visited. Diagnostic.
Definition types.h:1348
int triangleIndex
The triangle index if the shape is a mesh, height-field, or compound with child mesh.
Definition types.h:1342
bool usedFallback
Indicates that the time of impact detected initial overlap and used a fallback sphere as a last ditch...
Definition types.h:1641
b3Vec3 w
wB - wA
Definition types.h:1566
b3Vec3 origin
Start point of the ray cast.
Definition types.h:1311
b3Vec3 point
The surface hit point.
Definition types.h:1410
b3Vec3 wB
support point in proxyB
Definition types.h:1565
b3Vec3 normal
The world normal vector on the shape surface.
Definition types.h:1479
b3Vec3 wA
support point in proxyA
Definition types.h:1564
float fraction
The sweep time of the collision.
Definition types.h:1624
int childIndex
The child index if the shape is a compound.
Definition types.h:1345
bool canEncroach
Allow shape cast to encroach when initially touching. This only works if the radius is greater than z...
Definition types.h:1385
int simplexCount
The number of simplexes stored in the simplex array.
Definition types.h:1558
float fraction
The fraction of the input ray.
Definition types.h:1338
b3Pos point
The world point on the shape surface.
Definition types.h:1476
float fraction
The fraction along the ray hit.
Definition types.h:1483
int triangleIndex
The index of the mesh or height field triangle hit.
Definition types.h:1419
b3Vec3 c2
Ending center of mass world position.
Definition types.h:1586
uint64_t userMaterialId
The user material id at the hit point.
Definition types.h:1490
b3Vec3 translation
The sweep translation.
Definition types.h:1397
uint8_t indexA[4]
The cached simplex indices on shape A.
Definition types.h:1513
b3ShapeProxy proxyB
The proxy for shape B.
Definition types.h:1526
bool hit
Did the cast hit? If false, all other fields are invalid.
Definition types.h:1496
float metric
Value use to compare length, area, volume of two simplexes.
Definition types.h:1506
b3Vec3 normal
The hit normal.
Definition types.h:1621
b3Vec3 pointB
Closest point on shapeB, in shape A's frame.
Definition types.h:1554
float radius
The external radius of the point cloud.
Definition types.h:1367
uint16_t count
The number of stored simplex points.
Definition types.h:1510
int count
number of valid vertices
Definition types.h:1576
bool hit
Did the ray hit? If false, all other data is invalid.
Definition types.h:1354
float distance
The final distance.
Definition types.h:1627
uint64_t maskBits
The collision mask bits.
Definition types.h:1291
float maxFraction
The maximum fraction of the translation to consider, typically 1.
Definition types.h:1382
const char * name
Optional label combined with Ids to identify this query, e.g.
Definition types.h:1301
b3Transform transform
Transform of shape B in shape A's frame, the relative pose B in A.
Definition types.h:1527
b3ShapeProxy proxyA
The proxy for shape A.
Definition types.h:1537
int triangleIndex
The triangle index if the shape is a mesh or height-field.
Definition types.h:1486
uint8_t indexB[4]
The cached simplex indices on shape B.
Definition types.h:1516
b3ShapeId shapeId
The shape hit.
Definition types.h:1325
b3Vec3 point
The hit point.
Definition types.h:1618
b3Vec3 pointA
Closest point on shapeA, in shape A's frame.
Definition types.h:1553
int distanceIterations
Number of outer iterations.
Definition types.h:1630
int indexB
wB index
Definition types.h:1569
float maxFraction
Defines the sweep interval [0, tMax].
Definition types.h:1598
b3ShapeProxy proxyA
The proxy for shape A.
Definition types.h:1525
int pushBackIterations
Total number of push back iterations.
Definition types.h:1633
bool useRadii
Should the proxy radius be considered?
Definition types.h:1547
b3ShapeProxy proxyB
The proxy for shape B.
Definition types.h:1595
b3Transform transform
Transform of shape B in shape A's frame, the relative pose B in A (b3InvMulWorldTransforms( worldA,...
Definition types.h:1544
b3Vec3 normal
The surface normal at the hit point.
Definition types.h:1407
b3SimplexVertex vertices[4]
vertices
Definition types.h:1575
b3ShapeProxy proxy
A generic query shape.
Definition types.h:1376
bool hit
Did the cast hit?
Definition types.h:1428
uint64_t userMaterialId
The user material id at the hit point.
Definition types.h:1335
float distance
The final distance, zero if overlapped.
Definition types.h:1556
b3Vec3 localCenter
Local center of mass position.
Definition types.h:1584
int rootIterations
Total number of root iterations.
Definition types.h:1636
float maxFraction
The maximum fraction of the translation to consider, typically 1.
Definition types.h:1400
float maxFraction
The fraction of the translation to consider, typically 1.
Definition types.h:1529
int childIndex
The index of the compound child shape.
Definition types.h:1422
int materialIndex
The material index. May be -1 for null.
Definition types.h:1425
b3Vec3 translationB
The translation of shape B, in A's frame.
Definition types.h:1528
float maxFraction
The maximum fraction of the translation to consider, typically 1.
Definition types.h:1318
b3Vec3 translation
Translation of the ray cast.
Definition types.h:1315
const b3Vec3 * points
The point cloud.
Definition types.h:1361
int iterations
The number of iterations used. Diagnostic.
Definition types.h:1493
int iterations
The number of iterations used.
Definition types.h:1416
b3Sweep sweepA
The movement of shape A.
Definition types.h:1596
b3ShapeProxy proxyA
The proxy for shape A.
Definition types.h:1594
int indexA
wA index
Definition types.h:1568
b3Pos point
The world point of the hit.
Definition types.h:1328
b3Quat q1
Starting world rotation.
Definition types.h:1587
bool canEncroach
Allows shapes with a radius to move slightly closer if already touching.
Definition types.h:1530
float a
barycentric coordinates
Definition types.h:1567
b3Vec3 translation
The translation of the shape cast.
Definition types.h:1379
b3Sweep sweepB
The movement of shape B.
Definition types.h:1597
b3TOIState state
The type of result.
Definition types.h:1615
b3ShapeId shapeId
The shape hit.
Definition types.h:1473
uint64_t categoryBits
The collision category bits of this query. Normally you would just set one bit.
Definition types.h:1287
int iterations
Number of GJK iterations used.
Definition types.h:1557
int count
The number of points. Do not exceed B3_MAX_SHAPE_CAST_POINTS.
Definition types.h:1364
b3Quat q2
Ending world rotation.
Definition types.h:1588
b3AABB box
The AABB to cast, in the tree's frame.
Definition types.h:1394
uint64_t id
Optional id combined with name to identify this query in a recording, e.g.
Definition types.h:1295
int leafVisits
The number of BVH leaves visited. Diagnostic.
Definition types.h:1351
float fraction
The fraction of the input translation at collision.
Definition types.h:1413
b3Vec3 normal
The world normal of the shape surface at the hit point.
Definition types.h:1331
b3QueryFilter b3DefaultQueryFilter(void)
Use this to initialize your query filter.
b3CastOutput b3WorldCastOutput
Same type in single precision.
Definition types.h:1465
b3TOIState
Describes the TOI output.
Definition types.h:1603
Body cast result for ray and shape casts.
Definition types.h:1471
Low level ray cast or shape-cast output data.
Definition types.h:1405
Output for b3ShapeDistance.
Definition types.h:1552
The query filter is used to filter collisions between queries and shapes.
Definition types.h:1285
Result from b3World_RayCastClosest.
Definition types.h:1323
A shape proxy is used by the GJK algorithm. It can represent a convex shape.
Definition types.h:1359
Simplex from the GJK algorithm.
Definition types.h:1574
Used to warm start the GJK simplex.
Definition types.h:1504
Simplex vertex for debugging the GJK algorithm.
Definition types.h:1563
This describes the motion of a body/shape for TOI computation.
Definition types.h:1583
Time of impact output.
Definition types.h:1613
float motorSpeed
The desired motor speed in radians per second.
Definition types.h:854
b3JointDef base
Base joint definition.
Definition types.h:823
float targetAngle
The bodyB angle minus bodyA angle in the reference state (radians).
Definition types.h:827
float dampingRatio
The spring damping ratio, non-dimensional.
Definition types.h:836
float lowerAngle
The lower angle for the joint limit in radians. Minimum of -0.99*pi radians.
Definition types.h:842
bool enableMotor
A flag to enable the joint motor.
Definition types.h:848
float upperAngle
The upper angle for the joint limit in radians. Maximum of 0.99*pi radians.
Definition types.h:845
float maxMotorTorque
The maximum motor torque, typically in newton-meters.
Definition types.h:851
bool enableLimit
A flag to enable joint limits.
Definition types.h:839
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:833
bool enableSpring
Enable a rotational spring on the revolute hinge axis.
Definition types.h:830
b3RevoluteJointDef b3DefaultRevoluteJointDef(void)
Use this to initialize your joint definition.
Revolute joint definition.
Definition types.h:821
float restitution
The coefficient of restitution (bounce) usually in the range [0,1].
Definition types.h:405
float explosionScale
Explosion scale for b3World_Explode. non-dimensional.
Definition types.h:474
bool enableSensorEvents
Enable sensor events for this shape. This applies to sensors and non-sensors. False by default,...
Definition types.h:490
bool invokeContactCreation
When shapes are created they will scan the environment for collision the next time step.
Definition types.h:505
bool updateBodyMass
Should the body update the mass properties when this shape is created.
Definition types.h:509
float friction
The Coulomb (dry) friction coefficient, usually in the range [0,1].
Definition types.h:401
bool enableCustomFiltering
Enable custom filtering. Only one of the two shapes needs to enable custom filtering....
Definition types.h:480
bool isSensor
A sensor shape generates overlap events but never generates a collision response.
Definition types.h:487
uint64_t categoryBits
The collision category bits.
Definition types.h:372
bool enablePreSolveEvents
Enable pre-solve contact events for this shape.
Definition types.h:500
bool enableHitEvents
Enable hit events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors....
Definition types.h:496
b3Filter filter
Contact filtering data.
Definition types.h:477
float density
The density, usually in kg/m^3.
Definition types.h:471
uint32_t customColor
Custom debug draw color.
Definition types.h:421
int groupIndex
Collision groups allow a certain group of objects to never collide (negative) or always collide (posi...
Definition types.h:389
void * userData
Use this to store application specific shape data.
Definition types.h:459
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:512
bool enableContactEvents
Enable contact events for this shape. Only applies to kinematic and dynamic bodies....
Definition types.h:493
float rollingResistance
The rolling resistance usually in the range [0,1]. This is only used for spheres and capsules.
Definition types.h:408
uint64_t userMaterialId
User material identifier.
Definition types.h:416
b3SurfaceMaterial baseMaterial
The base surface material. Ignored for compound shapes.
Definition types.h:468
uint64_t maskBits
The collision mask bits.
Definition types.h:381
b3Vec3 tangentVelocity
The tangent velocity for conveyor belts.
Definition types.h:412
b3SurfaceMaterial * materials
Surface material used on mesh shapes per triangle. Ignored for convex shapes. Ignored for compound sh...
Definition types.h:462
int materialCount
Surface material count.
Definition types.h:465
b3SurfaceMaterial b3DefaultSurfaceMaterial(void)
Use this to initialize your surface material.
b3ShapeType
Shape type.
Definition types.h:431
b3Filter b3DefaultFilter(void)
Use this to initialize your filter.
b3ShapeDef b3DefaultShapeDef(void)
Use this to initialize your shape definition.
@ b3_capsuleShape
A capsule is an extruded sphere.
Definition types.h:433
@ b3_shapeTypeCount
The number of shape types.
Definition types.h:451
@ b3_heightShape
A height field useful for terrain.
Definition types.h:439
@ b3_compoundShape
A compound shape composed of up to 64K spheres, capsules, hulls, and meshes.
Definition types.h:436
@ b3_sphereShape
A sphere with an offset.
Definition types.h:448
@ b3_meshShape
A triangle soup.
Definition types.h:445
@ b3_hullShape
A convex hull.
Definition types.h:442
This is used to filter collision on shapes.
Definition types.h:359
Used to create a shape.
Definition types.h:457
Material properties supported per triangle on meshes and height fields.
Definition types.h:399
b3Vec3 center
The local center.
Definition types.h:1889
float radius
The radius.
Definition types.h:1892
A solid sphere.
Definition types.h:1887
bool enableMotor
A flag to enable the joint motor.
Definition types.h:898
float maxMotorTorque
The maximum motor torque, typically in newton-meters. Non-negative number.
Definition types.h:901
float lowerTwistAngle
The angle for the lower twist limit in radians. Minimum of -0.99*pi radians.
Definition types.h:892
b3Quat targetRotation
Target spring rotation, joint frame B relative to joint frame A.
Definition types.h:880
b3JointDef base
Base joint definition.
Definition types.h:867
bool enableConeLimit
A flag to enable the cone limit. The cone is centered on the frameA z-axis.
Definition types.h:883
bool enableSpring
Enable a rotational spring that attempts to align the two joint frames.
Definition types.h:870
float coneAngle
The angle for the cone limit in radians. Valid range is [0, pi].
Definition types.h:886
bool enableTwistLimit
A flag to enable the twist limit. The twist is centered on the frameB z-axis.
Definition types.h:889
float upperTwistAngle
The angle for the upper twist limit in radians. Maximum of 0.99*pi radians.
Definition types.h:895
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:874
float dampingRatio
The spring damping ratio, non-dimensional. Non-negative number.
Definition types.h:877
b3Vec3 motorVelocity
The desired motor angular velocity in radians per second.
Definition types.h:904
b3SphericalJointDef b3DefaultSphericalJointDef(void)
Use this to initialize your joint definition.
Spherical joint definition.
Definition types.h:865
int nodeCapacity
The allocated node space.
Definition types.h:1735
int * binIndices
Bins for sorting during rebuild.
Definition types.h:1753
b3Vec3 * leafCenters
Leaf bounding box centers for rebuild.
Definition types.h:1750
int nodeCount
The number of nodes.
Definition types.h:1732
b3TreeNodeChildren children
Children (internal node).
int child1
child node index 1
Definition types.h:1675
uint64_t version
The dynamic tree version.
Definition types.h:1723
uint64_t userData
User data (leaf node).
int freeList
Node free list.
Definition types.h:1741
int child2
child node index 2
Definition types.h:1676
int rebuildCapacity
Allocated space for rebuilding.
Definition types.h:1756
int nodeVisits
Number of internal nodes visited during the query.
Definition types.h:1763
int root
The root index.
Definition types.h:1729
int leafVisits
Number of leaf nodes visited during the query.
Definition types.h:1766
b3AABB * leafBoxes
Leaf bounding boxes for rebuild.
Definition types.h:1747
b3TreeNode * nodes
The tree nodes.
Definition types.h:1726
int next
The node freelist next index (free node).
int parent
The node parent index (allocated node).
int proxyCount
Number of proxies created.
Definition types.h:1738
int * leafIndices
Leaf indices for rebuild.
Definition types.h:1744
float b3TreeBoxCastCallbackFcn(const b3BoxCastInput *input, int proxyId, uint64_t userData, void *context)
This function receives clipped AABB cast input for a proxy.
Definition types.h:1782
float b3TreeRayCastCallbackFcn(const b3RayCastInput *input, int proxyId, uint64_t userData, void *context)
This function receives clipped ray cast input for a proxy.
Definition types.h:1789
bool b3TreeQueryCallbackFcn(int proxyId, uint64_t userData, void *context)
This function receives proxies found in the AABB query.
Definition types.h:1771
b3TreeNodeFlags
Flags for tree nodes. For internal usage.
Definition types.h:1666
float b3TreeQueryClosestCallbackFcn(float distanceSqrMin, int proxyId, uint64_t userData, void *context)
This function receives the minimum distance squared so far and proxy to check in the closest query.
Definition types.h:1775
The dynamic tree structure.
Definition types.h:1720
Tree node child indices. For internal usage.
Definition types.h:1674
These are performance results returned by dynamic tree queries.
Definition types.h:1761
float angularDampingRatio
Linear damping ratio, non-dimensional. Use 1 for critical damping.
Definition types.h:931
float linearHertz
Linear stiffness expressed as Hertz (cycles per second). Use zero for maximum stiffness.
Definition types.h:922
float linearDampingRatio
Linear damping ratio, non-dimensional. Use 1 for critical damping.
Definition types.h:928
float angularHertz
Angular stiffness as Hertz (cycles per second). Use zero for maximum stiffness.
Definition types.h:925
b3JointDef base
Base joint definition.
Definition types.h:919
b3WeldJointDef b3DefaultWeldJointDef(void)
Use this to initialize your joint definition.
Weld joint definition Connects two bodies together rigidly.
Definition types.h:917
float maxSteeringTorque
The maximum steering torque in N*m.
Definition types.h:989
bool enableSteering
Enable steering, otherwise the steering is fixed forward.
Definition types.h:977
bool enableSuspensionSpring
Enable a linear spring along the local axis.
Definition types.h:950
float lowerSteeringLimit
The lower steering angle in radians.
Definition types.h:995
float spinSpeed
The desired motor speed in radians per second.
Definition types.h:974
bool enableSteeringLimit
Enable/disable the steering angular limit.
Definition types.h:992
float targetSteeringAngle
The target steering angle in radians.
Definition types.h:986
float steeringHertz
Steering stiffness in Hertz.
Definition types.h:980
bool enableSuspensionLimit
Enable/disable the joint linear limit.
Definition types.h:959
float upperSuspensionLimit
The upper translation limit.
Definition types.h:965
float upperSteeringLimit
The upper steering angle in radians.
Definition types.h:998
float lowerSuspensionLimit
The lower suspension translation limit.
Definition types.h:962
float maxSpinTorque
The maximum motor torque, typically in newton-meters.
Definition types.h:971
float suspensionHertz
Spring stiffness in Hertz.
Definition types.h:953
float steeringDampingRatio
Spring damping ratio, non-dimensional.
Definition types.h:983
b3JointDef base
Base joint definition.
Definition types.h:947
bool enableSpinMotor
Enable/disable the joint rotational motor.
Definition types.h:968
float suspensionDampingRatio
Spring damping ratio, non-dimensional.
Definition types.h:956
b3WheelJointDef b3DefaultWheelJointDef(void)
Use this to initialize your joint definition.
Wheel joint definition Body A is the chassis and body B is the wheel.
Definition types.h:945
float contactDampingRatio
Contact bounciness.
Definition types.h:158
float contactHertz
Contact stiffness. Cycles per second. Increasing this increases the speed of overlap recovery,...
Definition types.h:154
b3Capacity capacity
Optional initial capacities.
Definition types.h:211
b3Vec3 gravity
Gravity vector. Box3D has no up-vector defined.
Definition types.h:143
void * userData
User data associated with a world.
Definition types.h:198
b3RestitutionCallback * restitutionCallback
Optional mixing callback for restitution. The default uses max(restitutionA, restitutionB).
Definition types.h:172
float contactSpeed
This parameter controls how fast overlap is resolved and usually has units of meters per second.
Definition types.h:163
float falloff
The falloff distance beyond the radius. Impulse is reduced to zero at this distance.
Definition types.h:1020
uint32_t workerCount
Number of workers to use with the provided task system.
Definition types.h:186
float radius
The radius of the explosion.
Definition types.h:1017
int contactCount
Number of expected contacts.
Definition types.h:135
bool enableContinuous
Enable continuous collision.
Definition types.h:178
int dynamicBodyCount
Number of expected dynamic and kinematic bodies.
Definition types.h:132
b3FrictionCallback * frictionCallback
Optional mixing callback for friction. The default uses sqrt(frictionA * frictionB).
Definition types.h:169
b3Pos position
The center of the explosion in world space.
Definition types.h:1014
b3FinishTaskCallback * finishTask
function to finish a task
Definition types.h:192
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:214
b3DestroyDebugShapeCallback * destroyDebugShape
Used to destroy debug draw shapes. This is called when a shape is modified or destroyed.
Definition types.h:205
void * userDebugShapeContext
This is passed to the debug shape callbacks to provide a user context.
Definition types.h:208
float impulsePerArea
Impulse per unit area.
Definition types.h:1025
int staticBodyCount
Number of expected static bodies.
Definition types.h:129
void * userTaskContext
User context that is provided to enqueueTask and finishTask.
Definition types.h:195
b3CreateDebugShapeCallback * createDebugShape
Used to create debug draw shapes.
Definition types.h:202
float hitEventThreshold
Hit event speed threshold, usually in m/s.
Definition types.h:151
uint64_t maskBits
Mask bits to filter shapes.
Definition types.h:1011
int staticShapeCount
Number of expected static shapes.
Definition types.h:123
int dynamicShapeCount
Number of expected dynamic and kinematic shapes.
Definition types.h:126
float restitutionThreshold
Restitution speed threshold, usually in m/s.
Definition types.h:147
b3EnqueueTaskCallback * enqueueTask
function to spawn task
Definition types.h:189
bool enableSleep
Can bodies go to sleep to improve performance.
Definition types.h:175
float maximumLinearSpeed
Maximum linear speed. Usually meters per second.
Definition types.h:166
void b3TaskCallback(void *taskContext)
Task interface This is the prototype for a Box3D task.
Definition types.h:20
b3WorldDef b3DefaultWorldDef(void)
Use this to initialize your world definition.
bool b3PreSolveFcn(b3ShapeId shapeIdA, b3ShapeId shapeIdB, b3Pos point, b3Vec3 normal, void *context)
Prototype for a pre-solve callback.
Definition types.h:88
b3ExplosionDef b3DefaultExplosionDef(void)
Use this to initialize your explosion definition.
bool b3CustomFilterFcn(b3ShapeId shapeIdA, b3ShapeId shapeIdB, void *context)
Prototype for a contact filter callback.
Definition types.h:73
void * b3EnqueueTaskCallback(b3TaskCallback *task, void *taskContext, void *userContext, const char *taskName)
These functions can be provided to Box3D to invoke a task system.
Definition types.h:31
float b3FrictionCallback(float frictionA, uint64_t userMaterialIdA, float frictionB, uint64_t userMaterialIdB)
Optional friction mixing callback.
Definition types.h:54
float b3RestitutionCallback(float restitutionA, uint64_t userMaterialIdA, float restitutionB, uint64_t userMaterialIdB)
Optional restitution mixing callback.
Definition types.h:60
void b3FinishTaskCallback(void *userTask, void *userContext)
Finishes a user task object that wraps a Box3D task.
Definition types.h:40
bool b3OverlapResultFcn(b3ShapeId shapeId, void *context)
Prototype callback for overlap queries.
Definition types.h:95
float b3CastResultFcn(b3ShapeId shapeId, b3Pos point, b3Vec3 normal, float fraction, uint64_t userMaterialId, int triangleIndex, int childIndex, void *context)
Prototype callback for ray casts.
Definition types.h:115
Optional world capacities that can be use to avoid run-time allocations.
Definition types.h:121
The explosion definition is used to configure options for explosions.
Definition types.h:1009
World definition used to create a simulation world.
Definition types.h:141
Child shape of a compound.
Definition types.h:2519
b3Transform transform
Transform of the shape into compound local space.
Definition types.h:2530
b3ShapeType type
The shape type (union tag).
Definition types.h:2537
int materialIndices[B3_MAX_COMPOUND_MESH_MATERIALS]
Material indices.
Definition types.h:2534
This struct is passed to b3World_Draw to draw a debug view of the simulation world.
Definition types.h:2949
void(* DrawSegmentFcn)(b3Pos p1, b3Pos p2, b3HexColor color, void *context)
Draw a line segment.
Definition types.h:2954
float jointScale
Global scaling for joint drawing.
Definition types.h:2984
bool drawShapes
Option to draw shapes.
Definition types.h:2987
void * context
User context that is passed as an argument to drawing callback functions.
Definition types.h:3029
int drawAnchorA
Draw contact anchor A or B.
Definition types.h:3008
void(* DrawSphereFcn)(b3Pos p, float radius, b3HexColor color, float alpha, void *context)
Draw a sphere.
Definition types.h:2963
bool drawGraphColors
Option to visualize the graph coloring used for contacts and joints.
Definition types.h:3011
void(* DrawStringFcn)(b3Pos p, const char *s, b3HexColor color, void *context)
Draw a string in world space.
Definition types.h:2975
void(* DrawBoundsFcn)(b3AABB aabb, b3HexColor color, void *context)
Draw a bounding box.
Definition types.h:2969
bool drawFrictionForces
Option to draw contact friction forces.
Definition types.h:3023
bool(* DrawShapeFcn)(void *userShape, b3WorldTransform transform, b3HexColor color, void *context)
Draws a shape and returns true if drawing should continue.
Definition types.h:2951
bool drawBounds
Option to draw the bounding boxes for shapes.
Definition types.h:2996
bool drawContacts
Option to draw contact points.
Definition types.h:3005
bool drawContactForces
Option to draw contact normal forces.
Definition types.h:3020
void(* DrawBoxFcn)(b3Vec3 extents, b3WorldTransform transform, b3HexColor color, void *context)
Draw an oriented box.
Definition types.h:2972
bool drawMass
Option to draw the mass and center of mass of dynamic bodies.
Definition types.h:2999
void(* DrawPointFcn)(b3Pos p, float size, b3HexColor color, void *context)
Draw a point.
Definition types.h:2960
bool drawJointExtras
Option to draw additional information for joints.
Definition types.h:2993
b3AABB drawingBounds
World bounds to use for debug draw.
Definition types.h:2978
void(* DrawCapsuleFcn)(b3Pos p1, b3Pos p2, float radius, b3HexColor color, float alpha, void *context)
Draw a capsule.
Definition types.h:2966
bool drawBodyNames
Option to draw body names.
Definition types.h:3002
bool drawJoints
Option to draw joints.
Definition types.h:2990
bool drawIslands
Option to draw islands as bounding boxes.
Definition types.h:3026
void(* DrawTransformFcn)(b3WorldTransform transform, void *context)
Draw a transform. Choose your own length scale.
Definition types.h:2957
bool drawContactFeatures
Option to draw contact features.
Definition types.h:3014
bool drawContactNormals
Option to draw contact normals.
Definition types.h:3017
float forceScale
Scale to use when drawing forces.
Definition types.h:2981
This is sent to the user for debug shape creation.
Definition types.h:2926
b3ShapeType type
Shape type.
Definition types.h:2931
b3ShapeId shapeId
Shape id.
Definition types.h:2928
A mesh BVH node.
Definition types.h:2111
uint32_t triangleOffset
The index of the leaf triangles.
Definition types.h:2142
union b3MeshNode::@177200325063254046111370015225332352105064355320 data
Anonymous union.
b3Vec3 lowerBound
The lower bound of the node AABB. Strategic placement for SIMD.
Definition types.h:2113
b3Vec3 upperBound
The upper bound of the node AABB. Strategic placement for SIMD.
Definition types.h:2139
A node in the dynamic tree.
Definition types.h:1682
uint64_t categoryBits
Category bits for collision filtering.
Definition types.h:1687
uint16_t height
Height of the node. Leaves have a height of 0.
Definition types.h:1708
uint16_t flags
Definition types.h:1711
b3AABB aabb
The node bounding box.
Definition types.h:1684