Skip to content

Commit 99f97da

Browse files
committed
Regen for latest Box2D + some new issues fixed
1 parent e4969ce commit 99f97da

9 files changed

Lines changed: 92 additions & 22 deletions

File tree

Box2dNet.Samples/Box2dMeshDrawer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void DrawWorld(b2WorldId worldId)
9494
drawJointExtras = false,
9595
drawBounds = false,
9696
drawMass = false,
97-
drawContactPoints = false,
97+
contactDrawType = b2ContactDrawType.b2_drawContacts_None,
9898
drawGraphColors = false,
9999
drawContactNormals = false,
100100
drawContactForces = false,

Box2dNet/Box2dNet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<RepositoryUrl>https://github.com/thomasvt/Box2D3Net</RepositoryUrl>
1515
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1616
<NoWarn>$(NoWarn);1591</NoWarn> <!-- suppress warnings for missing docs -->
17-
<Version>3.1.8.7</Version>
17+
<Version>3.1.8.8</Version>
1818
</PropertyGroup>
1919

2020
<ItemGroup>

Box2dNet/Interop/B2Api.DebugDraw.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ public struct b2DebugDraw
121121
/// Global scaling for joint drawing
122122
public float jointScale;
123123

124+
public b2ContactDrawType contactDrawType;
125+
124126
/// Option to draw shapes
125127
[MarshalAs(UnmanagedType.U1)] public bool drawShapes;
126128

@@ -139,9 +141,6 @@ public struct b2DebugDraw
139141
/// Option to draw body names
140142
[MarshalAs(UnmanagedType.U1)] public bool drawBodyNames;
141143

142-
/// Option to draw contact points
143-
[MarshalAs(UnmanagedType.U1)] public bool drawContactPoints;
144-
145144
/// Option to visualize the graph coloring used for contacts and joints
146145
[MarshalAs(UnmanagedType.U1)] public bool drawGraphColors;
147146

Box2dNet/Interop/B2Api.cs

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated by Box2dNetGen for Box2D v3 on 11/01/2026 07:32:50
1+
// Generated by Box2dNetGen for Box2D v3 on 25/03/2026 10:57:19
22

33
using System.Runtime.InteropServices;
44
using System.Numerics;
@@ -383,6 +383,20 @@ public enum b2HexColor
383383
b2_colorBox2DGreen = 0x8CC924,
384384
}
385385

386+
public enum b2ContactDrawType
387+
{
388+
389+
b2_drawContacts_None = 0,
390+
391+
b2_drawContacts_Clip = 1,
392+
393+
b2_drawContacts_AnchorA = 2,
394+
395+
b2_drawContacts_AnchorB = 3,
396+
397+
b2_drawContacts_Average = 4,
398+
}
399+
386400
/// <summary>
387401
/// Prototype for user allocation function
388402
/// </summary>
@@ -1658,21 +1672,26 @@ public partial struct b2ManifoldPoint
16581672
{
16591673

16601674
/// <summary>
1661-
/// Location of the contact point in world space. Subject to precision loss at large coordinates.
1662-
/// @note Should only be used for debugging.
1675+
/// Location of the contact point in world space when first clipped. Subject to precision
1676+
/// loss at large coordinates. This point lags behind when contact recycling is used.
1677+
/// @note Should only be used for debugging. Use anchorA and/or anchorB for game logic.
16631678
/// </summary>
16641679
/// <returns>Original C type: b2Vec2</returns>
1665-
public Vector2 point;
1680+
public Vector2 clipPoint;
16661681

16671682
/// <summary>
1668-
/// Location of the contact point relative to shapeA's origin in world space
1683+
/// Location of the contact point relative to shapeA's origin in world space.
1684+
/// This can be converted to a world point using:
1685+
/// b2Vec2 worldPointA = b2Add(b2Body_GetCenter(myBodyIdA), anchorA);
16691686
/// @note When used internally to the Box2D solver, this is relative to the body center of mass.
16701687
/// </summary>
16711688
/// <returns>Original C type: b2Vec2</returns>
16721689
public Vector2 anchorA;
16731690

16741691
/// <summary>
16751692
/// Location of the contact point relative to shapeB's origin in world space
1693+
/// This can be converted to a world point using:
1694+
/// b2Vec2 worldPointB = b2Add(b2Body_GetCenter(myBodyIdB), anchorB);
16761695
/// @note When used internally to the Box2D solver, this is relative to the body center of mass.
16771696
/// </summary>
16781697
/// <returns>Original C type: b2Vec2</returns>
@@ -1684,6 +1703,12 @@ public partial struct b2ManifoldPoint
16841703
/// <returns>Original C type: float</returns>
16851704
public float separation;
16861705

1706+
/// <summary>
1707+
/// Cached separation used for contact recycling
1708+
/// </summary>
1709+
/// <returns>Original C type: float</returns>
1710+
public float baseSeparation;
1711+
16871712
/// <summary>
16881713
/// The impulse along the manifold normal vector.
16891714
/// </summary>
@@ -1725,12 +1750,13 @@ public partial struct b2ManifoldPoint
17251750
[MarshalAs(UnmanagedType.U1)]
17261751
public bool persisted;
17271752

1728-
public b2ManifoldPoint(in Vector2 point, in Vector2 anchorA, in Vector2 anchorB, in float separation, in float normalImpulse, in float tangentImpulse, in float totalNormalImpulse, in float normalVelocity, in ushort id, in bool persisted)
1753+
public b2ManifoldPoint(in Vector2 clipPoint, in Vector2 anchorA, in Vector2 anchorB, in float separation, in float baseSeparation, in float normalImpulse, in float tangentImpulse, in float totalNormalImpulse, in float normalVelocity, in ushort id, in bool persisted)
17291754
{
1730-
this.point = point;
1755+
this.clipPoint = clipPoint;
17311756
this.anchorA = anchorA;
17321757
this.anchorB = anchorB;
17331758
this.separation = separation;
1759+
this.baseSeparation = baseSeparation;
17341760
this.normalImpulse = normalImpulse;
17351761
this.tangentImpulse = tangentImpulse;
17361762
this.totalNormalImpulse = totalNormalImpulse;
@@ -2727,21 +2753,24 @@ public partial struct b2ShapeDef
27272753
public bool isSensor;
27282754

27292755
/// <summary>
2730-
/// Enable sensor events for this shape. This applies to sensors and non-sensors. False by default, even for sensors.
2756+
/// Enable sensor events for this shape. This applies to sensors and non-sensors. Both shapes involved must have this flag set to true.
2757+
/// False by default, even for sensors.
27312758
/// </summary>
27322759
/// <returns>Original C type: bool</returns>
27332760
[MarshalAs(UnmanagedType.U1)]
27342761
public bool enableSensorEvents;
27352762

27362763
/// <summary>
2737-
/// Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. False by default.
2764+
/// Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Only one shape involved needs this flag set to true.
2765+
/// Ignored for sensors. False by default.
27382766
/// </summary>
27392767
/// <returns>Original C type: bool</returns>
27402768
[MarshalAs(UnmanagedType.U1)]
27412769
public bool enableContactEvents;
27422770

27432771
/// <summary>
2744-
/// Enable hit events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. False by default.
2772+
/// Enable hit events for this shape. Only applies to kinematic and dynamic bodies. Only one shape involved needs this flag set to true.
2773+
/// Ignored for sensors. False by default.
27452774
/// </summary>
27462775
/// <returns>Original C type: bool</returns>
27472776
[MarshalAs(UnmanagedType.U1)]
@@ -4166,6 +4195,21 @@ public static partial class B2Api
41664195
/// <returns>Original C type: int</returns>
41674196
public const int B2_MAX_POLYGON_VERTICES = 8;
41684197

4198+
/// <returns>Original C type: int</returns>
4199+
public const int B2_MAX_WORKERS = 64;
4200+
4201+
/// <returns>Original C type: int</returns>
4202+
public const int B2_GRAPH_COLOR_COUNT = 24;
4203+
4204+
/// <returns>Original C type: int</returns>
4205+
public const int B2_MAX_WORLDS = 128;
4206+
4207+
/// <returns>Original C type: float</returns>
4208+
public const float B2_AABB_MARGIN_FRACTION = 0.125f;
4209+
4210+
/// <returns>Original C type: float</returns>
4211+
public const float B2_TIME_TO_SLEEP = 0.5f;
4212+
41694213
/// <summary>
41704214
/// https://en.wikipedia.org/wiki/Pi
41714215
/// </summary>
@@ -4764,6 +4808,24 @@ public static void b2World_SetPreSolveCallback(b2WorldId worldId, b2PreSolveFcn
47644808
[DllImport(Box2DLibrary, CallingConvention = CallingConvention.Cdecl)]
47654809
public static extern void b2World_SetContactTuning(b2WorldId worldId, float hertz, float dampingRatio, float pushSpeed);
47664810

4811+
/// <summary>
4812+
/// Set the contact point recycling distance. Setting this to zero disables contact point recycling.
4813+
/// Usually in meters.
4814+
/// </summary>
4815+
/// <returns>Original C type: void</returns>
4816+
/// <param name="worldId">(Original C type: b2WorldId)</param>
4817+
/// <param name="recycleDistance">(Original C type: float)</param>
4818+
[DllImport(Box2DLibrary, CallingConvention = CallingConvention.Cdecl)]
4819+
public static extern void b2World_SetContactRecycleDistance(b2WorldId worldId, float recycleDistance);
4820+
4821+
/// <summary>
4822+
/// Get the contact point recycling distance. Usually in meters.
4823+
/// </summary>
4824+
/// <returns>Original C type: float</returns>
4825+
/// <param name="worldId">(Original C type: b2WorldId)</param>
4826+
[DllImport(Box2DLibrary, CallingConvention = CallingConvention.Cdecl)]
4827+
public static extern float b2World_GetContactRecycleDistance(b2WorldId worldId);
4828+
47674829
/// <summary>
47684830
/// Set the maximum linear speed. Usually in m/s.
47694831
/// </summary>
@@ -6050,7 +6112,7 @@ public static void b2World_SetRestitutionCallback(b2WorldId worldId, b2Restituti
60506112
/// <summary>
60516113
/// Get the maximum capacity required for retrieving all the overlapped shapes on a sensor shape.
60526114
/// This returns 0 if the provided shape is not a sensor.
6053-
/// @returns the required capacity to get all the overlaps in b2Shape_GetSensorOverlaps
6115+
/// @returns the required capacity to get all the overlaps in b2Shape_GetSensorData
60546116
/// </summary>
60556117
/// <returns>Original C type: int</returns>
60566118
/// <param name="shapeId">the id of a sensor shape
@@ -6061,7 +6123,7 @@ public static void b2World_SetRestitutionCallback(b2WorldId worldId, b2Restituti
60616123
public static extern int b2Shape_GetSensorCapacity(b2ShapeId shapeId);
60626124

60636125
/// <summary>
6064-
/// Get the overlap data for a sensor shape.
6126+
/// Get the overlap data for a sensor shape computed the previous world step.
60656127
/// @returns the number of elements filled in the provided array
60666128
/// @warning do not ignore the return value, it specifies the valid number of elements
60676129
/// @warning overlaps may contain destroyed shapes so use b2Shape_IsValid to confirm each overlap

Box2dNet/box2d.dll

3.5 KB
Binary file not shown.

Box2dNet/box2dd.dll

8.5 KB
Binary file not shown.

Box2dNetGen/Box2dNetGen/Extractors/ConstantsExtractor.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Text.RegularExpressions;
1+
using System.Diagnostics;
2+
using System.Text.RegularExpressions;
23

34
namespace Box2dNetGen.Extractors
45
{
@@ -9,12 +10,17 @@ internal class ConstantsExtractor
910
/// <summary>
1011
/// Extracts all `#define` constants that are useful for Box2dNet.
1112
/// </summary>
12-
public static IEnumerable<ApiConstant> ExtractAllPrecompilerDefines(string src)
13+
public static IEnumerable<ApiConstant> ExtractAllPrecompilerDefines(List<string> ignoreList, string src)
1314
{
1415
foreach (Match match in ApiConstantRegex.Matches(src))
1516
{
1617
var identifier = match.Groups["identifier"].Value;
17-
if (identifier.Contains('(')) continue; // skip #define's of functions
18+
19+
if (ignoreList.Contains(identifier))
20+
continue;
21+
if (identifier.Contains('('))
22+
continue; // skip #define's of functions
23+
1824
var value = match.Groups["value"].Value.Trim();
1925
var type = value.Contains('.') ? "float" : "int";
2026
if (type == "float" && !value.EndsWith("f")) value += "f";

Box2dNetGen/Box2dNetGen/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ internal class Program
3030
{ "b2Vec2", "Vector2" }
3131
};
3232

33+
private static readonly List<string> _precompilerConstantsIgnoreList = ["B2_ENABLE_VALIDATION"];
34+
3335
/// <summary>
3436
/// Logic that decides whether we generate the convenience initializer ctors (ctors with parameters to set all the struct's fields)
3537
/// </summary>
@@ -78,7 +80,7 @@ private static async Task BuildCsWrapperAsync(string box2dFolder, string csFilen
7880
var src = await ReadSourceFiles(Path.Combine(box2dFolder, "include\\box2d"));
7981

8082
Console.WriteLine("\n\nParsing C ...");
81-
var constants = ConstantsExtractor.ExtractAllPrecompilerDefines(src).ToList();
83+
var constants = ConstantsExtractor.ExtractAllPrecompilerDefines(_precompilerConstantsIgnoreList, src).ToList();
8284
var structs = new StructsExtractor(_excludedTypes, _structFieldModifiers).ExtractAllStructs(src).ToList();
8385
var delegates = DelegatesExtractor.ExtractAllDelegates(src).ToList();
8486
var functions = ApiFunctionsExtractor.ExtractAllApiFunctions(src).ToList();

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ There are now two folders with samples:
154154

155155
# Regenerating the wrapper
156156

157-
Normally, you don't need to regenerate the wrapper yourself. I regenerate every few weeks for the latest version of Box2D. The resulting Win x64 DLLs (debug and release) are also included in this repo and in the Nuget package.
157+
Normally, you don't need to regenerate the wrapper yourself. I regenerate every few weeks/months for the latest version of Box2D depending on how active the project is. The resulting Win x64 DLLs (debug and release) are also included in this repo and in the Nuget package.
158158

159159
But if you need to do it yourself anyway, perform these steps:
160160

@@ -196,6 +196,7 @@ Build the now updated Box2dNet solution and use the dll in your game, or directl
196196

197197
# History
198198

199+
* 2026/03/25: v3.1.8.8 - Regenerated
199200
* 2026/01/11: v3.1.8.7 - Regenerated
200201
* 2025/11/02: v3.1.8.6 - Regenerated
201202
* 2025/08/03: v3.1.8.5 - Regenerated

0 commit comments

Comments
 (0)