mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 12:38:24 +01:00
177 lines
9.3 KiB
C#
177 lines
9.3 KiB
C#
/*
|
|
* @brief Contains the Box2D typedefs ported to C#.
|
|
*
|
|
* @warning This file is auto-generated by Brutal.Box2D.Generate.
|
|
* Do not edit this file directly.
|
|
* If you want to change the generated code, modify the generation rules.
|
|
*/
|
|
using System.Runtime.InteropServices;
|
|
using Brutal.Numerics;
|
|
|
|
namespace Brutal.Box2DApi
|
|
{
|
|
/// Prototype for user allocation function
|
|
/// <param name="size">the allocation size in bytes </param>
|
|
/// <param name="alignment">the required alignment, guaranteed to be a power of 2 </param>
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public unsafe delegate void* B2AllocFcn(uint size, int alignment);
|
|
|
|
/// Prototype for user free function
|
|
/// <param name="mem">the memory previously allocated through `b2AllocFcn` </param>
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public delegate void B2FreeFcn(nint mem);
|
|
|
|
/// Prototype for the user assert callback. Return 0 to skip the debugger break.
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public unsafe delegate int B2AssertFcn(byte* condition, byte* fileName, int lineNumber);
|
|
|
|
/// This function receives proxies found in the AABB query.
|
|
/// RETURN: true if the query should continue
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public delegate Bool8 B2TreeQueryCallbackFcn(int proxyId, ulong userData, nint context);
|
|
|
|
/// This function receives clipped ray cast input for a proxy. The function
|
|
/// returns the new ray fraction.
|
|
/// - return a value of 0 to terminate the ray cast
|
|
/// - return a value less than input->maxFraction to clip the ray
|
|
/// - return a value of input->maxFraction to continue the ray cast without clipping
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public unsafe delegate float B2TreeRayCastCallbackFcn(
|
|
B2RayCastInput* input,
|
|
int proxyId,
|
|
ulong userData,
|
|
nint context
|
|
);
|
|
|
|
/// This function receives clipped ray cast input for a proxy. The function
|
|
/// returns the new ray fraction.
|
|
/// - return a value of 0 to terminate the ray cast
|
|
/// - return a value less than input->maxFraction to clip the ray
|
|
/// - return a value of input->maxFraction to continue the ray cast without clipping
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public unsafe delegate float B2TreeShapeCastCallbackFcn(
|
|
B2ShapeCastInput* input,
|
|
int proxyId,
|
|
ulong userData,
|
|
nint context
|
|
);
|
|
|
|
/// Task interface
|
|
/// This is prototype for a Box2D task. Your task system is expected to invoke the Box2D task with these arguments.
|
|
/// The task spans a range of the parallel-for: [startIndex, endIndex)
|
|
/// The worker index must correctly identify each worker in the user thread pool, expected in [0, workerCount).
|
|
/// A worker must only exist on only one thread at a time and is analogous to the thread index.
|
|
/// The task context is the context pointer sent from Box2D when it is enqueued.
|
|
/// The startIndex and endIndex are expected in the range [0, itemCount) where itemCount is the argument to b2EnqueueTaskCallback
|
|
/// below. Box2D expects startIndex
|
|
/// <
|
|
/// endIndex and will execute a loop like this:
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public delegate void B2TaskCallback(int startIndex, int endIndex, uint workerIndex, nint taskContext);
|
|
|
|
/// These functions can be provided to Box2D to invoke a task system. These are designed to work well with enkiTS.
|
|
/// Returns a pointer to the user's task object. May be nullptr. A nullptr indicates to Box2D that the work was executed
|
|
/// serially within the callback and there is no need to call b2FinishTaskCallback.
|
|
/// The itemCount is the number of Box2D work items that are to be partitioned among workers by the user's task system.
|
|
/// This is essentially a parallel-for. The minRange parameter is a suggestion of the minimum number of items to assign
|
|
/// per worker to reduce overhead. For example, suppose the task is small and that itemCount is 16. A minRange of 8 suggests
|
|
/// that your task system should split the work items among just two workers, even if you have more available.
|
|
/// In general the range [startIndex, endIndex) send to b2TaskCallback should obey:
|
|
/// endIndex - startIndex >= minRange
|
|
/// The exception of course is when itemCount
|
|
/// <
|
|
/// minRange.
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public unsafe delegate void* B2EnqueueTaskCallback(
|
|
nint task,
|
|
int itemCount,
|
|
int minRange,
|
|
nint taskContext,
|
|
nint userContext
|
|
);
|
|
|
|
/// Finishes a user task object that wraps a Box2D task.
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public delegate void B2FinishTaskCallback(nint userTask, nint userContext);
|
|
|
|
/// Optional friction mixing callback. This intentionally provides no context objects because this is called
|
|
/// from a worker thread.
|
|
/// WARNING: This function should not attempt to modify Box2D state or user application state.
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public delegate float B2FrictionCallback(
|
|
float frictionA,
|
|
int userMaterialIdA,
|
|
float frictionB,
|
|
int userMaterialIdB
|
|
);
|
|
|
|
/// Optional restitution mixing callback. This intentionally provides no context objects because this is called
|
|
/// from a worker thread.
|
|
/// WARNING: This function should not attempt to modify Box2D state or user application state.
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public delegate float B2RestitutionCallback(
|
|
float restitutionA,
|
|
int userMaterialIdA,
|
|
float restitutionB,
|
|
int userMaterialIdB
|
|
);
|
|
|
|
/// Prototype for a contact filter callback.
|
|
/// This is called when a contact pair is considered for collision. This allows you to
|
|
/// perform custom logic to prevent collision between shapes. This is only called if
|
|
/// one of the two shapes has custom filtering enabled.
|
|
/// Notes:
|
|
/// - this function must be thread-safe
|
|
/// - this is only called if one of the two shapes has enabled custom filtering
|
|
/// - this is called only for awake dynamic bodies
|
|
/// Return false if you want to disable the collision
|
|
/// SEE: b2ShapeDef
|
|
/// WARNING: Do not attempt to modify the world inside this callback
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public delegate Bool8 B2CustomFilterFcn(B2Shape shapeIdA, B2Shape shapeIdB, nint context);
|
|
|
|
/// Prototype for a pre-solve callback.
|
|
/// This is called after a contact is updated. This allows you to inspect a
|
|
/// contact before it goes to the solver. If you are careful, you can modify the
|
|
/// contact manifold (e.g. modify the normal).
|
|
/// Notes:
|
|
/// - this function must be thread-safe
|
|
/// - this is only called if the shape has enabled pre-solve events
|
|
/// - this is called only for awake dynamic bodies
|
|
/// - this is not called for sensors
|
|
/// - the supplied manifold has impulse values from the previous step
|
|
/// Return false if you want to disable the contact this step
|
|
/// WARNING: Do not attempt to modify the world inside this callback
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public unsafe delegate Bool8 B2PreSolveFcn(B2Shape shapeIdA, B2Shape shapeIdB, B2Manifold* manifold, nint context);
|
|
|
|
/// Prototype callback for overlap queries.
|
|
/// Called for each shape found in the query.
|
|
/// SEE: b2World_OverlapABB
|
|
/// RETURN: false to terminate the query.
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public delegate Bool8 B2OverlapResultFcn(B2Shape shapeId, nint context);
|
|
|
|
/// Prototype callback for ray and shape casts.
|
|
/// Called for each shape found in the query. You control how the ray cast
|
|
/// proceeds by returning a float:
|
|
/// return -1: ignore this shape and continue
|
|
/// return 0: terminate the ray cast
|
|
/// return fraction: clip the ray to this point
|
|
/// return 1: don't clip the ray and continue
|
|
/// A cast with initial overlap will return a zero fraction and a zero normal.
|
|
/// <param name="shapeId">the shape hit by the ray </param>
|
|
/// <param name="point">the point of initial intersection </param>
|
|
/// <param name="normal">the normal vector at the point of intersection, zero for a shape cast with initial overlap </param>
|
|
/// <param name="fraction">the fraction along the ray at the point of intersection, zero for a shape cast with initial overlap </param>
|
|
/// <param name="context">the user context </param>
|
|
/// RETURN: -1 to filter, 0 to terminate, fraction to clip the ray for closest hit, 1 to continue
|
|
/// SEE: b2World_CastRay
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public delegate float B2CastResultFcn(B2Shape shapeId, float2 point, float2 normal, float fraction, nint context);
|
|
|
|
/// Used to collect collision planes for character movers.
|
|
/// Return true to continue gathering planes.
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
public unsafe delegate Bool8 B2PlaneResultFcn(B2Shape shapeId, B2PlaneResult* plane, nint context);
|
|
}
|