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

@ -18,6 +18,18 @@
#define BENCHMARK_DEBUG 1
#endif
static b3ShapeId g_groundShapeId = { 0 };
b3ShapeId GetGroundShapeId( void )
{
return g_groundShapeId;
}
void ResetGroundShapeId( void )
{
g_groundShapeId = b3_nullShapeId;
}
void CreateJointGrid( b3WorldId worldId )
{
b3World_EnableSleeping( worldId, false );
@ -94,12 +106,12 @@ void CreateLargePyramid( b3WorldId worldId )
{
b3BodyDef bodyDef = b3DefaultBodyDef();
bodyDef.position = (b3Vec3){ 0.0f, -1.0f };
bodyDef.position = (b3Vec3){ 0.0f, -1.0f, 0.0f };
b3BodyId groundId = b3CreateBody( worldId, &bodyDef );
b3BoxHull box = b3MakeBoxHull( 100.0f, 1.0f, 100.0f );
b3ShapeDef shapeDef = b3DefaultShapeDef();
b3CreateHullShape( groundId, &shapeDef, &box.base );
g_groundShapeId = b3CreateHullShape( groundId, &shapeDef, &box.base );
}
b3BodyDef bodyDef = b3DefaultBodyDef();
@ -133,12 +145,12 @@ void CreateWidePyramid( b3WorldId worldId )
{
{
b3BodyDef bodyDef = b3DefaultBodyDef();
bodyDef.position = (b3Vec3){ 0.0f, -1.0f };
bodyDef.position = (b3Vec3){ 0.0f, -1.0f, 0.0f };
b3BodyId groundId = b3CreateBody( worldId, &bodyDef );
b3BoxHull box = b3MakeBoxHull( 100.0f, 1.0f, 100.0f );
b3ShapeDef shapeDef = b3DefaultShapeDef();
b3CreateHullShape( groundId, &shapeDef, &box.base );
g_groundShapeId = b3CreateHullShape( groundId, &shapeDef, &box.base );
}
const float boxSize = 2.0f;
@ -178,6 +190,7 @@ static void CreateSmallPyramid( b3WorldId worldId, int baseCount, float extent,
bodyDef.enableSleep = false;
b3ShapeDef shapeDef = b3DefaultShapeDef();
shapeDef.density = 100.0f;
b3BoxHull box = b3MakeBoxHull( extent, extent, extent );
@ -210,9 +223,8 @@ void CreateManyPyramids( b3WorldId worldId )
b3BodyId groundId = b3CreateBody( worldId, &bodyDef );
b3ShapeDef shapeDef = b3DefaultShapeDef();
b3BoxHull box = b3MakeBoxHull( groundExtent, 1.0f, groundExtent );
b3CreateHullShape( groundId, &shapeDef, &box.base );
g_groundShapeId = b3CreateHullShape( groundId, &shapeDef, &box.base );
}
float baseWidth = 2.0f * extent * baseCount;
@ -532,7 +544,7 @@ void CreateWasher( b3WorldId worldId )
b3BoxHull box = b3MakeBoxHull( 60.0f, 1.0f, 60.0f );
b3ShapeDef shapeDef = b3DefaultShapeDef();
b3CreateHullShape( groundId, &shapeDef, &box.base );
g_groundShapeId = b3CreateHullShape( groundId, &shapeDef, &box.base );
}
{
@ -794,7 +806,7 @@ void CreateJunkyard( b3WorldId worldId )
b3ShapeDef shapeDef = b3DefaultShapeDef();
{
b3BoxHull box = b3MakeBoxHull( 120.0f, 1.0f, 120.0f );
b3CreateHullShape( groundId, &shapeDef, &box.base );
g_groundShapeId = b3CreateHullShape( groundId, &shapeDef, &box.base );
}
{
b3Vec3 offset = { -50.0f, 8.0f, 0.0f };

View file

@ -15,6 +15,11 @@ extern "C"
{
#endif
// This is used by the sample app to draw a ground grid. Should only
// be used for box hulls.
b3ShapeId GetGroundShapeId( void );
void ResetGroundShapeId( void );
void CreateTrees25( b3WorldId worldId );
void CreateTrees50( b3WorldId worldId );
void CreateTrees100( b3WorldId worldId );

View file

@ -623,6 +623,15 @@ void Human_CreateParallelAnchors( Human* human, b3WorldId worldId )
}
}
void Human_SetBullet(Human* human, bool flag)
{
for ( int i = 0; i < bone_count; ++i )
{
Bone* bone = human->bones + i;
b3Body_SetBullet( bone->bodyId, flag );
}
}
#if 0
void Human::EnablePoseControl( b3World* world, float springHertz, bool poseControl )
{

View file

@ -73,6 +73,8 @@ void Human_AlignSpring( Human* human, b3WorldId worldId, b3BodyId groundId, floa
void Human_CreateMotorAnchors( Human* human, b3WorldId worldId );
void Human_CreateParallelAnchors( Human* human, b3WorldId worldId );
void Human_SetBullet( Human* human, bool flag );
// void Human_EnablePoseControl( Human* human, float springHertz, bool enablePoseControl );
// void Human_AdjustPoseControl( Human* human, float springHertz );
// void Human_DriveBase( Human* human, b3Transform transform, float timeStep );

View file

@ -25,7 +25,7 @@ OverflowColorPileData CreateOverflowColorPile( b3WorldId worldId )
b3BoxHull box = b3MakeBoxHull( 20.0f, 1.0f, 20.0f );
b3ShapeDef shapeDef = b3DefaultShapeDef();
b3CreateHullShape( groundId, &shapeDef, &box.base );
data.groundShapeId = b3CreateHullShape( groundId, &shapeDef, &box.base );
}
// Tall, heavy hub. Tall so neighbors can ring around it in multiple

View file

@ -15,6 +15,7 @@ extern "C"
// exercising the b3*_Overflow solver path that no other scene reaches.
typedef struct OverflowColorPileData
{
b3ShapeId groundShapeId;
b3BodyId hubId;
int neighborCount;
} OverflowColorPileData;