Missing functions (#21)
- add some missing functions - added config.h for users that vendor Box3D - joint unit tests - improve joint limit consistency - extend build matrix
This commit is contained in:
parent
70ba099709
commit
8441b4a06d
31 changed files with 918 additions and 410 deletions
|
|
@ -6,9 +6,19 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// Compile-time options. Edit box3d/config.h, or define BOX3D_USER_CONFIG to
|
||||
// point at your own copy.
|
||||
#ifdef BOX3D_USER_CONFIG
|
||||
#include BOX3D_USER_CONFIG
|
||||
#endif
|
||||
#include "config.h"
|
||||
|
||||
// clang-format off
|
||||
//
|
||||
// Shared library macros
|
||||
// Predefine BOX3D_EXPORT to reuse an existing export/import scheme, for example
|
||||
// when compiling Box3D into another shared library.
|
||||
#ifndef BOX3D_EXPORT
|
||||
#if defined(_WIN32) && defined(box3d_EXPORTS)
|
||||
// build the Windows DLL
|
||||
#define BOX3D_EXPORT __declspec(dllexport)
|
||||
|
|
@ -22,6 +32,7 @@
|
|||
// static library
|
||||
#define BOX3D_EXPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// C++ macros
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -500,7 +500,7 @@ B3_API b3BodyType b3Body_GetType( b3BodyId bodyId );
|
|||
/// properties regardless of the automatic mass setting.
|
||||
B3_API void b3Body_SetType( b3BodyId bodyId, b3BodyType type );
|
||||
|
||||
/// Set the body name. Up to B3_NAME_LENGTH characters including null termination.
|
||||
/// Set the body name. Up to B3_BODY_NAME_LENGTH characters including null termination.
|
||||
B3_API void b3Body_SetName( b3BodyId bodyId, const char* name );
|
||||
|
||||
/// Get the body name.
|
||||
|
|
@ -1382,7 +1382,6 @@ B3_API float b3PrismaticJoint_GetSpeed( b3JointId jointId );
|
|||
* @defgroup revolute_joint Revolute Joint
|
||||
* @brief A revolute joint allows for relative rotation about a single axis with no relative translation.
|
||||
*
|
||||
* The revolute joint is probably the most common joint. It can be used for ragdolls and chains.
|
||||
* Also called a *hinge* or *pin* joint.
|
||||
* @{
|
||||
*/
|
||||
|
|
|
|||
31
include/box3d/config.h
Normal file
31
include/box3d/config.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// SPDX-FileCopyrightText: 2026 Erin Catto
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
// Box3D compile-time options.
|
||||
//
|
||||
// Normally set by the CMake BOX3D_* options. If you build Box3D without its
|
||||
// CMake (dropping the sources into another project), set them here so the
|
||||
// library and your code agree. Edit this file, or keep your settings elsewhere
|
||||
// and point Box3D at them from your build:
|
||||
//
|
||||
// #define BOX3D_USER_CONFIG "my_box3d_config.h"
|
||||
//
|
||||
// A define passed on the compiler command line still wins over this file.
|
||||
|
||||
// Large world mode. Stores world positions in double precision. Affects ABI.
|
||||
//#define BOX3D_DOUBLE_PRECISION
|
||||
|
||||
// Build the scalar fallback instead of SSE2/NEON.
|
||||
//#define BOX3D_DISABLE_SIMD
|
||||
|
||||
// Enable internal validation in debug builds.
|
||||
//#define BOX3D_VALIDATE
|
||||
|
||||
// Decorate the public API with your own export macro instead of Box3D's
|
||||
// box3d_EXPORTS/BOX3D_DLL scheme, for example when compiling Box3D into another
|
||||
// shared library. A single value cannot switch between dllexport and dllimport,
|
||||
// so this suits embedding more than shipping Box3D as its own DLL.
|
||||
//#define BOX3D_EXPORT MYENGINE_API
|
||||
|
||||
|
|
@ -98,8 +98,16 @@ B3_API float b3GetStallThreshold( void );
|
|||
#define B3_TIME_TO_SLEEP 0.5f
|
||||
|
||||
/// Maximum length of the body name. Can be 0 if you don't need names.
|
||||
#ifndef B3_NAME_LENGTH
|
||||
#define B3_NAME_LENGTH 18
|
||||
/// Note: this gates recording capability.
|
||||
#ifndef B3_BODY_NAME_LENGTH
|
||||
#define B3_BODY_NAME_LENGTH 18
|
||||
#endif
|
||||
|
||||
/// Maximum length of the shape name. Can be 0 if you don't need names.
|
||||
/// Note: this gates recording capability.
|
||||
/// todo waiting on this because it breaks existing recordings
|
||||
#ifndef B3_SHAPE_NAME_LENGTH
|
||||
#define B3_SHAPE_NAME_LENGTH 18
|
||||
#endif
|
||||
|
||||
/// The maximum number of contact points between two touching shapes.
|
||||
|
|
|
|||
|
|
@ -30,7 +30,12 @@ typedef void b3TaskCallback( void* taskContext );
|
|||
/// @ingroup world
|
||||
typedef void* b3EnqueueTaskCallback( b3TaskCallback* task, void* taskContext, void* userContext, const char* taskName );
|
||||
|
||||
/// Finishes a user task object that wraps a Box3D task.
|
||||
/// Finishes a user task object that wraps a Box3D task. This must block until the task has completed.
|
||||
/// The step blocks here on the tasks it spawned, so b3World_Step holds its stack across every
|
||||
/// fork/join. Drive it from a thread you can dedicate to the step, or from a fiber this callback can
|
||||
/// park to free the underlying thread. In a job system that cannot park a job's stack, do not call
|
||||
/// b3World_Step from inside a job: a job that blocks on its own sub-jobs without yielding its thread
|
||||
/// can deadlock. The in-tree scheduler instead runs other pending tasks on the waiting thread.
|
||||
/// @ingroup world
|
||||
typedef void b3FinishTaskCallback( void* userTask, void* userContext );
|
||||
|
||||
|
|
@ -175,10 +180,9 @@ typedef struct b3WorldDef
|
|||
/// Number of workers to use with the provided task system. Box3D performs best when using only
|
||||
/// performance cores and accessing a single L2 cache. Efficiency cores and hyper-threading provide
|
||||
/// little benefit and may even harm performance.
|
||||
/// @note Box3D does not create threads. This is the number of threads your applications has created
|
||||
/// that you are allocating to b3World_Step.
|
||||
/// @warning Do not modify the default value unless you are also providing a task system and providing
|
||||
/// task callbacks (enqueueTask and finishTask).
|
||||
/// This is clamped to the range [1, B3_MAX_WORKERS]. Using a value above 1 will turn on multithreading.
|
||||
/// If task callbacks are provided then Box3D will use the user provided task system. Otherwise Box3D
|
||||
/// will create threads and use an internal scheduler.
|
||||
uint32_t workerCount;
|
||||
|
||||
/// function to spawn task
|
||||
|
|
@ -298,7 +302,7 @@ typedef struct b3BodyDef
|
|||
/// Sleep speed threshold, default is 0.05 meters per second
|
||||
float sleepThreshold;
|
||||
|
||||
/// Optional body name for debugging. Up to B3_NAME_LENGTH characters (including null termination)
|
||||
/// Optional body name for debugging. Up to B3_BODY_NAME_LENGTH characters (including null termination)
|
||||
const char* name;
|
||||
|
||||
/// Use this to store application specific body data.
|
||||
|
|
@ -833,10 +837,10 @@ typedef struct b3RevoluteJointDef
|
|||
/// A flag to enable joint limits.
|
||||
bool enableLimit;
|
||||
|
||||
/// The lower angle for the joint limit in radians.
|
||||
/// The lower angle for the joint limit in radians. Minimum of -0.99*pi radians.
|
||||
float lowerAngle;
|
||||
|
||||
/// The upper angle for the joint limit in radians.
|
||||
/// The upper angle for the joint limit in radians. Maximum of 0.99*pi radians.
|
||||
float upperAngle;
|
||||
|
||||
/// A flag to enable the joint motor.
|
||||
|
|
@ -883,10 +887,10 @@ typedef struct b3SphericalJointDef
|
|||
/// A flag to enable the twist limit. The twist is centered on the frameB z-axis.
|
||||
bool enableTwistLimit;
|
||||
|
||||
/// The angle for the lower twist limit in radians. Valid range is [-pi, pi].
|
||||
/// The angle for the lower twist limit in radians. Minimum of -0.99*pi radians.
|
||||
float lowerTwistAngle;
|
||||
|
||||
/// The angle for the upper twist limit in radians. Valid range is [-pi, pi].
|
||||
/// The angle for the upper twist limit in radians. Maximum of 0.99*pi radians.
|
||||
float upperTwistAngle;
|
||||
|
||||
/// A flag to enable the joint motor
|
||||
|
|
|
|||
Loading…
Reference in a new issue