Skip to content

Commit

Permalink
Getting ready (#181)
Browse files Browse the repository at this point in the history
New clang format.
Clean up.
  • Loading branch information
erincatto committed Aug 10, 2024
1 parent 7fdd976 commit 73f572b
Show file tree
Hide file tree
Showing 118 changed files with 14,372 additions and 13,702 deletions.
7 changes: 6 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ IndentAccessModifiers: false
AccessModifierOffset: -4

# AlignArrayOfStructures: Left
# AlignAfterOpenBracket: BlockIndent
# AlignAfterOpenBracket: BlockIndent

SpacesInParens: Custom
SpacesInParensOptions:
Other: true

9 changes: 9 additions & 0 deletions benchmark/amd7950x_sse2/joint_grid.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
threads,fps
1,357.551
2,691.193
3,1010.45
4,1317.42
5,1590.65
6,1858.78
7,2074.2
8,2261.67
9 changes: 9 additions & 0 deletions benchmark/amd7950x_sse2/large_pyramid.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
threads,fps
1,186.185
2,351.045
3,511.316
4,636.035
5,765.404
6,875.296
7,991.353
8,961.402
9 changes: 9 additions & 0 deletions benchmark/amd7950x_sse2/many_pyramids.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
threads,fps
1,48.5561
2,92.6231
3,137.175
4,176.644
5,214.941
6,253.39
7,288.631
8,312.527
9 changes: 9 additions & 0 deletions benchmark/amd7950x_sse2/smash.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
threads,fps
1,142.532
2,228.987
3,299.951
4,364.679
5,413.564
6,453.351
7,489.239
8,519.379
9 changes: 9 additions & 0 deletions benchmark/amd7950x_sse2/tumbler.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
threads,fps
1,276.905
2,453.522
3,592.946
4,702.383
5,826.52
6,919.179
7,1009.05
8,1062.61
40 changes: 20 additions & 20 deletions benchmark/joint_grid.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@

#include <stdlib.h>

b2WorldId JointGrid(b2WorldDef* worldDef)
b2WorldId JointGrid( b2WorldDef* worldDef )
{
// Turning gravity off to isolate joint performance.
worldDef->gravity = b2Vec2_zero;

b2WorldId worldId = b2CreateWorld(worldDef);
b2WorldId worldId = b2CreateWorld( worldDef );

#ifdef NDEBUG
int N = 100;
#else
int N = 10;
#endif

// Allocate to avoid huge stack usage
b2BodyId* bodies = malloc(N * N * sizeof(b2BodyId));
b2BodyId* bodies = malloc( N * N * sizeof( b2BodyId ) );
int index = 0;

b2ShapeDef shapeDef = b2DefaultShapeDef();
shapeDef.density = 1.0f;
shapeDef.filter.categoryBits = 2;
shapeDef.filter.maskBits = ~2u;

b2Circle circle = {{0.0f, 0.0f}, 0.4f};
b2Circle circle = { { 0.0f, 0.0f }, 0.4f };

b2RevoluteJointDef jd = b2DefaultRevoluteJointDef();
b2BodyDef bodyDef = b2DefaultBodyDef();
bodyDef.enableSleep = false;

for (int k = 0; k < N; ++k)
for ( int k = 0; k < N; ++k )
{
for (int i = 0; i < N; ++i)
for ( int i = 0; i < N; ++i )
{
float fk = (float)k;
float fi = (float)i;

if (k >= N / 2 - 3 && k <= N / 2 + 3 && i == 0)
if ( k >= N / 2 - 3 && k <= N / 2 + 3 && i == 0 )
{
bodyDef.type = b2_staticBody;
}
Expand All @@ -50,35 +50,35 @@ b2WorldId JointGrid(b2WorldDef* worldDef)
bodyDef.type = b2_dynamicBody;
}

bodyDef.position = (b2Vec2){fk, -fi};
bodyDef.position = ( b2Vec2 ){ fk, -fi };

b2BodyId body = b2CreateBody(worldId, &bodyDef);
b2BodyId body = b2CreateBody( worldId, &bodyDef );

b2CreateCircleShape(body, &shapeDef, &circle);
b2CreateCircleShape( body, &shapeDef, &circle );

if (i > 0)
if ( i > 0 )
{
jd.bodyIdA = bodies[index - 1];
jd.bodyIdB = body;
jd.localAnchorA = (b2Vec2){0.0f, -0.5f};
jd.localAnchorB = (b2Vec2){0.0f, 0.5f};
b2CreateRevoluteJoint(worldId, &jd);
jd.localAnchorA = ( b2Vec2 ){ 0.0f, -0.5f };
jd.localAnchorB = ( b2Vec2 ){ 0.0f, 0.5f };
b2CreateRevoluteJoint( worldId, &jd );
}

if (k > 0)
if ( k > 0 )
{
jd.bodyIdA = bodies[index - N];
jd.bodyIdB = body;
jd.localAnchorA = (b2Vec2){0.5f, 0.0f};
jd.localAnchorB = (b2Vec2){-0.5f, 0.0f};
b2CreateRevoluteJoint(worldId, &jd);
jd.localAnchorA = ( b2Vec2 ){ 0.5f, 0.0f };
jd.localAnchorB = ( b2Vec2 ){ -0.5f, 0.0f };
b2CreateRevoluteJoint( worldId, &jd );
}

bodies[index++] = body;
}
}

free(bodies);
free( bodies );

return worldId;
}
28 changes: 14 additions & 14 deletions benchmark/large_pyramid.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
#include "box2d/box2d.h"
#include "box2d/math_functions.h"

b2WorldId LargePyramid(b2WorldDef* worldDef)
b2WorldId LargePyramid( b2WorldDef* worldDef )
{
#ifdef NDEBUG
int baseCount = 100;
#else
int baseCount = 20;
#endif

b2WorldId worldId = b2CreateWorld(worldDef);
b2WorldId worldId = b2CreateWorld( worldDef );

{
b2BodyDef bodyDef = b2DefaultBodyDef();
bodyDef.position = (b2Vec2){0.0f, -1.0f};
b2BodyId groundId = b2CreateBody(worldId, &bodyDef);
bodyDef.position = ( b2Vec2 ){ 0.0f, -1.0f };
b2BodyId groundId = b2CreateBody( worldId, &bodyDef );

b2Polygon box = b2MakeBox(100.0f, 1.0f);
b2Polygon box = b2MakeBox( 100.0f, 1.0f );
b2ShapeDef shapeDef = b2DefaultShapeDef();
b2CreatePolygonShape(groundId, &shapeDef, &box);
b2CreatePolygonShape( groundId, &shapeDef, &box );
}

b2BodyDef bodyDef = b2DefaultBodyDef();
Expand All @@ -32,22 +32,22 @@ b2WorldId LargePyramid(b2WorldDef* worldDef)
shapeDef.density = 1.0f;

float h = 0.5f;
b2Polygon box = b2MakeSquare(h);
b2Polygon box = b2MakeSquare( h );

float shift = 1.0f * h;

for (int i = 0; i < baseCount; ++i)
for ( int i = 0; i < baseCount; ++i )
{
float y = (2.0f * i + 1.0f) * shift;
float y = ( 2.0f * i + 1.0f ) * shift;

for (int j = i; j < baseCount; ++j)
for ( int j = i; j < baseCount; ++j )
{
float x = (i + 1.0f) * shift + 2.0f * (j - i) * shift - h * baseCount;
float x = ( i + 1.0f ) * shift + 2.0f * ( j - i ) * shift - h * baseCount;

bodyDef.position = (b2Vec2){x, y};
bodyDef.position = ( b2Vec2 ){ x, y };

b2BodyId bodyId = b2CreateBody(worldId, &bodyDef);
b2CreatePolygonShape(bodyId, &shapeDef, &box);
b2BodyId bodyId = b2CreateBody( worldId, &bodyDef );
b2CreatePolygonShape( bodyId, &shapeDef, &box );
}
}

Expand Down
Loading

0 comments on commit 73f572b

Please sign in to comment.