add inline wrapper
This commit is contained in:
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
build
|
build
|
||||||
recovery
|
recovery
|
||||||
BeefSpace_user.toml
|
BeefSpace_user.toml
|
||||||
|
|
||||||
|
Setup/b2_all.h
|
||||||
|
|||||||
+20
-20
@@ -10,61 +10,61 @@ corlib = "*"
|
|||||||
"CxxBuildTool.git" = {Git = "https://git.unicon-gmbh.de/Rune/CxxBuildTool.git"}
|
"CxxBuildTool.git" = {Git = "https://git.unicon-gmbh.de/Rune/CxxBuildTool.git"}
|
||||||
|
|
||||||
[Configs.Debug.Win32]
|
[Configs.Debug.Win32]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.lib"]
|
LibPaths = ["$(BuildDir)/src/box2d.lib", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.lib"]
|
||||||
|
|
||||||
[Configs.Debug.Win64]
|
[Configs.Debug.Win64]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.lib"]
|
LibPaths = ["$(BuildDir)/src/box2d.lib", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.lib"]
|
||||||
|
|
||||||
[Configs.Debug.Linux32]
|
[Configs.Debug.Linux32]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.a"]
|
LibPaths = ["$(BuildDir)/src/box2d.a", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.a"]
|
||||||
|
|
||||||
[Configs.Debug.Linux64]
|
[Configs.Debug.Linux64]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.a"]
|
LibPaths = ["$(BuildDir)/src/box2d.a", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.a"]
|
||||||
|
|
||||||
[Configs.Debug.macOS]
|
[Configs.Debug.macOS]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.a"]
|
LibPaths = ["$(BuildDir)/src/box2d.a", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.a"]
|
||||||
|
|
||||||
[Configs.Release.Win32]
|
[Configs.Release.Win32]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.lib"]
|
LibPaths = ["$(BuildDir)/src/box2d.lib", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.lib"]
|
||||||
|
|
||||||
[Configs.Release.Win64]
|
[Configs.Release.Win64]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.lib"]
|
LibPaths = ["$(BuildDir)/src/box2d.lib", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.lib"]
|
||||||
|
|
||||||
[Configs.Release.Linux32]
|
[Configs.Release.Linux32]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.a"]
|
LibPaths = ["$(BuildDir)/src/box2d.a", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.a"]
|
||||||
|
|
||||||
[Configs.Release.Linux64]
|
[Configs.Release.Linux64]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.a"]
|
LibPaths = ["$(BuildDir)/src/box2d.a", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.a"]
|
||||||
|
|
||||||
[Configs.Release.macOS]
|
[Configs.Release.macOS]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.a"]
|
LibPaths = ["$(BuildDir)/src/box2d.a", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.a"]
|
||||||
|
|
||||||
[Configs.Paranoid.Win32]
|
[Configs.Paranoid.Win32]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.lib"]
|
LibPaths = ["$(BuildDir)/src/box2d.lib", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.lib"]
|
||||||
|
|
||||||
[Configs.Paranoid.Win64]
|
[Configs.Paranoid.Win64]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.lib"]
|
LibPaths = ["$(BuildDir)/src/box2d.lib", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.lib"]
|
||||||
|
|
||||||
[Configs.Paranoid.Linux32]
|
[Configs.Paranoid.Linux32]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.a"]
|
LibPaths = ["$(BuildDir)/src/box2d.a", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.a"]
|
||||||
|
|
||||||
[Configs.Paranoid.Linux64]
|
[Configs.Paranoid.Linux64]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.a"]
|
LibPaths = ["$(BuildDir)/src/box2d.a", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.a"]
|
||||||
|
|
||||||
[Configs.Paranoid.macOS]
|
[Configs.Paranoid.macOS]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.a"]
|
LibPaths = ["$(BuildDir)/src/box2d.a", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.a"]
|
||||||
|
|
||||||
[Configs.Test.Win32]
|
[Configs.Test.Win32]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.lib"]
|
LibPaths = ["$(BuildDir)/src/box2d.lib", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.lib"]
|
||||||
|
|
||||||
[Configs.Test.Win64]
|
[Configs.Test.Win64]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.lib"]
|
LibPaths = ["$(BuildDir)/src/box2d.lib", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.lib"]
|
||||||
|
|
||||||
[Configs.Test.Linux32]
|
[Configs.Test.Linux32]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.a"]
|
LibPaths = ["$(BuildDir)/src/box2d.a", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.a"]
|
||||||
|
|
||||||
[Configs.Test.Linux64]
|
[Configs.Test.Linux64]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.a"]
|
LibPaths = ["$(BuildDir)/src/box2d.a", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.a"]
|
||||||
|
|
||||||
[Configs.Test.macOS]
|
[Configs.Test.macOS]
|
||||||
LibPaths = ["$(BuildDir)/src/box2d.a"]
|
LibPaths = ["$(BuildDir)/src/box2d.a", "$(BuildDir)/inline_wrapper/b2_inline_wrapper.a"]
|
||||||
|
|||||||
+48
-8
@@ -8,7 +8,7 @@ using LibClang;
|
|||||||
|
|
||||||
namespace Box2D.Setup;
|
namespace Box2D.Setup;
|
||||||
|
|
||||||
class Box2DGenerator : Cpp2BeefGenerator, this(Span<char8*> args)
|
class Box2DGenerator : Cpp2BeefGenerator, this(Span<char8*> args, StreamWriter inlineWrapper)
|
||||||
{
|
{
|
||||||
protected override Span<char8*> Args => args;
|
protected override Span<char8*> Args => args;
|
||||||
protected override Flags Flags => .None;
|
protected override Flags Flags => .None;
|
||||||
@@ -74,16 +74,54 @@ class Box2DGenerator : Cpp2BeefGenerator, this(Span<char8*> args)
|
|||||||
return .Continue;
|
return .Continue;
|
||||||
}, &(this, default(void)));
|
}, &(this, default(void)));
|
||||||
str.Append('}');
|
str.Append('}');
|
||||||
|
return;
|
||||||
|
case .FunctionDecl:
|
||||||
|
if (Clang.Cursor_IsFunctionInlined(cursor) == 0) break;
|
||||||
|
let spelling = GetCursorSpelling!(cursor);
|
||||||
|
{
|
||||||
|
StringView signature = ScopeCXString!(Clang.GetCursorPrettyPrinted(cursor, printingPolicy));
|
||||||
|
Runtime.Assert(signature.StartsWith("static inline "));
|
||||||
|
signature.RemoveFromStart("static inline ".Length);
|
||||||
|
String wrapper = scope .(1024);
|
||||||
|
wrapper.Append('\n');
|
||||||
|
wrapper.Append(signature);
|
||||||
|
wrapper.Insert(wrapper.IndexOf(spelling), "beefb_");
|
||||||
|
if (signature.StartsWith("_Bool"))
|
||||||
|
wrapper.Replace(1...5, "bool");
|
||||||
|
wrapper.Append(" { ");
|
||||||
|
if (Clang.GetCursorResultType(cursor).kind != .Void)
|
||||||
|
wrapper.Append("return ");
|
||||||
|
wrapper.Append(spelling, "(");
|
||||||
|
let numArgs = Clang.Cursor_GetNumArguments(cursor);
|
||||||
|
for (let i < numArgs)
|
||||||
|
{
|
||||||
|
if (i > 0) wrapper.Append(", ");
|
||||||
|
let arg = Clang.Cursor_GetArgument(cursor, (.)i);
|
||||||
|
wrapper.Append(GetCursorSpelling!(arg));
|
||||||
|
}
|
||||||
|
wrapper.Append("); }");
|
||||||
|
inlineWrapper.Write(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
BeginCursor(cursor);
|
||||||
|
str.Append("[LinkName(\"beefb_", spelling, "\")] ");
|
||||||
|
AccessSpecifier(cursor);
|
||||||
|
str.Append("static extern ");
|
||||||
|
WriteTypeAndName(cursor, Clang.GetCursorResultType(cursor));
|
||||||
|
str.Append('(');
|
||||||
|
Method_Parameters(cursor);
|
||||||
|
str.Append(')');
|
||||||
|
str.Append(';');
|
||||||
|
return;
|
||||||
case .MacroDefinition:
|
case .MacroDefinition:
|
||||||
let spelling = GetCursorSpelling!(cursor);
|
let spelling = GetCursorSpelling!(cursor);
|
||||||
if (spelling == "B2_BREAKPOINT" || spelling == "B2_API" || spelling == "B2_INLINE" || spelling == "B2_ID_INLINE" || spelling == "B2_ZERO_INIT" || spelling == "B2_NULL_ID")
|
if (spelling == "B2_BREAKPOINT" || spelling == "B2_API" || spelling == "B2_INLINE" || spelling == "B2_ID_INLINE" || spelling == "B2_ZERO_INIT" || spelling == "B2_NULL_ID")
|
||||||
return;
|
return;
|
||||||
fallthrough;
|
case .VarDecl when GetCursorSpelling!(cursor) == "b2_emptySimplexCache":
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
if (_ == .VarDecl && GetCursorSpelling!(cursor) == "b2_emptySimplexCache")
|
|
||||||
return;
|
|
||||||
base.HandleCursor(cursor);
|
|
||||||
}
|
}
|
||||||
|
base.HandleCursor(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> functionNonPtrs = new .(8) ~ DeleteContainerAndItems!(_);
|
List<String> functionNonPtrs = new .(8) ~ DeleteContainerAndItems!(_);
|
||||||
@@ -189,8 +227,6 @@ class Box2DGenerator : Cpp2BeefGenerator, this(Span<char8*> args)
|
|||||||
}
|
}
|
||||||
base.WriteToken(token);
|
base.WriteToken(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
// There are functions you can override, but these are the most common
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Program
|
class Program
|
||||||
@@ -205,6 +241,7 @@ class Program
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StreamWriter inlineWrapper = scope .()..Create("../src/inline_wrapper.c");
|
||||||
{
|
{
|
||||||
StreamWriter all = scope .()..Create("b2_all.h");
|
StreamWriter all = scope .()..Create("b2_all.h");
|
||||||
for (let file in Directory.EnumerateFiles("../box2d/include/box2d"))
|
for (let file in Directory.EnumerateFiles("../box2d/include/box2d"))
|
||||||
@@ -213,10 +250,13 @@ class Program
|
|||||||
all.Write("#include <box2d/");
|
all.Write("#include <box2d/");
|
||||||
all.Write(filename);
|
all.Write(filename);
|
||||||
all.Write(">\n");
|
all.Write(">\n");
|
||||||
|
inlineWrapper.Write("#include <box2d/");
|
||||||
|
inlineWrapper.Write(filename);
|
||||||
|
inlineWrapper.Write(">\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scope Box2DGenerator(char8*[?]("--language=c", "-I../box2d/include")).Generate("b2_all.h");
|
scope Box2DGenerator(char8*[?]("--language=c", "-I../box2d/include"), inlineWrapper).Generate("b2_all.h");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,72 +124,72 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Store a world id into a uint32_t.
|
/// Store a world id into a uint32_t.
|
||||||
[LinkName("b2StoreWorldId")] public static extern uint32 StoreWorldId(b2WorldId id);
|
[LinkName("beefb_b2StoreWorldId")] public static extern uint32 StoreWorldId(b2WorldId id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Load a uint32_t into a world id.
|
/// Load a uint32_t into a world id.
|
||||||
[LinkName("b2LoadWorldId")] public static extern b2WorldId LoadWorldId(uint32 x);
|
[LinkName("beefb_b2LoadWorldId")] public static extern b2WorldId LoadWorldId(uint32 x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Store a body id into a uint64_t.
|
/// Store a body id into a uint64_t.
|
||||||
[LinkName("b2StoreBodyId")] public static extern uint64 StoreBodyId(b2BodyId id);
|
[LinkName("beefb_b2StoreBodyId")] public static extern uint64 StoreBodyId(b2BodyId id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Load a uint64_t into a body id.
|
/// Load a uint64_t into a body id.
|
||||||
[LinkName("b2LoadBodyId")] public static extern b2BodyId LoadBodyId(uint64 x);
|
[LinkName("beefb_b2LoadBodyId")] public static extern b2BodyId LoadBodyId(uint64 x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Store a shape id into a uint64_t.
|
/// Store a shape id into a uint64_t.
|
||||||
[LinkName("b2StoreShapeId")] public static extern uint64 StoreShapeId(b2ShapeId id);
|
[LinkName("beefb_b2StoreShapeId")] public static extern uint64 StoreShapeId(b2ShapeId id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Load a uint64_t into a shape id.
|
/// Load a uint64_t into a shape id.
|
||||||
[LinkName("b2LoadShapeId")] public static extern b2ShapeId LoadShapeId(uint64 x);
|
[LinkName("beefb_b2LoadShapeId")] public static extern b2ShapeId LoadShapeId(uint64 x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Store a chain id into a uint64_t.
|
/// Store a chain id into a uint64_t.
|
||||||
[LinkName("b2StoreChainId")] public static extern uint64 StoreChainId(b2ChainId id);
|
[LinkName("beefb_b2StoreChainId")] public static extern uint64 StoreChainId(b2ChainId id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Load a uint64_t into a chain id.
|
/// Load a uint64_t into a chain id.
|
||||||
[LinkName("b2LoadChainId")] public static extern b2ChainId LoadChainId(uint64 x);
|
[LinkName("beefb_b2LoadChainId")] public static extern b2ChainId LoadChainId(uint64 x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Store a joint id into a uint64_t.
|
/// Store a joint id into a uint64_t.
|
||||||
[LinkName("b2StoreJointId")] public static extern uint64 StoreJointId(b2JointId id);
|
[LinkName("beefb_b2StoreJointId")] public static extern uint64 StoreJointId(b2JointId id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Load a uint64_t into a joint id.
|
/// Load a uint64_t into a joint id.
|
||||||
[LinkName("b2LoadJointId")] public static extern b2JointId LoadJointId(uint64 x);
|
[LinkName("beefb_b2LoadJointId")] public static extern b2JointId LoadJointId(uint64 x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Store a contact id into 16 bytes
|
/// Store a contact id into 16 bytes
|
||||||
[LinkName("b2StoreContactId")] public static extern void StoreContactId(b2ContactId id, uint32[3] values);
|
[LinkName("beefb_b2StoreContactId")] public static extern void StoreContactId(b2ContactId id, uint32[3] values);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Load a two uint64_t into a contact id.
|
/// Load a two uint64_t into a contact id.
|
||||||
[LinkName("b2LoadContactId")] public static extern b2ContactId LoadContactId(uint32[3] values);
|
[LinkName("beefb_b2LoadContactId")] public static extern b2ContactId LoadContactId(uint32[3] values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
@@ -10,5 +10,7 @@ class Box2D
|
|||||||
{
|
{
|
||||||
if (!Compiler.IsBuilding) return;
|
if (!Compiler.IsBuilding) return;
|
||||||
CxxBuildTool.CMake(Compiler.ProjectDir + "/box2d", Compiler.BuildDir + "/" + Compiler.ProjectName, "-DBOX2D_SAMPLES=OFF -DBOX2D_UNIT_TESTS=OFF");
|
CxxBuildTool.CMake(Compiler.ProjectDir + "/box2d", Compiler.BuildDir + "/" + Compiler.ProjectName, "-DBOX2D_SAMPLES=OFF -DBOX2D_UNIT_TESTS=OFF");
|
||||||
|
CxxBuildTool.Ninja(Compiler.ProjectDir + "/src", Compiler.BuildDir + "/" + Compiler.ProjectName + "/inline_wrapper", "b2_inline_wrapper",
|
||||||
|
"-I" + Compiler.ProjectDir + "/box2d/include", "inline_wrapper.c");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+66
-66
@@ -121,56 +121,56 @@ extension Box2D
|
|||||||
[LinkName("b2IsValidPlane")] public static extern bool IsValidPlane(b2Plane a);
|
[LinkName("b2IsValidPlane")] public static extern bool IsValidPlane(b2Plane a);
|
||||||
|
|
||||||
/// @return the minimum of two integers
|
/// @return the minimum of two integers
|
||||||
[LinkName("b2MinInt")] public static extern c_int MinInt(c_int a, c_int b);
|
[LinkName("beefb_b2MinInt")] public static extern c_int MinInt(c_int a, c_int b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @return the maximum of two integers
|
/// @return the maximum of two integers
|
||||||
[LinkName("b2MaxInt")] public static extern c_int MaxInt(c_int a, c_int b);
|
[LinkName("beefb_b2MaxInt")] public static extern c_int MaxInt(c_int a, c_int b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @return the absolute value of an integer
|
/// @return the absolute value of an integer
|
||||||
[LinkName("b2AbsInt")] public static extern c_int AbsInt(c_int a);
|
[LinkName("beefb_b2AbsInt")] public static extern c_int AbsInt(c_int a);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @return an integer clamped between a lower and upper bound
|
/// @return an integer clamped between a lower and upper bound
|
||||||
[LinkName("b2ClampInt")] public static extern c_int ClampInt(c_int a, c_int lower, c_int upper);
|
[LinkName("beefb_b2ClampInt")] public static extern c_int ClampInt(c_int a, c_int lower, c_int upper);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
|
// https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
|
||||||
[LinkName("b2CeilingInt")] public static extern c_int CeilingInt(c_int numerator, c_int denominator);
|
[LinkName("beefb_b2CeilingInt")] public static extern c_int CeilingInt(c_int numerator, c_int denominator);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @return the minimum of two floats
|
/// @return the minimum of two floats
|
||||||
[LinkName("b2MinFloat")] public static extern float MinFloat(float a, float b);
|
[LinkName("beefb_b2MinFloat")] public static extern float MinFloat(float a, float b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @return the maximum of two floats
|
/// @return the maximum of two floats
|
||||||
[LinkName("b2MaxFloat")] public static extern float MaxFloat(float a, float b);
|
[LinkName("beefb_b2MaxFloat")] public static extern float MaxFloat(float a, float b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @return the absolute value of a float
|
/// @return the absolute value of a float
|
||||||
[LinkName("b2AbsFloat")] public static extern float AbsFloat(float a);
|
[LinkName("beefb_b2AbsFloat")] public static extern float AbsFloat(float a);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @return a float clamped between a lower and upper bound
|
/// @return a float clamped between a lower and upper bound
|
||||||
[LinkName("b2ClampFloat")] public static extern float ClampFloat(float a, float lower, float upper);
|
[LinkName("beefb_b2ClampFloat")] public static extern float ClampFloat(float a, float lower, float upper);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -186,92 +186,92 @@ extension Box2D
|
|||||||
[LinkName("b2ComputeCosSin")] public static extern b2CosSin ComputeCosSin(float radians);
|
[LinkName("b2ComputeCosSin")] public static extern b2CosSin ComputeCosSin(float radians);
|
||||||
|
|
||||||
/// Vector dot product
|
/// Vector dot product
|
||||||
[LinkName("b2Dot")] public static extern float Dot(b2Vec2 a, b2Vec2 b);
|
[LinkName("beefb_b2Dot")] public static extern float Dot(b2Vec2 a, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Vector cross product. In 2D this yields a scalar.
|
/// Vector cross product. In 2D this yields a scalar.
|
||||||
[LinkName("b2Cross")] public static extern float Cross(b2Vec2 a, b2Vec2 b);
|
[LinkName("beefb_b2Cross")] public static extern float Cross(b2Vec2 a, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Perform the cross product on a vector and a scalar. In 2D this produces a vector.
|
/// Perform the cross product on a vector and a scalar. In 2D this produces a vector.
|
||||||
[LinkName("b2CrossVS")] public static extern b2Vec2 CrossVS(b2Vec2 v, float s);
|
[LinkName("beefb_b2CrossVS")] public static extern b2Vec2 CrossVS(b2Vec2 v, float s);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Perform the cross product on a scalar and a vector. In 2D this produces a vector.
|
/// Perform the cross product on a scalar and a vector. In 2D this produces a vector.
|
||||||
[LinkName("b2CrossSV")] public static extern b2Vec2 CrossSV(float s, b2Vec2 v);
|
[LinkName("beefb_b2CrossSV")] public static extern b2Vec2 CrossSV(float s, b2Vec2 v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Get a left pointing perpendicular vector. Equivalent to b2CrossSV(1.0f, v)
|
/// Get a left pointing perpendicular vector. Equivalent to b2CrossSV(1.0f, v)
|
||||||
[LinkName("b2LeftPerp")] public static extern b2Vec2 LeftPerp(b2Vec2 v);
|
[LinkName("beefb_b2LeftPerp")] public static extern b2Vec2 LeftPerp(b2Vec2 v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Get a right pointing perpendicular vector. Equivalent to b2CrossVS(v, 1.0f)
|
/// Get a right pointing perpendicular vector. Equivalent to b2CrossVS(v, 1.0f)
|
||||||
[LinkName("b2RightPerp")] public static extern b2Vec2 RightPerp(b2Vec2 v);
|
[LinkName("beefb_b2RightPerp")] public static extern b2Vec2 RightPerp(b2Vec2 v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Vector addition
|
/// Vector addition
|
||||||
[LinkName("b2Add")] public static extern b2Vec2 Add(b2Vec2 a, b2Vec2 b);
|
[LinkName("beefb_b2Add")] public static extern b2Vec2 Add(b2Vec2 a, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Vector subtraction
|
/// Vector subtraction
|
||||||
[LinkName("b2Sub")] public static extern b2Vec2 Sub(b2Vec2 a, b2Vec2 b);
|
[LinkName("beefb_b2Sub")] public static extern b2Vec2 Sub(b2Vec2 a, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Vector negation
|
/// Vector negation
|
||||||
[LinkName("b2Neg")] public static extern b2Vec2 Neg(b2Vec2 a);
|
[LinkName("beefb_b2Neg")] public static extern b2Vec2 Neg(b2Vec2 a);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Vector linear interpolation
|
/// Vector linear interpolation
|
||||||
/// https://fgiesen.wordpress.com/2012/08/15/linear-interpolation-past-present-and-future/
|
/// https://fgiesen.wordpress.com/2012/08/15/linear-interpolation-past-present-and-future/
|
||||||
[LinkName("b2Lerp")] public static extern b2Vec2 Lerp(b2Vec2 a, b2Vec2 b, float t);
|
[LinkName("beefb_b2Lerp")] public static extern b2Vec2 Lerp(b2Vec2 a, b2Vec2 b, float t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Component-wise multiplication
|
/// Component-wise multiplication
|
||||||
[LinkName("b2Mul")] public static extern b2Vec2 Mul(b2Vec2 a, b2Vec2 b);
|
[LinkName("beefb_b2Mul")] public static extern b2Vec2 Mul(b2Vec2 a, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Multiply a scalar and vector
|
/// Multiply a scalar and vector
|
||||||
[LinkName("b2MulSV")] public static extern b2Vec2 MulSV(float s, b2Vec2 v);
|
[LinkName("beefb_b2MulSV")] public static extern b2Vec2 MulSV(float s, b2Vec2 v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// a + s * b
|
/// a + s * b
|
||||||
[LinkName("b2MulAdd")] public static extern b2Vec2 MulAdd(b2Vec2 a, float s, b2Vec2 b);
|
[LinkName("beefb_b2MulAdd")] public static extern b2Vec2 MulAdd(b2Vec2 a, float s, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// a - s * b
|
/// a - s * b
|
||||||
[LinkName("b2MulSub")] public static extern b2Vec2 MulSub(b2Vec2 a, float s, b2Vec2 b);
|
[LinkName("beefb_b2MulSub")] public static extern b2Vec2 MulSub(b2Vec2 a, float s, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Component-wise absolute vector
|
/// Component-wise absolute vector
|
||||||
[LinkName("b2Abs")] public static extern b2Vec2 Abs(b2Vec2 a);
|
[LinkName("beefb_b2Abs")] public static extern b2Vec2 Abs(b2Vec2 a);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Component-wise minimum vector
|
/// Component-wise minimum vector
|
||||||
[LinkName("b2Min")] public static extern b2Vec2 Min(b2Vec2 a, b2Vec2 b);
|
[LinkName("beefb_b2Min")] public static extern b2Vec2 Min(b2Vec2 a, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Component-wise maximum vector
|
/// Component-wise maximum vector
|
||||||
[LinkName("b2Max")] public static extern b2Vec2 Max(b2Vec2 a, b2Vec2 b);
|
[LinkName("beefb_b2Max")] public static extern b2Vec2 Max(b2Vec2 a, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -298,7 +298,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Component-wise clamp vector v into the range [a, b]
|
/// Component-wise clamp vector v into the range [a, b]
|
||||||
[LinkName("b2Clamp")] public static extern b2Vec2 Clamp(b2Vec2 v, b2Vec2 a, b2Vec2 b);
|
[LinkName("beefb_b2Clamp")] public static extern b2Vec2 Clamp(b2Vec2 v, b2Vec2 a, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -307,13 +307,13 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Get the length of this vector (the norm)
|
/// Get the length of this vector (the norm)
|
||||||
[LinkName("b2Length")] public static extern float Length(b2Vec2 v);
|
[LinkName("beefb_b2Length")] public static extern float Length(b2Vec2 v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Get the distance between two points
|
/// Get the distance between two points
|
||||||
[LinkName("b2Distance")] public static extern float Distance(b2Vec2 a, b2Vec2 b);
|
[LinkName("beefb_b2Distance")] public static extern float Distance(b2Vec2 a, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -322,7 +322,7 @@ extension Box2D
|
|||||||
|
|
||||||
/// Convert a vector into a unit vector if possible, otherwise returns the zero vector.
|
/// Convert a vector into a unit vector if possible, otherwise returns the zero vector.
|
||||||
/// todo MSVC is not inlining this function in several places per warning 4710
|
/// todo MSVC is not inlining this function in several places per warning 4710
|
||||||
[LinkName("b2Normalize")] public static extern b2Vec2 Normalize(b2Vec2 v);
|
[LinkName("beefb_b2Normalize")] public static extern b2Vec2 Normalize(b2Vec2 v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -336,7 +336,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Determines if the provided vector is normalized (norm(a) == 1).
|
/// Determines if the provided vector is normalized (norm(a) == 1).
|
||||||
[LinkName("b2IsNormalized")] public static extern bool IsNormalized(b2Vec2 a);
|
[LinkName("beefb_b2IsNormalized")] public static extern bool IsNormalized(b2Vec2 a);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -344,7 +344,7 @@ extension Box2D
|
|||||||
|
|
||||||
/// Convert a vector into a unit vector if possible, otherwise returns the zero vector. Also
|
/// Convert a vector into a unit vector if possible, otherwise returns the zero vector. Also
|
||||||
/// outputs the length.
|
/// outputs the length.
|
||||||
[LinkName("b2GetLengthAndNormalize")] public static extern b2Vec2 GetLengthAndNormalize(float* length, b2Vec2 v);
|
[LinkName("beefb_b2GetLengthAndNormalize")] public static extern b2Vec2 GetLengthAndNormalize(float* length, b2Vec2 v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -358,7 +358,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Normalize rotation
|
/// Normalize rotation
|
||||||
[LinkName("b2NormalizeRot")] public static extern b2Rot NormalizeRot(b2Rot q);
|
[LinkName("beefb_b2NormalizeRot")] public static extern b2Rot NormalizeRot(b2Rot q);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ extension Box2D
|
|||||||
/// Integrate rotation from angular velocity
|
/// Integrate rotation from angular velocity
|
||||||
/// @param q1 initial rotation
|
/// @param q1 initial rotation
|
||||||
/// @param deltaAngle the angular displacement in radians
|
/// @param deltaAngle the angular displacement in radians
|
||||||
[LinkName("b2IntegrateRotation")] public static extern b2Rot IntegrateRotation(b2Rot q1, float deltaAngle);
|
[LinkName("beefb_b2IntegrateRotation")] public static extern b2Rot IntegrateRotation(b2Rot q1, float deltaAngle);
|
||||||
|
|
||||||
// dc/dt = -omega * sin(t)
|
// dc/dt = -omega * sin(t)
|
||||||
// ds/dt = omega * cos(t)
|
// ds/dt = omega * cos(t)
|
||||||
@@ -383,27 +383,27 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Get the length squared of this vector
|
/// Get the length squared of this vector
|
||||||
[LinkName("b2LengthSquared")] public static extern float LengthSquared(b2Vec2 v);
|
[LinkName("beefb_b2LengthSquared")] public static extern float LengthSquared(b2Vec2 v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Get the distance squared between points
|
/// Get the distance squared between points
|
||||||
[LinkName("b2DistanceSquared")] public static extern float DistanceSquared(b2Vec2 a, b2Vec2 b);
|
[LinkName("beefb_b2DistanceSquared")] public static extern float DistanceSquared(b2Vec2 a, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Make a rotation using an angle in radians
|
/// Make a rotation using an angle in radians
|
||||||
[LinkName("b2MakeRot")] public static extern b2Rot MakeRot(float radians);
|
[LinkName("beefb_b2MakeRot")] public static extern b2Rot MakeRot(float radians);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Make a rotation using a unit vector
|
/// Make a rotation using a unit vector
|
||||||
[LinkName("b2MakeRotFromUnitVector")] public static extern b2Rot MakeRotFromUnitVector(b2Vec2 unitVector);
|
[LinkName("beefb_b2MakeRotFromUnitVector")] public static extern b2Rot MakeRotFromUnitVector(b2Vec2 unitVector);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -413,7 +413,7 @@ extension Box2D
|
|||||||
[LinkName("b2ComputeRotationBetweenUnitVectors")] public static extern b2Rot ComputeRotationBetweenUnitVectors(b2Vec2 v1, b2Vec2 v2);
|
[LinkName("b2ComputeRotationBetweenUnitVectors")] public static extern b2Rot ComputeRotationBetweenUnitVectors(b2Vec2 v1, b2Vec2 v2);
|
||||||
|
|
||||||
/// Is this rotation normalized?
|
/// Is this rotation normalized?
|
||||||
[LinkName("b2IsNormalizedRot")] public static extern bool IsNormalizedRot(b2Rot q);
|
[LinkName("beefb_b2IsNormalizedRot")] public static extern bool IsNormalizedRot(b2Rot q);
|
||||||
|
|
||||||
// larger tolerance due to failure on mingw 32-bit
|
// larger tolerance due to failure on mingw 32-bit
|
||||||
|
|
||||||
@@ -421,7 +421,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Get the inverse of a rotation
|
/// Get the inverse of a rotation
|
||||||
[LinkName("b2InvertRot")] public static extern b2Rot InvertRot(b2Rot a);
|
[LinkName("beefb_b2InvertRot")] public static extern b2Rot InvertRot(b2Rot a);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -429,7 +429,7 @@ extension Box2D
|
|||||||
/// Normalized linear interpolation
|
/// Normalized linear interpolation
|
||||||
/// https://fgiesen.wordpress.com/2012/08/15/linear-interpolation-past-present-and-future/
|
/// https://fgiesen.wordpress.com/2012/08/15/linear-interpolation-past-present-and-future/
|
||||||
/// https://web.archive.org/web/20170825184056/http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/
|
/// https://web.archive.org/web/20170825184056/http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/
|
||||||
[LinkName("b2NLerp")] public static extern b2Rot NLerp(b2Rot q1, b2Rot q2, float t);
|
[LinkName("beefb_b2NLerp")] public static extern b2Rot NLerp(b2Rot q1, b2Rot q2, float t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -447,7 +447,7 @@ extension Box2D
|
|||||||
/// @param q1 initial rotation
|
/// @param q1 initial rotation
|
||||||
/// @param q2 final rotation
|
/// @param q2 final rotation
|
||||||
/// @param inv_h inverse time step
|
/// @param inv_h inverse time step
|
||||||
[LinkName("b2ComputeAngularVelocity")] public static extern float ComputeAngularVelocity(b2Rot q1, b2Rot q2, float inv_h);
|
[LinkName("beefb_b2ComputeAngularVelocity")] public static extern float ComputeAngularVelocity(b2Rot q1, b2Rot q2, float inv_h);
|
||||||
|
|
||||||
// ds/dt = omega * cos(t)
|
// ds/dt = omega * cos(t)
|
||||||
// dc/dt = -omega * sin(t)
|
// dc/dt = -omega * sin(t)
|
||||||
@@ -464,27 +464,27 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Get the angle in radians in the range [-pi, pi]
|
/// Get the angle in radians in the range [-pi, pi]
|
||||||
[LinkName("b2Rot_GetAngle")] public static extern float Rot_GetAngle(b2Rot q);
|
[LinkName("beefb_b2Rot_GetAngle")] public static extern float Rot_GetAngle(b2Rot q);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Get the x-axis
|
/// Get the x-axis
|
||||||
[LinkName("b2Rot_GetXAxis")] public static extern b2Vec2 Rot_GetXAxis(b2Rot q);
|
[LinkName("beefb_b2Rot_GetXAxis")] public static extern b2Vec2 Rot_GetXAxis(b2Rot q);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Get the y-axis
|
/// Get the y-axis
|
||||||
[LinkName("b2Rot_GetYAxis")] public static extern b2Vec2 Rot_GetYAxis(b2Rot q);
|
[LinkName("beefb_b2Rot_GetYAxis")] public static extern b2Vec2 Rot_GetYAxis(b2Rot q);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Multiply two rotations: q * r
|
/// Multiply two rotations: q * r
|
||||||
[LinkName("b2MulRot")] public static extern b2Rot MulRot(b2Rot q, b2Rot r);
|
[LinkName("beefb_b2MulRot")] public static extern b2Rot MulRot(b2Rot q, b2Rot r);
|
||||||
|
|
||||||
// [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]
|
// [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]
|
||||||
// [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]
|
// [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]
|
||||||
@@ -498,7 +498,7 @@ extension Box2D
|
|||||||
|
|
||||||
/// Transpose multiply two rotations: inv(a) * b
|
/// Transpose multiply two rotations: inv(a) * b
|
||||||
/// This rotates a vector local in frame b into a vector local in frame a
|
/// This rotates a vector local in frame b into a vector local in frame a
|
||||||
[LinkName("b2InvMulRot")] public static extern b2Rot InvMulRot(b2Rot a, b2Rot b);
|
[LinkName("beefb_b2InvMulRot")] public static extern b2Rot InvMulRot(b2Rot a, b2Rot b);
|
||||||
|
|
||||||
// [ ac as] * [bc -bs] = [ac*bc+qs*bs -ac*bs+as*bc]
|
// [ ac as] * [bc -bs] = [ac*bc+qs*bs -ac*bs+as*bc]
|
||||||
// [-as ac] [bs bc] [-as*bc+ac*bs as*bs+ac*bc]
|
// [-as ac] [bs bc] [-as*bc+ac*bs as*bs+ac*bc]
|
||||||
@@ -511,7 +511,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Relative angle between a and b
|
/// Relative angle between a and b
|
||||||
[LinkName("b2RelativeAngle")] public static extern float RelativeAngle(b2Rot a, b2Rot b);
|
[LinkName("beefb_b2RelativeAngle")] public static extern float RelativeAngle(b2Rot a, b2Rot b);
|
||||||
|
|
||||||
// sin(b - a) = bs * ac - bc * as
|
// sin(b - a) = bs * ac - bc * as
|
||||||
// cos(b - a) = bc * ac + bs * as
|
// cos(b - a) = bc * ac + bs * as
|
||||||
@@ -521,26 +521,26 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Convert any angle into the range [-pi, pi]
|
/// Convert any angle into the range [-pi, pi]
|
||||||
[LinkName("b2UnwindAngle")] public static extern float UnwindAngle(float radians);
|
[LinkName("beefb_b2UnwindAngle")] public static extern float UnwindAngle(float radians);
|
||||||
|
|
||||||
// Assuming this is deterministic
|
// Assuming this is deterministic
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Rotate a vector
|
/// Rotate a vector
|
||||||
[LinkName("b2RotateVector")] public static extern b2Vec2 RotateVector(b2Rot q, b2Vec2 v);
|
[LinkName("beefb_b2RotateVector")] public static extern b2Vec2 RotateVector(b2Rot q, b2Vec2 v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Inverse rotate a vector
|
/// Inverse rotate a vector
|
||||||
[LinkName("b2InvRotateVector")] public static extern b2Vec2 InvRotateVector(b2Rot q, b2Vec2 v);
|
[LinkName("beefb_b2InvRotateVector")] public static extern b2Vec2 InvRotateVector(b2Rot q, b2Vec2 v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Transform a point (e.g. local space to world space)
|
/// Transform a point (e.g. local space to world space)
|
||||||
[LinkName("b2TransformPoint")] public static extern b2Vec2 TransformPoint(b2Transform t, b2Vec2 p);
|
[LinkName("beefb_b2TransformPoint")] public static extern b2Vec2 TransformPoint(b2Transform t, b2Vec2 p);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -549,7 +549,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Inverse transform a point (e.g. world space to local space)
|
/// Inverse transform a point (e.g. world space to local space)
|
||||||
[LinkName("b2InvTransformPoint")] public static extern b2Vec2 InvTransformPoint(b2Transform t, b2Vec2 p);
|
[LinkName("beefb_b2InvTransformPoint")] public static extern b2Vec2 InvTransformPoint(b2Transform t, b2Vec2 p);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -561,7 +561,7 @@ extension Box2D
|
|||||||
/// in the world frame.
|
/// in the world frame.
|
||||||
/// v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p
|
/// v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p
|
||||||
/// = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p
|
/// = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p
|
||||||
[LinkName("b2MulTransforms")] public static extern b2Transform MulTransforms(b2Transform A, b2Transform B);
|
[LinkName("beefb_b2MulTransforms")] public static extern b2Transform MulTransforms(b2Transform A, b2Transform B);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -572,7 +572,7 @@ extension Box2D
|
|||||||
/// Creates a transform that converts a local point in frame B to a local point in frame A.
|
/// Creates a transform that converts a local point in frame B to a local point in frame A.
|
||||||
/// v2 = A.q' * (B.q * v1 + B.p - A.p)
|
/// v2 = A.q' * (B.q * v1 + B.p - A.p)
|
||||||
/// = A.q' * B.q * v1 + A.q' * (B.p - A.p)
|
/// = A.q' * B.q * v1 + A.q' * (B.p - A.p)
|
||||||
[LinkName("b2InvMulTransforms")] public static extern b2Transform InvMulTransforms(b2Transform A, b2Transform B);
|
[LinkName("beefb_b2InvMulTransforms")] public static extern b2Transform InvMulTransforms(b2Transform A, b2Transform B);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -581,7 +581,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Multiply a 2-by-2 matrix times a 2D vector
|
/// Multiply a 2-by-2 matrix times a 2D vector
|
||||||
[LinkName("b2MulMV")] public static extern b2Vec2 MulMV(b2Mat22 A, b2Vec2 v);
|
[LinkName("beefb_b2MulMV")] public static extern b2Vec2 MulMV(b2Mat22 A, b2Vec2 v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -591,7 +591,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Get the inverse of a 2-by-2 matrix
|
/// Get the inverse of a 2-by-2 matrix
|
||||||
[LinkName("b2GetInverse22")] public static extern b2Mat22 GetInverse22(b2Mat22 A);
|
[LinkName("beefb_b2GetInverse22")] public static extern b2Mat22 GetInverse22(b2Mat22 A);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -609,7 +609,7 @@ extension Box2D
|
|||||||
|
|
||||||
/// Solve A * x = b, where b is a column vector. This is more efficient
|
/// Solve A * x = b, where b is a column vector. This is more efficient
|
||||||
/// than computing the inverse in one-shot cases.
|
/// than computing the inverse in one-shot cases.
|
||||||
[LinkName("b2Solve22")] public static extern b2Vec2 Solve22(b2Mat22 A, b2Vec2 b);
|
[LinkName("beefb_b2Solve22")] public static extern b2Vec2 Solve22(b2Mat22 A, b2Vec2 b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -622,7 +622,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Does a fully contain b
|
/// Does a fully contain b
|
||||||
[LinkName("b2AABB_Contains")] public static extern bool AABB_Contains(b2AABB a, b2AABB b);
|
[LinkName("beefb_b2AABB_Contains")] public static extern bool AABB_Contains(b2AABB a, b2AABB b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -633,21 +633,21 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Get the center of the AABB.
|
/// Get the center of the AABB.
|
||||||
[LinkName("b2AABB_Center")] public static extern b2Vec2 AABB_Center(b2AABB a);
|
[LinkName("beefb_b2AABB_Center")] public static extern b2Vec2 AABB_Center(b2AABB a);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Get the extents of the AABB (half-widths).
|
/// Get the extents of the AABB (half-widths).
|
||||||
[LinkName("b2AABB_Extents")] public static extern b2Vec2 AABB_Extents(b2AABB a);
|
[LinkName("beefb_b2AABB_Extents")] public static extern b2Vec2 AABB_Extents(b2AABB a);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Union of two AABBs
|
/// Union of two AABBs
|
||||||
[LinkName("b2AABB_Union")] public static extern b2AABB AABB_Union(b2AABB a, b2AABB b);
|
[LinkName("beefb_b2AABB_Union")] public static extern b2AABB AABB_Union(b2AABB a, b2AABB b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -658,14 +658,14 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Do a and b overlap
|
/// Do a and b overlap
|
||||||
[LinkName("b2AABB_Overlaps")] public static extern bool AABB_Overlaps(b2AABB a, b2AABB b);
|
[LinkName("beefb_b2AABB_Overlaps")] public static extern bool AABB_Overlaps(b2AABB a, b2AABB b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Compute the bounding box of an array of circles
|
/// Compute the bounding box of an array of circles
|
||||||
[LinkName("b2MakeAABB")] public static extern b2AABB MakeAABB(b2Vec2* points, c_int count, float radius);
|
[LinkName("beefb_b2MakeAABB")] public static extern b2AABB MakeAABB(b2Vec2* points, c_int count, float radius);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -683,7 +683,7 @@ extension Box2D
|
|||||||
|
|
||||||
|
|
||||||
/// Signed separation of a point from a plane
|
/// Signed separation of a point from a plane
|
||||||
[LinkName("b2PlaneSeparation")] public static extern float PlaneSeparation(b2Plane plane, b2Vec2 point);
|
[LinkName("beefb_b2PlaneSeparation")] public static extern float PlaneSeparation(b2Plane plane, b2Vec2 point);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -693,7 +693,7 @@ extension Box2D
|
|||||||
/// position += timeStep * newVelocity
|
/// position += timeStep * newVelocity
|
||||||
/// This drives towards a zero position. By using implicit integration we get a stable solution
|
/// This drives towards a zero position. By using implicit integration we get a stable solution
|
||||||
/// that doesn't require transcendental functions.
|
/// that doesn't require transcendental functions.
|
||||||
[LinkName("b2SpringDamper")] public static extern float SpringDamper(float hertz, float dampingRatio, float position, float velocity, float timeStep);
|
[LinkName("beefb_b2SpringDamper")] public static extern float SpringDamper(float hertz, float dampingRatio, float position, float velocity, float timeStep);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
#include <box2d/base.h>
|
||||||
|
#include <box2d/box2d.h>
|
||||||
|
#include <box2d/collision.h>
|
||||||
|
#include <box2d/constants.h>
|
||||||
|
#include <box2d/id.h>
|
||||||
|
#include <box2d/math_functions.h>
|
||||||
|
#include <box2d/types.h>
|
||||||
|
|
||||||
|
int beefb_b2MinInt(int a, int b) { return b2MinInt(a, b); }
|
||||||
|
int beefb_b2MaxInt(int a, int b) { return b2MaxInt(a, b); }
|
||||||
|
int beefb_b2AbsInt(int a) { return b2AbsInt(a); }
|
||||||
|
int beefb_b2ClampInt(int a, int lower, int upper) { return b2ClampInt(a, lower, upper); }
|
||||||
|
int beefb_b2CeilingInt(int numerator, int denominator) { return b2CeilingInt(numerator, denominator); }
|
||||||
|
float beefb_b2MinFloat(float a, float b) { return b2MinFloat(a, b); }
|
||||||
|
float beefb_b2MaxFloat(float a, float b) { return b2MaxFloat(a, b); }
|
||||||
|
float beefb_b2AbsFloat(float a) { return b2AbsFloat(a); }
|
||||||
|
float beefb_b2ClampFloat(float a, float lower, float upper) { return b2ClampFloat(a, lower, upper); }
|
||||||
|
float beefb_b2Dot(b2Vec2 a, b2Vec2 b) { return b2Dot(a, b); }
|
||||||
|
float beefb_b2Cross(b2Vec2 a, b2Vec2 b) { return b2Cross(a, b); }
|
||||||
|
b2Vec2 beefb_b2CrossVS(b2Vec2 v, float s) { return b2CrossVS(v, s); }
|
||||||
|
b2Vec2 beefb_b2CrossSV(float s, b2Vec2 v) { return b2CrossSV(s, v); }
|
||||||
|
b2Vec2 beefb_b2LeftPerp(b2Vec2 v) { return b2LeftPerp(v); }
|
||||||
|
b2Vec2 beefb_b2RightPerp(b2Vec2 v) { return b2RightPerp(v); }
|
||||||
|
b2Vec2 beefb_b2Add(b2Vec2 a, b2Vec2 b) { return b2Add(a, b); }
|
||||||
|
b2Vec2 beefb_b2Sub(b2Vec2 a, b2Vec2 b) { return b2Sub(a, b); }
|
||||||
|
b2Vec2 beefb_b2Neg(b2Vec2 a) { return b2Neg(a); }
|
||||||
|
b2Vec2 beefb_b2Lerp(b2Vec2 a, b2Vec2 b, float t) { return b2Lerp(a, b, t); }
|
||||||
|
b2Vec2 beefb_b2Mul(b2Vec2 a, b2Vec2 b) { return b2Mul(a, b); }
|
||||||
|
b2Vec2 beefb_b2MulSV(float s, b2Vec2 v) { return b2MulSV(s, v); }
|
||||||
|
b2Vec2 beefb_b2MulAdd(b2Vec2 a, float s, b2Vec2 b) { return b2MulAdd(a, s, b); }
|
||||||
|
b2Vec2 beefb_b2MulSub(b2Vec2 a, float s, b2Vec2 b) { return b2MulSub(a, s, b); }
|
||||||
|
b2Vec2 beefb_b2Abs(b2Vec2 a) { return b2Abs(a); }
|
||||||
|
b2Vec2 beefb_b2Min(b2Vec2 a, b2Vec2 b) { return b2Min(a, b); }
|
||||||
|
b2Vec2 beefb_b2Max(b2Vec2 a, b2Vec2 b) { return b2Max(a, b); }
|
||||||
|
b2Vec2 beefb_b2Clamp(b2Vec2 v, b2Vec2 a, b2Vec2 b) { return b2Clamp(v, a, b); }
|
||||||
|
float beefb_b2Length(b2Vec2 v) { return b2Length(v); }
|
||||||
|
float beefb_b2Distance(b2Vec2 a, b2Vec2 b) { return b2Distance(a, b); }
|
||||||
|
b2Vec2 beefb_b2Normalize(b2Vec2 v) { return b2Normalize(v); }
|
||||||
|
bool beefb_b2IsNormalized(b2Vec2 a) { return b2IsNormalized(a); }
|
||||||
|
b2Vec2 beefb_b2GetLengthAndNormalize(float *length, b2Vec2 v) { return b2GetLengthAndNormalize(length, v); }
|
||||||
|
b2Rot beefb_b2NormalizeRot(b2Rot q) { return b2NormalizeRot(q); }
|
||||||
|
b2Rot beefb_b2IntegrateRotation(b2Rot q1, float deltaAngle) { return b2IntegrateRotation(q1, deltaAngle); }
|
||||||
|
float beefb_b2LengthSquared(b2Vec2 v) { return b2LengthSquared(v); }
|
||||||
|
float beefb_b2DistanceSquared(b2Vec2 a, b2Vec2 b) { return b2DistanceSquared(a, b); }
|
||||||
|
b2Rot beefb_b2MakeRot(float radians) { return b2MakeRot(radians); }
|
||||||
|
b2Rot beefb_b2MakeRotFromUnitVector(b2Vec2 unitVector) { return b2MakeRotFromUnitVector(unitVector); }
|
||||||
|
bool beefb_b2IsNormalizedRot(b2Rot q) { return b2IsNormalizedRot(q); }
|
||||||
|
b2Rot beefb_b2InvertRot(b2Rot a) { return b2InvertRot(a); }
|
||||||
|
b2Rot beefb_b2NLerp(b2Rot q1, b2Rot q2, float t) { return b2NLerp(q1, q2, t); }
|
||||||
|
float beefb_b2ComputeAngularVelocity(b2Rot q1, b2Rot q2, float inv_h) { return b2ComputeAngularVelocity(q1, q2, inv_h); }
|
||||||
|
float beefb_b2Rot_GetAngle(b2Rot q) { return b2Rot_GetAngle(q); }
|
||||||
|
b2Vec2 beefb_b2Rot_GetXAxis(b2Rot q) { return b2Rot_GetXAxis(q); }
|
||||||
|
b2Vec2 beefb_b2Rot_GetYAxis(b2Rot q) { return b2Rot_GetYAxis(q); }
|
||||||
|
b2Rot beefb_b2MulRot(b2Rot q, b2Rot r) { return b2MulRot(q, r); }
|
||||||
|
b2Rot beefb_b2InvMulRot(b2Rot a, b2Rot b) { return b2InvMulRot(a, b); }
|
||||||
|
float beefb_b2RelativeAngle(b2Rot a, b2Rot b) { return b2RelativeAngle(a, b); }
|
||||||
|
float beefb_b2UnwindAngle(float radians) { return b2UnwindAngle(radians); }
|
||||||
|
b2Vec2 beefb_b2RotateVector(b2Rot q, b2Vec2 v) { return b2RotateVector(q, v); }
|
||||||
|
b2Vec2 beefb_b2InvRotateVector(b2Rot q, b2Vec2 v) { return b2InvRotateVector(q, v); }
|
||||||
|
b2Vec2 beefb_b2TransformPoint(b2Transform t, const b2Vec2 p) { return b2TransformPoint(t, p); }
|
||||||
|
b2Vec2 beefb_b2InvTransformPoint(b2Transform t, const b2Vec2 p) { return b2InvTransformPoint(t, p); }
|
||||||
|
b2Transform beefb_b2MulTransforms(b2Transform A, b2Transform B) { return b2MulTransforms(A, B); }
|
||||||
|
b2Transform beefb_b2InvMulTransforms(b2Transform A, b2Transform B) { return b2InvMulTransforms(A, B); }
|
||||||
|
b2Vec2 beefb_b2MulMV(b2Mat22 A, b2Vec2 v) { return b2MulMV(A, v); }
|
||||||
|
b2Mat22 beefb_b2GetInverse22(b2Mat22 A) { return b2GetInverse22(A); }
|
||||||
|
b2Vec2 beefb_b2Solve22(b2Mat22 A, b2Vec2 b) { return b2Solve22(A, b); }
|
||||||
|
bool beefb_b2AABB_Contains(b2AABB a, b2AABB b) { return b2AABB_Contains(a, b); }
|
||||||
|
b2Vec2 beefb_b2AABB_Center(b2AABB a) { return b2AABB_Center(a); }
|
||||||
|
b2Vec2 beefb_b2AABB_Extents(b2AABB a) { return b2AABB_Extents(a); }
|
||||||
|
b2AABB beefb_b2AABB_Union(b2AABB a, b2AABB b) { return b2AABB_Union(a, b); }
|
||||||
|
bool beefb_b2AABB_Overlaps(b2AABB a, b2AABB b) { return b2AABB_Overlaps(a, b); }
|
||||||
|
b2AABB beefb_b2MakeAABB(const b2Vec2 *points, int count, float radius) { return b2MakeAABB(points, count, radius); }
|
||||||
|
float beefb_b2PlaneSeparation(b2Plane plane, b2Vec2 point) { return b2PlaneSeparation(plane, point); }
|
||||||
|
float beefb_b2SpringDamper(float hertz, float dampingRatio, float position, float velocity, float timeStep) { return b2SpringDamper(hertz, dampingRatio, position, velocity, timeStep); }
|
||||||
|
uint32_t beefb_b2StoreWorldId(b2WorldId id) { return b2StoreWorldId(id); }
|
||||||
|
b2WorldId beefb_b2LoadWorldId(uint32_t x) { return b2LoadWorldId(x); }
|
||||||
|
uint64_t beefb_b2StoreBodyId(b2BodyId id) { return b2StoreBodyId(id); }
|
||||||
|
b2BodyId beefb_b2LoadBodyId(uint64_t x) { return b2LoadBodyId(x); }
|
||||||
|
uint64_t beefb_b2StoreShapeId(b2ShapeId id) { return b2StoreShapeId(id); }
|
||||||
|
b2ShapeId beefb_b2LoadShapeId(uint64_t x) { return b2LoadShapeId(x); }
|
||||||
|
uint64_t beefb_b2StoreChainId(b2ChainId id) { return b2StoreChainId(id); }
|
||||||
|
b2ChainId beefb_b2LoadChainId(uint64_t x) { return b2LoadChainId(x); }
|
||||||
|
uint64_t beefb_b2StoreJointId(b2JointId id) { return b2StoreJointId(id); }
|
||||||
|
b2JointId beefb_b2LoadJointId(uint64_t x) { return b2LoadJointId(x); }
|
||||||
|
void beefb_b2StoreContactId(b2ContactId id, uint32_t values[3]) { b2StoreContactId(id, values); }
|
||||||
|
b2ContactId beefb_b2LoadContactId(uint32_t values[3]) { return b2LoadContactId(values); }
|
||||||
Reference in New Issue
Block a user