Skip to content

Commit

Permalink
Update box2d submodule to v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BeanCheeseBurrito committed Aug 12, 2024
1 parent b43f2ec commit b3efe91
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 154 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ on:
push-packages:
description: 'Push nuget packages'
required: true
default: 'false'
default: false
type: boolean

use-auto-generated-version:
description: 'Use auto-generated version'
required: true
default: 'true'
default: true
type: boolean

nuget-registry:
Expand Down Expand Up @@ -69,22 +69,22 @@ jobs:
- name: Build Projects
shell: bash
run: |
dotnet build --property:Deterministic=true -c Debug
dotnet build --property:Deterministic=true -c Release
dotnet build -c Debug
dotnet build -c Release
- name: Run Tests
shell: bash
run: dotnet test --no-build --verbosity minimal
run: dotnet test

- name: Pack Nuget Packages
shell: bash
run: |
if [ '${{ github.event.inputs.nuget-registry }}' == 'NuGet' ]; then
dotnet pack --no-build --property:NugetVersionSuffix=$NugetVersionSuffix -c Debug
dotnet pack --no-build --property:NugetVersionSuffix=$NugetVersionSuffix -c Release
dotnet pack --property:NugetVersionSuffix=$NugetVersionSuffix -c Debug
dotnet pack --property:NugetVersionSuffix=$NugetVersionSuffix -c Release
else
dotnet pack --no-build --property:NugetVersionSuffix=$NugetVersionSuffix --property:DebugType=embedded -c Debug
dotnet pack --no-build --property:NugetVersionSuffix=$NugetVersionSuffix --property:DebugType=embedded -c Release
dotnet pack --property:NugetVersionSuffix=$NugetVersionSuffix --property:Box2DPackPdb=true -c Debug
dotnet pack --property:NugetVersionSuffix=$NugetVersionSuffix --property:Box2DPackPdb=true -c Release
fi
- name: Upload Artifacts
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "native/box2c"]
path = native/box2c
url = https://github.com/erincatto/box2c
[submodule "native/box2d"]
path = native/box2d
url = https://github.com/erincatto/box2d
3 changes: 2 additions & 1 deletion Box2D.NET.Bindgen/Box2D.NET.Bindgen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ContinuousIntegrationBuild>false</ContinuousIntegrationBuild>
<Deterministic>false</Deterministic>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bindgen.NET" Version="0.1.13"/>
<PackageReference Include="Bindgen.NET" Version="0.1.14"/>
</ItemGroup>

</Project>
13 changes: 7 additions & 6 deletions Box2D.NET.Bindgen/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Runtime.CompilerServices;
using Bindgen.NET;

const string library = "box2c";
const string library = "box2d";

BindingOptions options = new()
{
Expand All @@ -12,10 +12,11 @@
DllFilePaths =
{
library,
"runtimes/linux-x64/native/" + library,
"runtimes/linux-arm64/native/" + library,
"runtimes/osx-x64/native/" + library,
"runtimes/osx-arm64/native/" + library,
"lib" + library,
"runtimes/linux-x64/native/lib" + library,
"runtimes/linux-arm64/native/lib" + library,
"runtimes/osx-x64/native/lib" + library,
"runtimes/osx-arm64/native/lib" + library,
"runtimes/win-x64/native/" + library,
"runtimes/win-arm64/native/" + library
},
Expand Down Expand Up @@ -70,7 +71,7 @@ string GetCurrentFilePath([CallerFilePath] string filePath = "")

string GetNativeDirectory(string path)
{
return GetCurrentFilePath() + "/../../native/box2c/" + path;
return GetCurrentFilePath() + "/../../native/box2d/" + path;
}

string GetOutputDirectory(string fileName)
Expand Down
115 changes: 83 additions & 32 deletions Box2D.NET.Bindings/B2.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ public static unsafe partial class B2
[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2Body_EnableSleep", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern void BodyEnableSleep(BodyId bodyId, byte enableSleep);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2Body_GetAngle", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern float BodyGetAngle(BodyId bodyId);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2Body_GetAngularDamping", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern float BodyGetAngularDamping(BodyId bodyId);

Expand Down Expand Up @@ -203,7 +200,7 @@ public static unsafe partial class B2
public static extern void BodySetSleepThreshold(BodyId bodyId, float sleepVelocity);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2Body_SetTransform", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern void BodySetTransform(BodyId bodyId, Vec2 position, float angle);
public static extern void BodySetTransform(BodyId bodyId, Vec2 position, Rot rotation);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2Body_SetType", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern void BodySetType(BodyId bodyId, BodyType type);
Expand Down Expand Up @@ -233,28 +230,28 @@ public static unsafe partial class B2
public static extern Manifold CollideCapsuleAndCircle(Capsule* capsuleA, Transform xfA, Circle* circleB, Transform xfB);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2CollideCapsules", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern Manifold CollideCapsules(Capsule* capsuleA, Transform xfA, Capsule* capsuleB, Transform xfB, DistanceCache* cache);
public static extern Manifold CollideCapsules(Capsule* capsuleA, Transform xfA, Capsule* capsuleB, Transform xfB);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2CollideCircles", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern Manifold CollideCircles(Circle* circleA, Transform xfA, Circle* circleB, Transform xfB);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2CollidePolygonAndCapsule", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern Manifold CollidePolygonAndCapsule(Polygon* polygonA, Transform xfA, Capsule* capsuleB, Transform xfB, DistanceCache* cache);
public static extern Manifold CollidePolygonAndCapsule(Polygon* polygonA, Transform xfA, Capsule* capsuleB, Transform xfB);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2CollidePolygonAndCircle", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern Manifold CollidePolygonAndCircle(Polygon* polygonA, Transform xfA, Circle* circleB, Transform xfB);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2CollidePolygons", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern Manifold CollidePolygons(Polygon* polyA, Transform xfA, Polygon* polyB, Transform xfB, DistanceCache* cache);
public static extern Manifold CollidePolygons(Polygon* polygonA, Transform xfA, Polygon* polygonB, Transform xfB);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2CollideSegmentAndCapsule", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern Manifold CollideSegmentAndCapsule(Segment* segmentA, Transform xfA, Capsule* capsuleB, Transform xfB, DistanceCache* cache);
public static extern Manifold CollideSegmentAndCapsule(Segment* segmentA, Transform xfA, Capsule* capsuleB, Transform xfB);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2CollideSegmentAndCircle", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern Manifold CollideSegmentAndCircle(Segment* segmentA, Transform xfA, Circle* circleB, Transform xfB);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2CollideSegmentAndPolygon", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern Manifold CollideSegmentAndPolygon(Segment* segmentA, Transform xfA, Polygon* polygonB, Transform xfB, DistanceCache* cache);
public static extern Manifold CollideSegmentAndPolygon(Segment* segmentA, Transform xfA, Polygon* polygonB, Transform xfB);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2CollideSmoothSegmentAndCapsule", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern Manifold CollideSmoothSegmentAndCapsule(SmoothSegment* smoothSegmentA, Transform xfA, Capsule* capsuleB, Transform xfB, DistanceCache* cache);
Expand Down Expand Up @@ -1058,7 +1055,7 @@ public static unsafe partial class B2
public static extern CastOutput ShapeCastSegment(ShapeCastInput* input, Segment* shape);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2ShapeDistance", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern DistanceOutput ShapeDistance(DistanceCache* cache, DistanceInput* input);
public static extern DistanceOutput ShapeDistance(DistanceCache* cache, DistanceInput* input, Simplex* simplexes, int simplexCapacity);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2SleepMilliseconds", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern void SleepMilliseconds(int milliseconds);
Expand Down Expand Up @@ -1268,7 +1265,7 @@ public partial struct BodyDef

public Vec2 position;

public float angle;
public Rot rotation;

public Vec2 linearVelocity;

Expand Down Expand Up @@ -1296,6 +1293,8 @@ public partial struct BodyDef

public byte automaticMass;

public byte allowFastRotation;

public int internalValue;
}

Expand Down Expand Up @@ -1512,8 +1511,6 @@ public partial struct DebugDraw

public partial struct DistanceCache
{
public float metric;

public ushort count;

public fixed byte indexA[3];
Expand Down Expand Up @@ -1580,6 +1577,8 @@ public partial struct DistanceOutput
public float distance;

public int iterations;

public int simplexCount;
}

public partial struct DistanceProxy
Expand Down Expand Up @@ -1739,7 +1738,7 @@ public partial struct MassData

public Vec2 center;

public float I;
public float rotationalInertia;
}

public partial struct Mat22
Expand Down Expand Up @@ -2124,6 +2123,8 @@ public partial struct ShapeDef

public Filter filter;

public uint customColor;

public byte isSensor;

public byte enableSensorEvents;
Expand All @@ -2148,6 +2149,32 @@ public partial struct ShapeId
public ushort revision;
}

public partial struct Simplex
{
public SimplexVertex v1;

public SimplexVertex v2;

public SimplexVertex v3;

public int count;
}

public partial struct SimplexVertex
{
public Vec2 wA;

public Vec2 wB;

public Vec2 w;

public float a;

public int indexA;

public int indexB;
}

public partial struct SmoothSegment
{
public Vec2 ghost1;
Expand Down Expand Up @@ -2212,7 +2239,7 @@ public partial struct TreeNode

public uint categoryBits;

public AnonymousRecord_collision_L586_C2 AnonymousRecord_collision_L586_C2_Field;
public AnonymousRecord_collision_L608_C2 AnonymousRecord_collision_L608_C2_Field;

public int child1;

Expand All @@ -2226,12 +2253,12 @@ public partial struct TreeNode

public fixed byte pad[9];

public ref int parent => ref AnonymousRecord_collision_L586_C2_Field.parent;
public ref int parent => ref AnonymousRecord_collision_L608_C2_Field.parent;

public ref int next => ref AnonymousRecord_collision_L586_C2_Field.next;
public ref int next => ref AnonymousRecord_collision_L608_C2_Field.next;

[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Explicit)]
public partial struct AnonymousRecord_collision_L586_C2
public partial struct AnonymousRecord_collision_L608_C2
{
[System.Runtime.InteropServices.FieldOffset(0)]
public int parent;
Expand Down Expand Up @@ -2339,6 +2366,8 @@ public partial struct WorldDef

public float jointDampingRatio;

public float maximumLinearVelocity;

public byte enableSleep;

public byte enableContinous;
Expand Down Expand Up @@ -2524,7 +2553,11 @@ public enum HexColor : uint
colorWhite = 16777215,
colorWhiteSmoke = 16119285,
colorYellow = 16776960,
colorYellowGreen = 10145074
colorYellowGreen = 10145074,
colorBox2DRed = 14430514,
colorBox2DBlue = 3190463,
colorBox2DGreen = 9226532,
colorBox2DYellow = 16772748
}

public enum JointType : uint
Expand Down Expand Up @@ -2873,6 +2906,14 @@ public enum TOIState : uint

public const HexColor colorYellowGreen = HexColor.colorYellowGreen;

public const HexColor colorBox2DRed = HexColor.colorBox2DRed;

public const HexColor colorBox2DBlue = HexColor.colorBox2DBlue;

public const HexColor colorBox2DGreen = HexColor.colorBox2DGreen;

public const HexColor colorBox2DYellow = HexColor.colorBox2DYellow;

public const JointType distanceJoint = JointType.distanceJoint;

public const JointType motorJoint = JointType.motorJoint;
Expand Down Expand Up @@ -2919,19 +2960,20 @@ public enum TOIState : uint

public partial class BindgenInternal
{
public const string DllImportPath = "box2c";
public const string DllImportPath = "box2d";

static BindgenInternal()
{
DllFilePaths = new System.Collections.Generic.List<string>
{
"box2c",
"runtimes/linux-x64/native/box2c",
"runtimes/linux-arm64/native/box2c",
"runtimes/osx-x64/native/box2c",
"runtimes/osx-arm64/native/box2c",
"runtimes/win-x64/native/box2c",
"runtimes/win-arm64/native/box2c"
"box2d",
"libbox2d",
"runtimes/linux-x64/native/libbox2d",
"runtimes/linux-arm64/native/libbox2d",
"runtimes/osx-x64/native/libbox2d",
"runtimes/osx-arm64/native/libbox2d",
"runtimes/win-x64/native/box2d",
"runtimes/win-arm64/native/box2d"
};
}
}
Expand Down Expand Up @@ -2983,8 +3025,8 @@ public partial class BindgenInternal

public static bool TryLoad(string path, out System.IntPtr handle)
{
#if NET5_0_OR_GREATER
return System.Runtime.InteropServices.NativeLibrary.TryLoad(path, out handle);
#if NETCOREAPP3_0_OR_GREATER
return System.Runtime.InteropServices.NativeLibrary.TryLoad(path, System.Reflection.Assembly.GetExecutingAssembly(), null, out handle);
#else
handle = System.IntPtr.Zero;
if (IsLinux)
Expand All @@ -2999,7 +3041,7 @@ public static bool TryLoad(string path, out System.IntPtr handle)

public static System.IntPtr GetExport(string symbol)
{
#if NET5_0_OR_GREATER
#if NETCOREAPP3_0_OR_GREATER
return System.Runtime.InteropServices.NativeLibrary.GetExport(LibraryHandle, symbol);
#else
if (IsLinux)
Expand Down Expand Up @@ -3044,6 +3086,14 @@ public static System.IntPtr GetExport(string symbol)

public static void ResolveLibrary()
{
System.IntPtr handle = default;
#if NETCOREAPP3_0_OR_GREATER
foreach (string dllFilePath in DllFilePaths)
{
if (TryLoad(dllFilePath, out handle))
goto Return;
}
#else
string fileExtension;
if (IsLinux)
fileExtension = ".so";
Expand All @@ -3053,12 +3103,12 @@ public static void ResolveLibrary()
fileExtension = ".dll";
else
throw new System.InvalidOperationException("Can't determine native library file extension for the current system.");
System.IntPtr handle = default;
foreach (string dllFilePath in DllFilePaths)
{
string fileName = System.IO.Path.GetFileName(dllFilePath);
string parentDir = $"{dllFilePath}/..";
string searchDir = System.IO.Path.IsPathRooted(dllFilePath) ? System.IO.Path.GetFullPath(parentDir) + "/" : System.IO.Path.GetFullPath(System.AppDomain.CurrentDomain.BaseDirectory + parentDir) + "/";
string exeDir = System.IO.Path.GetFullPath(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)!);
string searchDir = System.IO.Path.IsPathRooted(dllFilePath) ? System.IO.Path.GetFullPath(parentDir) + "/" : System.IO.Path.GetFullPath($"{exeDir}/{parentDir}") + "/";
if (TryLoad($"{searchDir}{fileName}", out handle))
goto Return;
if (TryLoad($"{searchDir}{fileName}{fileExtension}", out handle))
Expand All @@ -3076,6 +3126,7 @@ public static void ResolveLibrary()
goto Return;
}

#endif
#if NET7_0_OR_GREATER
handle = System.Runtime.InteropServices.NativeLibrary.GetMainProgramHandle();
#else
Expand Down
Loading

0 comments on commit b3efe91

Please sign in to comment.