Skip to content

Commit b3efe91

Browse files
Update box2d submodule to v3.0.0
1 parent b43f2ec commit b3efe91

File tree

13 files changed

+212
-154
lines changed

13 files changed

+212
-154
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ on:
88
push-packages:
99
description: 'Push nuget packages'
1010
required: true
11-
default: 'false'
11+
default: false
1212
type: boolean
1313

1414
use-auto-generated-version:
1515
description: 'Use auto-generated version'
1616
required: true
17-
default: 'true'
17+
default: true
1818
type: boolean
1919

2020
nuget-registry:
@@ -69,22 +69,22 @@ jobs:
6969
- name: Build Projects
7070
shell: bash
7171
run: |
72-
dotnet build --property:Deterministic=true -c Debug
73-
dotnet build --property:Deterministic=true -c Release
72+
dotnet build -c Debug
73+
dotnet build -c Release
7474
7575
- name: Run Tests
7676
shell: bash
77-
run: dotnet test --no-build --verbosity minimal
77+
run: dotnet test
7878

7979
- name: Pack Nuget Packages
8080
shell: bash
8181
run: |
8282
if [ '${{ github.event.inputs.nuget-registry }}' == 'NuGet' ]; then
83-
dotnet pack --no-build --property:NugetVersionSuffix=$NugetVersionSuffix -c Debug
84-
dotnet pack --no-build --property:NugetVersionSuffix=$NugetVersionSuffix -c Release
83+
dotnet pack --property:NugetVersionSuffix=$NugetVersionSuffix -c Debug
84+
dotnet pack --property:NugetVersionSuffix=$NugetVersionSuffix -c Release
8585
else
86-
dotnet pack --no-build --property:NugetVersionSuffix=$NugetVersionSuffix --property:DebugType=embedded -c Debug
87-
dotnet pack --no-build --property:NugetVersionSuffix=$NugetVersionSuffix --property:DebugType=embedded -c Release
86+
dotnet pack --property:NugetVersionSuffix=$NugetVersionSuffix --property:Box2DPackPdb=true -c Debug
87+
dotnet pack --property:NugetVersionSuffix=$NugetVersionSuffix --property:Box2DPackPdb=true -c Release
8888
fi
8989
9090
- name: Upload Artifacts

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "native/box2c"]
2-
path = native/box2c
3-
url = https://github.com/erincatto/box2c
1+
[submodule "native/box2d"]
2+
path = native/box2d
3+
url = https://github.com/erincatto/box2d

Box2D.NET.Bindgen/Box2D.NET.Bindgen.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<ContinuousIntegrationBuild>false</ContinuousIntegrationBuild>
9+
<Deterministic>false</Deterministic>
910
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
1011
</PropertyGroup>
1112

1213
<ItemGroup>
13-
<PackageReference Include="Bindgen.NET" Version="0.1.13"/>
14+
<PackageReference Include="Bindgen.NET" Version="0.1.14"/>
1415
</ItemGroup>
1516

1617
</Project>

Box2D.NET.Bindgen/Program.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Runtime.CompilerServices;
22
using Bindgen.NET;
33

4-
const string library = "box2c";
4+
const string library = "box2d";
55

66
BindingOptions options = new()
77
{
@@ -12,10 +12,11 @@
1212
DllFilePaths =
1313
{
1414
library,
15-
"runtimes/linux-x64/native/" + library,
16-
"runtimes/linux-arm64/native/" + library,
17-
"runtimes/osx-x64/native/" + library,
18-
"runtimes/osx-arm64/native/" + library,
15+
"lib" + library,
16+
"runtimes/linux-x64/native/lib" + library,
17+
"runtimes/linux-arm64/native/lib" + library,
18+
"runtimes/osx-x64/native/lib" + library,
19+
"runtimes/osx-arm64/native/lib" + library,
1920
"runtimes/win-x64/native/" + library,
2021
"runtimes/win-arm64/native/" + library
2122
},
@@ -70,7 +71,7 @@ string GetCurrentFilePath([CallerFilePath] string filePath = "")
7071

7172
string GetNativeDirectory(string path)
7273
{
73-
return GetCurrentFilePath() + "/../../native/box2c/" + path;
74+
return GetCurrentFilePath() + "/../../native/box2d/" + path;
7475
}
7576

7677
string GetOutputDirectory(string fileName)

Box2D.NET.Bindings/B2.g.cs

Lines changed: 83 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ public static unsafe partial class B2
6767
[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2Body_EnableSleep", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
6868
public static extern void BodyEnableSleep(BodyId bodyId, byte enableSleep);
6969

70-
[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2Body_GetAngle", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
71-
public static extern float BodyGetAngle(BodyId bodyId);
72-
7370
[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "b2Body_GetAngularDamping", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
7471
public static extern float BodyGetAngularDamping(BodyId bodyId);
7572

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

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

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

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

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

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

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

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

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

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

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

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

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

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

12691266
public Vec2 position;
12701267

1271-
public float angle;
1268+
public Rot rotation;
12721269

12731270
public Vec2 linearVelocity;
12741271

@@ -1296,6 +1293,8 @@ public partial struct BodyDef
12961293

12971294
public byte automaticMass;
12981295

1296+
public byte allowFastRotation;
1297+
12991298
public int internalValue;
13001299
}
13011300

@@ -1512,8 +1511,6 @@ public partial struct DebugDraw
15121511

15131512
public partial struct DistanceCache
15141513
{
1515-
public float metric;
1516-
15171514
public ushort count;
15181515

15191516
public fixed byte indexA[3];
@@ -1580,6 +1577,8 @@ public partial struct DistanceOutput
15801577
public float distance;
15811578

15821579
public int iterations;
1580+
1581+
public int simplexCount;
15831582
}
15841583

15851584
public partial struct DistanceProxy
@@ -1739,7 +1738,7 @@ public partial struct MassData
17391738

17401739
public Vec2 center;
17411740

1742-
public float I;
1741+
public float rotationalInertia;
17431742
}
17441743

17451744
public partial struct Mat22
@@ -2124,6 +2123,8 @@ public partial struct ShapeDef
21242123

21252124
public Filter filter;
21262125

2126+
public uint customColor;
2127+
21272128
public byte isSensor;
21282129

21292130
public byte enableSensorEvents;
@@ -2148,6 +2149,32 @@ public partial struct ShapeId
21482149
public ushort revision;
21492150
}
21502151

2152+
public partial struct Simplex
2153+
{
2154+
public SimplexVertex v1;
2155+
2156+
public SimplexVertex v2;
2157+
2158+
public SimplexVertex v3;
2159+
2160+
public int count;
2161+
}
2162+
2163+
public partial struct SimplexVertex
2164+
{
2165+
public Vec2 wA;
2166+
2167+
public Vec2 wB;
2168+
2169+
public Vec2 w;
2170+
2171+
public float a;
2172+
2173+
public int indexA;
2174+
2175+
public int indexB;
2176+
}
2177+
21512178
public partial struct SmoothSegment
21522179
{
21532180
public Vec2 ghost1;
@@ -2212,7 +2239,7 @@ public partial struct TreeNode
22122239

22132240
public uint categoryBits;
22142241

2215-
public AnonymousRecord_collision_L586_C2 AnonymousRecord_collision_L586_C2_Field;
2242+
public AnonymousRecord_collision_L608_C2 AnonymousRecord_collision_L608_C2_Field;
22162243

22172244
public int child1;
22182245

@@ -2226,12 +2253,12 @@ public partial struct TreeNode
22262253

22272254
public fixed byte pad[9];
22282255

2229-
public ref int parent => ref AnonymousRecord_collision_L586_C2_Field.parent;
2256+
public ref int parent => ref AnonymousRecord_collision_L608_C2_Field.parent;
22302257

2231-
public ref int next => ref AnonymousRecord_collision_L586_C2_Field.next;
2258+
public ref int next => ref AnonymousRecord_collision_L608_C2_Field.next;
22322259

22332260
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Explicit)]
2234-
public partial struct AnonymousRecord_collision_L586_C2
2261+
public partial struct AnonymousRecord_collision_L608_C2
22352262
{
22362263
[System.Runtime.InteropServices.FieldOffset(0)]
22372264
public int parent;
@@ -2339,6 +2366,8 @@ public partial struct WorldDef
23392366

23402367
public float jointDampingRatio;
23412368

2369+
public float maximumLinearVelocity;
2370+
23422371
public byte enableSleep;
23432372

23442373
public byte enableContinous;
@@ -2524,7 +2553,11 @@ public enum HexColor : uint
25242553
colorWhite = 16777215,
25252554
colorWhiteSmoke = 16119285,
25262555
colorYellow = 16776960,
2527-
colorYellowGreen = 10145074
2556+
colorYellowGreen = 10145074,
2557+
colorBox2DRed = 14430514,
2558+
colorBox2DBlue = 3190463,
2559+
colorBox2DGreen = 9226532,
2560+
colorBox2DYellow = 16772748
25282561
}
25292562

25302563
public enum JointType : uint
@@ -2873,6 +2906,14 @@ public enum TOIState : uint
28732906

28742907
public const HexColor colorYellowGreen = HexColor.colorYellowGreen;
28752908

2909+
public const HexColor colorBox2DRed = HexColor.colorBox2DRed;
2910+
2911+
public const HexColor colorBox2DBlue = HexColor.colorBox2DBlue;
2912+
2913+
public const HexColor colorBox2DGreen = HexColor.colorBox2DGreen;
2914+
2915+
public const HexColor colorBox2DYellow = HexColor.colorBox2DYellow;
2916+
28762917
public const JointType distanceJoint = JointType.distanceJoint;
28772918

28782919
public const JointType motorJoint = JointType.motorJoint;
@@ -2919,19 +2960,20 @@ public enum TOIState : uint
29192960

29202961
public partial class BindgenInternal
29212962
{
2922-
public const string DllImportPath = "box2c";
2963+
public const string DllImportPath = "box2d";
29232964

29242965
static BindgenInternal()
29252966
{
29262967
DllFilePaths = new System.Collections.Generic.List<string>
29272968
{
2928-
"box2c",
2929-
"runtimes/linux-x64/native/box2c",
2930-
"runtimes/linux-arm64/native/box2c",
2931-
"runtimes/osx-x64/native/box2c",
2932-
"runtimes/osx-arm64/native/box2c",
2933-
"runtimes/win-x64/native/box2c",
2934-
"runtimes/win-arm64/native/box2c"
2969+
"box2d",
2970+
"libbox2d",
2971+
"runtimes/linux-x64/native/libbox2d",
2972+
"runtimes/linux-arm64/native/libbox2d",
2973+
"runtimes/osx-x64/native/libbox2d",
2974+
"runtimes/osx-arm64/native/libbox2d",
2975+
"runtimes/win-x64/native/box2d",
2976+
"runtimes/win-arm64/native/box2d"
29352977
};
29362978
}
29372979
}
@@ -2983,8 +3025,8 @@ public partial class BindgenInternal
29833025

29843026
public static bool TryLoad(string path, out System.IntPtr handle)
29853027
{
2986-
#if NET5_0_OR_GREATER
2987-
return System.Runtime.InteropServices.NativeLibrary.TryLoad(path, out handle);
3028+
#if NETCOREAPP3_0_OR_GREATER
3029+
return System.Runtime.InteropServices.NativeLibrary.TryLoad(path, System.Reflection.Assembly.GetExecutingAssembly(), null, out handle);
29883030
#else
29893031
handle = System.IntPtr.Zero;
29903032
if (IsLinux)
@@ -2999,7 +3041,7 @@ public static bool TryLoad(string path, out System.IntPtr handle)
29993041

30003042
public static System.IntPtr GetExport(string symbol)
30013043
{
3002-
#if NET5_0_OR_GREATER
3044+
#if NETCOREAPP3_0_OR_GREATER
30033045
return System.Runtime.InteropServices.NativeLibrary.GetExport(LibraryHandle, symbol);
30043046
#else
30053047
if (IsLinux)
@@ -3044,6 +3086,14 @@ public static System.IntPtr GetExport(string symbol)
30443086

30453087
public static void ResolveLibrary()
30463088
{
3089+
System.IntPtr handle = default;
3090+
#if NETCOREAPP3_0_OR_GREATER
3091+
foreach (string dllFilePath in DllFilePaths)
3092+
{
3093+
if (TryLoad(dllFilePath, out handle))
3094+
goto Return;
3095+
}
3096+
#else
30473097
string fileExtension;
30483098
if (IsLinux)
30493099
fileExtension = ".so";
@@ -3053,12 +3103,12 @@ public static void ResolveLibrary()
30533103
fileExtension = ".dll";
30543104
else
30553105
throw new System.InvalidOperationException("Can't determine native library file extension for the current system.");
3056-
System.IntPtr handle = default;
30573106
foreach (string dllFilePath in DllFilePaths)
30583107
{
30593108
string fileName = System.IO.Path.GetFileName(dllFilePath);
30603109
string parentDir = $"{dllFilePath}/..";
3061-
string searchDir = System.IO.Path.IsPathRooted(dllFilePath) ? System.IO.Path.GetFullPath(parentDir) + "/" : System.IO.Path.GetFullPath(System.AppDomain.CurrentDomain.BaseDirectory + parentDir) + "/";
3110+
string exeDir = System.IO.Path.GetFullPath(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)!);
3111+
string searchDir = System.IO.Path.IsPathRooted(dllFilePath) ? System.IO.Path.GetFullPath(parentDir) + "/" : System.IO.Path.GetFullPath($"{exeDir}/{parentDir}") + "/";
30623112
if (TryLoad($"{searchDir}{fileName}", out handle))
30633113
goto Return;
30643114
if (TryLoad($"{searchDir}{fileName}{fileExtension}", out handle))
@@ -3076,6 +3126,7 @@ public static void ResolveLibrary()
30763126
goto Return;
30773127
}
30783128

3129+
#endif
30793130
#if NET7_0_OR_GREATER
30803131
handle = System.Runtime.InteropServices.NativeLibrary.GetMainProgramHandle();
30813132
#else

0 commit comments

Comments
 (0)