New sample renderer and UI (#10)

No changes to simulation
This commit is contained in:
Erin Catto 2026-06-06 10:06:05 -07:00 • committed by GitHub
commit 9e02b7f3b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
196 changed files with 116992 additions and 29969 deletions

View file

@ -158,6 +158,9 @@ B3_API float b3GetMillisecondsAndReset( uint64_t* ticks );
/// Yield to be used in a busy loop.
B3_API void b3Yield( void );
/// Sleep the current thread for a number of milliseconds.
B3_API void b3Sleep( int milliseconds );
// Simple djb2 hash function for determinism testing
#define B3_HASH_INIT 5381
B3_API uint32_t b3Hash( uint32_t hash, const uint8_t* data, int count );

View file

@ -31,7 +31,8 @@ typedef struct b3SurfaceMaterial
/// combining functions. It is not used internally.
uint64_t userMaterialId;
/// Custom debug draw color. Ignored if 0.
/// Custom debug draw color. Ignored if 0. The low 24 bits are RGB. The high byte may
/// carry a b3DebugMaterial preset, see b3MakeDebugColor.
/// @see b3HexColor
uint32_t customColor;
} b3SurfaceMaterial;

View file

@ -1457,6 +1457,27 @@ typedef enum b3HexColor
b3_colorBox2DYellow = 0xFFEE8C
} b3HexColor;
/// Debug draw material preset. Optionally packed into the unused high byte of a
/// b3HexColor (or b3SurfaceMaterial::customColor) to drive the renderer's PBR
/// roughness and metalness. The low 24 bits stay RGB, so a plain 0xRRGGBB color
/// reads as b3_debugMaterialDefault and keeps the renderer's per-body-type look.
typedef enum b3DebugMaterial
{
b3_debugMaterialDefault = 0,
b3_debugMaterialMatte,
b3_debugMaterialSoft,
b3_debugMaterialDead,
b3_debugMaterialGlossy,
b3_debugMaterialMetallic
} b3DebugMaterial;
/// Pack an RGB color with a material preset for debug draw. The preset rides in
/// the high byte where the color converters ignore it.
B3_INLINE uint32_t b3MakeDebugColor( b3HexColor rgb, b3DebugMaterial material )
{
return ( (uint32_t)rgb & 0x00FFFFFFu ) | ( (uint32_t)material << 24 );
}
/// Get the visualization color assigned to a constraint graph color slot. The last index
/// (B3_GRAPH_COLOR_COUNT - 1) is the overflow color.
B3_API b3HexColor b3GetGraphColor( int index );