#pragma once
#include "bitset.h"
#include "contact.h"
#include "joint.h"
#include "box2d/constants.h"
#include "box2d/types.h"
typedef struct b2Body b2Body;
typedef struct b2Contact b2Contact;
typedef struct b2StepContext b2StepContext;
typedef struct b2World b2World;
#define B2_OVERFLOW_INDEX ( B2_GRAPH_COLOR_COUNT - 1 )
#define B2_DYNAMIC_COLOR_COUNT ( B2_GRAPH_COLOR_COUNT - 4 )
typedef struct b2GraphColor
{
b2BitSet bodySet;
b2Array( b2ContactSim ) contactSims;
b2Array( b2JointSim ) jointSims;
union
{
struct b2ContactConstraintWide* wideConstraints;
struct b2ContactConstraint* overflowConstraints;
};
int wideConstraintCount;
} b2GraphColor;
typedef struct b2ConstraintGraph
{
b2GraphColor colors[B2_GRAPH_COLOR_COUNT];
} b2ConstraintGraph;
void b2CreateGraph( b2ConstraintGraph* graph, const b2Capacity* capacity );
void b2DestroyGraph( b2ConstraintGraph* graph );
void b2AddContactToGraph( b2World* world, b2ContactSim* contactSim, b2Contact* contact );
void b2RemoveContactFromGraph( b2World* world, int bodyIdA, int bodyIdB, int colorIndex, int localIndex );
b2JointSim* b2CreateJointInGraph( b2World* world, b2Joint* joint );
void b2AddJointToGraph( b2World* world, b2JointSim* jointSim, b2Joint* joint );
void b2RemoveJointFromGraph( b2World* world, int bodyIdA, int bodyIdB, int colorIndex, int localIndex );