Skip to content

Commit e4969ce

Browse files
author
Thomas Vantroyen
committed
Regenerate from latest Box2D
1 parent 821ba20 commit e4969ce

5 files changed

Lines changed: 112 additions & 53 deletions

File tree

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.6</Version>
17+
<Version>3.1.8.7</Version>
1818
</PropertyGroup>
1919

2020
<ItemGroup>

Box2dNet/Interop/B2Api.cs

Lines changed: 102 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated by Box2dNetGen for Box2D v3 on 02/11/2025 15:17:57
1+
// Generated by Box2dNetGen for Box2D v3 on 11/01/2026 07:32:50
22

33
using System.Runtime.InteropServices;
44
using System.Numerics;
@@ -404,10 +404,14 @@ public enum b2HexColor
404404
/// <returns>Original C type: void</returns>
405405
/// <param name="mem">the memory previously allocated through `b2AllocFcn`
406406
/// (Original C type: void*)</param>
407+
/// <param name="size">the allocation size in bytes
408+
/// (Original C type: unsigned int)</param>
407409
/// <param name="mem">the memory previously allocated through `b2AllocFcn`
408410
/// (Original C type: void*)</param>
411+
/// <param name="size">the allocation size in bytes
412+
/// (Original C type: unsigned int)</param>
409413
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
410-
public delegate void b2FreeFcn(IntPtr /* void* */ mem);
414+
public delegate void b2FreeFcn(IntPtr /* void* */ mem, uint size);
411415

412416
/// <summary>
413417
/// Prototype for the user assert callback. Return 0 to skip the debugger break.
@@ -419,6 +423,14 @@ public enum b2HexColor
419423
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
420424
public delegate int b2AssertFcn(string condition, string fileName, int lineNumber);
421425

426+
/// <summary>
427+
/// Prototype for user log callback. Used to log warnings.
428+
/// </summary>
429+
/// <returns>Original C type: void</returns>
430+
/// <param name="message">(Original C type: const char*)</param>
431+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
432+
public delegate void b2LogFcn(string message);
433+
422434
/// <summary>
423435
/// This function receives proxies found in the AABB query.
424436
/// @return true if the query should continue
@@ -1687,6 +1699,8 @@ public partial struct b2ManifoldPoint
16871699
/// <summary>
16881700
/// The total normal impulse applied across sub-stepping and restitution. This is important
16891701
/// to identify speculative contact points that had an interaction in the time step.
1702+
/// This includes the warm starting impulse, the sub-step delta impulse, and the restitution
1703+
/// impulse.
16901704
/// </summary>
16911705
/// <returns>Original C type: float</returns>
16921706
public float totalNormalImpulse;
@@ -2469,10 +2483,20 @@ public partial struct b2BodyDef
24692483
public bool isAwake;
24702484

24712485
/// <summary>
2472-
/// Treat this body as high speed object that performs continuous collision detection
2486+
/// Treat this body as a high speed object that performs continuous collision detection
24732487
/// against dynamic and kinematic bodies, but not other bullet bodies.
24742488
/// @warning Bullets should be used sparingly. They are not a solution for general dynamic-versus-dynamic
2475-
/// continuous collision.
2489+
/// continuous collision. They do not guarantee accurate collision if both bodies are fast moving because
2490+
/// the bullet does a continuous check after all non-bullet bodies have moved. You could get unlucky and have
2491+
/// the bullet body end a time step very close to a non-bullet body and the non-bullet body then moves over
2492+
/// the bullet body. In continuous collision, initial overlap is ignored to avoid freezing bodies in place.
2493+
/// I do not recommend using them for game projectiles if precise collision timing is needed. Instead consider
2494+
/// using a ray or shape cast. You can use a marching ray or shape cast for projectile that moves over time.
2495+
/// If you want a fast moving projectile to collide with a fast moving target, you need to consider the relative
2496+
/// movement in your ray or shape cast. This is out of the scope of Box2D.
2497+
/// So what are good use cases for bullets? Pinball games or games with dynamic containers that hold other objects.
2498+
/// It should be a use case where it doesn't break the game if there is a collision missed, but the having them
2499+
/// captured improves the quality of the game.
24762500
/// </summary>
24772501
/// <returns>Original C type: bool</returns>
24782502
[MarshalAs(UnmanagedType.U1)]
@@ -2742,6 +2766,7 @@ public partial struct b2ShapeDef
27422766

27432767
/// <summary>
27442768
/// Should the body update the mass properties when this shape is created. Default is true.
2769+
/// Warning: if this is true, you MUST call b2Body_ApplyMassFromShapes before simulating the world.
27452770
/// </summary>
27462771
/// <returns>Original C type: bool</returns>
27472772
[MarshalAs(UnmanagedType.U1)]
@@ -2801,7 +2826,8 @@ public partial struct b2ChainDef
28012826

28022827
/// <summary>
28032828
/// The material count. Must be 1 or count. This allows you to provide one
2804-
/// material for all segments or a unique material per segment.
2829+
/// material for all segments or a unique material per segment. For open
2830+
/// chains, the material on the ghost segments are place holders.
28052831
/// </summary>
28062832
/// <returns>Original C type: int</returns>
28072833
public int materialCount;
@@ -3174,13 +3200,13 @@ public partial struct b2DistanceJointDef
31743200
public bool enableLimit;
31753201

31763202
/// <summary>
3177-
/// Minimum length. Clamped to a stable minimum value.
3203+
/// Minimum length for limit. Clamped to a stable minimum value.
31783204
/// </summary>
31793205
/// <returns>Original C type: float</returns>
31803206
public float minLength;
31813207

31823208
/// <summary>
3183-
/// Maximum length. Must be greater than or equal to the minimum length.
3209+
/// Maximum length for limit. Must be greater than or equal to the minimum length.
31843210
/// </summary>
31853211
/// <returns>Original C type: float</returns>
31863212
public float maxLength;
@@ -3860,6 +3886,14 @@ public partial struct b2ContactHitEvent
38603886
/// <returns>Original C type: b2ShapeId</returns>
38613887
public b2ShapeId shapeIdB;
38623888

3889+
/// <summary>
3890+
/// Id of the contact.
3891+
/// @warning this contact may have been destroyed
3892+
/// @see b2Contact_IsValid
3893+
/// </summary>
3894+
/// <returns>Original C type: b2ContactId</returns>
3895+
public b2ContactId contactId;
3896+
38633897
/// <summary>
38643898
/// Point where the shapes hit at the beginning of the time step.
38653899
/// This is a mid-point between the two surfaces. It could be at speculative
@@ -3880,10 +3914,11 @@ public partial struct b2ContactHitEvent
38803914
/// <returns>Original C type: float</returns>
38813915
public float approachSpeed;
38823916

3883-
public b2ContactHitEvent(in b2ShapeId shapeIdA, in b2ShapeId shapeIdB, in Vector2 point, in Vector2 normal, in float approachSpeed)
3917+
public b2ContactHitEvent(in b2ShapeId shapeIdA, in b2ShapeId shapeIdB, in b2ContactId contactId, in Vector2 point, in Vector2 normal, in float approachSpeed)
38843918
{
38853919
this.shapeIdA = shapeIdA;
38863920
this.shapeIdB = shapeIdB;
3921+
this.contactId = contactId;
38873922
this.point = point;
38883923
this.normal = normal;
38893924
this.approachSpeed = approachSpeed;
@@ -4170,7 +4205,7 @@ public static void b2SetAllocator(b2AllocFcn allocFcn, b2FreeFcn freeFcn)
41704205
public static extern int b2GetByteCount();
41714206

41724207
/// <summary>
4173-
/// Override the default assert callback
4208+
/// Override the default assert function
41744209
/// </summary>
41754210
/// <returns>Original C type: void</returns>
41764211
/// <param name="assertFcn">a non-null assert callback
@@ -4181,7 +4216,7 @@ public static void b2SetAllocator(b2AllocFcn allocFcn, b2FreeFcn freeFcn)
41814216
public static extern void b2SetAssertFcn(IntPtr assertFcn);
41824217

41834218
/// <summary>
4184-
/// Override the default assert callback
4219+
/// Override the default assert function
41854220
/// </summary>
41864221
/// <returns>Original C type: void</returns>
41874222
/// <param name="assertFcn">a non-null assert callback
@@ -4193,6 +4228,30 @@ public static void b2SetAssertFcn(b2AssertFcn assertFcn)
41934228
b2SetAssertFcn(Marshal.GetFunctionPointerForDelegate(assertFcn));
41944229
}
41954230

4231+
/// <summary>
4232+
/// Override the default log function
4233+
/// </summary>
4234+
/// <returns>Original C type: void</returns>
4235+
/// <param name="logFcn">a non-null log callback
4236+
/// (Original C type: b2LogFcn*)</param>
4237+
/// <param name="logFcn">a non-null log callback
4238+
/// (Original C type: b2LogFcn*)</param>
4239+
[DllImport(Box2DLibrary, CallingConvention = CallingConvention.Cdecl)]
4240+
public static extern void b2SetLogFcn(IntPtr logFcn);
4241+
4242+
/// <summary>
4243+
/// Override the default log function
4244+
/// </summary>
4245+
/// <returns>Original C type: void</returns>
4246+
/// <param name="logFcn">a non-null log callback
4247+
/// (Original C type: b2LogFcn*)</param>
4248+
/// <param name="logFcn">a non-null log callback
4249+
/// (Original C type: b2LogFcn*)</param>
4250+
public static void b2SetLogFcn(b2LogFcn logFcn)
4251+
{
4252+
b2SetLogFcn(Marshal.GetFunctionPointerForDelegate(logFcn));
4253+
}
4254+
41964255
/// <summary>
41974256
/// Get the current version of Box2D
41984257
/// </summary>
@@ -5032,15 +5091,28 @@ public static void b2World_SetRestitutionCallback(b2WorldId worldId, b2Restituti
50325091
/// <summary>
50335092
/// Set the velocity to reach the given transform after a given time step.
50345093
/// The result will be close but maybe not exact. This is meant for kinematic bodies.
5035-
/// The target is not applied if the velocity would be below the sleep threshold.
5036-
/// This will automatically wake the body if asleep.
5094+
/// The target is not applied if the velocity would be below the sleep threshold and
5095+
/// the body is currently asleep.
50375096
/// </summary>
50385097
/// <returns>Original C type: void</returns>
5039-
/// <param name="bodyId">(Original C type: b2BodyId)</param>
5040-
/// <param name="target">(Original C type: b2Transform)</param>
5041-
/// <param name="timeStep">(Original C type: float)</param>
5098+
/// <param name="bodyId">The body id
5099+
/// (Original C type: b2BodyId)</param>
5100+
/// <param name="target">The target transform for the body
5101+
/// (Original C type: b2Transform)</param>
5102+
/// <param name="timeStep">The time step of the next call to b2World_Step
5103+
/// (Original C type: float)</param>
5104+
/// <param name="wake">Option to wake the body or not
5105+
/// (Original C type: bool)</param>
5106+
/// <param name="bodyId">The body id
5107+
/// (Original C type: b2BodyId)</param>
5108+
/// <param name="target">The target transform for the body
5109+
/// (Original C type: b2Transform)</param>
5110+
/// <param name="timeStep">The time step of the next call to b2World_Step
5111+
/// (Original C type: float)</param>
5112+
/// <param name="wake">Option to wake the body or not
5113+
/// (Original C type: bool)</param>
50425114
[DllImport(Box2DLibrary, CallingConvention = CallingConvention.Cdecl)]
5043-
public static extern void b2Body_SetTargetTransform(b2BodyId bodyId, b2Transform target, float timeStep);
5115+
public static extern void b2Body_SetTargetTransform(b2BodyId bodyId, b2Transform target, float timeStep, [MarshalAs(UnmanagedType.U1)] bool wake);
50445116

50455117
/// <summary>
50465118
/// Get the linear velocity of a local point attached to a body. Usually in meters per second.
@@ -5125,6 +5197,19 @@ public static void b2World_SetRestitutionCallback(b2WorldId worldId, b2Restituti
51255197
[DllImport(Box2DLibrary, CallingConvention = CallingConvention.Cdecl)]
51265198
public static extern void b2Body_ApplyTorque(b2BodyId bodyId, float torque, [MarshalAs(UnmanagedType.U1)] bool wake);
51275199

5200+
/// <summary>
5201+
/// Clear the force and torque on this body. Forces and torques are automatically cleared after each world
5202+
/// step. So this only needs to be called if the application wants to remove the effect of previous
5203+
/// calls to apply forces and torques before the world step is called.
5204+
/// </summary>
5205+
/// <returns>Original C type: void</returns>
5206+
/// <param name="bodyId">The body id
5207+
/// (Original C type: b2BodyId)</param>
5208+
/// <param name="bodyId">The body id
5209+
/// (Original C type: b2BodyId)</param>
5210+
[DllImport(Box2DLibrary, CallingConvention = CallingConvention.Cdecl)]
5211+
public static extern void b2Body_ClearForces(b2BodyId bodyId);
5212+
51285213
/// <summary>
51295214
/// Apply an impulse at a point. This immediately modifies the velocity.
51305215
/// It also modifies the angular velocity if the point of application
@@ -5557,7 +5642,7 @@ public static void b2World_SetRestitutionCallback(b2WorldId worldId, b2Restituti
55575642
/// <summary>
55585643
/// Create a capsule shape and attach it to a body. The shape definition and geometry are fully cloned.
55595644
/// Contacts are not created until the next time step.
5560-
/// @return the shape id for accessing the shape
5645+
/// @return the shape id for accessing the shape, this will be b2_nullShapeId if the length is too small.
55615646
/// </summary>
55625647
/// <returns>Original C type: b2ShapeId</returns>
55635648
/// <param name="bodyId">(Original C type: b2BodyId)</param>

Box2dNet/box2d.dll

512 Bytes
Binary file not shown.

Box2dNet/box2dd.dll

-1 KB
Binary file not shown.

README.md

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -196,43 +196,17 @@ Build the now updated Box2dNet solution and use the dll in your game, or directl
196196

197197
# History
198198

199-
## 2025/11/02: v3.1.8.6 for Box2D v3.1.1
200-
201-
* Regenerated for latest commits on Box2D
202-
203-
## 2025/08/03: v3.1.8.5 for Box2D v3.1.1
204-
205-
* Regenerated for latest commits on Box2D
206-
* Messed up a few version numbers...
207-
208-
## 2025/06/29: v3.1.8.2 for Box2D v3.1.1
209-
210-
* Regenerated for latest commits on Box2D
211-
212-
## 2025/06/22: v3.1.8 for Box2D v3.1.1
213-
214-
* Started with the Box2D samples app rewritten in .NET + MonoGame: contains 1 sample now
215-
* B2DebugDraw struct bug fixed.
216-
217-
## 2025/06/15: v3.1.7 for Box2D v3.1.1
218-
219-
* Regenerated for updated Box2D
220-
* Quite some changes in the Box2D original code since previous time. Box2dNetGen was refactored and adjusted accordingly.
199+
* 2026/01/11: v3.1.8.7 - Regenerated
200+
* 2025/11/02: v3.1.8.6 - Regenerated
201+
* 2025/08/03: v3.1.8.5 - Regenerated
202+
* 2025/06/29: v3.1.8.2 - Regenerated
203+
* 2025/06/22: v3.1.8 - Regenerated + 1 Box2D sample rewritten in .NET + MonoGame + B2DebugDraw struct bug fixed.
204+
* 2025/06/15: v3.1.7 - Regenerated + Box2dNetGen was refactored according to many changes in Box2D C code.
221205

222206
> Box2D started using 3-part version labels. This messed up Box2dNet's versioning where the first two parts were Box2D's version and the third was for Box2dNet changes. I will switch to another system as of Box2D v3.2.0
223207
224-
## 2025/06/15: v3.1.6 for Box2D v3.1
225-
226-
* Small adjustment for Godot. https://github.com/thomasvt/Box2DNet/issues/2
227-
228-
## 2025/05/06: v3.1.5 for Box2D v3.1
229-
230-
* Added Span-based convenience properties like `b2BodyEvents.moveEventsAsSpan`.
231-
* Box2d API methods that take delegate pointers (IntPtr) were annoying to use as you couldn't see the actual delegate. Box2DNet now also generates an overload for these methods with the actual delegate as parameter. eg. `b2World_CastShape(b2WorldId worldId, in b2ShapeProxy proxy, Vector2 translation, b2QueryFilter filter, __b2CastResultFcn fcn__, IntPtr context)`
232-
233-
## 2025/05/04: v3.1.4 for Box2D v3.1
234-
235-
* Regenerated for updated Box2D
236-
* Started publishing `Box2dNet` as a nuget package
208+
* 2025/06/15: v3.1.6 - regenerated for Box2D v3.1 + https://github.com/thomasvt/Box2DNet/issues/2
209+
* 2025/05/06: v3.1.5 - regenerated for Box2D v3.1 + Span-based convenience properties + overloads with strongly typed delegates
210+
* 2025/05/04: v3.1.4 - regenerated for Box2D v3.1 + Started publishing `Box2dNet` as a nuget package
237211

238212
... older history not logged ...

0 commit comments

Comments
 (0)