Dynamic Mover (#202)

Port the dynamic character mover from Box2D including the mover joint
and pogo joint.

Match the mover and sample structure of Box2D.
This commit is contained in:
Erin Catto 2026-10-27 22:33:17 -07:00 • committed by GitHub
commit 3362633204
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 4580 additions and 885 deletions

View file

@ -11,6 +11,7 @@
// Fed from the host event loop; read with the KEY_* aliases in gfx/keycodes.h.
bool IsKeyDown( int key );
void SetKeyDown( int key, bool down );
void ClearKeysDown();
// Key action passed to Keyboard, matching the old GLFW press/release values so
// sample code reads naturally without leaking sokol_app event types.
@ -20,6 +21,17 @@ enum
ACTION_PRESS = 1,
};
// Character input relative to the camera. Throttle x is forward and y is right.
struct MoverInput
{
b3Vec3 forward;
b3Vec3 right;
b3Vec2 throttle;
bool jump;
bool sprint;
bool walk;
};
struct SampleContext
{
void Save();
@ -85,6 +97,9 @@ struct SampleContext
// UI visibility (Tab / View > Hide UI). When hidden only the minimal HUD shows.
bool showUI = true;
// Viewport text: HUD, sample text lines and world labels.
bool showText = true;
// Bottom metrics drawer (M), set by Ctrl+O for the fuzzy picker.
bool showMetrics = false;
bool openSamplePicker = false;
@ -211,6 +226,9 @@ public:
void ToggleThirdPerson();
// WASD, space, shift and ctrl, active only in third person so the free camera keeps its keys.
MoverInput GetMoverInput() const;
B3_PRINTF_FORMAT( 2, 3 )
void DrawTextLine( const char* text, ... );
void ResetProfile();