mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 13:08:24 +01:00
first
This commit is contained in:
parent
bd62d51ec9
commit
b578433e37
8 changed files with 784842 additions and 0 deletions
68
Brutal.Box2D/B2Joint.cs
Normal file
68
Brutal.Box2D/B2Joint.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices.Marshalling;
|
||||
|
||||
namespace Brutal.Box2DApi;
|
||||
|
||||
[NativeMarshalling(typeof(B2JointMarshaller<B2Joint>))]
|
||||
public partial class B2Joint : IBox2DObject<B2Joint>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
internal ulong InteropValue;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsNull()
|
||||
{
|
||||
return InteropValue == 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Equals(B2Joint? x, B2Joint? y)
|
||||
{
|
||||
if (x is null && y is null)
|
||||
return true;
|
||||
|
||||
if (x is null || y is null)
|
||||
return false;
|
||||
|
||||
return x.InteropValue == y.InteropValue;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int GetHashCode(B2Joint obj)
|
||||
{
|
||||
if (obj.IsNull())
|
||||
return 0;
|
||||
|
||||
return obj.InteropValue.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
[CustomMarshaller(typeof(B2Joint), MarshalMode.Default, typeof(B2JointMarshaller<B2Joint>))]
|
||||
[CustomMarshaller(typeof(B2DistanceJoint), MarshalMode.Default, typeof(B2JointMarshaller<B2DistanceJoint>))]
|
||||
[CustomMarshaller(typeof(B2FilterJoint), MarshalMode.Default, typeof(B2JointMarshaller<B2FilterJoint>))]
|
||||
[CustomMarshaller(typeof(B2MotorJoint), MarshalMode.Default, typeof(B2JointMarshaller<B2MotorJoint>))]
|
||||
[CustomMarshaller(typeof(B2MouseJoint), MarshalMode.Default, typeof(B2JointMarshaller<B2MouseJoint>))]
|
||||
[CustomMarshaller(typeof(B2PrismaticJoint), MarshalMode.Default, typeof(B2JointMarshaller<B2PrismaticJoint>))]
|
||||
[CustomMarshaller(typeof(B2RevoluteJoint), MarshalMode.Default, typeof(B2JointMarshaller<B2RevoluteJoint>))]
|
||||
[CustomMarshaller(typeof(B2WeldJoint), MarshalMode.Default, typeof(B2JointMarshaller<B2WeldJoint>))]
|
||||
[CustomMarshaller(typeof(B2WheelJoint), MarshalMode.Default, typeof(B2JointMarshaller<B2WheelJoint>))]
|
||||
internal static class B2JointMarshaller<T>
|
||||
where T : B2Joint, new()
|
||||
{
|
||||
internal static ulong ConvertToUnmanaged(T? managed)
|
||||
{
|
||||
if (managed is null)
|
||||
return 0;
|
||||
|
||||
return managed.InteropValue;
|
||||
}
|
||||
|
||||
internal static T? ConvertToManaged(ulong unmanaged)
|
||||
{
|
||||
if (unmanaged == 0)
|
||||
return null;
|
||||
|
||||
return new T { InteropValue = unmanaged };
|
||||
}
|
||||
}
|
||||
32
Brutal.Box2D/Box2D.cs
Normal file
32
Brutal.Box2D/Box2D.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Brutal.Box2DApi;
|
||||
|
||||
/// <summary>
|
||||
/// A 2D physics engine.
|
||||
/// </summary>
|
||||
public static partial class Box2D
|
||||
{
|
||||
private const string Dll =
|
||||
#if DEBUG
|
||||
"box2dd";
|
||||
#else
|
||||
"box2d";
|
||||
#endif
|
||||
|
||||
static Box2D()
|
||||
{
|
||||
// Load the GLFW native library
|
||||
var glfwNative = NativeLibrary.Load(Dll, typeof(Box2D).Assembly, DllImportSearchPath.AssemblyDirectory);
|
||||
|
||||
// Assign the native library to the assembly resolver
|
||||
NativeLibrary.SetDllImportResolver(
|
||||
typeof(Box2D).Assembly,
|
||||
(libraryName, _, _) =>
|
||||
{
|
||||
return glfwNative;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
2459
Brutal.Box2D/Box2D.gen.cs
Normal file
2459
Brutal.Box2D/Box2D.gen.cs
Normal file
File diff suppressed because it is too large
Load diff
539
Brutal.Box2D/Enumerations.gen.cs
Normal file
539
Brutal.Box2D/Enumerations.gen.cs
Normal file
|
|
@ -0,0 +1,539 @@
|
|||
/*
|
||||
* @brief Contains the Box2D enumerations 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.
|
||||
*/
|
||||
namespace Brutal.Box2DApi
|
||||
{
|
||||
/// Describes the TOI output
|
||||
public enum B2ToiState : uint
|
||||
{
|
||||
///
|
||||
Unknown = 0U,
|
||||
|
||||
///
|
||||
Failed = 1U,
|
||||
|
||||
///
|
||||
Overlapped = 2U,
|
||||
|
||||
///
|
||||
Hit = 3U,
|
||||
|
||||
///
|
||||
Separated = 4U,
|
||||
}
|
||||
|
||||
/// The body simulation type.
|
||||
/// Each body is one of these three types. The type determines how the body behaves in the simulation.
|
||||
public enum B2BodyType : uint
|
||||
{
|
||||
/// zero mass, zero velocity, may be manually moved
|
||||
Static = 0,
|
||||
|
||||
/// zero mass, velocity set by user, moved by solver
|
||||
Kinematic = 1,
|
||||
|
||||
/// positive mass, velocity determined by forces, moved by solver
|
||||
Dynamic = 2,
|
||||
|
||||
/// number of body types
|
||||
TypeCount = 3U,
|
||||
}
|
||||
|
||||
/// Shape type
|
||||
public enum B2ShapeType : uint
|
||||
{
|
||||
/// A circle with an offset
|
||||
Circle = 0U,
|
||||
|
||||
/// A capsule is an extruded circle
|
||||
Capsule = 1U,
|
||||
|
||||
/// A line segment
|
||||
Segment = 2U,
|
||||
|
||||
/// A convex polygon
|
||||
Polygon = 3U,
|
||||
|
||||
/// A line segment owned by a chain shape
|
||||
ChainSegment = 4U,
|
||||
|
||||
/// The number of shape types
|
||||
TypeCount = 5U,
|
||||
}
|
||||
|
||||
/// Joint type enumeration
|
||||
/// This is useful because all joint types use b2JointId and sometimes you
|
||||
/// want to get the type of a joint.
|
||||
public enum B2JointType : uint
|
||||
{
|
||||
///
|
||||
Distance = 0U,
|
||||
|
||||
///
|
||||
Filter = 1U,
|
||||
|
||||
///
|
||||
Motor = 2U,
|
||||
|
||||
///
|
||||
Mouse = 3U,
|
||||
|
||||
///
|
||||
Prismatic = 4U,
|
||||
|
||||
///
|
||||
Revolute = 5U,
|
||||
|
||||
///
|
||||
Weld = 6U,
|
||||
|
||||
///
|
||||
Wheel = 7U,
|
||||
}
|
||||
|
||||
/// These colors are used for debug draw and mostly match the named SVG colors.
|
||||
/// See https://www.rapidtables.com/web/color/index.html
|
||||
/// https://johndecember.com/html/spec/colorsvg.html
|
||||
/// https://upload.wikimedia.org/wikipedia/commons/2/2b/SVG_Recognized_color_keyword_names.svg
|
||||
public enum B2HexColor : uint
|
||||
{
|
||||
///
|
||||
AliceBlue = 0xF0F8FF,
|
||||
|
||||
///
|
||||
AntiqueWhite = 0xFAEBD7,
|
||||
|
||||
///
|
||||
Aqua = 0x00FFFF,
|
||||
|
||||
///
|
||||
Aquamarine = 0x7FFFD4,
|
||||
|
||||
///
|
||||
Azure = 0xF0FFFF,
|
||||
|
||||
///
|
||||
Beige = 0xF5F5DC,
|
||||
|
||||
///
|
||||
Bisque = 0xFFE4C4,
|
||||
|
||||
///
|
||||
Black = 0x000000,
|
||||
|
||||
///
|
||||
BlanchedAlmond = 0xFFEBCD,
|
||||
|
||||
///
|
||||
Blue = 0x0000FF,
|
||||
|
||||
///
|
||||
BlueViolet = 0x8A2BE2,
|
||||
|
||||
///
|
||||
Brown = 0xA52A2A,
|
||||
|
||||
///
|
||||
Burlywood = 0xDEB887,
|
||||
|
||||
///
|
||||
CadetBlue = 0x5F9EA0,
|
||||
|
||||
///
|
||||
Chartreuse = 0x7FFF00,
|
||||
|
||||
///
|
||||
Chocolate = 0xD2691E,
|
||||
|
||||
///
|
||||
Coral = 0xFF7F50,
|
||||
|
||||
///
|
||||
CornflowerBlue = 0x6495ED,
|
||||
|
||||
///
|
||||
Cornsilk = 0xFFF8DC,
|
||||
|
||||
///
|
||||
Crimson = 0xDC143C,
|
||||
|
||||
///
|
||||
Cyan = 0x00FFFF,
|
||||
|
||||
///
|
||||
DarkBlue = 0x00008B,
|
||||
|
||||
///
|
||||
DarkCyan = 0x008B8B,
|
||||
|
||||
///
|
||||
DarkGoldenRod = 0xB8860B,
|
||||
|
||||
///
|
||||
DarkGray = 0xA9A9A9,
|
||||
|
||||
///
|
||||
DarkGreen = 0x006400,
|
||||
|
||||
///
|
||||
DarkKhaki = 0xBDB76B,
|
||||
|
||||
///
|
||||
DarkMagenta = 0x8B008B,
|
||||
|
||||
///
|
||||
DarkOliveGreen = 0x556B2F,
|
||||
|
||||
///
|
||||
DarkOrange = 0xFF8C00,
|
||||
|
||||
///
|
||||
DarkOrchid = 0x9932CC,
|
||||
|
||||
///
|
||||
DarkRed = 0x8B0000,
|
||||
|
||||
///
|
||||
DarkSalmon = 0xE9967A,
|
||||
|
||||
///
|
||||
DarkSeaGreen = 0x8FBC8F,
|
||||
|
||||
///
|
||||
DarkSlateBlue = 0x483D8B,
|
||||
|
||||
///
|
||||
DarkSlateGray = 0x2F4F4F,
|
||||
|
||||
///
|
||||
DarkTurquoise = 0x00CED1,
|
||||
|
||||
///
|
||||
DarkViolet = 0x9400D3,
|
||||
|
||||
///
|
||||
DeepPink = 0xFF1493,
|
||||
|
||||
///
|
||||
DeepSkyBlue = 0x00BFFF,
|
||||
|
||||
///
|
||||
DimGray = 0x696969,
|
||||
|
||||
///
|
||||
DodgerBlue = 0x1E90FF,
|
||||
|
||||
///
|
||||
FireBrick = 0xB22222,
|
||||
|
||||
///
|
||||
FloralWhite = 0xFFFAF0,
|
||||
|
||||
///
|
||||
ForestGreen = 0x228B22,
|
||||
|
||||
///
|
||||
Fuchsia = 0xFF00FF,
|
||||
|
||||
///
|
||||
Gainsboro = 0xDCDCDC,
|
||||
|
||||
///
|
||||
GhostWhite = 0xF8F8FF,
|
||||
|
||||
///
|
||||
Gold = 0xFFD700,
|
||||
|
||||
///
|
||||
GoldenRod = 0xDAA520,
|
||||
|
||||
///
|
||||
Gray = 0x808080,
|
||||
|
||||
///
|
||||
Green = 0x008000,
|
||||
|
||||
///
|
||||
GreenYellow = 0xADFF2F,
|
||||
|
||||
///
|
||||
HoneyDew = 0xF0FFF0,
|
||||
|
||||
///
|
||||
HotPink = 0xFF69B4,
|
||||
|
||||
///
|
||||
IndianRed = 0xCD5C5C,
|
||||
|
||||
///
|
||||
Indigo = 0x4B0082,
|
||||
|
||||
///
|
||||
Ivory = 0xFFFFF0,
|
||||
|
||||
///
|
||||
Khaki = 0xF0E68C,
|
||||
|
||||
///
|
||||
Lavender = 0xE6E6FA,
|
||||
|
||||
///
|
||||
LavenderBlush = 0xFFF0F5,
|
||||
|
||||
///
|
||||
LawnGreen = 0x7CFC00,
|
||||
|
||||
///
|
||||
LemonChiffon = 0xFFFACD,
|
||||
|
||||
///
|
||||
LightBlue = 0xADD8E6,
|
||||
|
||||
///
|
||||
LightCoral = 0xF08080,
|
||||
|
||||
///
|
||||
LightCyan = 0xE0FFFF,
|
||||
|
||||
///
|
||||
LightGoldenRodYellow = 0xFAFAD2,
|
||||
|
||||
///
|
||||
LightGray = 0xD3D3D3,
|
||||
|
||||
///
|
||||
LightGreen = 0x90EE90,
|
||||
|
||||
///
|
||||
LightPink = 0xFFB6C1,
|
||||
|
||||
///
|
||||
LightSalmon = 0xFFA07A,
|
||||
|
||||
///
|
||||
LightSeaGreen = 0x20B2AA,
|
||||
|
||||
///
|
||||
LightSkyBlue = 0x87CEFA,
|
||||
|
||||
///
|
||||
LightSlateGray = 0x778899,
|
||||
|
||||
///
|
||||
LightSteelBlue = 0xB0C4DE,
|
||||
|
||||
///
|
||||
LightYellow = 0xFFFFE0,
|
||||
|
||||
///
|
||||
Lime = 0x00FF00,
|
||||
|
||||
///
|
||||
LimeGreen = 0x32CD32,
|
||||
|
||||
///
|
||||
Linen = 0xFAF0E6,
|
||||
|
||||
///
|
||||
Magenta = 0xFF00FF,
|
||||
|
||||
///
|
||||
Maroon = 0x800000,
|
||||
|
||||
///
|
||||
MediumAquaMarine = 0x66CDAA,
|
||||
|
||||
///
|
||||
MediumBlue = 0x0000CD,
|
||||
|
||||
///
|
||||
MediumOrchid = 0xBA55D3,
|
||||
|
||||
///
|
||||
MediumPurple = 0x9370DB,
|
||||
|
||||
///
|
||||
MediumSeaGreen = 0x3CB371,
|
||||
|
||||
///
|
||||
MediumSlateBlue = 0x7B68EE,
|
||||
|
||||
///
|
||||
MediumSpringGreen = 0x00FA9A,
|
||||
|
||||
///
|
||||
MediumTurquoise = 0x48D1CC,
|
||||
|
||||
///
|
||||
MediumVioletRed = 0xC71585,
|
||||
|
||||
///
|
||||
MidnightBlue = 0x191970,
|
||||
|
||||
///
|
||||
MintCream = 0xF5FFFA,
|
||||
|
||||
///
|
||||
MistyRose = 0xFFE4E1,
|
||||
|
||||
///
|
||||
Moccasin = 0xFFE4B5,
|
||||
|
||||
///
|
||||
NavajoWhite = 0xFFDEAD,
|
||||
|
||||
///
|
||||
Navy = 0x000080,
|
||||
|
||||
///
|
||||
OldLace = 0xFDF5E6,
|
||||
|
||||
///
|
||||
Olive = 0x808000,
|
||||
|
||||
///
|
||||
OliveDrab = 0x6B8E23,
|
||||
|
||||
///
|
||||
Orange = 0xFFA500,
|
||||
|
||||
///
|
||||
OrangeRed = 0xFF4500,
|
||||
|
||||
///
|
||||
Orchid = 0xDA70D6,
|
||||
|
||||
///
|
||||
PaleGoldenRod = 0xEEE8AA,
|
||||
|
||||
///
|
||||
PaleGreen = 0x98FB98,
|
||||
|
||||
///
|
||||
PaleTurquoise = 0xAFEEEE,
|
||||
|
||||
///
|
||||
PaleVioletRed = 0xDB7093,
|
||||
|
||||
///
|
||||
PapayaWhip = 0xFFEFD5,
|
||||
|
||||
///
|
||||
PeachPuff = 0xFFDAB9,
|
||||
|
||||
///
|
||||
Peru = 0xCD853F,
|
||||
|
||||
///
|
||||
Pink = 0xFFC0CB,
|
||||
|
||||
///
|
||||
Plum = 0xDDA0DD,
|
||||
|
||||
///
|
||||
PowderBlue = 0xB0E0E6,
|
||||
|
||||
///
|
||||
Purple = 0x800080,
|
||||
|
||||
///
|
||||
RebeccaPurple = 0x663399,
|
||||
|
||||
///
|
||||
Red = 0xFF0000,
|
||||
|
||||
///
|
||||
RosyBrown = 0xBC8F8F,
|
||||
|
||||
///
|
||||
RoyalBlue = 0x4169E1,
|
||||
|
||||
///
|
||||
SaddleBrown = 0x8B4513,
|
||||
|
||||
///
|
||||
Salmon = 0xFA8072,
|
||||
|
||||
///
|
||||
SandyBrown = 0xF4A460,
|
||||
|
||||
///
|
||||
SeaGreen = 0x2E8B57,
|
||||
|
||||
///
|
||||
SeaShell = 0xFFF5EE,
|
||||
|
||||
///
|
||||
Sienna = 0xA0522D,
|
||||
|
||||
///
|
||||
Silver = 0xC0C0C0,
|
||||
|
||||
///
|
||||
SkyBlue = 0x87CEEB,
|
||||
|
||||
///
|
||||
SlateBlue = 0x6A5ACD,
|
||||
|
||||
///
|
||||
SlateGray = 0x708090,
|
||||
|
||||
///
|
||||
Snow = 0xFFFAFA,
|
||||
|
||||
///
|
||||
SpringGreen = 0x00FF7F,
|
||||
|
||||
///
|
||||
SteelBlue = 0x4682B4,
|
||||
|
||||
///
|
||||
Tan = 0xD2B48C,
|
||||
|
||||
///
|
||||
Teal = 0x008080,
|
||||
|
||||
///
|
||||
Thistle = 0xD8BFD8,
|
||||
|
||||
///
|
||||
Tomato = 0xFF6347,
|
||||
|
||||
///
|
||||
Turquoise = 0x40E0D0,
|
||||
|
||||
///
|
||||
Violet = 0xEE82EE,
|
||||
|
||||
///
|
||||
Wheat = 0xF5DEB3,
|
||||
|
||||
///
|
||||
White = 0xFFFFFF,
|
||||
|
||||
///
|
||||
WhiteSmoke = 0xF5F5F5,
|
||||
|
||||
///
|
||||
Yellow = 0xFFFF00,
|
||||
|
||||
///
|
||||
YellowGreen = 0x9ACD32,
|
||||
|
||||
///
|
||||
Box2DRed = 0xDC3132,
|
||||
|
||||
///
|
||||
Box2DBlue = 0x30AEBF,
|
||||
|
||||
///
|
||||
Box2DGreen = 0x8CC924,
|
||||
|
||||
///
|
||||
Box2DYellow = 0xFFEE8C,
|
||||
}
|
||||
}
|
||||
33
Brutal.Box2D/LICENSES/BRUTAL-BOX2D-THIRD-PARTY-NOTICES.txt
Normal file
33
Brutal.Box2D/LICENSES/BRUTAL-BOX2D-THIRD-PARTY-NOTICES.txt
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
Brutal.Box2D redistributes the third-party components listed below. Each is
|
||||
reproduced with the license that governs it.
|
||||
|
||||
============================================================
|
||||
Box2D 3.1.1 -- MIT -- https://github.com/erincatto/box2d
|
||||
Shipped as: box2d.dll / libbox2d.so / libbox2d.dylib
|
||||
============================================================
|
||||
|
||||
Built from Box2D's own sources only. The upstream project also carries glad and
|
||||
jsmn; both belong to its samples application, which this build does not produce,
|
||||
so neither reaches the libraries shipped here.
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Erin Catto
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
239
Brutal.Box2D/Structs.cs
Normal file
239
Brutal.Box2D/Structs.cs
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
using Brutal.Numerics;
|
||||
|
||||
namespace Brutal.Box2DApi;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for Box2D objects.
|
||||
/// </summary>
|
||||
public interface IBox2DObject<T> : INullable, IEqualityComparer<T> { }
|
||||
|
||||
public partial record struct B2World : IBox2DObject<B2World>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool IsNull()
|
||||
{
|
||||
return Index1 == 0 && Generation == 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Equals(B2World x, B2World y)
|
||||
{
|
||||
return x.Index1 == y.Index1 && x.Generation == y.Generation;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int GetHashCode(B2World obj)
|
||||
{
|
||||
return HashCode.Combine(obj.Index1, obj.Generation);
|
||||
}
|
||||
}
|
||||
|
||||
public partial record struct B2Body : IBox2DObject<B2Body>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool IsNull()
|
||||
{
|
||||
return Index1 == 0 && Generation == 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Equals(B2Body x, B2Body y)
|
||||
{
|
||||
return x.Index1 == y.Index1 && x.Generation == y.Generation;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int GetHashCode(B2Body obj)
|
||||
{
|
||||
return HashCode.Combine(obj.Index1, obj.Generation);
|
||||
}
|
||||
}
|
||||
|
||||
public partial record struct B2Chain : IBox2DObject<B2Chain>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool IsNull()
|
||||
{
|
||||
return Index1 == 0 && Generation == 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Equals(B2Chain x, B2Chain y)
|
||||
{
|
||||
return x.Index1 == y.Index1 && x.Generation == y.Generation;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int GetHashCode(B2Chain obj)
|
||||
{
|
||||
return HashCode.Combine(obj.Index1, obj.Generation);
|
||||
}
|
||||
}
|
||||
|
||||
public partial record struct B2Shape : IBox2DObject<B2Shape>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool IsNull()
|
||||
{
|
||||
return Index1 == 0 && Generation == 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Equals(B2Shape x, B2Shape y)
|
||||
{
|
||||
return x.Index1 == y.Index1 && x.Generation == y.Generation;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int GetHashCode(B2Shape obj)
|
||||
{
|
||||
return HashCode.Combine(obj.Index1, obj.Generation);
|
||||
}
|
||||
}
|
||||
|
||||
public partial struct B2BodyDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultBodyDef"/>
|
||||
public static readonly B2BodyDef Default = Box2D.DefaultBodyDef();
|
||||
}
|
||||
|
||||
public partial struct B2ChainDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultChainDef"/>
|
||||
public static readonly B2ChainDef Default = Box2D.DefaultChainDef();
|
||||
}
|
||||
|
||||
public partial struct B2DebugDraw
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultDebugDraw"/>
|
||||
public static readonly B2DebugDraw Default = Box2D.DefaultDebugDraw();
|
||||
}
|
||||
|
||||
public partial struct B2DistanceJointDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultDistanceJointDef"/>
|
||||
public static readonly B2DistanceJointDef Default = Box2D.DefaultDistanceJointDef();
|
||||
}
|
||||
|
||||
public partial struct B2ExplosionDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultExplosionDef"/>
|
||||
public static readonly B2ExplosionDef Default = Box2D.DefaultExplosionDef();
|
||||
}
|
||||
|
||||
public partial struct B2Filter
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultFilter"/>
|
||||
public static readonly B2Filter Default = Box2D.DefaultFilter();
|
||||
}
|
||||
|
||||
public partial struct B2FilterJointDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultFilterJointDef"/>
|
||||
public static readonly B2FilterJointDef Default = Box2D.DefaultFilterJointDef();
|
||||
}
|
||||
|
||||
public partial struct B2MotorJointDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultMotorJointDef"/>
|
||||
public static readonly B2MotorJointDef Default = Box2D.DefaultMotorJointDef();
|
||||
}
|
||||
|
||||
public partial struct B2MouseJointDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultMouseJointDef"/>
|
||||
public static readonly B2MouseJointDef Default = Box2D.DefaultMouseJointDef();
|
||||
}
|
||||
|
||||
public partial struct B2PrismaticJointDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultPrismaticJointDef"/>
|
||||
public static readonly B2PrismaticJointDef Default = Box2D.DefaultPrismaticJointDef();
|
||||
}
|
||||
|
||||
public partial struct B2QueryFilter
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultQueryFilter"/>
|
||||
public static readonly B2QueryFilter Default = Box2D.DefaultQueryFilter();
|
||||
}
|
||||
|
||||
public partial struct B2RevoluteJointDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultRevoluteJointDef"/>
|
||||
public static readonly B2RevoluteJointDef Default = Box2D.DefaultRevoluteJointDef();
|
||||
}
|
||||
|
||||
public partial struct B2WheelJointDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultWheelJointDef"/>
|
||||
public static readonly B2WheelJointDef Default = Box2D.DefaultWheelJointDef();
|
||||
}
|
||||
|
||||
public partial struct B2WeldJointDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultWeldJointDef"/>
|
||||
public static readonly B2WeldJointDef Default = Box2D.DefaultWeldJointDef();
|
||||
}
|
||||
|
||||
public partial struct B2SurfaceMaterial
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultSurfaceMaterial"/>
|
||||
public static readonly B2SurfaceMaterial Default = Box2D.DefaultSurfaceMaterial();
|
||||
}
|
||||
|
||||
public partial struct B2ShapeDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultShapeDef"/>
|
||||
public static readonly B2ShapeDef Default = Box2D.DefaultShapeDef();
|
||||
}
|
||||
|
||||
public partial struct B2WorldDef
|
||||
{
|
||||
/// <inheritdoc cref="Box2D.DefaultWorldDef"/>
|
||||
public static readonly B2WorldDef Default = Box2D.DefaultWorldDef();
|
||||
}
|
||||
|
||||
public partial struct B2Rot
|
||||
{
|
||||
/// <summary>
|
||||
/// An identity rotation.
|
||||
/// </summary>
|
||||
public static readonly B2Rot Identity = new(0);
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a rotation by sine and cosine values.
|
||||
/// </summary>
|
||||
public B2Rot(float sine, float cosine)
|
||||
{
|
||||
S = sine;
|
||||
C = cosine;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a rotation by an angle in radians.
|
||||
/// </summary>
|
||||
public B2Rot(float angle)
|
||||
{
|
||||
S = MathF.Sin(angle);
|
||||
C = MathF.Cos(angle);
|
||||
}
|
||||
}
|
||||
|
||||
public partial struct B2Transform
|
||||
{
|
||||
/// <summary>
|
||||
/// An identity transformation.
|
||||
/// </summary>
|
||||
public static readonly B2Transform Identity = new(float2.Zero, B2Rot.Identity);
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a transformation with a position and a rotation.
|
||||
/// </summary>
|
||||
public B2Transform(float2 p, B2Rot q)
|
||||
{
|
||||
P = p;
|
||||
Q = q;
|
||||
}
|
||||
}
|
||||
4679
Brutal.Box2D/Structs.gen.cs
Normal file
4679
Brutal.Box2D/Structs.gen.cs
Normal file
File diff suppressed because it is too large
Load diff
177
Brutal.Box2D/Typedefs.gen.cs
Normal file
177
Brutal.Box2D/Typedefs.gen.cs
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
* @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);
|
||||
}
|
||||
Loading…
Reference in a new issue