Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/Box2D.NET/B2ArenaAllocatorIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ internal static int Next<T>()
return b2AtomicFetchAddInt(ref _indices, 1);
}

public static int Index<T>() where T : new()
internal static int Index<T>() where T : new()
{
return B2ArenaAllocatorIndexer<T>.Index;
}
}

internal class B2ArenaAllocatorIndexer<T> where T : new()
{
public static readonly int Index = B2ArenaAllocatorIndexer.Next<T>();
internal static readonly int Index = B2ArenaAllocatorIndexer.Next<T>();

private B2ArenaAllocatorIndexer()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Box2D.NET/B2BoardPhases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public static bool b2BroadPhase_TestOverlap(B2BroadPhase bp, int proxyKeyA, int
return b2AABB_Overlaps(aabbA, aabbB);
}

public static void b2BroadPhase_RebuildTrees(B2BroadPhase bp)
internal static void b2BroadPhase_RebuildTrees(B2BroadPhase bp)
{
b2DynamicTree_Rebuild(bp.trees[(int)B2BodyType.b2_dynamicBody], false);
b2DynamicTree_Rebuild(bp.trees[(int)B2BodyType.b2_kinematicBody], false);
Expand All @@ -519,15 +519,15 @@ public static int b2BroadPhase_GetShapeIndex(B2BroadPhase bp, int proxyKey)
return (int)b2DynamicTree_GetUserData(bp.trees[typeIndex], proxyId);
}

public static void b2ValidateBroadphase(B2BroadPhase bp)
internal static void b2ValidateBroadphase(B2BroadPhase bp)
{
b2DynamicTree_Validate(bp.trees[(int)B2BodyType.b2_dynamicBody]);
b2DynamicTree_Validate(bp.trees[(int)B2BodyType.b2_kinematicBody]);

// TODO_ERIN validate every shape AABB is contained in tree AABB
}

public static void b2ValidateNoEnlarged(B2BroadPhase bp)
internal static void b2ValidateNoEnlarged(B2BroadPhase bp)
{
#if DEBUG
for (int j = 0; j < (int)B2BodyType.b2_bodyTypeCount; ++j)
Expand Down
12 changes: 6 additions & 6 deletions src/Box2D.NET/B2Bodies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static class B2Bodies
public const int B2_NAME_LENGTH = 32;

// Identity body state, notice the deltaRotation is {1, 0}
public static readonly B2BodyState b2_identityBodyState = new B2BodyState()
internal static readonly B2BodyState b2_identityBodyState = new B2BodyState()
{
linearVelocity = new B2Vec2(0.0f, 0.0f),
angularVelocity = 0.0f,
Expand Down Expand Up @@ -119,7 +119,7 @@ public static void b2CreateIslandForBody(B2World world, int setIndex, B2Body bod
island.bodyCount = 1;
}

public static void b2RemoveBodyFromIsland(B2World world, B2Body body)
internal static void b2RemoveBodyFromIsland(B2World world, B2Body body)
{
if (body.islandId == B2_NULL_INDEX)
{
Expand Down Expand Up @@ -351,7 +351,7 @@ public static B2BodyId b2CreateBody(B2WorldId worldId, ref B2BodyDef def)
}

// careful calling this because it can invalidate body, state, joint, and contact pointers
public static bool b2WakeBody(B2World world, B2Body body)
internal static bool b2WakeBody(B2World world, B2Body body)
{
if (body.setIndex >= (int)B2SetType.b2_firstSleepingSet)
{
Expand Down Expand Up @@ -549,7 +549,7 @@ public static B2AABB b2Body_ComputeAABB(B2BodyId bodyId)
return aabb;
}

public static void b2UpdateBodyMassData(B2World world, B2Body body)
internal static void b2UpdateBodyMassData(B2World world, B2Body body)
{
B2BodySim bodySim = b2GetBodySim(world, body);

Expand Down Expand Up @@ -1050,7 +1050,7 @@ public static void b2Body_ApplyTorque(B2BodyId bodyId, float torque, bool wake)
/// step. So this only needs to be called if the application wants to remove the effect of previous
/// calls to apply forces and torques before the world step is called.
/// @param bodyId The body id
public static void b2Body_ClearForces(B2BodyId bodyId)
internal static void b2Body_ClearForces(B2BodyId bodyId)
{
B2World world = b2GetWorld(bodyId.world0);
B2Body body = b2GetBodyFullId(world, bodyId);
Expand Down Expand Up @@ -2035,7 +2035,7 @@ public static int b2Body_GetJoints(B2BodyId bodyId, Span<B2JointId> jointArray,
}


public static bool b2ShouldBodiesCollide(B2World world, B2Body bodyA, B2Body bodyB)
internal static bool b2ShouldBodiesCollide(B2World world, B2Body bodyA, B2Body bodyB)
{
if (bodyA.type != B2BodyType.b2_dynamicBody && bodyB.type != B2BodyType.b2_dynamicBody)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Box2D.NET/B2BodyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class B2BodyState
// the solver and must use zero delta rotation for static bodies (c,s) = (1,0)
public B2Rot deltaRotation; // 8

public static B2BodyState Create(B2BodyState other) // todo : @ikpil how to remove
internal static B2BodyState Create(B2BodyState other) // todo : @ikpil how to remove
{
var state = new B2BodyState();
state.CopyFrom(other);
Expand Down
10 changes: 5 additions & 5 deletions src/Box2D.NET/B2Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class B2Constants
{
// Used to detect bad values. Positions greater than about 16km will have precision
// problems, so 100km as a limit should be fine in all cases.
public static float B2_HUGE => (100000.0f * b2_lengthUnitsPerMeter);
internal static float B2_HUGE => (100000.0f * b2_lengthUnitsPerMeter);

// Maximum parallel workers. Used to size some static arrays.
public const int B2_MAX_WORKERS = 64;
Expand All @@ -24,26 +24,26 @@ public static class B2Constants
// chosen to be numerically significant, but visually insignificant. In meters.
// Normally this is 0.5cm.
// @warning modifying this can have a significant impact on stability
public static float B2_LINEAR_SLOP => (0.005f * b2_lengthUnitsPerMeter);
internal static float B2_LINEAR_SLOP => (0.005f * b2_lengthUnitsPerMeter);

// Maximum number of simultaneous worlds that can be allocated
public const int B2_MAX_WORLDS = 128;

// The maximum rotation of a body per time step. This limit is very large and is used
// to prevent numerical problems. You shouldn't need to adjust this.
// @warning increasing this to 0.5f * b2_pi or greater will break continuous collision.
public static readonly float B2_MAX_ROTATION = (0.25f * B2MathFunction.B2_PI);
internal static readonly float B2_MAX_ROTATION = (0.25f * B2MathFunction.B2_PI);

// Box2D uses limited speculative collision. This reduces jitter.
// Normally this is 2cm.
// @warning modifying this can have a significant impact on performance and stability
public static readonly float B2_SPECULATIVE_DISTANCE = (4.0f * B2_LINEAR_SLOP);
internal static readonly float B2_SPECULATIVE_DISTANCE = (4.0f * B2_LINEAR_SLOP);

// This is used to fatten AABBs in the dynamic tree. This allows proxies
// to move by a small amount without triggering a tree adjustment. This is in meters.
// Normally this is 5cm.
// @warning modifying this can have a significant impact on performance
public static float B2_AABB_MARGIN => (0.05f * b2_lengthUnitsPerMeter);
internal static float B2_AABB_MARGIN => (0.05f * b2_lengthUnitsPerMeter);

// The time that a body must be still before it will go to sleep. In seconds.
public const float B2_TIME_TO_SLEEP = 0.5f;
Expand Down
12 changes: 6 additions & 6 deletions src/Box2D.NET/B2ConstraintGraphs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static void b2DestroyGraph(ref B2ConstraintGraph graph)

// Contacts are always created as non-touching. They get cloned into the constraint
// graph once they are found to be touching.
public static void b2AddContactToGraph(B2World world, B2ContactSim contactSim, B2Contact contact)
internal static void b2AddContactToGraph(B2World world, B2ContactSim contactSim, B2Contact contact)
{
B2_ASSERT(contactSim.manifold.pointCount > 0);
B2_ASSERT(0 != (contactSim.simFlags & (uint)B2ContactSimFlags.b2_simTouchingFlag));
Expand Down Expand Up @@ -215,7 +215,7 @@ public static void b2AddContactToGraph(B2World world, B2ContactSim contactSim, B
}
}

public static void b2RemoveContactFromGraph(B2World world, int bodyIdA, int bodyIdB, int colorIndex, int localIndex)
internal static void b2RemoveContactFromGraph(B2World world, int bodyIdA, int bodyIdB, int colorIndex, int localIndex)
{
ref B2ConstraintGraph graph = ref world.constraintGraph;

Expand Down Expand Up @@ -311,7 +311,7 @@ static int b2AssignJointColor(ref B2ConstraintGraph graph, int bodyIdA, int body
return B2_OVERFLOW_INDEX;
}

public static ref B2JointSim b2CreateJointInGraph(B2World world, B2Joint joint)
internal static ref B2JointSim b2CreateJointInGraph(B2World world, B2Joint joint)
{
ref B2ConstraintGraph graph = ref world.constraintGraph;

Expand All @@ -331,14 +331,14 @@ public static ref B2JointSim b2CreateJointInGraph(B2World world, B2Joint joint)
return ref jointSim;
}

public static void b2AddJointToGraph(B2World world, B2JointSim jointSim, B2Joint joint)
internal static void b2AddJointToGraph(B2World world, B2JointSim jointSim, B2Joint joint)
{
B2JointSim jointDst = b2CreateJointInGraph(world, joint);
//memcpy( jointDst, jointSim, sizeof( b2JointSim ) );
jointDst.CopyFrom(jointSim);
}

public static void b2RemoveJointFromGraph(B2World world, int bodyIdA, int bodyIdB, int colorIndex, int localIndex)
internal static void b2RemoveJointFromGraph(B2World world, int bodyIdA, int bodyIdB, int colorIndex, int localIndex)
{
ref B2ConstraintGraph graph = ref world.constraintGraph;

Expand Down Expand Up @@ -366,7 +366,7 @@ public static void b2RemoveJointFromGraph(B2World world, int bodyIdA, int bodyId
}
}

public static readonly B2HexColor[] b2_graphColors = new B2HexColor[]
internal static readonly B2HexColor[] b2_graphColors = new B2HexColor[]
{
B2HexColor.b2_colorRed, B2HexColor.b2_colorOrange, B2HexColor.b2_colorYellow, B2HexColor.b2_colorGreen, B2HexColor.b2_colorCyan, B2HexColor.b2_colorBlue,
B2HexColor.b2_colorViolet, B2HexColor.b2_colorPink, B2HexColor.b2_colorChocolate, B2HexColor.b2_colorGoldenRod, B2HexColor.b2_colorCoral, B2HexColor.b2_colorRosyBrown,
Expand Down
24 changes: 12 additions & 12 deletions src/Box2D.NET/B2ContactSolvers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static class B2ContactSolvers
// s(t) = s0 + dot(cB0 + dpB + rot(dqB, rB0) - cA0 - dpA - rot(dqA, rA0), normal)
// s(t) = s0 + dot(cB0 - cA0, normal) + dot(dpB - dpA + rot(dqB, rB0) - rot(dqA, rA0), normal)
// s_base = s0 + dot(cB0 - cA0, normal)
public static void b2PrepareOverflowContacts(B2StepContext context)
internal static void b2PrepareOverflowContacts(B2StepContext context)
{
b2TracyCZoneNC(B2TracyCZone.prepare_overflow_contact, "Prepare Overflow Contact", B2HexColor.b2_colorYellow, true);

Expand Down Expand Up @@ -165,7 +165,7 @@ public static void b2PrepareOverflowContacts(B2StepContext context)
b2TracyCZoneEnd(B2TracyCZone.prepare_overflow_contact);
}

public static void b2WarmStartOverflowContacts(B2StepContext context)
internal static void b2WarmStartOverflowContacts(B2StepContext context)
{
b2TracyCZoneNC(B2TracyCZone.warmstart_overflow_contact, "WarmStart Overflow Contact", B2HexColor.b2_colorDarkOrange, true);

Expand Down Expand Up @@ -239,7 +239,7 @@ public static void b2WarmStartOverflowContacts(B2StepContext context)
b2TracyCZoneEnd(B2TracyCZone.warmstart_overflow_contact);
}

public static void b2SolveOverflowContacts(B2StepContext context, bool useBias)
internal static void b2SolveOverflowContacts(B2StepContext context, bool useBias)
{
b2TracyCZoneNC(B2TracyCZone.solve_contact, "Solve Contact", B2HexColor.b2_colorAliceBlue, true);

Expand Down Expand Up @@ -401,7 +401,7 @@ public static void b2SolveOverflowContacts(B2StepContext context, bool useBias)
b2TracyCZoneEnd(B2TracyCZone.solve_contact);
}

public static void b2ApplyOverflowRestitution(B2StepContext context)
internal static void b2ApplyOverflowRestitution(B2StepContext context)
{
b2TracyCZoneNC(B2TracyCZone.overflow_resitution, "Overflow Restitution", B2HexColor.b2_colorViolet, true);

Expand Down Expand Up @@ -506,7 +506,7 @@ public static void b2ApplyOverflowRestitution(B2StepContext context)
b2TracyCZoneEnd(B2TracyCZone.overflow_resitution);
}

public static void b2StoreOverflowImpulses(B2StepContext context)
internal static void b2StoreOverflowImpulses(B2StepContext context)
{
b2TracyCZoneNC(B2TracyCZone.store_impulses, "Store", B2HexColor.b2_colorFireBrick, true);

Expand Down Expand Up @@ -1107,7 +1107,7 @@ static void b2ScatterBodies( b2BodyState* states, int* indices, const b2BodyStat
#else

// This is a load and transpose
public static B2BodyStateW b2GatherBodies(B2BodyState[] states, ReadOnlySpan<int> indices)
internal static B2BodyStateW b2GatherBodies(B2BodyState[] states, ReadOnlySpan<int> indices)
{
B2BodyState identity = b2_identityBodyState;

Expand All @@ -1130,7 +1130,7 @@ public static B2BodyStateW b2GatherBodies(B2BodyState[] states, ReadOnlySpan<int
}

// This writes only the velocities back to the solver bodies
public static void b2ScatterBodies(B2BodyState[] states, ReadOnlySpan<int> indices, ref B2BodyStateW simdBody)
internal static void b2ScatterBodies(B2BodyState[] states, ReadOnlySpan<int> indices, ref B2BodyStateW simdBody)
{
if (indices[0] != B2_NULL_INDEX && (states[indices[0]].flags & (uint)B2BodyFlags.b2_dynamicFlag) != 0)
{
Expand Down Expand Up @@ -1168,7 +1168,7 @@ public static void b2ScatterBodies(B2BodyState[] states, ReadOnlySpan<int> indic
#endif

// Contacts that live within the constraint graph coloring
public static void b2PrepareContactsTask(int startIndex, int endIndex, B2StepContext context)
internal static void b2PrepareContactsTask(int startIndex, int endIndex, B2StepContext context)
{
b2TracyCZoneNC(B2TracyCZone.prepare_contact, "Prepare Contact", B2HexColor.b2_colorYellow, true);
B2World world = context.world;
Expand Down Expand Up @@ -1423,7 +1423,7 @@ public static void b2PrepareContactsTask(int startIndex, int endIndex, B2StepCon
b2TracyCZoneEnd(B2TracyCZone.prepare_contact);
}

public static void b2WarmStartContactsTask(int startIndex, int endIndex, B2StepContext context, int colorIndex)
internal static void b2WarmStartContactsTask(int startIndex, int endIndex, B2StepContext context, int colorIndex)
{
b2TracyCZoneNC(B2TracyCZone.warm_start_contact, "Warm Start", B2HexColor.b2_colorGreen, true);

Expand Down Expand Up @@ -1481,7 +1481,7 @@ public static void b2WarmStartContactsTask(int startIndex, int endIndex, B2StepC
b2TracyCZoneEnd(B2TracyCZone.warm_start_contact);
}

public static void b2SolveContactsTask(int startIndex, int endIndex, B2StepContext context, int colorIndex, bool useBias)
internal static void b2SolveContactsTask(int startIndex, int endIndex, B2StepContext context, int colorIndex, bool useBias)
{
b2TracyCZoneNC(B2TracyCZone.solve_contact, "Solve Contact", B2HexColor.b2_colorAliceBlue, true);

Expand Down Expand Up @@ -1719,7 +1719,7 @@ public static void b2SolveContactsTask(int startIndex, int endIndex, B2StepConte
b2TracyCZoneEnd(B2TracyCZone.solve_contact);
}

public static void b2ApplyRestitutionTask(int startIndex, int endIndex, B2StepContext context, int colorIndex)
internal static void b2ApplyRestitutionTask(int startIndex, int endIndex, B2StepContext context, int colorIndex)
{
b2TracyCZoneNC(B2TracyCZone.restitution, "Restitution", B2HexColor.b2_colorDodgerBlue, true);

Expand Down Expand Up @@ -1834,7 +1834,7 @@ public static void b2ApplyRestitutionTask(int startIndex, int endIndex, B2StepCo
b2TracyCZoneEnd(B2TracyCZone.restitution);
}

public static void b2StoreImpulsesTask(int startIndex, int endIndex, B2StepContext context)
internal static void b2StoreImpulsesTask(int startIndex, int endIndex, B2StepContext context)
{
b2TracyCZoneNC(B2TracyCZone.store_impulses, "Store", B2HexColor.b2_colorFireBrick, true);

Expand Down
Loading
Loading