fix: update BMap bindings
- send message in console if PyBMap fail to load native dynamic library. this is good for user experience. - remove snippet from BMap bindings generator. We now insert generated code manually. - fix C sharp code generation issue in BMap bidnings generator. - add some content for BMapSharp.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -3,11 +3,21 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
||||
|
||||
<PackageId>BMapSharp</PackageId>
|
||||
<Version>1.0.0</Version>
|
||||
<Authors>yyc12345</Authors>
|
||||
<Company>BearKidsTeam</Company>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="$([System.OperatingSystem]::IsWindows())">
|
||||
<DefineConstants>BMAP_OS_WINDOWS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$([System.OperatingSystem]::IsLinux()) Or $([System.OperatingSystem]::IsFreeBSD())">
|
||||
<DefineConstants>BMAP_OS_LINUX</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$([System.OperatingSystem]::IsMacOS())">
|
||||
<DefineConstants>BMAP_OS_MACOS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace BMapSharp {
|
||||
namespace BMapSharp.BMapWrapper {
|
||||
|
||||
|
||||
|
||||
|
@ -1,7 +1,103 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Numerics;
|
||||
|
||||
namespace BMapSharp {
|
||||
namespace BMapSharp.VirtoolsTypes {
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
|
||||
public struct VxVector2 {
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float X;
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float Y;
|
||||
|
||||
public VxVector2(float _x = 0.0f, float _y = 0.0f) {
|
||||
this.X = _x;
|
||||
this.Y = _y;
|
||||
}
|
||||
public VxVector2(Vector2 vec) {
|
||||
this.FromManaged(vec);
|
||||
}
|
||||
public void FromManaged(Vector2 vec) {
|
||||
this.X = vec.X;
|
||||
this.Y = vec.Y;
|
||||
}
|
||||
public Vector2 ToManaged() {
|
||||
return new Vector2(this.X, this.Y);
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
|
||||
public struct VxVector3 {
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float X;
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float Y;
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float Z;
|
||||
|
||||
public VxVector3(float _x = 0.0f, float _y = 0.0f, float _z = 0.0f) {
|
||||
this.X = _x;
|
||||
this.Y = _y;
|
||||
this.Z = _z;
|
||||
}
|
||||
public VxVector3(Vector3 vec) {
|
||||
this.FromManaged(vec);
|
||||
}
|
||||
public void FromManaged(Vector3 vec) {
|
||||
this.X = vec.X;
|
||||
this.Y = vec.Y;
|
||||
this.Z = vec.Z;
|
||||
}
|
||||
public Vector3 ToManaged() {
|
||||
return new Vector3(this.X, this.Y, this.Z);
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
|
||||
public struct VxColor {
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float A;
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float R;
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float G;
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float B;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
|
||||
public struct VxVector4 {
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float X;
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float Y;
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float Z;
|
||||
[MarshalAs(UnmanagedType.R4)]
|
||||
public float W;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
|
||||
public struct VxMatrix {
|
||||
public VxVector4 x;
|
||||
public VxVector4 y;
|
||||
public VxVector4 z;
|
||||
public VxVector4 w;
|
||||
}
|
||||
|
||||
public struct CKFaceIndices {
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint I1;
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint I2;
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint I3;
|
||||
|
||||
public CKFaceIndices(uint i1 = 0u, uint i2 = 0u, uint i3 = 0u) {
|
||||
this.I1 = i1;
|
||||
this.I2 = i2;
|
||||
this.I3 = i3;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -78,12 +78,13 @@ elif sys.platform.startswith('darwin'):
|
||||
else:
|
||||
_g_BMapLibName = "BMap.bin"
|
||||
|
||||
_g_BMapLibPath: str = os.path.join(os.path.dirname(__file__), _g_BMapLibName)
|
||||
|
||||
_g_BMapModule: ctypes.CDLL | None = None
|
||||
try:
|
||||
_g_BMapModule = ctypes.cdll.LoadLibrary(
|
||||
os.path.join(os.path.dirname(__file__), _g_BMapLibName)
|
||||
)
|
||||
_g_BMapModule = ctypes.cdll.LoadLibrary(_g_BMapLibPath)
|
||||
except:
|
||||
print(f'Fail to load native BMap dynamic library file "{_g_BMapLibPath}".')
|
||||
_g_BMapModule = None
|
||||
|
||||
def is_bmap_available() -> bool:
|
||||
@ -107,6 +108,8 @@ def _create_bmap_func(fct_name: str, fct_params: list[typing.Any]) -> typing.Cal
|
||||
|
||||
#region Function Defines
|
||||
|
||||
##### GENERATED FUNCTIONS BEGIN #####
|
||||
|
||||
## BMInit
|
||||
# @return True if no error, otherwise False.
|
||||
BMInit = _create_bmap_func('BMInit', [])
|
||||
@ -781,5 +784,6 @@ BM3dObject_GetVisibility = _create_bmap_func('BM3dObject_GetVisibility', [bm_voi
|
||||
# @return True if no error, otherwise False.
|
||||
BM3dObject_SetVisibility = _create_bmap_func('BM3dObject_SetVisibility', [bm_void_p, bm_CKID, bm_bool])
|
||||
|
||||
#endregion
|
||||
##### GENERATED FUNCTIONS END #####
|
||||
|
||||
#endregion
|
||||
|
Reference in New Issue
Block a user