Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph coloring #48

Merged
merged 51 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4f2301f
wip
erincatto Aug 7, 2023
5136235
wip
erincatto Aug 12, 2023
39291dc
wip
erincatto Aug 13, 2023
9bd2843
TGS wip
erincatto Aug 14, 2023
4e3a721
fixes for tgs
erincatto Aug 16, 2023
6392ddb
fixes
erincatto Aug 16, 2023
73ea6a7
high mass ratio test
erincatto Aug 17, 2023
3d29e55
wip
erincatto Aug 23, 2023
9c00dd0
sticky friction
erincatto Aug 26, 2023
bbc3031
wip
erincatto Sep 1, 2023
edbcf14
fixes
erincatto Sep 1, 2023
593c3d2
testing
erincatto Sep 2, 2023
2325a9f
static contacts kinda last
erincatto Sep 3, 2023
9a212e3
weld joint
erincatto Sep 4, 2023
266cd4d
dirk step testing
erincatto Sep 4, 2023
609d1cc
remove Dirk stepper
erincatto Sep 5, 2023
fb4999c
wip
erincatto Sep 10, 2023
a1e48ad
wip
erincatto Sep 11, 2023
2c100a0
wip
erincatto Sep 13, 2023
ee95f57
parallel
erincatto Sep 13, 2023
8b484ae
wip
erincatto Sep 18, 2023
a86f78e
refactored graph solver
erincatto Sep 18, 2023
a7cdad5
clean up
erincatto Sep 19, 2023
6bafbd4
something broke
erincatto Sep 20, 2023
96e1eea
fix worker re-entrance on thread 0
erincatto Sep 21, 2023
1323884
wip
erincatto Sep 23, 2023
dffd3c2
fix joints
erincatto Sep 24, 2023
0d58f34
AVX wip
erincatto Sep 25, 2023
92b7c81
wip
erincatto Sep 26, 2023
add7ec6
more avx
erincatto Sep 27, 2023
2a3b07c
avx stuff
erincatto Oct 5, 2023
3a3eb36
wip hooking up avx
erincatto Oct 6, 2023
2906e7e
avx working
erincatto Oct 7, 2023
d6fb34a
fixes
erincatto Oct 7, 2023
ae8a007
island sleeping wip
erincatto Oct 13, 2023
f34c0f5
island sleeping
erincatto Oct 14, 2023
8aab30e
wip
erincatto Oct 14, 2023
ef603d1
overflow contact contraints support
erincatto Oct 16, 2023
88c1562
wip split islands (crashes)
erincatto Oct 19, 2023
74eb27f
fixed island splitting bug
erincatto Oct 20, 2023
a9f22ac
color stats
erincatto Oct 20, 2023
5e6c6e5
fix invalid islands
erincatto Oct 22, 2023
ddd1f58
continuous wip
erincatto Oct 22, 2023
102b369
continuous working
erincatto Oct 23, 2023
b7d9a60
restitution wip
erincatto Oct 25, 2023
1a03b84
fix restitution
erincatto Oct 26, 2023
a72b970
CI fix
erincatto Oct 26, 2023
4255711
removed FMA
erincatto Oct 26, 2023
a19c0eb
CI fix
erincatto Oct 26, 2023
1697caf
CI fix
erincatto Oct 26, 2023
3017255
CI fixes
erincatto Oct 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterUnion: true
BeforeWhile: true

ColumnLimit: 140
PointerAlignment: Left
UseTab: Always
BreakConstructorInitializers: BeforeComma

# when VS updates clang-format to v16
# InsertNewlineAtEOF: true
InsertNewlineAtEOF: true

IncludeBlocks: Regroup

Expand Down
7 changes: 7 additions & 0 deletions include/box2d/aabb.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ static inline bool b2AABB_Contains(b2AABB a, b2AABB b)
return s;
}

static inline bool b2AABB_ContainsWithMargin(b2AABB a, b2AABB b, float margin)
{
bool s = (a.lowerBound.x <= b.lowerBound.x - margin) & (a.lowerBound.y <= b.lowerBound.y - margin) &
(b.upperBound.x + margin <= a.upperBound.x) & (b.upperBound.y + margin <= a.upperBound.y);
return s;
}

/// Do a and b overlap
static inline bool b2AABB_Overlaps(b2AABB a, b2AABB b)
{
Expand Down
6 changes: 4 additions & 2 deletions include/box2d/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#include <stdint.h>

#ifdef __cplusplus
#define BOX2D_CPP extern "C"
#else
Expand All @@ -22,7 +24,7 @@
#define BOX2D_API BOX2D_CPP
#endif

typedef void* b2AllocFcn(int size);
typedef void* b2AllocFcn(uint32_t size);
typedef void b2FreeFcn(void* mem);

// Return 0 to
Expand All @@ -37,7 +39,7 @@ extern "C"
void b2SetAllocator(b2AllocFcn* allocFcn, b2FreeFcn* freeFcn);

/// Total bytes allocated by Box2D
int b2GetByteCount(void);
uint32_t b2GetByteCount(void);

extern b2AssertFcn* Box2DAssertCallback;

Expand Down
46 changes: 34 additions & 12 deletions include/box2d/box2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ BOX2D_API void b2World_Step(b2WorldId worldId, float timeStep, int32_t velocityI
/// Call this to draw shapes and other debug draw data. This is intentionally non-const.
BOX2D_API void b2World_Draw(b2WorldId worldId, b2DebugDraw* debugDraw);

/// Enable/disable sleep.
BOX2D_API void b2World_EnableSleeping(b2WorldId worldId, bool flag);

/// Enable/disable continuous collision.
BOX2D_API void b2World_EnableContinuous(b2WorldId worldId, bool flag);

/// Get the current profile.
BOX2D_API struct b2Profile b2World_GetProfile(b2WorldId worldId);

BOX2D_API struct b2Statistics b2World_GetStatistics(b2WorldId worldId);

/// Create a rigid body given a definition. No reference to the definition is retained.
/// @warning This function is locked during callbacks.
BOX2D_API b2BodyId b2World_CreateBody(b2WorldId worldId, const b2BodyDef* def);
Expand Down Expand Up @@ -74,20 +63,53 @@ BOX2D_API bool b2Shape_TestPoint(b2ShapeId shapeId, b2Vec2 point);

BOX2D_API b2JointId b2World_CreateMouseJoint(b2WorldId worldId, const b2MouseJointDef* def);
BOX2D_API b2JointId b2World_CreateRevoluteJoint(b2WorldId worldId, const b2RevoluteJointDef* def);
BOX2D_API b2JointId b2World_CreateWeldJoint(b2WorldId worldId, const b2WeldJointDef* def);
BOX2D_API void b2World_DestroyJoint(b2JointId jointId);

BOX2D_API b2BodyId b2Joint_GetBodyA(b2JointId jointId);
BOX2D_API b2BodyId b2Joint_GetBodyB(b2JointId jointId);

BOX2D_API void b2MouseJoint_SetTarget(b2JointId jointId, b2Vec2 target);

BOX2D_API void b2RevoluteJoint_EnableLimit(b2JointId jointId, bool enableLimit);
BOX2D_API void b2RevoluteJoint_EnableMotor(b2JointId jointId, bool enableMotor);
BOX2D_API void b2RevoluteJoint_SetMotorSpeed(b2JointId jointId, float motorSpeed);
BOX2D_API float b2RevoluteJoint_GetMotorTorque(b2JointId jointId, float inverseTimeStep);
BOX2D_API void b2RevoluteJoint_SetMaxMotorTorque(b2JointId jointId, float torque);
BOX2D_API b2Vec2 b2RevoluteJoint_GetConstraintForce(b2JointId jointId);

/// This function receives shapes found in the AABB query.
/// This function receives shapes found in the AABB query.
/// @return true if the query should continue
typedef bool b2QueryCallbackFcn(b2ShapeId shapeId, void* context);

/// Query the world for all shapse that potentially overlap the provided AABB.
/// @param callback a user implemented callback function.
/// @param aabb the query box.
BOX2D_API void b2World_QueryAABB(b2WorldId worldId, b2AABB aabb, b2QueryCallbackFcn* fcn, void* context);


/// Advanced API for testing and special cases

/// Enable/disable sleep.
BOX2D_API void b2World_EnableSleeping(b2WorldId worldId, bool flag);

/// Enable/disable contact warm starting. Improves stacking stability.
BOX2D_API void b2World_EnableWarmStarting(b2WorldId worldId, bool flag);

/// Enable/disable continuous collision.
BOX2D_API void b2World_EnableContinuous(b2WorldId worldId, bool flag);

/// Adjust the restitution threshold
BOX2D_API void b2World_SetRestitutionThreshold(b2WorldId worldId, float value);

/// Adjust the maximum contact constraint push out velocity
BOX2D_API void b2World_SetMaximumPushoutVelocity(b2WorldId worldId, float value);

/// Adjust the contact stiffness in cycles per second.
BOX2D_API void b2World_SetContactHertz(b2WorldId worldId, float value);

/// Get the current profile
BOX2D_API struct b2Profile b2World_GetProfile(b2WorldId worldId);

/// Get counters and sizes
BOX2D_API struct b2Statistics b2World_GetStatistics(b2WorldId worldId);
2 changes: 1 addition & 1 deletion include/box2d/callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef void b2EndContactFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, void* conte
/// get an EndContact callback. However, you may get a BeginContact callback
/// the next step.
/// - the supplied manifold has impulse values from the previous frame
typedef bool b2PreSolveFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Manifold* manifold, void* context);
typedef bool b2PreSolveFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Manifold* manifold, int32_t color, void* context);
BOX2D_API void b2World_SetPreSolveCallback(b2WorldId worldId, b2PreSolveFcn* fcn, void* context);

/// This lets you inspect a contact after the solver is finished. This is useful
Expand Down
Loading