Import from Google Code.
This commit is contained in:
Родитель
6de9dd22a2
Коммит
06fd078864
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
|
@ -0,0 +1,128 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
// Finds all references to a specified namespace within assemblies.
|
||||
// This way a wrapper with a minimal subset of classes and methods can be generated.
|
||||
class AssemblySubset
|
||||
{
|
||||
List<TypeReference> subsetTypes = new List<TypeReference>();
|
||||
List<MethodReference> subsetMethods = new List<MethodReference>();
|
||||
|
||||
bool AddTypeReference(TypeReference type, string namespaceName)
|
||||
{
|
||||
if (type.Namespace == namespaceName ||
|
||||
(type.Namespace.StartsWith(namespaceName) && type.Namespace[namespaceName.Length] == '.'))
|
||||
{
|
||||
if (type.IsArray)
|
||||
{
|
||||
var arrayElementType = (type as ArrayType).ElementType;
|
||||
if (!subsetTypes.Contains(arrayElementType))
|
||||
{
|
||||
subsetTypes.Add(arrayElementType);
|
||||
}
|
||||
}
|
||||
else if (type.IsByReference)
|
||||
{
|
||||
var byRefElementType = (type as ByReferenceType).ElementType;
|
||||
if (!subsetTypes.Contains(byRefElementType))
|
||||
{
|
||||
subsetTypes.Add(byRefElementType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!subsetTypes.Contains(type))
|
||||
{
|
||||
subsetTypes.Add(type);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AddMethodReference(MethodReference method, string namespaceName)
|
||||
{
|
||||
if (method.DeclaringType.Namespace == namespaceName)
|
||||
{
|
||||
if (!subsetMethods.Contains(method))
|
||||
{
|
||||
subsetMethods.Add(method);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void LoadAssembly(string assemblyName, string namespaceName)
|
||||
{
|
||||
AssemblyDefinition assembly;
|
||||
try
|
||||
{
|
||||
assembly = AssemblyDefinition.ReadAssembly(assemblyName);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
Console.Write(e);
|
||||
return;
|
||||
}
|
||||
|
||||
var module = assembly.MainModule;
|
||||
foreach (var type in module.Types)
|
||||
{
|
||||
foreach (var field in type.Fields)
|
||||
{
|
||||
AddTypeReference(field.FieldType, namespaceName);
|
||||
}
|
||||
|
||||
foreach (var method in type.Methods)
|
||||
{
|
||||
if (!method.HasBody)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (var instruction in method.Body.Instructions)
|
||||
{
|
||||
var operand = instruction.Operand;
|
||||
if (operand != null)
|
||||
{
|
||||
if (operand is MethodReference)
|
||||
{
|
||||
var methodOp = operand as MethodReference;
|
||||
if (AddTypeReference(methodOp.ReturnType, namespaceName))
|
||||
{
|
||||
AddMethodReference(methodOp, namespaceName);
|
||||
continue;
|
||||
}
|
||||
foreach (var param in methodOp.Parameters)
|
||||
{
|
||||
if (AddTypeReference(param.ParameterType, namespaceName))
|
||||
{
|
||||
AddMethodReference(methodOp, namespaceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (operand is FieldReference)
|
||||
{
|
||||
var field = operand as FieldReference;
|
||||
AddTypeReference(field.FieldType, namespaceName);
|
||||
}
|
||||
else if (operand is VariableReference)
|
||||
{
|
||||
var variable = operand as VariableReference;
|
||||
AddTypeReference(variable.VariableType, namespaceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AddTypeReference(method.ReturnType, namespaceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{6FE07518-C310-4BB4-9C78-2CEAFADE1D99}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BulletSharpGen</RootNamespace>
|
||||
<AssemblyName>BulletSharpGen</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ClangSharp">
|
||||
<HintPath>.\ClangSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil">
|
||||
<HintPath>.\Mono.Cecil.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblySubset.cs" />
|
||||
<Compile Include="BulletParser.cs" />
|
||||
<Compile Include="CMakeWriter.cs" />
|
||||
<Compile Include="CppCliWriter.cs" />
|
||||
<Compile Include="ExtensionsWriter.cs" />
|
||||
<Compile Include="FilterWriter.cs" />
|
||||
<Compile Include="PInvokeWriter.cs" />
|
||||
<Compile Include="ProjectConfiguration.cs" />
|
||||
<Compile Include="SlnWriter.cs" />
|
||||
<Compile Include="CppReader.cs" />
|
||||
<Compile Include="ClassDefinition.cs" />
|
||||
<Compile Include="EnumDefinition.cs" />
|
||||
<Compile Include="FieldDefinition.cs" />
|
||||
<Compile Include="HeaderDefinition.cs" />
|
||||
<Compile Include="MethodDefinition.cs" />
|
||||
<Compile Include="ParameterDefinition.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="PropertyDefinition.cs" />
|
||||
<Compile Include="TypeRefDefinition.cs" />
|
||||
<Compile Include="WrapperWriter.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="libclang.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BulletSharpGen", "BulletSharpGen.csproj", "{6FE07518-C310-4BB4-9C78-2CEAFADE1D99}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6FE07518-C310-4BB4-9C78-2CEAFADE1D99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6FE07518-C310-4BB4-9C78-2CEAFADE1D99}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6FE07518-C310-4BB4-9C78-2CEAFADE1D99}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6FE07518-C310-4BB4-9C78-2CEAFADE1D99}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,153 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
class CMakeWriter
|
||||
{
|
||||
private Dictionary<string, HeaderDefinition> headerDefinitions;
|
||||
private string namespaceName;
|
||||
|
||||
StreamWriter cmakeWriter;
|
||||
|
||||
public CMakeWriter(Dictionary<string, HeaderDefinition> headerDefinitions, string namespaceName)
|
||||
{
|
||||
this.headerDefinitions = headerDefinitions;
|
||||
this.namespaceName = namespaceName;
|
||||
}
|
||||
|
||||
void Write(string s)
|
||||
{
|
||||
cmakeWriter.Write(s);
|
||||
}
|
||||
|
||||
void WriteLine(string s)
|
||||
{
|
||||
cmakeWriter.WriteLine(s);
|
||||
}
|
||||
|
||||
void WriteLine()
|
||||
{
|
||||
cmakeWriter.WriteLine();
|
||||
}
|
||||
|
||||
public void Output()
|
||||
{
|
||||
string outDirectoryC = namespaceName + "_c";
|
||||
|
||||
Directory.CreateDirectory(outDirectoryC);
|
||||
|
||||
// C++ header file (includes all other headers)
|
||||
string cmakeFilename = "CMakeLists.txt";
|
||||
var cmakeFile = new FileStream(outDirectoryC + "\\" + cmakeFilename, FileMode.Create, FileAccess.Write);
|
||||
cmakeWriter = new StreamWriter(cmakeFile);
|
||||
|
||||
WriteLine("CMAKE_MINIMUM_REQUIRED (VERSION 2.6)");
|
||||
WriteLine("PROJECT (libbulletc)");
|
||||
WriteLine();
|
||||
WriteLine("IF (NOT CMAKE_BUILD_TYPE)");
|
||||
WriteLine("# SET(CMAKE_BUILD_TYPE \"Debug\")");
|
||||
WriteLine(" SET(CMAKE_BUILD_TYPE \"MinSizeRel\")");
|
||||
WriteLine("ENDIF (NOT CMAKE_BUILD_TYPE)");
|
||||
WriteLine();
|
||||
WriteLine("FIND_PATH(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h");
|
||||
WriteLine(" PATHS");
|
||||
WriteLine(" ${PROJECT_SOURCE_DIR}/../../bullet/src/");
|
||||
WriteLine(" ${PROJECT_SOURCE_DIR}/../bullet/src/");
|
||||
WriteLine(" ${PROJECT_SOURCE_DIR}/../../bullet3/src/");
|
||||
WriteLine(" ${PROJECT_SOURCE_DIR}/../bullet3/src/");
|
||||
WriteLine(" ENV CPATH");
|
||||
WriteLine(" /usr/include");
|
||||
WriteLine(" /usr/local/include");
|
||||
WriteLine(" /opt/local/include");
|
||||
WriteLine(" NO_DEFAULT_PATH");
|
||||
WriteLine(")");
|
||||
WriteLine("INCLUDE_DIRECTORIES(${BULLET_INCLUDE_DIR})");
|
||||
WriteLine("INCLUDE_DIRECTORIES(${BULLET_INCLUDE_DIR}/../Extras/Serialize/BulletWorldImporter/)");
|
||||
WriteLine();
|
||||
|
||||
WriteLine("IF(${CMAKE_GENERATOR} MATCHES \"Unix Makefiles\")");
|
||||
WriteLine(" SET(BULLET_LIB_DIR ${BULLET_INCLUDE_DIR}/..)");
|
||||
WriteLine(" LINK_DIRECTORIES(${BULLET_LIB_DIR}/build/src/BulletCollision)");
|
||||
WriteLine(" LINK_DIRECTORIES(${BULLET_LIB_DIR}/build/src/BulletDynamics)");
|
||||
WriteLine(" LINK_DIRECTORIES(${BULLET_LIB_DIR}/build/src/BulletSoftBody)");
|
||||
WriteLine(" LINK_DIRECTORIES(${BULLET_LIB_DIR}/build/src/LinearMath)");
|
||||
WriteLine(" LINK_DIRECTORIES(${BULLET_LIB_DIR}/build/Extras/Serialize/BulletFileLoader)");
|
||||
WriteLine(" LINK_DIRECTORIES(${BULLET_LIB_DIR}/build/Extras/Serialize/BulletWorldImporter)");
|
||||
WriteLine(" LINK_DIRECTORIES(${BULLET_LIB_DIR}/build/Extras/Serialize/BulletXmlWorldImporter)");
|
||||
WriteLine(" SET(BULLETC_LIB bulletc)");
|
||||
WriteLine("ELSE()");
|
||||
WriteLine(" IF(${CMAKE_GENERATOR} MATCHES \"Visual Studio 9 2008\")");
|
||||
WriteLine(" SET(REL_LIB_DIR msvc/2008)");
|
||||
WriteLine(" ELSEIF(${CMAKE_GENERATOR} MATCHES \"Visual Studio 10\")");
|
||||
WriteLine(" SET(REL_LIB_DIR msvc/2010)");
|
||||
WriteLine(" ELSEIF(${CMAKE_GENERATOR} MATCHES \"Visual Studio 11\")");
|
||||
WriteLine(" SET(REL_LIB_DIR msvc/2012)");
|
||||
WriteLine(" ELSEIF(${CMAKE_GENERATOR} MATCHES \"Visual Studio 12\")");
|
||||
WriteLine(" SET(REL_LIB_DIR msvc/2013)");
|
||||
WriteLine(" ENDIF()");
|
||||
WriteLine(" LINK_DIRECTORIES(${BULLET_INCLUDE_DIR}/../${REL_LIB_DIR}/lib/${CMAKE_CFG_INTDIR})");
|
||||
WriteLine(" SET(BULLETC_LIB libbulletc)");
|
||||
WriteLine(" SET(LIB_SUFFIX _${CMAKE_CFG_INTDIR}.lib)");
|
||||
WriteLine("ENDIF()");
|
||||
WriteLine();
|
||||
|
||||
AddLibrary();
|
||||
WriteLine();
|
||||
|
||||
WriteLine("TARGET_LINK_LIBRARIES(${BULLETC_LIB} BulletCollision${LIB_SUFFIX})");
|
||||
WriteLine("TARGET_LINK_LIBRARIES(${BULLETC_LIB} BulletDynamics${LIB_SUFFIX})");
|
||||
WriteLine("TARGET_LINK_LIBRARIES(${BULLETC_LIB} LinearMath${LIB_SUFFIX})");
|
||||
WriteLine("TARGET_LINK_LIBRARIES(${BULLETC_LIB} BulletFileLoader${LIB_SUFFIX})");
|
||||
WriteLine("TARGET_LINK_LIBRARIES(${BULLETC_LIB} BulletSoftBody${LIB_SUFFIX})");
|
||||
WriteLine("TARGET_LINK_LIBRARIES(${BULLETC_LIB} BulletWorldImporter${LIB_SUFFIX})");
|
||||
WriteLine("TARGET_LINK_LIBRARIES(${BULLETC_LIB} BulletXmlWorldImporter${LIB_SUFFIX})");
|
||||
|
||||
cmakeWriter.Dispose();
|
||||
cmakeFile.Dispose();
|
||||
}
|
||||
|
||||
void AddLibrary()
|
||||
{
|
||||
List<string> sources = new List<string>();
|
||||
var headers = headerDefinitions.Values.Where(x => !x.IsExcluded).OrderBy(x => x.Name);
|
||||
|
||||
foreach (HeaderDefinition header in headers)
|
||||
{
|
||||
sources.Add(header.Name + "_wrap.cpp");
|
||||
sources.Add(header.Name + "_wrap.h");
|
||||
}
|
||||
//sources.OrderBy(x => x.Na);
|
||||
|
||||
WriteLine("ADD_LIBRARY(${BULLETC_LIB} SHARED");
|
||||
WriteSources(new string[] {
|
||||
"dllmain.cpp"
|
||||
});
|
||||
WriteSources(new string[] {
|
||||
"conversion.h",
|
||||
"main.h",
|
||||
"collections.cpp",
|
||||
"collections.h",
|
||||
}, "src");
|
||||
WriteSources(sources, "src");
|
||||
WriteLine(")");
|
||||
}
|
||||
|
||||
void WriteSources(IEnumerable<string> files, string directory)
|
||||
{
|
||||
foreach (string file in files)
|
||||
{
|
||||
WriteLine(string.Format(" {0}/{1}", directory, file));
|
||||
}
|
||||
}
|
||||
|
||||
void WriteSources(IEnumerable<string> files)
|
||||
{
|
||||
foreach (string file in files)
|
||||
{
|
||||
WriteLine(string.Format(" {0}", file));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Двоичный файл не отображается.
|
@ -0,0 +1,111 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
class ClassDefinition
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public List<ClassDefinition> Classes { get; private set; }
|
||||
public TypeRefDefinition BaseClass { get; set; }
|
||||
public ClassDefinition Parent { get; private set; }
|
||||
public HeaderDefinition Header { get; private set; }
|
||||
public List<MethodDefinition> Methods { get; private set; }
|
||||
public List<PropertyDefinition> Properties { get; private set; }
|
||||
public List<FieldDefinition> Fields { get; private set; }
|
||||
public bool IsAbstract { get; set; }
|
||||
public bool IsStruct { get; set; }
|
||||
public bool IsTemplate { get; set; }
|
||||
|
||||
public bool HidePublicConstructors { get; set; }
|
||||
public bool NoInternalConstructor { get; set; }
|
||||
public bool IsTrackingDisposable { get; set; }
|
||||
public bool HasPreventDelete { get; set; }
|
||||
public bool IsExcluded { get; set; }
|
||||
|
||||
// For function prototypes IsTypeDef == true, but TypedefUnderlyingType == null
|
||||
public bool IsTypedef { get; set; }
|
||||
public TypeRefDefinition TypedefUnderlyingType { get; set; }
|
||||
|
||||
// Pure enum = enum wrapped in a struct
|
||||
public EnumDefinition Enum { get; set; }
|
||||
public bool IsPureEnum
|
||||
{
|
||||
get { return Enum != null && Methods.Count == 0; }
|
||||
}
|
||||
|
||||
public string ManagedName { get; set; }
|
||||
|
||||
public IEnumerable<ClassDefinition> AllSubClasses
|
||||
{
|
||||
get
|
||||
{
|
||||
List<ClassDefinition> subClasses = new List<ClassDefinition>();
|
||||
foreach (ClassDefinition cl in Classes)
|
||||
{
|
||||
subClasses.AddRange(cl.AllSubClasses);
|
||||
subClasses.Add(cl);
|
||||
}
|
||||
return subClasses;
|
||||
}
|
||||
}
|
||||
|
||||
public string FullName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Parent != null)
|
||||
{
|
||||
return Parent.FullName + "::" + Name;
|
||||
}
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
public string FullNameCS
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Parent != null)
|
||||
{
|
||||
return Parent.FullNameCS + '_' + Name;
|
||||
}
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
public string FullNameManaged
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Parent != null)
|
||||
{
|
||||
return Parent.FullNameManaged + "::" + ManagedName;
|
||||
}
|
||||
return ManagedName;
|
||||
}
|
||||
}
|
||||
|
||||
public ClassDefinition(string name, ClassDefinition parent)
|
||||
: this(name, parent.Header)
|
||||
{
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
public ClassDefinition(string name, HeaderDefinition header)
|
||||
{
|
||||
Name = name;
|
||||
Header = header;
|
||||
|
||||
Classes = new List<ClassDefinition>();
|
||||
Methods = new List<MethodDefinition>();
|
||||
Properties = new List<PropertyDefinition>();
|
||||
Fields = new List<FieldDefinition>();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,456 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using ClangSharp;
|
||||
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
class CppReader
|
||||
{
|
||||
string src;
|
||||
Index index;
|
||||
List<string> headerQueue = new List<string>();
|
||||
List<string> clangOptions = new List<string>();
|
||||
Dictionary<string, string> excludedMethods = new Dictionary<string, string>();
|
||||
AccessSpecifier currentMemberAccess;
|
||||
HeaderDefinition currentHeader;
|
||||
ClassDefinition currentClass;
|
||||
MethodDefinition currentMethod;
|
||||
ParameterDefinition currentParameter;
|
||||
EnumDefinition currentEnum;
|
||||
FieldDefinition currentField;
|
||||
bool currentFieldHasSpecializedParameter;
|
||||
TranslationUnit currentTU;
|
||||
|
||||
public Dictionary<string, ClassDefinition> ClassDefinitions = new Dictionary<string, ClassDefinition>();
|
||||
public Dictionary<string, HeaderDefinition> HeaderDefinitions = new Dictionary<string, HeaderDefinition>();
|
||||
|
||||
public CppReader(string sourceDirectory)
|
||||
{
|
||||
src = Path.GetFullPath(sourceDirectory);
|
||||
src = src.Replace('\\', '/');
|
||||
|
||||
string[] commonHeaders;
|
||||
List<string> excludedHeaders = new List<string>();
|
||||
|
||||
// Exclude C API
|
||||
excludedHeaders.Add(src + "Bullet-C-Api.h");
|
||||
|
||||
// Include directory
|
||||
clangOptions.Add("-I");
|
||||
clangOptions.Add(src);
|
||||
|
||||
// WorldImporter include directory
|
||||
clangOptions.Add("-I");
|
||||
clangOptions.Add(src + "../Extras/Serialize/BulletWorldImporter");
|
||||
|
||||
// Specify C++ headers, not C ones
|
||||
clangOptions.Add("-x");
|
||||
clangOptions.Add("c++-header");
|
||||
|
||||
// Exclude irrelevant methods
|
||||
excludedMethods.Add("operator new", null);
|
||||
excludedMethods.Add("operator delete", null);
|
||||
excludedMethods.Add("operator new[]", null);
|
||||
excludedMethods.Add("operator delete[]", null);
|
||||
excludedMethods.Add("operator+=", null);
|
||||
excludedMethods.Add("operator-=", null);
|
||||
excludedMethods.Add("operator*=", null);
|
||||
excludedMethods.Add("operator/=", null);
|
||||
excludedMethods.Add("operator==", null);
|
||||
excludedMethods.Add("operator!=", null);
|
||||
excludedMethods.Add("operator()", null);
|
||||
|
||||
// Enumerate all header files in the source tree
|
||||
var headerFiles = Directory.EnumerateFiles(src, "*.h", SearchOption.AllDirectories);
|
||||
foreach (string header in headerFiles)
|
||||
{
|
||||
if (header.Contains("GpuSoftBodySolvers") || header.Contains("vectormath"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string headerCanonical = header.Replace('\\', '/');
|
||||
if (!excludedHeaders.Contains(headerCanonical))
|
||||
{
|
||||
headerQueue.Add(headerCanonical);
|
||||
}
|
||||
}
|
||||
|
||||
Console.Write("Reading headers");
|
||||
|
||||
index = new Index();
|
||||
|
||||
// Parse the common headers
|
||||
commonHeaders = new[] { src + "btBulletCollisionCommon.h", src + "btBulletDynamicsCommon.h" };
|
||||
foreach (string commonHeader in commonHeaders)
|
||||
{
|
||||
if (!headerQueue.Contains(commonHeader))
|
||||
{
|
||||
Console.WriteLine("Could not find " + commonHeader);
|
||||
return;
|
||||
}
|
||||
ReadHeader(commonHeader);
|
||||
}
|
||||
|
||||
while (headerQueue.Count != 0)
|
||||
{
|
||||
ReadHeader(headerQueue[0]);
|
||||
}
|
||||
|
||||
if (Directory.Exists(src + "..\\Extras\\"))
|
||||
{
|
||||
ReadHeader(src + "..\\Extras\\Serialize\\BulletFileLoader\\btBulletFile.h");
|
||||
ReadHeader(src + "..\\Extras\\Serialize\\BulletWorldImporter\\btBulletWorldImporter.h");
|
||||
ReadHeader(src + "..\\Extras\\Serialize\\BulletWorldImporter\\btWorldImporter.h");
|
||||
ReadHeader(src + "..\\Extras\\Serialize\\BulletXmlWorldImporter\\btBulletXmlWorldImporter.h");
|
||||
ReadHeader(src + "..\\Extras\\HACD\\hacdHACD.h");
|
||||
}
|
||||
|
||||
index.Dispose();
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Read complete - headers: " + HeaderDefinitions.Count + ", classes: " + ClassDefinitions.Count);
|
||||
}
|
||||
|
||||
Cursor.ChildVisitResult HeaderVisitor(Cursor cursor, Cursor parent)
|
||||
{
|
||||
string filename = cursor.Extent.Start.File.Name.Replace('\\', '/');
|
||||
if (!filename.StartsWith(src, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return Cursor.ChildVisitResult.Continue;
|
||||
}
|
||||
|
||||
// Have we visited this header already?
|
||||
if (HeaderDefinitions.ContainsKey(filename))
|
||||
{
|
||||
currentHeader = HeaderDefinitions[filename];
|
||||
}
|
||||
else
|
||||
{
|
||||
// No, define a new one
|
||||
string relativeFilename = filename.Substring(src.Length);
|
||||
currentHeader = new HeaderDefinition(relativeFilename);
|
||||
HeaderDefinitions.Add(filename, currentHeader);
|
||||
headerQueue.Remove(filename);
|
||||
}
|
||||
|
||||
if ((cursor.Kind == CursorKind.ClassDecl || cursor.Kind == CursorKind.StructDecl ||
|
||||
cursor.Kind == CursorKind.ClassTemplate || cursor.Kind == CursorKind.TypedefDecl) && cursor.IsDefinition)
|
||||
{
|
||||
ParseClassCursor(cursor);
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.EnumDecl)
|
||||
{
|
||||
currentEnum = new EnumDefinition(cursor.Spelling);
|
||||
currentHeader.Enums.Add(currentEnum);
|
||||
cursor.VisitChildren(EnumVisitor);
|
||||
currentEnum = null;
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.Namespace)
|
||||
{
|
||||
return Cursor.ChildVisitResult.Recurse;
|
||||
}
|
||||
return Cursor.ChildVisitResult.Continue;
|
||||
}
|
||||
|
||||
Cursor.ChildVisitResult EnumVisitor(Cursor cursor, Cursor parent)
|
||||
{
|
||||
if (cursor.Kind == CursorKind.EnumConstantDecl)
|
||||
{
|
||||
currentEnum.EnumConstants.Add(cursor.Spelling);
|
||||
currentEnum.EnumConstantValues.Add(cursor.Spelling);
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.IntegerLiteral)
|
||||
{
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.ParenExpr)
|
||||
{
|
||||
return Cursor.ChildVisitResult.Continue;
|
||||
}
|
||||
return Cursor.ChildVisitResult.Recurse;
|
||||
}
|
||||
|
||||
void ParseClassCursor(Cursor cursor)
|
||||
{
|
||||
string className = cursor.Spelling;
|
||||
string fullyQualifiedName;
|
||||
|
||||
if (cursor.Type.TypeKind != ClangSharp.Type.Kind.Invalid)
|
||||
{
|
||||
fullyQualifiedName = TypeRefDefinition.GetFullyQualifiedName(cursor.Type);
|
||||
}
|
||||
else if (currentClass != null)
|
||||
{
|
||||
fullyQualifiedName = currentClass.FullName + "::" + className;
|
||||
}
|
||||
else
|
||||
{
|
||||
fullyQualifiedName = className;
|
||||
}
|
||||
|
||||
if (ClassDefinitions.ContainsKey(fullyQualifiedName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(className) && cursor.Kind == CursorKind.StructDecl && currentClass == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentClass != null)
|
||||
{
|
||||
currentClass = new ClassDefinition(className, currentClass);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentClass = new ClassDefinition(className, currentHeader);
|
||||
}
|
||||
|
||||
// Unnamed struct escapes to the surrounding scope
|
||||
if (!(string.IsNullOrEmpty(className) && cursor.Kind == CursorKind.StructDecl))
|
||||
{
|
||||
ClassDefinitions.Add(fullyQualifiedName, currentClass);
|
||||
|
||||
if (currentClass.Parent != null)
|
||||
{
|
||||
currentClass.Parent.Classes.Add(currentClass);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentHeader.Classes.Add(currentClass);
|
||||
}
|
||||
}
|
||||
|
||||
AccessSpecifier parentMemberAccess = currentMemberAccess;
|
||||
|
||||
// Default class/struct access specifier
|
||||
if (cursor.Kind == CursorKind.ClassDecl)
|
||||
{
|
||||
currentMemberAccess = AccessSpecifier.Private;
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.StructDecl)
|
||||
{
|
||||
currentClass.IsStruct = true;
|
||||
currentMemberAccess = AccessSpecifier.Public;
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.ClassTemplate)
|
||||
{
|
||||
currentClass.IsTemplate = true;
|
||||
if (cursor.TemplateCursorKind != CursorKind.ClassDecl)
|
||||
{
|
||||
currentMemberAccess = AccessSpecifier.Private;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentMemberAccess = AccessSpecifier.Public;
|
||||
}
|
||||
}
|
||||
|
||||
if (cursor.Kind == CursorKind.EnumDecl)
|
||||
{
|
||||
currentEnum = new EnumDefinition(fullyQualifiedName);
|
||||
currentHeader.Enums.Add(currentEnum);
|
||||
cursor.VisitChildren(EnumVisitor);
|
||||
if (currentClass != null && currentClass.IsStruct)
|
||||
{
|
||||
// Enum wrapped in a struct
|
||||
currentClass.Enum = currentEnum;
|
||||
}
|
||||
currentEnum = null;
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.TypedefDecl)
|
||||
{
|
||||
currentClass.IsTypedef = true;
|
||||
if (cursor.TypedefDeclUnderlyingType.Canonical.TypeKind != ClangSharp.Type.Kind.FunctionProto)
|
||||
{
|
||||
currentClass.TypedefUnderlyingType = new TypeRefDefinition(cursor.TypedefDeclUnderlyingType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor.VisitChildren(ClassVisitor);
|
||||
}
|
||||
|
||||
// Restore parent state
|
||||
currentClass = currentClass.Parent;
|
||||
currentMemberAccess = parentMemberAccess;
|
||||
}
|
||||
|
||||
Cursor.ChildVisitResult MethodTemplateTypeVisitor(Cursor cursor, Cursor parent)
|
||||
{
|
||||
if (cursor.Kind == CursorKind.TypeRef)
|
||||
{
|
||||
if (cursor.Referenced.Kind == CursorKind.TemplateTypeParameter)
|
||||
{
|
||||
if (currentParameter != null)
|
||||
{
|
||||
currentParameter.Type.HasTemplateTypeParameter = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentMethod.ReturnType.HasTemplateTypeParameter = true;
|
||||
}
|
||||
return Cursor.ChildVisitResult.Break;
|
||||
}
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.TemplateRef)
|
||||
{
|
||||
// TODO
|
||||
return Cursor.ChildVisitResult.Recurse;
|
||||
}
|
||||
return Cursor.ChildVisitResult.Continue;
|
||||
}
|
||||
|
||||
Cursor.ChildVisitResult FieldTemplateTypeVisitor(Cursor cursor, Cursor parent)
|
||||
{
|
||||
if (cursor.Kind == CursorKind.TypeRef)
|
||||
{
|
||||
if (cursor.Referenced.Kind == CursorKind.TemplateTypeParameter)
|
||||
{
|
||||
currentField.Type.HasTemplateTypeParameter = true;
|
||||
}
|
||||
else if (currentFieldHasSpecializedParameter)
|
||||
{
|
||||
currentField.Type.SpecializedTemplateType = new TypeRefDefinition(cursor.Type);
|
||||
}
|
||||
return Cursor.ChildVisitResult.Break;
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.TemplateRef)
|
||||
{
|
||||
if (!parent.Type.Declaration.SpecializedCursorTemplate.IsInvalid)
|
||||
{
|
||||
currentFieldHasSpecializedParameter = true;
|
||||
return Cursor.ChildVisitResult.Continue;
|
||||
}
|
||||
else if (parent.Type.Declaration.Kind == CursorKind.ClassTemplate)
|
||||
{
|
||||
currentField.Type.HasTemplateTypeParameter = true;
|
||||
return Cursor.ChildVisitResult.Break;
|
||||
}
|
||||
}
|
||||
return Cursor.ChildVisitResult.Continue;
|
||||
}
|
||||
|
||||
Cursor.ChildVisitResult ClassVisitor(Cursor cursor, Cursor parent)
|
||||
{
|
||||
if (cursor.Kind == CursorKind.CxxAccessSpecifier)
|
||||
{
|
||||
currentMemberAccess = cursor.AccessSpecifier;
|
||||
return Cursor.ChildVisitResult.Continue;
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.CxxBaseSpecifier)
|
||||
{
|
||||
currentClass.BaseClass = new TypeRefDefinition(cursor.Type);
|
||||
return Cursor.ChildVisitResult.Continue;
|
||||
}
|
||||
|
||||
if (currentMemberAccess != AccessSpecifier.Public)
|
||||
{
|
||||
return Cursor.ChildVisitResult.Continue;
|
||||
}
|
||||
|
||||
if ((cursor.Kind == CursorKind.ClassDecl || cursor.Kind == CursorKind.StructDecl ||
|
||||
cursor.Kind == CursorKind.ClassTemplate || cursor.Kind == CursorKind.TypedefDecl ||
|
||||
cursor.Kind == CursorKind.EnumDecl) && cursor.IsDefinition)
|
||||
{
|
||||
ParseClassCursor(cursor);
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.CxxMethod || cursor.Kind == CursorKind.Constructor)
|
||||
{
|
||||
string methodName = cursor.Spelling;
|
||||
if (excludedMethods.ContainsKey(methodName))
|
||||
{
|
||||
return Cursor.ChildVisitResult.Continue;
|
||||
}
|
||||
|
||||
currentMethod = new MethodDefinition(methodName, currentClass, cursor.NumArguments);
|
||||
currentMethod.ReturnType = new TypeRefDefinition(cursor.ResultType);
|
||||
currentMethod.IsStatic = cursor.IsStaticCxxMethod;
|
||||
currentMethod.IsConstructor = cursor.Kind == CursorKind.Constructor;
|
||||
|
||||
if (cursor.IsVirtualCxxMethod)
|
||||
{
|
||||
currentMethod.IsVirtual = true;
|
||||
if (cursor.IsPureVirtualCxxMethod)
|
||||
{
|
||||
currentMethod.IsAbstract = true;
|
||||
currentClass.IsAbstract = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the return type is a template
|
||||
cursor.VisitChildren(MethodTemplateTypeVisitor);
|
||||
|
||||
// Parse arguments
|
||||
for (uint i = 0; i < cursor.NumArguments; i++)
|
||||
{
|
||||
Cursor arg = cursor.GetArgument(i);
|
||||
|
||||
string parameterName = arg.Spelling;
|
||||
if (parameterName.Length == 0)
|
||||
{
|
||||
parameterName = "__unnamed" + i;
|
||||
}
|
||||
currentParameter = new ParameterDefinition(parameterName, new TypeRefDefinition(arg.Type));
|
||||
currentMethod.Parameters[i] = currentParameter;
|
||||
arg.VisitChildren(MethodTemplateTypeVisitor);
|
||||
currentParameter = null;
|
||||
|
||||
// Check if it's a const or optional parameter
|
||||
IEnumerable<Token> argTokens = currentTU.Tokenize(arg.Extent);
|
||||
foreach (Token token in argTokens)
|
||||
{
|
||||
if (token.Spelling.Equals("="))
|
||||
{
|
||||
currentMethod.Parameters[i].IsOptional = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentMethod = null;
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.FieldDecl)
|
||||
{
|
||||
currentField = new FieldDefinition(cursor.Spelling,
|
||||
new TypeRefDefinition(cursor.Type), currentClass);
|
||||
currentFieldHasSpecializedParameter = false;
|
||||
cursor.VisitChildren(FieldTemplateTypeVisitor);
|
||||
currentField = null;
|
||||
}
|
||||
else if (cursor.Kind == CursorKind.UnionDecl)
|
||||
{
|
||||
return Cursor.ChildVisitResult.Recurse;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Console.WriteLine(cursor.Spelling);
|
||||
}
|
||||
return Cursor.ChildVisitResult.Continue;
|
||||
}
|
||||
|
||||
void ReadHeader(string headerFile)
|
||||
{
|
||||
Console.Write('.');
|
||||
|
||||
var unsavedFiles = new UnsavedFile[] { };
|
||||
if (headerFile.EndsWith("PosixThreadSupport.h"))
|
||||
{
|
||||
List<string> clangOptionsPThread = new List<string>(clangOptions);
|
||||
clangOptionsPThread.Add("-DUSE_PTHREADS");
|
||||
currentTU = index.CreateTranslationUnit(headerFile, clangOptionsPThread.ToArray(), unsavedFiles, TranslationUnitFlags.SkipFunctionBodies);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentTU = index.CreateTranslationUnit(headerFile, clangOptions.ToArray(), unsavedFiles, TranslationUnitFlags.SkipFunctionBodies);
|
||||
}
|
||||
var cur = currentTU.Cursor;
|
||||
cur.VisitChildren(HeaderVisitor);
|
||||
currentTU.Dispose();
|
||||
currentTU = null;
|
||||
headerQueue.Remove(headerFile);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
class EnumDefinition
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public List<string> EnumConstants { get; private set; }
|
||||
public List<string> EnumConstantValues { get; private set; }
|
||||
|
||||
public EnumDefinition(string name)
|
||||
{
|
||||
Name = name;
|
||||
EnumConstants = new List<string>();
|
||||
EnumConstantValues = new List<string>();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,415 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
class ExtensionsWriter : WrapperWriter
|
||||
{
|
||||
Dictionary<string, string> _extensionClassesInternal = new Dictionary<string, string>();
|
||||
Dictionary<string, string> _extensionClassesExternal = new Dictionary<string, string>();
|
||||
Dictionary<string, string> _returnTypeConversion = new Dictionary<string, string>();
|
||||
|
||||
List<KeyValuePair<string, string>> _extensionMethods = new List<KeyValuePair<string, string>>();
|
||||
|
||||
public ExtensionsWriter(IEnumerable<HeaderDefinition> headerDefinitions, string namespaceName)
|
||||
: base(headerDefinitions, namespaceName)
|
||||
{
|
||||
_extensionClassesInternal.Add("Matrix3x3", "BulletSharp.Math.Matrix");
|
||||
_extensionClassesInternal.Add("Quaternion", "BulletSharp.Math.Quaternion");
|
||||
_extensionClassesInternal.Add("Transform", "BulletSharp.Math.Matrix");
|
||||
_extensionClassesInternal.Add("Vector3", "BulletSharp.Math.Vector3");
|
||||
|
||||
_extensionClassesExternal.Add("Matrix3x3", "OpenTK.Matrix4");
|
||||
_extensionClassesExternal.Add("Quaternion", "OpenTK.Quaternion");
|
||||
_extensionClassesExternal.Add("Transform", "OpenTK.Matrix4");
|
||||
_extensionClassesExternal.Add("Vector3", "OpenTK.Vector3");
|
||||
|
||||
_returnTypeConversion.Add("Matrix3x3", ".ToOpenTK()");
|
||||
_returnTypeConversion.Add("Quaternion", ".ToOpenTK()");
|
||||
_returnTypeConversion.Add("Transform", ".ToOpenTK()");
|
||||
_returnTypeConversion.Add("Vector3", ".ToOpenTK()");
|
||||
}
|
||||
|
||||
bool MethodNeedsExtensions(MethodDefinition method)
|
||||
{
|
||||
// Extension constructors & static extension methods not supported
|
||||
if (method.IsConstructor || method.IsStatic)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var param in method.Parameters)
|
||||
{
|
||||
if (_extensionClassesInternal.ContainsKey(param.Type.ManagedName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ClassNeedsExtensions(ClassDefinition c)
|
||||
{
|
||||
foreach (var prop in c.Properties)
|
||||
{
|
||||
if (_extensionClassesInternal.ContainsKey(prop.Type.ManagedName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var method in c.Methods)
|
||||
{
|
||||
if (MethodNeedsExtensions(method))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Output()
|
||||
{
|
||||
string outDirectory = NamespaceName + "_extensions";
|
||||
|
||||
foreach (HeaderDefinition header in headerDefinitions)
|
||||
{
|
||||
bool headerNeedsExtensions = false;
|
||||
foreach (var c in header.Classes)
|
||||
{
|
||||
if (ClassNeedsExtensions(c))
|
||||
{
|
||||
headerNeedsExtensions = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!headerNeedsExtensions)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(outDirectory);
|
||||
|
||||
// C# extensions file
|
||||
var csFile = new FileStream(outDirectory + "\\" + header.ManagedName + "Extensions.cs", FileMode.Create, FileAccess.Write);
|
||||
csWriter = new StreamWriter(csFile);
|
||||
csWriter.WriteLine("using System.ComponentModel;");
|
||||
csWriter.WriteLine();
|
||||
csWriter.Write("namespace ");
|
||||
csWriter.WriteLine(NamespaceName);
|
||||
csWriter.WriteLine('{');
|
||||
hasCSWhiteSpace = true;
|
||||
|
||||
foreach (var c in header.Classes)
|
||||
{
|
||||
WriteClass(c);
|
||||
}
|
||||
|
||||
csWriter.WriteLine("}");
|
||||
|
||||
csWriter.Dispose();
|
||||
csFile.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteClass(ClassDefinition c)
|
||||
{
|
||||
foreach (var child in c.Classes)
|
||||
{
|
||||
WriteClass(child);
|
||||
}
|
||||
|
||||
if (!ClassNeedsExtensions(c))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_extensionMethods.Clear();
|
||||
|
||||
EnsureWhiteSpace(WriteTo.CS);
|
||||
WriteTabs(1, WriteTo.CS);
|
||||
csWriter.WriteLine("[EditorBrowsable(EditorBrowsableState.Never)]");
|
||||
WriteTabs(1, WriteTo.CS);
|
||||
csWriter.Write("public static class ");
|
||||
csWriter.Write(c.ManagedName);
|
||||
csWriter.WriteLine("Extensions");
|
||||
WriteTabs(1, WriteTo.CS);
|
||||
csWriter.WriteLine('{');
|
||||
|
||||
foreach (var prop in c.Properties)
|
||||
{
|
||||
if (_extensionClassesInternal.ContainsKey(prop.Type.ManagedName))
|
||||
{
|
||||
// Getter with out parameter
|
||||
bufferBuilder.Clear();
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
Write("public unsafe static void Get", WriteTo.Buffer);
|
||||
Write(prop.Name, WriteTo.Buffer);
|
||||
Write("(this ", WriteTo.Buffer);
|
||||
Write(c.ManagedName, WriteTo.Buffer);
|
||||
Write(" obj, out ", WriteTo.Buffer);
|
||||
Write(_extensionClassesExternal[prop.Type.ManagedName], WriteTo.Buffer);
|
||||
WriteLine(" value)", WriteTo.Buffer);
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
WriteLine('{', WriteTo.Buffer);
|
||||
|
||||
WriteTabs(3, WriteTo.Buffer);
|
||||
Write("fixed (", WriteTo.Buffer);
|
||||
Write(_extensionClassesExternal[prop.Type.ManagedName], WriteTo.Buffer);
|
||||
WriteLine("* valuePtr = &value)", WriteTo.Buffer);
|
||||
WriteTabs(3, WriteTo.Buffer);
|
||||
WriteLine('{', WriteTo.Buffer);
|
||||
WriteTabs(4, WriteTo.Buffer);
|
||||
Write("*(", WriteTo.Buffer);
|
||||
Write(_extensionClassesInternal[prop.Type.ManagedName], WriteTo.Buffer);
|
||||
Write("*)valuePtr = obj.", WriteTo.Buffer);
|
||||
Write(prop.Name, WriteTo.Buffer);
|
||||
WriteLine(';', WriteTo.Buffer);
|
||||
WriteTabs(3, WriteTo.Buffer);
|
||||
WriteLine('}', WriteTo.Buffer);
|
||||
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
WriteLine('}', WriteTo.Buffer);
|
||||
|
||||
_extensionMethods.Add(new KeyValuePair<string, string>("Get" + prop.Name, bufferBuilder.ToString()));
|
||||
|
||||
// Getter with return value
|
||||
bufferBuilder.Clear();
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
Write("public static ", WriteTo.Buffer);
|
||||
Write(_extensionClassesExternal[prop.Type.ManagedName], WriteTo.Buffer);
|
||||
Write(" Get", WriteTo.Buffer);
|
||||
Write(prop.Name, WriteTo.Buffer);
|
||||
Write("(this ", WriteTo.Buffer);
|
||||
Write(c.ManagedName, WriteTo.Buffer);
|
||||
WriteLine(" obj)", WriteTo.Buffer);
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
WriteLine('{', WriteTo.Buffer);
|
||||
|
||||
WriteTabs(3, WriteTo.Buffer);
|
||||
Write(_extensionClassesExternal[prop.Type.ManagedName], WriteTo.Buffer);
|
||||
WriteLine(" value;", WriteTo.Buffer);
|
||||
WriteTabs(3, WriteTo.Buffer);
|
||||
Write("Get", WriteTo.Buffer);
|
||||
Write(prop.Name, WriteTo.Buffer);
|
||||
WriteLine("(obj, out value);", WriteTo.Buffer);
|
||||
WriteTabs(3, WriteTo.Buffer);
|
||||
WriteLine("return value;", WriteTo.Buffer);
|
||||
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
WriteLine('}', WriteTo.Buffer);
|
||||
|
||||
_extensionMethods.Add(new KeyValuePair<string, string>("Get" + prop.Name, bufferBuilder.ToString()));
|
||||
|
||||
if (prop.Setter == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Setter with ref parameter
|
||||
bufferBuilder.Clear();
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
Write("public unsafe static void Set", WriteTo.Buffer);
|
||||
Write(prop.Name, WriteTo.Buffer);
|
||||
Write("(this ", WriteTo.Buffer);
|
||||
Write(c.ManagedName, WriteTo.Buffer);
|
||||
Write(" obj, ref ", WriteTo.Buffer);
|
||||
Write(_extensionClassesExternal[prop.Type.ManagedName], WriteTo.Buffer);
|
||||
WriteLine(" value)", WriteTo.Buffer);
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
WriteLine('{', WriteTo.Buffer);
|
||||
|
||||
WriteTabs(3, WriteTo.Buffer);
|
||||
Write("fixed (", WriteTo.Buffer);
|
||||
Write(_extensionClassesExternal[prop.Type.ManagedName], WriteTo.Buffer);
|
||||
WriteLine("* valuePtr = &value)", WriteTo.Buffer);
|
||||
WriteTabs(3, WriteTo.Buffer);
|
||||
WriteLine('{', WriteTo.Buffer);
|
||||
WriteTabs(4, WriteTo.Buffer);
|
||||
Write("obj.", WriteTo.Buffer);
|
||||
Write(prop.Name, WriteTo.Buffer);
|
||||
Write(" = *(", WriteTo.Buffer);
|
||||
Write(_extensionClassesInternal[prop.Type.ManagedName], WriteTo.Buffer);
|
||||
WriteLine("*)valuePtr;", WriteTo.Buffer);
|
||||
WriteTabs(3, WriteTo.Buffer);
|
||||
WriteLine('}', WriteTo.Buffer);
|
||||
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
WriteLine('}', WriteTo.Buffer);
|
||||
|
||||
_extensionMethods.Add(new KeyValuePair<string, string>("Set" + prop.Name, bufferBuilder.ToString()));
|
||||
|
||||
// Setter with non-ref parameter
|
||||
bufferBuilder.Clear();
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
Write("public static void Set", WriteTo.Buffer);
|
||||
Write(prop.Name, WriteTo.Buffer);
|
||||
Write("(this ", WriteTo.Buffer);
|
||||
Write(c.ManagedName, WriteTo.Buffer);
|
||||
Write(" obj, ", WriteTo.Buffer);
|
||||
Write(_extensionClassesExternal[prop.Type.ManagedName], WriteTo.Buffer);
|
||||
WriteLine(" value)", WriteTo.Buffer);
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
WriteLine('{', WriteTo.Buffer);
|
||||
|
||||
WriteTabs(3, WriteTo.Buffer);
|
||||
Write("Set", WriteTo.Buffer);
|
||||
Write(prop.Name, WriteTo.Buffer);
|
||||
WriteLine("(obj, ref value);", WriteTo.Buffer);
|
||||
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
WriteLine('}', WriteTo.Buffer);
|
||||
|
||||
_extensionMethods.Add(new KeyValuePair<string, string>("Set" + prop.Name, bufferBuilder.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var method in c.Methods)
|
||||
{
|
||||
if (!MethodNeedsExtensions(method))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
WriteMethod(method);
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<string, string> method in _extensionMethods.OrderBy(key => key.Key))
|
||||
{
|
||||
EnsureWhiteSpace(WriteTo.CS);
|
||||
csWriter.Write(method.Value);
|
||||
hasCSWhiteSpace = false;
|
||||
}
|
||||
|
||||
WriteTabs(1, WriteTo.CS);
|
||||
csWriter.WriteLine('}');
|
||||
hasCSWhiteSpace = false;
|
||||
}
|
||||
|
||||
private void WriteMethod(MethodDefinition method, int numOptionalParams = 0)
|
||||
{
|
||||
bool convertReturnType = _extensionClassesInternal.ContainsKey(method.ReturnType.ManagedName);
|
||||
|
||||
bufferBuilder.Clear();
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
Write("public unsafe static ", WriteTo.Buffer);
|
||||
if (convertReturnType)
|
||||
{
|
||||
Write(_extensionClassesExternal[method.ReturnType.ManagedName], WriteTo.Buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Write(method.ReturnType.ManagedName, WriteTo.Buffer);
|
||||
}
|
||||
Write(' ', WriteTo.Buffer);
|
||||
Write(method.ManagedName, WriteTo.Buffer);
|
||||
Write("(this ", WriteTo.Buffer);
|
||||
Write(method.Parent.ManagedName, WriteTo.Buffer);
|
||||
Write(" obj", WriteTo.Buffer);
|
||||
|
||||
List<ParameterDefinition> extendedParams = new List<ParameterDefinition>();
|
||||
int numParameters = method.Parameters.Length - numOptionalParams;
|
||||
for (int i = 0; i < numParameters; i++)
|
||||
{
|
||||
Write(", ", WriteTo.Buffer);
|
||||
|
||||
var param = method.Parameters[i];
|
||||
if (_extensionClassesInternal.ContainsKey(param.Type.ManagedName))
|
||||
{
|
||||
Write("ref ", WriteTo.Buffer);
|
||||
Write(_extensionClassesExternal[param.Type.ManagedName], WriteTo.Buffer);
|
||||
Write(' ', WriteTo.Buffer);
|
||||
Write(param.Name, WriteTo.Buffer);
|
||||
extendedParams.Add(param);
|
||||
}
|
||||
else
|
||||
{
|
||||
Write(param.Type.ManagedName, WriteTo.Buffer);
|
||||
Write(' ', WriteTo.Buffer);
|
||||
Write(param.Name, WriteTo.Buffer);
|
||||
}
|
||||
}
|
||||
WriteLine(')', WriteTo.Buffer);
|
||||
|
||||
WriteTabs(2, WriteTo.Buffer);
|
||||
WriteLine('{', WriteTo.Buffer);
|
||||
|
||||
// Fix parameter pointers
|
||||
int tabs = 3;
|
||||
foreach (var param in extendedParams)
|
||||
{
|
||||
WriteTabs(tabs, WriteTo.Buffer);
|
||||
Write("fixed (", WriteTo.Buffer);
|
||||
Write(_extensionClassesExternal[param.Type.ManagedName], WriteTo.Buffer);
|
||||
Write("* ", WriteTo.Buffer);
|
||||
Write(param.Name, WriteTo.Buffer);
|
||||
Write("Ptr = &", WriteTo.Buffer);
|
||||
Write(param.Name, WriteTo.Buffer);
|
||||
WriteLine(')', WriteTo.Buffer);
|
||||
WriteTabs(tabs, WriteTo.Buffer);
|
||||
WriteLine('{', WriteTo.Buffer);
|
||||
tabs++;
|
||||
}
|
||||
|
||||
WriteTabs(tabs, WriteTo.Buffer);
|
||||
if (method.ReturnType.Name != "void")
|
||||
{
|
||||
Write("return ", WriteTo.Buffer);
|
||||
}
|
||||
Write("obj.", WriteTo.Buffer);
|
||||
Write(method.ManagedName, WriteTo.Buffer);
|
||||
Write('(', WriteTo.Buffer);
|
||||
bool hasOptionalParam = false;
|
||||
for (int i = 0; i < numParameters; i++)
|
||||
{
|
||||
var param = method.Parameters[i];
|
||||
if (_extensionClassesInternal.ContainsKey(param.Type.ManagedName))
|
||||
{
|
||||
Write("ref *(", WriteTo.Buffer);
|
||||
Write(_extensionClassesInternal[param.Type.ManagedName], WriteTo.Buffer);
|
||||
Write("*)", WriteTo.Buffer);
|
||||
Write(param.Name, WriteTo.Buffer);
|
||||
Write("Ptr", WriteTo.Buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Write(param.Name, WriteTo.Buffer);
|
||||
}
|
||||
|
||||
if (param.IsOptional)
|
||||
{
|
||||
hasOptionalParam = true;
|
||||
}
|
||||
|
||||
if (i != numParameters - 1)
|
||||
{
|
||||
Write(", ", WriteTo.Buffer);
|
||||
}
|
||||
}
|
||||
Write(')', WriteTo.Buffer);
|
||||
if (convertReturnType)
|
||||
{
|
||||
Write(_returnTypeConversion[method.ReturnType.ManagedName], WriteTo.Buffer);
|
||||
}
|
||||
WriteLine(';', WriteTo.Buffer);
|
||||
|
||||
// Close fixed blocks
|
||||
while (tabs != 2)
|
||||
{
|
||||
tabs--;
|
||||
WriteTabs(tabs, WriteTo.Buffer);
|
||||
WriteLine('}', WriteTo.Buffer);
|
||||
}
|
||||
|
||||
_extensionMethods.Add(new KeyValuePair<string, string>(method.Name, bufferBuilder.ToString()));
|
||||
|
||||
if (hasOptionalParam)
|
||||
{
|
||||
WriteMethod(method, numOptionalParams + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
namespace BulletSharpGen
|
||||
{
|
||||
class FieldDefinition
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public TypeRefDefinition Type { get; private set; }
|
||||
public ClassDefinition Parent { get; private set; }
|
||||
|
||||
public FieldDefinition(string name, TypeRefDefinition type, ClassDefinition parent)
|
||||
{
|
||||
Name = name;
|
||||
Type = type;
|
||||
Parent = parent;
|
||||
|
||||
parent.Fields.Add(this);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,430 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
enum FilterType
|
||||
{
|
||||
None,
|
||||
Simple,
|
||||
Structured
|
||||
}
|
||||
|
||||
class Filter : IComparable<Filter>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Filter Parent { get; set; }
|
||||
public List<Filter> SubFilters { get; private set; }
|
||||
public List<string> Files { get; private set; }
|
||||
public string Guid { get; set; }
|
||||
public string Extensions { get; set; }
|
||||
|
||||
public string FullName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Parent != null)
|
||||
{
|
||||
if ("<root>".Equals(Parent.Name))
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
return Parent.FullName + '\\' + Name;
|
||||
}
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
public Filter() : this("<root>", null)
|
||||
{
|
||||
}
|
||||
|
||||
int GetStringHash(string value)
|
||||
{
|
||||
// return name.GetHashCode(); // Hash might change between .NET versions
|
||||
|
||||
int hash = 0x5d5d5d5d;
|
||||
char[] chars = value.ToCharArray();
|
||||
foreach (var c in chars)
|
||||
{
|
||||
hash += c;
|
||||
hash -= c << 16;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
public Filter(string name, string guid, string extensions = null)
|
||||
{
|
||||
Name = name;
|
||||
SubFilters = new List<Filter>();
|
||||
Files = new List<string>();
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
{
|
||||
//System.Guid newGuid = System.Guid.NewGuid();
|
||||
//Guid = newGuid.ToString();
|
||||
|
||||
// GUIDs should stay the same, so use filter name as seed instead
|
||||
Random random = new Random(GetStringHash(name));
|
||||
var guidBuilder = new StringBuilder();
|
||||
guidBuilder.Append(random.Next(0xFFFF).ToString("X4"));
|
||||
guidBuilder.Append(random.Next(0xFFFF).ToString("X4"));
|
||||
guidBuilder.Append('-');
|
||||
guidBuilder.Append(random.Next(0xFFFF).ToString("X4"));
|
||||
guidBuilder.Append('-');
|
||||
guidBuilder.Append(random.Next(0xFFFF).ToString("X4"));
|
||||
guidBuilder.Append('-');
|
||||
guidBuilder.Append(random.Next(0xFFFF).ToString("X4"));
|
||||
guidBuilder.Append('-');
|
||||
guidBuilder.Append(random.Next(0xFFFF).ToString("X4"));
|
||||
guidBuilder.Append(random.Next(0xFFFF).ToString("X4"));
|
||||
guidBuilder.Append(random.Next(0xFFFF).ToString("X4"));
|
||||
Guid = guidBuilder.ToString().ToLower();
|
||||
}
|
||||
else
|
||||
{
|
||||
Guid = guid;
|
||||
}
|
||||
Extensions = extensions;
|
||||
}
|
||||
|
||||
public void Add(Filter filter)
|
||||
{
|
||||
SubFilters.Add(filter);
|
||||
filter.Parent = this;
|
||||
}
|
||||
|
||||
public void AddFile(string path, string managedFilename)
|
||||
{
|
||||
int rootFolderIndex = path.IndexOf('/');
|
||||
if (rootFolderIndex == -1)
|
||||
{
|
||||
Files.Add(managedFilename);
|
||||
return;
|
||||
}
|
||||
string rootFolder = path.Substring(0, rootFolderIndex);
|
||||
if (rootFolder.Equals(".."))
|
||||
{
|
||||
AddFile(path.Substring(rootFolderIndex + 1), managedFilename);
|
||||
return;
|
||||
}
|
||||
Filter subFilter = GetChild(rootFolder);
|
||||
if (subFilter == null)
|
||||
{
|
||||
subFilter = new Filter(rootFolder, null);
|
||||
Add(subFilter);
|
||||
}
|
||||
subFilter.AddFile(path.Substring(rootFolderIndex + 1), managedFilename);
|
||||
}
|
||||
|
||||
public Filter GetChild(string index)
|
||||
{
|
||||
foreach (var filter in SubFilters)
|
||||
{
|
||||
if (filter.Name.Equals(index))
|
||||
{
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Filter GetFilter(string filename)
|
||||
{
|
||||
foreach (var file in Files)
|
||||
{
|
||||
if (file.Equals(filename))
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
foreach (var filter in SubFilters)
|
||||
{
|
||||
var result = filter.GetFilter(filename);
|
||||
if (result != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
void GetFileListRecursive(List<string> list)
|
||||
{
|
||||
foreach (string name in Files)
|
||||
{
|
||||
list.Add(name);
|
||||
}
|
||||
foreach (var filter in SubFilters)
|
||||
{
|
||||
filter.GetFileListRecursive(list);
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> GetFileList(bool sorted = false)
|
||||
{
|
||||
var list = new List<string>();
|
||||
GetFileListRecursive(list);
|
||||
if (sorted)
|
||||
{
|
||||
list.Sort();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void Sort()
|
||||
{
|
||||
Files.Sort();
|
||||
SubFilters.Sort();
|
||||
}
|
||||
|
||||
public int CompareTo(Filter other)
|
||||
{
|
||||
return Name.CompareTo(other.Name);
|
||||
}
|
||||
}
|
||||
|
||||
class FilterWriter
|
||||
{
|
||||
public Filter RootFilter { get; private set; }
|
||||
|
||||
FilterType filterType = FilterType.Structured;
|
||||
string namespaceName;
|
||||
StreamWriter filterWriter;
|
||||
|
||||
public FilterWriter(string namespaceName)
|
||||
{
|
||||
this.namespaceName = namespaceName;
|
||||
RootFilter = new Filter();
|
||||
}
|
||||
|
||||
void Write(string value)
|
||||
{
|
||||
filterWriter.Write(value);
|
||||
}
|
||||
|
||||
void WriteLine(string value)
|
||||
{
|
||||
filterWriter.WriteLine(value);
|
||||
}
|
||||
|
||||
void OutputTabs(int n)
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
filterWriter.Write("\t");
|
||||
}
|
||||
}
|
||||
|
||||
void OutputFilter(Filter filter)
|
||||
{
|
||||
Write(" <Filter Include=\"");
|
||||
Write(filter.FullName);
|
||||
WriteLine("\">");
|
||||
Write(" <UniqueIdentifier>{");
|
||||
Write(filter.Guid);
|
||||
WriteLine("}</UniqueIdentifier>");
|
||||
if (!string.IsNullOrEmpty(filter.Extensions))
|
||||
{
|
||||
Write(" <Extensions>");
|
||||
Write(filter.Extensions);
|
||||
WriteLine("</Extensions>");
|
||||
}
|
||||
WriteLine(" </Filter>");
|
||||
foreach (var subFilter in filter.SubFilters)
|
||||
{
|
||||
OutputFilter(subFilter);
|
||||
}
|
||||
}
|
||||
|
||||
void OutputFilter2008(Filter filter, int level, string extension, IList<ProjectConfiguration> confs = null)
|
||||
{
|
||||
OutputTabs(level);
|
||||
WriteLine("<Filter");
|
||||
OutputTabs(level + 1);
|
||||
Write("Name=\"");
|
||||
Write(filter.Name);
|
||||
WriteLine("\"");
|
||||
if (!string.IsNullOrEmpty(filter.Extensions))
|
||||
{
|
||||
OutputTabs(level + 1);
|
||||
Write("Filter=\"");
|
||||
Write(filter.Extensions);
|
||||
WriteLine("\"");
|
||||
}
|
||||
OutputTabs(level + 1);
|
||||
WriteLine(">");
|
||||
foreach (string filename in filter.Files.OrderBy(f => f))
|
||||
{
|
||||
OutputTabs(level + 1);
|
||||
WriteLine("<File");
|
||||
OutputTabs(level + 2);
|
||||
Write("RelativePath=\"");
|
||||
Write(filename);
|
||||
Write(extension);
|
||||
WriteLine("\"");
|
||||
OutputTabs(level + 2);
|
||||
WriteLine(">");
|
||||
if (filename.EndsWith("Stdafx", StringComparison.InvariantCultureIgnoreCase) &&
|
||||
".cpp".Equals(extension, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
foreach (var conf in confs)
|
||||
{
|
||||
OutputTabs(level + 2);
|
||||
WriteLine("<FileConfiguration");
|
||||
OutputTabs(level + 3);
|
||||
Write("Name=\"");
|
||||
Write(conf.IsDebug ? "Debug " : "Release ");
|
||||
Write(conf.Name);
|
||||
WriteLine("|Win32\"");
|
||||
OutputTabs(level + 3);
|
||||
WriteLine(">");
|
||||
OutputTabs(level + 3);
|
||||
WriteLine("<Tool");
|
||||
OutputTabs(level + 4);
|
||||
WriteLine("Name=\"VCCLCompilerTool\"");
|
||||
OutputTabs(level + 4);
|
||||
WriteLine("UsePrecompiledHeader=\"1\"");
|
||||
OutputTabs(level + 3);
|
||||
WriteLine("/>");
|
||||
OutputTabs(level + 2);
|
||||
WriteLine("</FileConfiguration>");
|
||||
}
|
||||
}
|
||||
OutputTabs(level + 1);
|
||||
WriteLine("</File>");
|
||||
}
|
||||
foreach (var subFilter in filter.SubFilters)
|
||||
{
|
||||
OutputFilter2008(subFilter, level + 1, extension, confs);
|
||||
}
|
||||
OutputTabs(level);
|
||||
WriteLine("</Filter>");
|
||||
}
|
||||
|
||||
void OutputFiles(Filter root, string action, string extension)
|
||||
{
|
||||
WriteLine(" <ItemGroup>");
|
||||
foreach (var filename in root.GetFileList(true))
|
||||
{
|
||||
Write(" <");
|
||||
Write(action);
|
||||
Write(" Include=\"");
|
||||
Write(filename);
|
||||
Write(extension);
|
||||
WriteLine("\">");
|
||||
Write(" <Filter>");
|
||||
Write(root.GetFilter(filename).FullName);
|
||||
WriteLine("</Filter>");
|
||||
Write(" </");
|
||||
Write(action);
|
||||
WriteLine(">");
|
||||
}
|
||||
WriteLine(" </ItemGroup>");
|
||||
}
|
||||
|
||||
public void Output(TargetVS targetVS, string outDirectory)
|
||||
{
|
||||
string filterFilename = namespaceName + ".vcxproj.filters";
|
||||
var filterFile = new FileStream(outDirectory + "\\" + filterFilename, FileMode.Create, FileAccess.Write);
|
||||
filterWriter = new StreamWriter(filterFile, Encoding.UTF8);
|
||||
|
||||
WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||
WriteLine("<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">");
|
||||
|
||||
WriteLine(" <ItemGroup>");
|
||||
foreach (var filter in RootFilter.SubFilters)
|
||||
{
|
||||
OutputFilter(filter);
|
||||
}
|
||||
WriteLine(" </ItemGroup>");
|
||||
|
||||
OutputFiles(RootFilter.GetChild("Source Files"), "ClCompile", ".cpp");
|
||||
OutputFiles(RootFilter.GetChild("Resource Files"), "ResourceCompile", "");
|
||||
OutputFiles(RootFilter.GetChild("Header Files"), "ClInclude", ".h");
|
||||
|
||||
Write("</Project>");
|
||||
|
||||
filterWriter.Dispose();
|
||||
filterFile.Dispose();
|
||||
}
|
||||
|
||||
public void Output2008(StreamWriter projectWriter, IList<ProjectConfiguration> confs, string outDirectory)
|
||||
{
|
||||
filterWriter = projectWriter;
|
||||
|
||||
WriteLine("\t<Files>");
|
||||
OutputFilter2008(RootFilter.GetChild("Source Files"), 2, ".cpp", confs);
|
||||
OutputFilter2008(RootFilter.GetChild("Header Files"), 2, ".h");
|
||||
OutputFilter2008(RootFilter.GetChild("Resource Files"), 2, "");
|
||||
WriteLine("\t</Files>");
|
||||
}
|
||||
|
||||
public void Output2008_2(StreamWriter projectWriter, IList<ProjectConfiguration> confs, string outDirectory)
|
||||
{
|
||||
filterWriter = projectWriter;
|
||||
|
||||
WriteLine("\t<Files>");
|
||||
|
||||
WriteLine("\t\t<Filter");
|
||||
WriteLine("\t\t\tName=\"Source Files\"");
|
||||
WriteLine("\t\t\tFilter=\"cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx\"");
|
||||
WriteLine("\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\"");
|
||||
WriteLine("\t\t\t>");
|
||||
var sourceFiles = RootFilter.GetChild("Source Files").GetFileList();
|
||||
foreach (var sourceFile in sourceFiles)
|
||||
{
|
||||
WriteLine("\t\t\t<File");
|
||||
Write("\t\t\t\tRelativePath=\"");
|
||||
Write(sourceFile);
|
||||
WriteLine(".cpp\"");
|
||||
WriteLine("\t\t\t\t>");
|
||||
if (sourceFile.EndsWith("Stdafx", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
foreach (var conf in confs)
|
||||
{
|
||||
WriteLine("\t\t\t\t<FileConfiguration");
|
||||
Write("\t\t\t\t\tName=\"");
|
||||
Write(conf.IsDebug ? "Debug " : "Release ");
|
||||
Write(conf.Name);
|
||||
WriteLine("|Win32\"");
|
||||
WriteLine("\t\t\t\t\t>");
|
||||
WriteLine("\t\t\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\t\t\tName=\"VCCLCompilerTool\"");
|
||||
WriteLine("\t\t\t\t\t\tUsePrecompiledHeader=\"1\"");
|
||||
WriteLine("\t\t\t\t\t/>");
|
||||
WriteLine("\t\t\t\t</FileConfiguration>");
|
||||
}
|
||||
}
|
||||
WriteLine("\t\t\t</File>");
|
||||
}
|
||||
WriteLine("\t\t</Filter>");
|
||||
|
||||
WriteLine("\t\t<Filter");
|
||||
WriteLine("\t\t\tName=\"Header Files\"");
|
||||
WriteLine("\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"");
|
||||
WriteLine("\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\"");
|
||||
WriteLine("\t\t\t>");
|
||||
var headerFiles = RootFilter.GetChild("Header Files").GetFileList();
|
||||
foreach (var headerFile in headerFiles)
|
||||
{
|
||||
WriteLine("\t\t\t<File");
|
||||
Write("\t\t\t\tRelativePath=\"");
|
||||
Write(headerFile);
|
||||
WriteLine(".h\"");
|
||||
WriteLine("\t\t\t\t>");
|
||||
WriteLine("\t\t\t</File>");
|
||||
}
|
||||
WriteLine("\t\t</Filter>");
|
||||
|
||||
WriteLine("\t</Files>");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
class HeaderDefinition
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Filename { get; set; }
|
||||
public List<ClassDefinition> Classes { get; set; }
|
||||
public List<HeaderDefinition> Includes { get; set; }
|
||||
public List<EnumDefinition> Enums { get; set; }
|
||||
|
||||
string _managedName;
|
||||
public string ManagedName
|
||||
{
|
||||
get { return _managedName ?? Name; }
|
||||
set { _managedName = value; }
|
||||
}
|
||||
|
||||
public IEnumerable<ClassDefinition> AllSubClasses
|
||||
{
|
||||
get
|
||||
{
|
||||
List<ClassDefinition> subClasses = new List<ClassDefinition>();
|
||||
foreach (ClassDefinition cl in Classes)
|
||||
{
|
||||
subClasses.AddRange(cl.AllSubClasses);
|
||||
subClasses.Add(cl);
|
||||
}
|
||||
return subClasses;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExcluded
|
||||
{
|
||||
get { return Classes.All(x => x.IsExcluded); }
|
||||
}
|
||||
|
||||
public HeaderDefinition(string filename)
|
||||
{
|
||||
Name = Path.GetFileNameWithoutExtension(filename);
|
||||
Filename = filename;
|
||||
Classes = new List<ClassDefinition>();
|
||||
Includes = new List<HeaderDefinition>();
|
||||
Enums = new List<EnumDefinition>();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
namespace BulletSharpGen
|
||||
{
|
||||
class MethodDefinition
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public string ManagedName { get; set; }
|
||||
public ClassDefinition Parent { get; private set; }
|
||||
public TypeRefDefinition ReturnType { get; set; }
|
||||
public ParameterDefinition[] Parameters { get; set; }
|
||||
public bool IsStatic { get; set; }
|
||||
public bool IsAbstract { get; set; }
|
||||
public bool IsConstructor { get; set; }
|
||||
public bool IsVirtual { get; set; }
|
||||
public FieldDefinition Field { get; set; } // get/set method target
|
||||
public PropertyDefinition Property { get; set; } // property that wraps this get/set method
|
||||
|
||||
public bool IsVoid
|
||||
{
|
||||
get { return ReturnType != null && ReturnType.IsBasic && ReturnType.Name.Equals("void"); }
|
||||
}
|
||||
|
||||
public int NumOptionalParameters
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = Parameters.Length - 1; i >= 0; i--)
|
||||
{
|
||||
if (!Parameters[i].IsOptional)
|
||||
{
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public MethodDefinition(string name, ClassDefinition parent, int numArgs)
|
||||
{
|
||||
Name = name;
|
||||
Parent = parent;
|
||||
Parameters = new ParameterDefinition[numArgs];
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
parent.Methods.Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
public MethodDefinition Copy()
|
||||
{
|
||||
var m = new MethodDefinition(Name, Parent, Parameters.Length);
|
||||
for (int i = 0; i < Parameters.Length; i++)
|
||||
{
|
||||
m.Parameters[i] = Parameters[i].Copy();
|
||||
}
|
||||
Parameters.CopyTo(m.Parameters, 0);
|
||||
m.Field = Field;
|
||||
m.Property = Property;
|
||||
m.IsAbstract = IsAbstract;
|
||||
m.IsConstructor = IsConstructor;
|
||||
m.ManagedName = ManagedName;
|
||||
m.IsStatic = IsStatic;
|
||||
m.ReturnType = ReturnType;
|
||||
return m;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var m = obj as MethodDefinition;
|
||||
if ((System.Object)m == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m.Name.Equals(Name) || m.Parameters.Length != Parameters.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m.ReturnType.Equals(ReturnType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Parameters.Length; i++)
|
||||
{
|
||||
// Parameter names can vary, but types must match
|
||||
if (!m.Parameters[i].Type.Equals(Parameters[i].Type))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return m.IsStatic == IsStatic;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
Двоичный файл не отображается.
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,29 @@
|
|||
namespace BulletSharpGen
|
||||
{
|
||||
class ParameterDefinition
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public TypeRefDefinition Type { get; private set; }
|
||||
public bool IsOptional { get; set; }
|
||||
public string ManagedName { get; set; }
|
||||
|
||||
public ParameterDefinition(string name, TypeRefDefinition type, bool isOptional = false)
|
||||
{
|
||||
Name = name;
|
||||
Type = type;
|
||||
IsOptional = isOptional;
|
||||
}
|
||||
|
||||
internal ParameterDefinition Copy()
|
||||
{
|
||||
ParameterDefinition p = new ParameterDefinition(Name, Type, IsOptional);
|
||||
p.ManagedName = ManagedName;
|
||||
return p;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Type.ToString() + ' ' + Name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,226 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
class Program
|
||||
{
|
||||
const string NamespaceName = "BulletSharp";
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// If true, outputs C++/CLI wrapper,
|
||||
// if false, outputs C wrapper with C# code.
|
||||
bool cppCliMode = false;
|
||||
|
||||
//var subset = new AssemblySubset();
|
||||
//subset.LoadAssembly("..\\..\\..\\bulletsharp\\demos\\Generic\\bin\\Release\\BasicDemo.exe", "BulletSharp");
|
||||
//subset.LoadAssembly("..\\..\\..\\bulletsharp\\demos\\Generic\\bin\\Release\\DemoFramework.dll", "BulletSharp");
|
||||
|
||||
string sourceFolder = "D:\\src\\bullet3\\src\\";
|
||||
//sourceFolder = "..\\..\\..\\bullet\\src\\";
|
||||
|
||||
if (!Directory.Exists(sourceFolder))
|
||||
{
|
||||
Console.WriteLine("Source folder \"" + sourceFolder + "\" not found");
|
||||
Console.Write("Press any key to continue...");
|
||||
Console.ReadKey();
|
||||
return;
|
||||
}
|
||||
|
||||
var reader = new CppReader(sourceFolder);
|
||||
var parser = new BulletParser(reader.ClassDefinitions, reader.HeaderDefinitions);
|
||||
var externalHeaders = parser.ExternalHeaders.Values;
|
||||
if (cppCliMode)
|
||||
{
|
||||
var writer = new CppCliWriter(externalHeaders, NamespaceName);
|
||||
writer.Output();
|
||||
}
|
||||
else
|
||||
{
|
||||
var writer = new PInvokeWriter(externalHeaders, NamespaceName);
|
||||
writer.Output();
|
||||
|
||||
var extensionWriter = new ExtensionsWriter(externalHeaders, NamespaceName);
|
||||
extensionWriter.Output();
|
||||
}
|
||||
|
||||
|
||||
OutputSolution(TargetVS.VS2008, externalHeaders);
|
||||
OutputSolution(TargetVS.VS2010, externalHeaders);
|
||||
OutputSolution(TargetVS.VS2012, externalHeaders);
|
||||
OutputSolution(TargetVS.VS2013, externalHeaders);
|
||||
|
||||
CMakeWriter cmake = new CMakeWriter(parser.ExternalHeaders, NamespaceName);
|
||||
cmake.Output();
|
||||
|
||||
Console.Write("Press any key to continue...");
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
static void OutputSolution(TargetVS targetVS, IEnumerable<HeaderDefinition> headerDefinitions)
|
||||
{
|
||||
string targetVersionString;
|
||||
switch (targetVS)
|
||||
{
|
||||
case TargetVS.VS2008:
|
||||
targetVersionString = "2008";
|
||||
break;
|
||||
case TargetVS.VS2010:
|
||||
targetVersionString = "2010";
|
||||
break;
|
||||
case TargetVS.VS2012:
|
||||
targetVersionString = "2012";
|
||||
break;
|
||||
case TargetVS.VS2013:
|
||||
targetVersionString = "2013";
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
string slnRelDir = (targetVS == TargetVS.VS2010) ? "" : "..\\";
|
||||
string rootFolder = slnRelDir + "src\\";
|
||||
|
||||
List<ProjectConfiguration> confs = new List<ProjectConfiguration>();
|
||||
confs.Add(new ProjectConfiguration("Axiom", true, "GRAPHICS_AXIOM", slnRelDir + "..\\Axiom-SDK-0.8.3376.12322\\bin\\Net35"));
|
||||
confs.Add(new ProjectConfiguration("Axiom", false, "GRAPHICS_AXIOM", slnRelDir + "..\\Axiom-SDK-0.8.3376.12322\\bin\\Net35"));
|
||||
confs.Add(new ProjectConfiguration("Generic", true, "GRAPHICS_GENERIC"));
|
||||
confs.Add(new ProjectConfiguration("Generic", false, "GRAPHICS_GENERIC"));
|
||||
confs.Add(new ProjectConfiguration("Mogre", true, "GRAPHICS_MOGRE", "C:\\MogreSDK\\bin\\Debug"));
|
||||
confs.Add(new ProjectConfiguration("Mogre", false, "GRAPHICS_MOGRE", "C:\\MogreSDK\\bin\\Release"));
|
||||
if (targetVS != TargetVS.VS2008)
|
||||
{
|
||||
confs.Add(new ProjectConfiguration("MonoGame", true, "GRAPHICS_MONOGAME", "$(ProgramFiles)\\MonoGame\\v3.0\\Assemblies\\WindowsGL\\;$(ProgramFiles(x86))\\MonoGame\\v3.0\\Assemblies\\WindowsGL\\"));
|
||||
confs.Add(new ProjectConfiguration("MonoGame", false, "GRAPHICS_MONOGAME", "$(ProgramFiles)\\MonoGame\\v3.0\\Assemblies\\WindowsGL\\;$(ProgramFiles(x86))\\MonoGame\\v3.0\\Assemblies\\WindowsGL\\"));
|
||||
}
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
confs.Add(new ProjectConfiguration("OpenTK", true, "GRAPHICS_OPENTK", "$(USERPROFILE)\\My Documents\\OpenTK\\1.1\\Binaries\\OpenTK\\Release"));
|
||||
confs.Add(new ProjectConfiguration("OpenTK", false, "GRAPHICS_OPENTK", "$(USERPROFILE)\\My Documents\\OpenTK\\1.1\\Binaries\\OpenTK\\Release"));
|
||||
confs.Add(new ProjectConfiguration("SharpDX", true, "GRAPHICS_SHARPDX", slnRelDir + "..\\SharpDX\\Bin\\DirectX11-net20"));
|
||||
confs.Add(new ProjectConfiguration("SharpDX", false, "GRAPHICS_SHARPDX", slnRelDir + "..\\SharpDX\\Bin\\DirectX11-net20"));
|
||||
confs.Add(new ProjectConfiguration("SlimDX", true, "GRAPHICS_SLIMDX", "$(PROGRAMFILES)\\SlimDX SDK (January 2012)\\Bin\\net20\\;$(PROGRAMFILES(x86))\\SlimDX SDK (June 2010)\\Bin\\net20\\"));
|
||||
confs.Add(new ProjectConfiguration("SlimDX", false, "GRAPHICS_SLIMDX", "$(PROGRAMFILES)\\SlimDX SDK (January 2012)\\Bin\\net20\\;$(PROGRAMFILES(x86))\\SlimDX SDK (June 2010)\\Bin\\net20\\"));
|
||||
}
|
||||
else
|
||||
{
|
||||
confs.Add(new ProjectConfiguration("OpenTK", true, "GRAPHICS_OPENTK")
|
||||
{
|
||||
ConditionalRef = "OpenTK",
|
||||
ConditionalRefAssembly = "OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4"
|
||||
});
|
||||
confs.Add(new ProjectConfiguration("OpenTK", false, "GRAPHICS_OPENTK")
|
||||
{
|
||||
ConditionalRef = "OpenTK",
|
||||
ConditionalRefAssembly = "OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4"
|
||||
});
|
||||
confs.Add(new ProjectConfiguration("SharpDX", true, "GRAPHICS_SHARPDX", slnRelDir + "..\\SharpDX\\Bin\\DirectX11-net40"));
|
||||
confs.Add(new ProjectConfiguration("SharpDX", false, "GRAPHICS_SHARPDX", slnRelDir + "..\\SharpDX\\Bin\\DirectX11-net40"));
|
||||
confs.Add(new ProjectConfiguration("SlimDX", true, "GRAPHICS_SLIMDX", "$(PROGRAMFILES)\\SlimDX SDK (January 2012)\\Bin\\net40\\;$(PROGRAMFILES(x86))\\SlimDX SDK (June 2010)\\Bin\\net40\\"));
|
||||
confs.Add(new ProjectConfiguration("SlimDX", false, "GRAPHICS_SLIMDX", "$(PROGRAMFILES)\\SlimDX SDK (January 2012)\\Bin\\net40\\;$(PROGRAMFILES(x86))\\SlimDX SDK (June 2010)\\Bin\\net40\\"));
|
||||
}
|
||||
//confs.Add(new ProjectConfiguration("SlimMath", true, "GRAPHICS_SLIMMATH", slnRelDir + "..\\SlimMath\\SlimMath\\bin\\Release"));
|
||||
//confs.Add(new ProjectConfiguration("SlimMath", false, "GRAPHICS_SLIMMATH", slnRelDir + "..\\SlimMath\\SlimMath\\bin\\Debug"));
|
||||
if (targetVS != TargetVS.VS2008)
|
||||
{
|
||||
confs.Add(new ProjectConfiguration("Windows API Code Pack", true, "GRAPHICS_WAPICODEPACK", slnRelDir + "..\\Windows API Code Pack 1.1\\binaries\\DirectX"));
|
||||
confs.Add(new ProjectConfiguration("Windows API Code Pack", false, "GRAPHICS_WAPICODEPACK", slnRelDir + "..\\Windows API Code Pack 1.1\\binaries\\DirectX"));
|
||||
}
|
||||
confs.Add(new ProjectConfiguration("XNA 3.1", true, "GRAPHICS_XNA31", "$(ProgramFiles)\\Microsoft XNA\\XNA Game Studio\\v3.1\\References\\Windows\\x86\\;$(ProgramFiles(x86))\\Microsoft XNA\\XNA Game Studio\\v3.1\\References\\Windows\\x86\\"));
|
||||
confs.Add(new ProjectConfiguration("XNA 3.1", false, "GRAPHICS_XNA31", "$(ProgramFiles)\\Microsoft XNA\\XNA Game Studio\\v3.1\\References\\Windows\\x86\\;$(ProgramFiles(x86))\\Microsoft XNA\\XNA Game Studio\\v3.1\\References\\Windows\\x86\\"));
|
||||
if (targetVS != TargetVS.VS2008)
|
||||
{
|
||||
confs.Add(new ProjectConfiguration("XNA 4.0", true, "GRAPHICS_XNA40", "$(ProgramFiles)\\Microsoft XNA\\XNA Game Studio\\v4.0\\References\\Windows\\x86\\;$(ProgramFiles(x86))\\Microsoft XNA\\XNA Game Studio\\v4.0\\References\\Windows\\x86\\"));
|
||||
confs.Add(new ProjectConfiguration("XNA 4.0", false, "GRAPHICS_XNA40", "$(ProgramFiles)\\Microsoft XNA\\XNA Game Studio\\v4.0\\References\\Windows\\x86\\;$(ProgramFiles(x86))\\Microsoft XNA\\XNA Game Studio\\v4.0\\References\\Windows\\x86\\"));
|
||||
}
|
||||
|
||||
var filterWriter = new FilterWriter(NamespaceName);
|
||||
var sourceFilter = new Filter("Source Files", "4FC737F1-C7A5-4376-A066-2A32D752A2FF", "cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx");
|
||||
var headerFilter = new Filter("Header Files", "93995380-89BD-4b04-88EB-625FBE52EBFB", "h;hh;hpp;hxx;hm;inl;inc;xsd");
|
||||
var resourceFilter = new Filter("Resource Files", "67DA6AB6-F800-4c08-8B7A-83BB121AAD01", "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms");
|
||||
filterWriter.RootFilter.Add(sourceFilter);
|
||||
filterWriter.RootFilter.Add(headerFilter);
|
||||
filterWriter.RootFilter.Add(resourceFilter);
|
||||
|
||||
sourceFilter.AddFile("", rootFolder + "Stdafx");
|
||||
sourceFilter.AddFile("", rootFolder + "AssemblyInfo");
|
||||
sourceFilter.AddFile("", rootFolder + "Collections");
|
||||
sourceFilter.AddFile("", rootFolder + "Math");
|
||||
sourceFilter.AddFile("", rootFolder + "StringConv");
|
||||
sourceFilter.AddFile("", rootFolder + "DataStream");
|
||||
sourceFilter.AddFile("", rootFolder + "Matrix");
|
||||
sourceFilter.AddFile("", rootFolder + "Quaternion");
|
||||
sourceFilter.AddFile("", rootFolder + "Utilities");
|
||||
sourceFilter.AddFile("", rootFolder + "Vector3");
|
||||
sourceFilter.AddFile("", rootFolder + "Vector4");
|
||||
|
||||
headerFilter.AddFile("", rootFolder + "Stdafx");
|
||||
headerFilter.AddFile("", rootFolder + "Collections");
|
||||
headerFilter.AddFile("", rootFolder + "Enums");
|
||||
headerFilter.AddFile("", rootFolder + "ITrackingDisposable");
|
||||
headerFilter.AddFile("", rootFolder + "Math");
|
||||
headerFilter.AddFile("", rootFolder + "StringConv");
|
||||
headerFilter.AddFile("", rootFolder + "Version");
|
||||
headerFilter.AddFile("", rootFolder + "DataStream");
|
||||
headerFilter.AddFile("", rootFolder + "Matrix");
|
||||
headerFilter.AddFile("", rootFolder + "Quaternion");
|
||||
headerFilter.AddFile("", rootFolder + "Utilities");
|
||||
headerFilter.AddFile("", rootFolder + "Vector3");
|
||||
headerFilter.AddFile("", rootFolder + "Vector4");
|
||||
|
||||
foreach (HeaderDefinition header in headerDefinitions)
|
||||
{
|
||||
if (header.Classes.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sourceFilter.AddFile(header.Filename, rootFolder + header.ManagedName);
|
||||
headerFilter.AddFile(header.Filename, rootFolder + header.ManagedName);
|
||||
}
|
||||
|
||||
sourceFilter.AddFile("BulletCollision/CollisionDispatch/", rootFolder + "InternalEdgeUtility");
|
||||
sourceFilter.AddFile("BulletCollision/CollisionShapes/", rootFolder + "BulletMaterial");
|
||||
sourceFilter.AddFile("BulletCollision/NarrowPhaseCollision/", rootFolder + "SimplexSolverInterface");
|
||||
sourceFilter.AddFile("LinearMath/", rootFolder + "DebugDraw");
|
||||
sourceFilter.AddFile("MultiThreaded/GpuSoftBodySolvers/OpenCL/", rootFolder + "SoftBodySolverOpenCL");
|
||||
sourceFilter.AddFile("OpenCL/", rootFolder + "OpenCL");
|
||||
sourceFilter.AddFile("SoftBody/", rootFolder + "SoftBodySolver");
|
||||
headerFilter.AddFile("BulletCollision/CollisionDispatch/", rootFolder + "InternalEdgeUtility");
|
||||
headerFilter.AddFile("BulletCollision/CollisionShapes/", rootFolder + "BulletMaterial");
|
||||
headerFilter.AddFile("BulletCollision/NarrowPhaseCollision/", rootFolder + "SimplexSolverInterface");
|
||||
headerFilter.AddFile("LinearMath/", rootFolder + "DebugDraw");
|
||||
headerFilter.AddFile("BulletDynamics/Character/", rootFolder + "ICharacterController");
|
||||
headerFilter.AddFile("LinearMath/", rootFolder + "IDebugDraw");
|
||||
headerFilter.AddFile("MultiThreaded/GpuSoftBodySolvers/OpenCL/", rootFolder + "SoftBodySolverOpenCL");
|
||||
headerFilter.AddFile("OpenCL/", rootFolder + "OpenCL");
|
||||
headerFilter.AddFile("SoftBody/", rootFolder + "SoftBodySolver");
|
||||
|
||||
resourceFilter.AddFile("", rootFolder + "Resources.rc");
|
||||
|
||||
filterWriter.RootFilter.Sort();
|
||||
|
||||
string bulletRoot = "..\\bullet3";
|
||||
|
||||
var slnWriter = new SlnWriter(filterWriter, NamespaceName)
|
||||
{
|
||||
IncludeDirectories = string.Format("{0}\\src;{0}\\Extras\\HACD;{0}\\Extras\\Serialize\\BulletWorldImporter;$(CUDA_INC_PATH);$(AMDAPPSDKROOT)include;", slnRelDir + bulletRoot),
|
||||
FilterWriter = filterWriter
|
||||
};
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
slnWriter.LibraryDirectoriesRelease = slnRelDir + bulletRoot + "\\msvc\\2008\\lib\\MinSizeRel";
|
||||
slnWriter.LibraryDirectoriesDebug = slnRelDir + bulletRoot + "\\msvc\\2008\\lib\\Debug";
|
||||
}
|
||||
else
|
||||
{
|
||||
slnWriter.LibraryDirectoriesRelease = slnRelDir + bulletRoot + "\\msvc\\" + targetVersionString + "\\lib\\MinSizeRel;$(AMDAPPSDKROOT)lib\\x86\\;$(CUDA_LIB_PATH);";
|
||||
slnWriter.LibraryDirectoriesDebug = slnRelDir + bulletRoot + "\\msvc\\" + targetVersionString + "\\lib\\Debug;$(AMDAPPSDKROOT)lib\\x86\\;$(CUDA_LIB_PATH);";
|
||||
}
|
||||
slnWriter.Output(targetVS, confs, "sln" + targetVersionString);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
namespace BulletSharpGen
|
||||
{
|
||||
class ProjectConfiguration
|
||||
{
|
||||
public ProjectConfiguration(string name, bool isDebug, string definitions, string usingDirectories = null)
|
||||
{
|
||||
Name = name;
|
||||
IsDebug = isDebug;
|
||||
Definitions = definitions;
|
||||
UsingDirectories = usingDirectories;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public bool IsDebug { get; set; }
|
||||
public string Definitions { get; set; }
|
||||
public string UsingDirectories { get; set; }
|
||||
public string ConditionalRef { get; set; }
|
||||
public string ConditionalRefAssembly { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
class PropertyDefinition
|
||||
{
|
||||
public MethodDefinition Getter { get; private set; }
|
||||
public MethodDefinition Setter { get; set; }
|
||||
public ClassDefinition Parent { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
|
||||
public TypeRefDefinition Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return Getter.ReturnType;
|
||||
}
|
||||
}
|
||||
|
||||
// Property from getter method
|
||||
public PropertyDefinition(MethodDefinition getter)
|
||||
{
|
||||
Getter = getter;
|
||||
Parent = getter.Parent;
|
||||
Parent.Properties.Add(this);
|
||||
getter.Property = this;
|
||||
|
||||
string name = getter.Name;
|
||||
|
||||
// one_two_three -> oneTwoThree
|
||||
while (name.Contains("_"))
|
||||
{
|
||||
int pos = name.IndexOf('_');
|
||||
name = name.Substring(0, pos) + name.Substring(pos + 1, 1).ToUpper() + name.Substring(pos + 2);
|
||||
}
|
||||
|
||||
if (name.StartsWith("get", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
Name = name.Substring(3);
|
||||
}
|
||||
else if (name.StartsWith("is", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
Name = name[0].ToString().ToUpper() + name.Substring(1);
|
||||
}
|
||||
else if (name.StartsWith("has", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
Name = name[0].ToString().ToUpper() + name.Substring(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,845 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
enum TargetVS
|
||||
{
|
||||
VS2008,
|
||||
VS2010,
|
||||
VS2012,
|
||||
VS2013
|
||||
}
|
||||
|
||||
class SlnWriter
|
||||
{
|
||||
FilterWriter filterWriter;
|
||||
string namespaceName;
|
||||
|
||||
StreamWriter solutionWriter, projectWriter;
|
||||
TargetVS targetVS;
|
||||
FilterType filterType = FilterType.Structured;
|
||||
|
||||
public string IncludeDirectories { get; set; }
|
||||
public string LibraryDirectoriesDebug { get; set; }
|
||||
public string LibraryDirectoriesRelease { get; set; }
|
||||
public bool X64 { get; set; }
|
||||
public FilterWriter FilterWriter { get; set; }
|
||||
|
||||
public SlnWriter(FilterWriter filterWriter, string namespaceName)
|
||||
{
|
||||
this.filterWriter = filterWriter;
|
||||
this.namespaceName = namespaceName;
|
||||
|
||||
X64 = true;
|
||||
}
|
||||
|
||||
void Write(char value)
|
||||
{
|
||||
projectWriter.Write(value);
|
||||
}
|
||||
|
||||
void Write(string value)
|
||||
{
|
||||
projectWriter.Write(value);
|
||||
}
|
||||
|
||||
void WriteLine(string value)
|
||||
{
|
||||
projectWriter.WriteLine(value);
|
||||
}
|
||||
|
||||
void WriteLine()
|
||||
{
|
||||
projectWriter.WriteLine();
|
||||
}
|
||||
|
||||
void WriteSln(string value)
|
||||
{
|
||||
solutionWriter.Write(value);
|
||||
}
|
||||
|
||||
void WriteLineSln(string value)
|
||||
{
|
||||
solutionWriter.WriteLine(value);
|
||||
}
|
||||
|
||||
void WriteLineSln()
|
||||
{
|
||||
solutionWriter.WriteLine();
|
||||
}
|
||||
|
||||
void WriteProjectConfigurationNameSln(ProjectConfiguration conf)
|
||||
{
|
||||
WriteSln(conf.IsDebug ? "Debug " : "Release ");
|
||||
WriteSln(conf.Name);
|
||||
}
|
||||
|
||||
void WriteProjectConfigurationName(ProjectConfiguration conf)
|
||||
{
|
||||
Write(conf.IsDebug ? "Debug " : "Release ");
|
||||
Write(conf.Name);
|
||||
}
|
||||
|
||||
void OutputProjectConfiguration(ProjectConfiguration conf, bool x64)
|
||||
{
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
WriteLine("\t\t<Configuration");
|
||||
Write("\t\t\tName=\"");
|
||||
WriteProjectConfigurationName(conf);
|
||||
WriteLine(x64 ? "|x64\"" : "|Win32\"");
|
||||
WriteLine("\t\t\tOutputDirectory=\"$(SolutionDir)$(ConfigurationName)\"");
|
||||
WriteLine("\t\t\tIntermediateDirectory=\"$(ConfigurationName)\"");
|
||||
WriteLine("\t\t\tConfigurationType=\"2\"");
|
||||
WriteLine("\t\t\tCharacterSet=\"1\"");
|
||||
WriteLine("\t\t\tManagedExtensions=\"1\"");
|
||||
if (!conf.IsDebug)
|
||||
{
|
||||
WriteLine("\t\t\tWholeProgramOptimization=\"1\"");
|
||||
}
|
||||
WriteLine("\t\t\t>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCPreBuildEventTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCCustomBuildTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCXMLDataGeneratorTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCMIDLTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCCLCompilerTool\"");
|
||||
if (conf.IsDebug)
|
||||
{
|
||||
WriteLine("\t\t\t\tOptimization=\"0\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine("\t\t\t\tInlineFunctionExpansion=\"2\"");
|
||||
//WriteLine("\t\t\t\tFavorSizeOrSpeed=\"2\"");
|
||||
WriteLine("\t\t\t\tFavorSizeOrSpeed=\"1\"");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(IncludeDirectories))
|
||||
{
|
||||
Write("\t\t\t\tAdditionalIncludeDirectories=\"");
|
||||
Write(IncludeDirectories);
|
||||
WriteLine("\"");
|
||||
}
|
||||
Write("\t\t\t\tAdditionalUsingDirectories=\"");
|
||||
Write(conf.UsingDirectories);
|
||||
WriteLine("\"");
|
||||
Write("\t\t\t\tPreprocessorDefinitions=\"");
|
||||
Write(conf.Definitions);
|
||||
if (!string.IsNullOrEmpty(conf.Definitions) && !conf.Definitions.EndsWith(";"))
|
||||
{
|
||||
Write(';');
|
||||
}
|
||||
//if (!x64)
|
||||
{
|
||||
Write("WIN32;");
|
||||
}
|
||||
Write(conf.IsDebug ? "_DEBUG;" : "NDEBUG;");
|
||||
WriteLine("\"");
|
||||
if (conf.IsDebug)
|
||||
{
|
||||
WriteLine("\t\t\t\tRuntimeLibrary=\"3\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine("\t\t\t\tRuntimeLibrary=\"2\"");
|
||||
}
|
||||
WriteLine("\t\t\t\tFloatingPointModel=\"0\"");
|
||||
//WriteLine("\t\t\t\tEnableEnhancedInstructionSet=\"0\"");
|
||||
WriteLine("\t\t\t\tUsePrecompiledHeader=\"2\"");
|
||||
if (conf.IsDebug)
|
||||
{
|
||||
WriteLine("\t\t\t\tWarningLevel=\"3\"");
|
||||
WriteLine("\t\t\t\tDebugInformationFormat=\"3\"");
|
||||
WriteLine("\t\t\t\tDisableSpecificWarnings=\"4793\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine("\t\t\t\tWarningLevel=\"1\"");
|
||||
}
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCManagedResourceCompilerTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCResourceCompilerTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCPreLinkEventTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCLinkerTool\"");
|
||||
Write("\t\t\t\tAdditionalDependencies=\"");
|
||||
if (conf.IsDebug)
|
||||
{
|
||||
WriteLine("LinearMath_Debug.lib BulletCollision_Debug.lib BulletDynamics_Debug.lib\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine("LinearMath_MinSizeRel.lib BulletCollision_MinsizeRel.lib BulletDynamics_MinsizeRel.lib\"");
|
||||
}
|
||||
WriteLine("\t\t\t\tLinkIncremental=\"1\"");
|
||||
if (conf.IsDebug)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(LibraryDirectoriesDebug))
|
||||
{
|
||||
Write("\t\t\t\tAdditionalLibraryDirectories=\"");
|
||||
Write(LibraryDirectoriesDebug);
|
||||
WriteLine("\"");
|
||||
}
|
||||
WriteLine("\t\t\t\tGenerateDebugInformation=\"true\"");
|
||||
WriteLine("\t\t\t\tAssemblyDebug=\"1\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(LibraryDirectoriesRelease))
|
||||
{
|
||||
Write("\t\t\t\tAdditionalLibraryDirectories=\"");
|
||||
Write(LibraryDirectoriesRelease);
|
||||
WriteLine("\"");
|
||||
}
|
||||
WriteLine("\t\t\t\tGenerateDebugInformation=\"false\"");
|
||||
}
|
||||
WriteLine("\t\t\t\tTargetMachine=\"1\"");
|
||||
//WriteLine("\t\t\t\tCLRUnmanagedCodeCheck=\"true\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCALinkTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCManifestTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCXDCMakeTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCBscMakeTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCFxCopTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCAppVerifierTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t\t<Tool");
|
||||
WriteLine("\t\t\t\tName=\"VCPostBuildEventTool\"");
|
||||
WriteLine("\t\t\t/>");
|
||||
WriteLine("\t\t</Configuration>");
|
||||
}
|
||||
else
|
||||
{
|
||||
Write(" <ProjectConfiguration Include=\"");
|
||||
WriteProjectConfigurationName(conf);
|
||||
WriteLine(x64 ? "|x64\">" : "|Win32\">");
|
||||
Write(" <Configuration>");
|
||||
WriteProjectConfigurationName(conf);
|
||||
WriteLine("</Configuration>");
|
||||
Write(" <Platform>");
|
||||
Write(x64 ? "x64" : "Win32");
|
||||
WriteLine("</Platform>");
|
||||
WriteLine(" </ProjectConfiguration>");
|
||||
}
|
||||
}
|
||||
|
||||
void OutputPropertyGroupConfiguration(ProjectConfiguration conf, bool x64)
|
||||
{
|
||||
Write(" <PropertyGroup Condition=\"\'$(Configuration)|$(Platform)'=='");
|
||||
WriteProjectConfigurationName(conf);
|
||||
Write(x64 ? "|x64" : "|Win32");
|
||||
WriteLine("'\" Label=\"Configuration\">");
|
||||
WriteLine(" <ConfigurationType>DynamicLibrary</ConfigurationType>");
|
||||
WriteLine(" <CharacterSet>Unicode</CharacterSet>");
|
||||
WriteLine(" <CLRSupport>true</CLRSupport>");
|
||||
if (conf.IsDebug)
|
||||
{
|
||||
if (targetVS == TargetVS.VS2012 || targetVS == TargetVS.VS2013)
|
||||
{
|
||||
WriteLine(" <UseDebugLibraries>true</UseDebugLibraries>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" <WholeProgramOptimization>true</WholeProgramOptimization>");
|
||||
}
|
||||
if (targetVS == TargetVS.VS2012)
|
||||
{
|
||||
WriteLine(" <PlatformToolset>v110</PlatformToolset>");
|
||||
}
|
||||
else if (targetVS == TargetVS.VS2013)
|
||||
{
|
||||
WriteLine(" <PlatformToolset>v120</PlatformToolset>");
|
||||
}
|
||||
WriteLine(" </PropertyGroup>");
|
||||
}
|
||||
|
||||
void OutputImportGroupPropertySheets(ProjectConfiguration conf)
|
||||
{
|
||||
Write(" <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='");
|
||||
WriteProjectConfigurationName(conf);
|
||||
Write(X64 ? "|x64" : "|Win32");
|
||||
WriteLine("'\" Label=\"PropertySheets\">");
|
||||
WriteLine(" <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />");
|
||||
WriteLine(" </ImportGroup>");
|
||||
}
|
||||
|
||||
void OutputPropertyGroupConfiguration2(ProjectConfiguration conf, bool x64)
|
||||
{
|
||||
Write(" <OutDir Condition=\"'$(Configuration)|$(Platform)'=='");
|
||||
WriteProjectConfigurationName(conf);
|
||||
Write(x64 ? "|x64" : "|Win32");
|
||||
WriteLine("'\">$(SolutionDir)$(Configuration)\\</OutDir>");
|
||||
Write(" <IntDir Condition=\"'$(Configuration)|$(Platform)'=='");
|
||||
WriteProjectConfigurationName(conf);
|
||||
Write(x64 ? "|x64" : "|Win32");
|
||||
WriteLine("'\">$(Configuration)\\</IntDir>");
|
||||
Write(" <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='");
|
||||
WriteProjectConfigurationName(conf);
|
||||
Write(x64 ? "|x64" : "|Win32");
|
||||
WriteLine("'\">false</LinkIncremental>");
|
||||
}
|
||||
|
||||
void OutputItemDefinitionGroup(ProjectConfiguration conf, bool x64)
|
||||
{
|
||||
Write(" <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='");
|
||||
WriteProjectConfigurationName(conf);
|
||||
Write(x64 ? "|x64" : "|Win32");
|
||||
WriteLine("'\">");
|
||||
WriteLine(" <ClCompile>");
|
||||
if (conf.IsDebug)
|
||||
{
|
||||
WriteLine(" <Optimization>Disabled</Optimization>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>");
|
||||
WriteLine(" <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(IncludeDirectories))
|
||||
{
|
||||
Write(" <AdditionalIncludeDirectories>");
|
||||
Write(IncludeDirectories);
|
||||
WriteLine("%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>");
|
||||
}
|
||||
Write(" <AdditionalUsingDirectories>");
|
||||
Write(conf.UsingDirectories);
|
||||
if (!string.IsNullOrEmpty(conf.UsingDirectories) && !conf.UsingDirectories.EndsWith(";"))
|
||||
{
|
||||
Write(';');
|
||||
}
|
||||
WriteLine("%(AdditionalUsingDirectories)</AdditionalUsingDirectories>");
|
||||
Write(" <PreprocessorDefinitions>");
|
||||
Write(conf.Definitions);
|
||||
if (!string.IsNullOrEmpty(conf.Definitions) && !conf.Definitions.EndsWith(";"))
|
||||
{
|
||||
Write(';');
|
||||
}
|
||||
//if (!x64)
|
||||
{
|
||||
Write("WIN32;");
|
||||
}
|
||||
Write(conf.IsDebug ? "_DEBUG;" : "NDEBUG;");
|
||||
WriteLine("%(PreprocessorDefinitions)</PreprocessorDefinitions>");
|
||||
if (conf.IsDebug)
|
||||
{
|
||||
WriteLine(" <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>");
|
||||
WriteLine(" <BufferSecurityCheck>false</BufferSecurityCheck>");
|
||||
}
|
||||
WriteLine(" <FloatingPointModel>Precise</FloatingPointModel>");
|
||||
WriteLine(" <PrecompiledHeader>Use</PrecompiledHeader>");
|
||||
if (conf.IsDebug)
|
||||
{
|
||||
WriteLine(" <WarningLevel>Level3</WarningLevel>");
|
||||
WriteLine(" <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>");
|
||||
WriteLine(" <DisableSpecificWarnings>4793;%(DisableSpecificWarnings)</DisableSpecificWarnings>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" <WarningLevel>Level1</WarningLevel>");
|
||||
}
|
||||
WriteLine(" </ClCompile>");
|
||||
WriteLine(" <Link>");
|
||||
if (conf.IsDebug)
|
||||
{
|
||||
WriteLine(" <AdditionalDependencies>LinearMath_Debug.lib;BulletCollision_Debug.lib;BulletDynamics_Debug.lib</AdditionalDependencies>");
|
||||
if (!string.IsNullOrEmpty(LibraryDirectoriesDebug))
|
||||
{
|
||||
Write(" <AdditionalLibraryDirectories>");
|
||||
Write(LibraryDirectoriesDebug);
|
||||
WriteLine("%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>");
|
||||
}
|
||||
WriteLine(" <GenerateDebugInformation>true</GenerateDebugInformation>");
|
||||
WriteLine(" <AssemblyDebug>true</AssemblyDebug>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" <AdditionalDependencies>LinearMath_MinSizeRel.lib;BulletCollision_MinsizeRel.lib;BulletDynamics_MinsizeRel.lib</AdditionalDependencies>");
|
||||
if (!string.IsNullOrEmpty(LibraryDirectoriesRelease))
|
||||
{
|
||||
Write(" <AdditionalLibraryDirectories>");
|
||||
Write(LibraryDirectoriesRelease);
|
||||
WriteLine("%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>");
|
||||
}
|
||||
}
|
||||
if (!x64)
|
||||
{
|
||||
WriteLine(" <TargetMachine>MachineX86</TargetMachine>");
|
||||
}
|
||||
//WriteLine(" <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>");
|
||||
WriteLine(" </Link>");
|
||||
WriteLine(" </ItemDefinitionGroup>");
|
||||
}
|
||||
|
||||
void OutputItemGroupReference(string referenceName, string assemblyName)
|
||||
{
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
WriteLine("\t\t<AssemblyReference");
|
||||
Write("\t\t\tRelativePath=\"");
|
||||
Write(referenceName);
|
||||
WriteLine(".dll\"");
|
||||
Write("\t\t\tAssemblyName=\"");
|
||||
Write(assemblyName);
|
||||
WriteLine("\"");
|
||||
WriteLine("\t\t\tMinFrameworkVersion=\"131072\"");
|
||||
WriteLine("\t\t/>");
|
||||
}
|
||||
else
|
||||
{
|
||||
Write(" <Reference Include=\"");
|
||||
Write(referenceName);
|
||||
WriteLine("\">");
|
||||
WriteLine(" <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>");
|
||||
WriteLine(" <ReferenceOutputAssembly>true</ReferenceOutputAssembly>");
|
||||
WriteLine(" </Reference>");
|
||||
}
|
||||
}
|
||||
|
||||
void OutputItemGroupReferenceConditional(string condition, string referenceName, string assemblyName)
|
||||
{
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
WriteLine("\t<References>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" <ItemGroup>");
|
||||
}
|
||||
OutputItemGroupReference(referenceName, assemblyName);
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
WriteLine("\t</References>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" </ItemGroup>");
|
||||
}
|
||||
}
|
||||
|
||||
public void Output(TargetVS targetVS, IList<ProjectConfiguration> confs, string outDirectory)
|
||||
{
|
||||
Directory.CreateDirectory(outDirectory);
|
||||
var solutionFile = new FileStream(outDirectory + "\\" + namespaceName + ".sln", FileMode.Create, FileAccess.Write);
|
||||
solutionWriter = new StreamWriter(solutionFile, Encoding.UTF8);
|
||||
|
||||
this.targetVS = targetVS;
|
||||
confs = confs.OrderBy(c => !c.IsDebug).ThenBy(c => c.Name).ToList();
|
||||
|
||||
var projectGuid = new Guid("5A0DEF7E-B7E3-45E9-A511-0F03CECFF8C0");
|
||||
string projectGuidString = projectGuid.ToString().ToUpper();
|
||||
|
||||
WriteLineSln();
|
||||
WriteSln("Microsoft Visual Studio Solution File, Format Version ");
|
||||
switch (targetVS)
|
||||
{
|
||||
case TargetVS.VS2008:
|
||||
WriteLineSln("10.00");
|
||||
WriteLineSln("# Visual C++ Express 2008");
|
||||
break;
|
||||
case TargetVS.VS2010:
|
||||
WriteLineSln("11.00");
|
||||
WriteLineSln("# Visual Studio 2010");
|
||||
break;
|
||||
case TargetVS.VS2012:
|
||||
WriteLineSln("12.00");
|
||||
WriteLineSln("# Visual Studio 11");
|
||||
break;
|
||||
case TargetVS.VS2013:
|
||||
WriteLineSln("12.00");
|
||||
WriteLineSln("# Visual Studio 2013");
|
||||
WriteLineSln("VisualStudioVersion = 12.0.21005.1");
|
||||
//WriteLineSln("MinimumVisualStudioVersion = 10.0.40219.1");
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Guid vcppProjectType = new Guid("8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942");
|
||||
string vcppProjectTypeString = vcppProjectType.ToString().ToUpper();
|
||||
WriteSln("Project(\"{");
|
||||
WriteSln(vcppProjectTypeString);
|
||||
WriteSln("}\") = \"");
|
||||
WriteSln(namespaceName);
|
||||
WriteSln("\", \"");
|
||||
WriteSln(namespaceName);
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
WriteSln(".vcproj\", \"{");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteSln(".vcxproj\", \"{");
|
||||
}
|
||||
WriteSln(projectGuidString);
|
||||
WriteLineSln("}\"");
|
||||
WriteLineSln("EndProject");
|
||||
|
||||
WriteLineSln("Global");
|
||||
|
||||
WriteLineSln("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution");
|
||||
foreach (var conf in confs)
|
||||
{
|
||||
WriteSln("\t\t");
|
||||
WriteProjectConfigurationNameSln(conf);
|
||||
WriteSln("|Win32 = ");
|
||||
WriteProjectConfigurationNameSln(conf);
|
||||
WriteLineSln("|Win32");
|
||||
if (X64)
|
||||
{
|
||||
WriteSln("\t\t");
|
||||
WriteProjectConfigurationNameSln(conf);
|
||||
WriteSln("|x64 = ");
|
||||
WriteProjectConfigurationNameSln(conf);
|
||||
WriteLineSln("|x64");
|
||||
}
|
||||
}
|
||||
WriteLineSln("\tEndGlobalSection");
|
||||
|
||||
WriteLineSln("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution");
|
||||
foreach (var conf in confs)
|
||||
{
|
||||
WriteSln("\t\t{");
|
||||
WriteSln(projectGuidString);
|
||||
WriteSln("}.");
|
||||
WriteProjectConfigurationNameSln(conf);
|
||||
WriteSln("|Win32.ActiveCfg = ");
|
||||
WriteProjectConfigurationNameSln(conf);
|
||||
WriteLineSln("|Win32");
|
||||
|
||||
WriteSln("\t\t{");
|
||||
WriteSln(projectGuidString);
|
||||
WriteSln("}.");
|
||||
WriteProjectConfigurationNameSln(conf);
|
||||
WriteSln("|Win32.Build.0 = ");
|
||||
WriteProjectConfigurationNameSln(conf);
|
||||
WriteLineSln("|Win32");
|
||||
|
||||
if (X64)
|
||||
{
|
||||
WriteSln("\t\t{");
|
||||
WriteSln(projectGuidString);
|
||||
WriteSln("}.");
|
||||
WriteProjectConfigurationNameSln(conf);
|
||||
WriteSln("|x64.ActiveCfg = ");
|
||||
WriteProjectConfigurationNameSln(conf);
|
||||
WriteLineSln("|x64");
|
||||
|
||||
WriteSln("\t\t{");
|
||||
WriteSln(projectGuidString);
|
||||
WriteSln("}.");
|
||||
WriteProjectConfigurationNameSln(conf);
|
||||
WriteSln("|x64.Build.0 = ");
|
||||
WriteProjectConfigurationNameSln(conf);
|
||||
WriteLineSln("|x64");
|
||||
}
|
||||
}
|
||||
WriteLineSln("\tEndGlobalSection");
|
||||
|
||||
WriteLineSln("\tGlobalSection(SolutionProperties) = preSolution");
|
||||
WriteLineSln("\t\tHideSolutionNode = FALSE");
|
||||
WriteLineSln("\tEndGlobalSection");
|
||||
WriteLineSln("EndGlobal");
|
||||
|
||||
solutionWriter.Dispose();
|
||||
solutionFile.Dispose();
|
||||
|
||||
|
||||
string projectFilename = namespaceName + (targetVS == TargetVS.VS2008 ? ".vcproj" : ".vcxproj");
|
||||
var projectFile = new FileStream(outDirectory + "\\" + projectFilename, FileMode.Create, FileAccess.Write);
|
||||
projectWriter = new StreamWriter(projectFile, Encoding.UTF8);
|
||||
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
WriteLine("<?xml version=\"1.0\" encoding=\"Windows-1252\"?>");
|
||||
WriteLine("<VisualStudioProject");
|
||||
WriteLine("\tProjectType=\"Visual C++\"");
|
||||
WriteLine("\tVersion=\"9.00\"");
|
||||
Write("\tName=\"");
|
||||
Write(namespaceName);
|
||||
WriteLine("\"");
|
||||
Write("\tProjectGUID=\"{");
|
||||
Write(projectGuidString);
|
||||
WriteLine("}\"");
|
||||
Write("\tRootNamespace=\"");
|
||||
Write(namespaceName);
|
||||
WriteLine("\"");
|
||||
WriteLine("\tKeyword=\"ManagedCProj\"");
|
||||
WriteLine(" TargetFrameworkVersion=\"131072\"");
|
||||
WriteLine("\t>");
|
||||
WriteLine("\t<Platforms>");
|
||||
WriteLine("\t\t<Platform");
|
||||
WriteLine("\t\t\tName=\"Win32\"");
|
||||
WriteLine("\t\t/>");
|
||||
WriteLine("\t</Platforms>");
|
||||
WriteLine("\t<ToolFiles>");
|
||||
WriteLine("\t</ToolFiles>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||
Write("<Project DefaultTargets=\"Build\" ToolsVersion=\"");
|
||||
switch (targetVS)
|
||||
{
|
||||
case TargetVS.VS2010:
|
||||
case TargetVS.VS2012:
|
||||
Write("4.0");
|
||||
break;
|
||||
case TargetVS.VS2013:
|
||||
Write("12.0");
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
WriteLine("\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">");
|
||||
}
|
||||
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
WriteLine("\t<Configurations>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" <ItemGroup Label=\"ProjectConfigurations\">");
|
||||
}
|
||||
foreach (var conf in confs)
|
||||
{
|
||||
OutputProjectConfiguration(conf, false);
|
||||
if (X64)
|
||||
{
|
||||
OutputProjectConfiguration(conf, true);
|
||||
}
|
||||
}
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
WriteLine("\t</Configurations>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" </ItemGroup>");
|
||||
|
||||
if (targetVS != TargetVS.VS2010)
|
||||
{
|
||||
WriteLine(" <PropertyGroup Label=\"Globals\">");
|
||||
WriteLine(" <VCTargetsPath Condition=\"\'$(VCTargetsPath11)\' != \'\' and \'$(VSVersion)\' == \'\' and \'$(VisualStudioVersion)\' == \'\'\">$(VCTargetsPath11)</VCTargetsPath>");
|
||||
WriteLine(" </PropertyGroup>");
|
||||
}
|
||||
WriteLine(" <PropertyGroup Label=\"Globals\">");
|
||||
Write(" <ProjectGuid>{");
|
||||
Write(projectGuidString);
|
||||
WriteLine("}</ProjectGuid>");
|
||||
if (targetVS != TargetVS.VS2010)
|
||||
{
|
||||
WriteLine(" <TargetFrameworkVersion Condition=\"\'$(Configuration)\'==\'Debug XNA 3.1\' OR \'$(Configuration)\'==\'Release XNA 3.1\'\">v2.0</TargetFrameworkVersion>");
|
||||
WriteLine(" <TargetFrameworkVersion Condition=\"\'$(Configuration)\'==\'Debug XNA 4.0\' OR \'$(Configuration)\'==\'Release XNA 4.0\'\">v4.0</TargetFrameworkVersion>");
|
||||
if (targetVS == TargetVS.VS2012)
|
||||
{
|
||||
WriteLine(" <TargetFrameworkVersion Condition=\"\'$(TargetFrameworkVersion)\'==\'\'\">v4.5</TargetFrameworkVersion>");
|
||||
}
|
||||
else // if (targetVS == TargetVS.VS2013)
|
||||
{
|
||||
WriteLine(" <TargetFrameworkVersion Condition=\"\'$(TargetFrameworkVersion)\'==\'\'\">v4.5.1</TargetFrameworkVersion>");
|
||||
}
|
||||
}
|
||||
Write(" <RootNamespace>");
|
||||
Write(namespaceName);
|
||||
WriteLine("</RootNamespace>");
|
||||
WriteLine(" <Keyword>ManagedCProj</Keyword>");
|
||||
WriteLine(" </PropertyGroup>");
|
||||
|
||||
|
||||
WriteLine(" <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />");
|
||||
|
||||
|
||||
foreach (var conf in confs)
|
||||
{
|
||||
OutputPropertyGroupConfiguration(conf, false);
|
||||
if (X64)
|
||||
{
|
||||
OutputPropertyGroupConfiguration(conf, true);
|
||||
}
|
||||
}
|
||||
|
||||
WriteLine(" <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />");
|
||||
WriteLine(" <ImportGroup Label=\"ExtensionSettings\">");
|
||||
WriteLine(" </ImportGroup>");
|
||||
|
||||
|
||||
foreach (var conf in confs)
|
||||
{
|
||||
OutputImportGroupPropertySheets(conf);
|
||||
}
|
||||
|
||||
|
||||
WriteLine(" <PropertyGroup Label=\"UserMacros\" />");
|
||||
WriteLine(" <PropertyGroup>");
|
||||
WriteLine(" <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>");
|
||||
foreach (var conf in confs)
|
||||
{
|
||||
OutputPropertyGroupConfiguration2(conf, false);
|
||||
if (X64)
|
||||
{
|
||||
OutputPropertyGroupConfiguration2(conf, true);
|
||||
}
|
||||
}
|
||||
WriteLine(" </PropertyGroup>");
|
||||
|
||||
|
||||
foreach (var conf in confs)
|
||||
{
|
||||
OutputItemDefinitionGroup(conf, false);
|
||||
if (X64)
|
||||
{
|
||||
OutputItemDefinitionGroup(conf, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
WriteLine("\t<References>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" <ItemGroup>");
|
||||
}
|
||||
OutputItemGroupReference("System", "System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL");
|
||||
OutputItemGroupReference("System.Drawing", "System.Drawing, Version=2.0.0.0, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL");
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
WriteLine("\t</References>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" </ItemGroup>");
|
||||
}
|
||||
|
||||
foreach (var conf in confs)
|
||||
{
|
||||
if (conf.ConditionalRef != null && conf.ConditionalRefAssembly != null)
|
||||
{
|
||||
if (targetVS != TargetVS.VS2008)
|
||||
{
|
||||
WriteLine(string.Format(" <ItemGroup Condition=\"'$(Configuration)'=='{0} {1}'\">", conf.IsDebug ? "Debug" : "Release", conf.Name));
|
||||
WriteLine(string.Format(" <Reference Include=\"{0}\">", conf.ConditionalRefAssembly));
|
||||
WriteLine(" </Reference>");
|
||||
WriteLine(" </ItemGroup>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (targetVS == TargetVS.VS2008)
|
||||
{
|
||||
filterWriter.Output2008(projectWriter, confs, outDirectory);
|
||||
|
||||
WriteLine("\t<Globals>");
|
||||
WriteLine("\t</Globals>");
|
||||
WriteLine("</VisualStudioProject>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(" <ItemGroup>");
|
||||
var sourceFiles = filterWriter.RootFilter.GetChild("Source Files").GetFileList();
|
||||
foreach (var sourceFile in sourceFiles)
|
||||
{
|
||||
Write(" <ClCompile Include=\"");
|
||||
Write(sourceFile);
|
||||
if (sourceFile.EndsWith("Stdafx", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
WriteLine(".cpp\">");
|
||||
foreach (var conf in confs)
|
||||
{
|
||||
Write(" <PrecompiledHeader Condition=\"'$(Configuration)|$(Platform)'=='");
|
||||
WriteProjectConfigurationName(conf);
|
||||
WriteLine("|Win32'\">Create</PrecompiledHeader>");
|
||||
if (X64)
|
||||
{
|
||||
Write(" <PrecompiledHeader Condition=\"'$(Configuration)|$(Platform)'=='");
|
||||
WriteProjectConfigurationName(conf);
|
||||
WriteLine("|x64'\">Create</PrecompiledHeader>");
|
||||
}
|
||||
}
|
||||
WriteLine(" </ClCompile>");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine(".cpp\" />");
|
||||
}
|
||||
}
|
||||
WriteLine(" </ItemGroup>");
|
||||
|
||||
WriteLine(" <ItemGroup>");
|
||||
var resourceFiles = filterWriter.RootFilter.GetChild("Resource Files").GetFileList();
|
||||
foreach (var resourceFile in resourceFiles)
|
||||
{
|
||||
Write(" <ResourceCompile Include=\"");
|
||||
Write(resourceFile);
|
||||
WriteLine("\" />");
|
||||
}
|
||||
WriteLine(" </ItemGroup>");
|
||||
|
||||
WriteLine(" <ItemGroup>");
|
||||
var headerFiles = filterWriter.RootFilter.GetChild("Header Files").GetFileList();
|
||||
foreach (var headerFile in headerFiles)
|
||||
{
|
||||
Write(" <ClInclude Include=\"");
|
||||
Write(headerFile);
|
||||
WriteLine(".h\" />");
|
||||
}
|
||||
WriteLine(" </ItemGroup>");
|
||||
|
||||
WriteLine(" <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />");
|
||||
WriteLine(" <ImportGroup Label=\"ExtensionTargets\">");
|
||||
WriteLine(" </ImportGroup>");
|
||||
|
||||
Write("</Project>");
|
||||
}
|
||||
|
||||
projectWriter.Dispose();
|
||||
projectFile.Dispose();
|
||||
|
||||
|
||||
if (FilterWriter != null && targetVS != TargetVS.VS2008)
|
||||
{
|
||||
FilterWriter.Output(targetVS, outDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,281 @@
|
|||
using System;
|
||||
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
class TypeRefDefinition
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public bool IsBasic { get; set; }
|
||||
public bool IsPointer { get; set; }
|
||||
public bool IsReference { get; set; }
|
||||
public bool IsConstantArray { get; set; }
|
||||
public bool IsConst { get; set; }
|
||||
public TypeRefDefinition Referenced { get; set; }
|
||||
public bool HasTemplateTypeParameter { get; set; }
|
||||
public TypeRefDefinition SpecializedTemplateType { get; set; }
|
||||
|
||||
private bool _unresolved;
|
||||
public ClassDefinition Target { get; set; }
|
||||
|
||||
public string FullName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Target != null)
|
||||
{
|
||||
return Target.FullName;
|
||||
}
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
public string ManagedName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsBasic)
|
||||
{
|
||||
if (Name.Equals("unsigned char"))
|
||||
{
|
||||
return "byte";
|
||||
}
|
||||
if (Referenced != null)
|
||||
{
|
||||
return Referenced.ManagedName;
|
||||
}
|
||||
return Name;
|
||||
}
|
||||
if (HasTemplateTypeParameter)
|
||||
{
|
||||
return "T";
|
||||
}
|
||||
if (IsPointer || IsReference || IsConstantArray)
|
||||
{
|
||||
return Referenced.ManagedName;
|
||||
}
|
||||
if (Target == null)
|
||||
{
|
||||
if (!_unresolved)
|
||||
{
|
||||
Console.WriteLine("Unresolved reference to " + Name);
|
||||
}
|
||||
_unresolved = true;
|
||||
return Name;
|
||||
}
|
||||
if (SpecializedTemplateType != null)
|
||||
{
|
||||
return Target.ManagedName + "<" + SpecializedTemplateType.ManagedName + ">";
|
||||
}
|
||||
return Target.ManagedName;
|
||||
}
|
||||
}
|
||||
|
||||
public string ManagedNameCS
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsBasic)
|
||||
{
|
||||
if (Name.Equals("unsigned short"))
|
||||
{
|
||||
return "ushort";
|
||||
}
|
||||
if (Name.Equals("unsigned int"))
|
||||
{
|
||||
return "uint";
|
||||
}
|
||||
if (Name.Equals("unsigned long"))
|
||||
{
|
||||
return "ulong";
|
||||
}
|
||||
}
|
||||
return ManagedName;
|
||||
}
|
||||
}
|
||||
|
||||
public string ManagedTypeRefName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsPointer || IsReference || IsConstantArray)
|
||||
{
|
||||
if (IsBasic)
|
||||
{
|
||||
return ManagedName + '*';
|
||||
}
|
||||
switch (ManagedName)
|
||||
{
|
||||
case "void":
|
||||
return "IntPtr";
|
||||
case "char":
|
||||
return "String^";
|
||||
case "float":
|
||||
return string.Format("array<{0}>^", Referenced.Name);
|
||||
}
|
||||
return ManagedName + '^';
|
||||
}
|
||||
return ManagedName;
|
||||
}
|
||||
}
|
||||
|
||||
public TypeRefDefinition(ClangSharp.Type type)
|
||||
{
|
||||
IsConst = type.IsConstQualifiedType;
|
||||
|
||||
switch (type.TypeKind)
|
||||
{
|
||||
case ClangSharp.Type.Kind.Void:
|
||||
case ClangSharp.Type.Kind.Bool:
|
||||
case ClangSharp.Type.Kind.CharS:
|
||||
case ClangSharp.Type.Kind.Double:
|
||||
case ClangSharp.Type.Kind.Float:
|
||||
case ClangSharp.Type.Kind.Int:
|
||||
case ClangSharp.Type.Kind.UChar:
|
||||
case ClangSharp.Type.Kind.UInt:
|
||||
Name = type.Spelling;
|
||||
IsBasic = true;
|
||||
break;
|
||||
case ClangSharp.Type.Kind.Long:
|
||||
Name = "long";
|
||||
IsBasic = true;
|
||||
break;
|
||||
case ClangSharp.Type.Kind.LongLong:
|
||||
Name = "long long";
|
||||
IsBasic = true;
|
||||
break;
|
||||
case ClangSharp.Type.Kind.Short:
|
||||
Name = "short";
|
||||
IsBasic = true;
|
||||
break;
|
||||
case ClangSharp.Type.Kind.ULong:
|
||||
Name = "unsigned long";
|
||||
IsBasic = true;
|
||||
break;
|
||||
case ClangSharp.Type.Kind.UShort:
|
||||
Name = "unsigned short";
|
||||
IsBasic = true;
|
||||
break;
|
||||
case ClangSharp.Type.Kind.Typedef:
|
||||
Name = GetFullyQualifiedName(type);
|
||||
Referenced = new TypeRefDefinition(type.Canonical);
|
||||
IsBasic = Referenced.IsBasic;
|
||||
break;
|
||||
case ClangSharp.Type.Kind.Pointer:
|
||||
Referenced = new TypeRefDefinition(type.Pointee);
|
||||
IsPointer = true;
|
||||
break;
|
||||
case ClangSharp.Type.Kind.LValueReference:
|
||||
Referenced = new TypeRefDefinition(type.Pointee);
|
||||
IsReference = true;
|
||||
break;
|
||||
case ClangSharp.Type.Kind.ConstantArray:
|
||||
Referenced = new TypeRefDefinition(type.ArrayElementType);
|
||||
IsConstantArray = true;
|
||||
break;
|
||||
case ClangSharp.Type.Kind.FunctionProto:
|
||||
// ??
|
||||
break;
|
||||
case ClangSharp.Type.Kind.Enum:
|
||||
Name = type.Canonical.Declaration.Spelling;
|
||||
IsBasic = true;
|
||||
break;
|
||||
case ClangSharp.Type.Kind.Record:
|
||||
case ClangSharp.Type.Kind.Unexposed:
|
||||
Name = GetFullyQualifiedName(type);
|
||||
break;
|
||||
case ClangSharp.Type.Kind.DependentSizedArray:
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public TypeRefDefinition()
|
||||
{
|
||||
Name = "void";
|
||||
IsBasic = true;
|
||||
}
|
||||
|
||||
public TypeRefDefinition Copy()
|
||||
{
|
||||
var t = new TypeRefDefinition();
|
||||
t.HasTemplateTypeParameter = HasTemplateTypeParameter;
|
||||
t.IsBasic = IsBasic;
|
||||
t.IsConst = IsConst;
|
||||
t.IsConstantArray = IsConstantArray;
|
||||
t.IsPointer = IsPointer;
|
||||
t.IsReference = IsReference;
|
||||
t.Name = Name;
|
||||
t.Referenced = Referenced;
|
||||
t.SpecializedTemplateType = SpecializedTemplateType;
|
||||
t.Target = Target;
|
||||
return t;
|
||||
}
|
||||
|
||||
public static string GetFullyQualifiedName(ClangSharp.Type type)
|
||||
{
|
||||
string name;
|
||||
var decl = type.Declaration;
|
||||
if (decl.IsInvalid)
|
||||
{
|
||||
name = "[unexposed type]";
|
||||
}
|
||||
else
|
||||
{
|
||||
name = decl.Spelling;
|
||||
while (decl.SemanticParent.Kind == ClangSharp.CursorKind.ClassDecl ||
|
||||
decl.SemanticParent.Kind == ClangSharp.CursorKind.StructDecl ||
|
||||
decl.SemanticParent.Kind == ClangSharp.CursorKind.ClassTemplate ||
|
||||
decl.SemanticParent.Kind == ClangSharp.CursorKind.Namespace)
|
||||
{
|
||||
name = decl.SemanticParent.Spelling + "::" + name;
|
||||
decl = decl.SemanticParent;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TypeRefDefinition t = obj as TypeRefDefinition;
|
||||
if (t == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t.IsBasic != IsBasic ||
|
||||
t.IsConstantArray != IsConstantArray ||
|
||||
t.IsPointer != IsPointer ||
|
||||
t.IsReference != IsReference)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsPointer || IsReference || IsConstantArray)
|
||||
{
|
||||
return t.Referenced.Equals(Referenced);
|
||||
}
|
||||
|
||||
if (Name == null)
|
||||
{
|
||||
return t.Name == null;
|
||||
}
|
||||
return t.Name.Equals(Name);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ManagedName;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace BulletSharpGen
|
||||
{
|
||||
[Flags]
|
||||
enum WriteTo
|
||||
{
|
||||
None = 0,
|
||||
Header = 1,
|
||||
Source = 2,
|
||||
CS = 4,
|
||||
Buffer = 8,
|
||||
AllFiles = Header | Source | CS
|
||||
}
|
||||
|
||||
class WrapperWriter
|
||||
{
|
||||
protected IEnumerable<HeaderDefinition> headerDefinitions;
|
||||
protected string NamespaceName { get; private set; }
|
||||
|
||||
protected StreamWriter headerWriter, sourceWriter, csWriter;
|
||||
protected StringBuilder bufferBuilder = new StringBuilder();
|
||||
protected bool hasHeaderWhiteSpace;
|
||||
protected bool hasSourceWhiteSpace;
|
||||
protected bool hasCSWhiteSpace;
|
||||
|
||||
public WrapperWriter(IEnumerable<HeaderDefinition> headerDefinitions, string namespaceName)
|
||||
{
|
||||
this.headerDefinitions = headerDefinitions;
|
||||
this.NamespaceName = namespaceName;
|
||||
}
|
||||
|
||||
protected void Write(string s, WriteTo to = WriteTo.AllFiles)
|
||||
{
|
||||
if ((to & WriteTo.Header) != 0)
|
||||
{
|
||||
headerWriter.Write(s);
|
||||
}
|
||||
if ((to & WriteTo.Source) != 0)
|
||||
{
|
||||
sourceWriter.Write(s);
|
||||
}
|
||||
if ((to & WriteTo.CS) != 0)
|
||||
{
|
||||
csWriter.Write(s);
|
||||
}
|
||||
if ((to & WriteTo.Buffer) != 0)
|
||||
{
|
||||
bufferBuilder.Append(s);
|
||||
}
|
||||
}
|
||||
|
||||
protected void Write(char c, WriteTo to = WriteTo.AllFiles)
|
||||
{
|
||||
Write(c.ToString(), to);
|
||||
}
|
||||
|
||||
protected void WriteLine(string s, WriteTo to = WriteTo.AllFiles)
|
||||
{
|
||||
Write(s, to);
|
||||
WriteLine(to);
|
||||
}
|
||||
|
||||
protected void WriteLine(char c, WriteTo to = WriteTo.AllFiles)
|
||||
{
|
||||
Write(c, to);
|
||||
WriteLine(to);
|
||||
}
|
||||
|
||||
protected void WriteLine(WriteTo to = WriteTo.AllFiles)
|
||||
{
|
||||
Write("\r\n", to);
|
||||
}
|
||||
|
||||
protected void WriteTabs(int n, WriteTo to = WriteTo.Header)
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
Write('\t', to);
|
||||
}
|
||||
}
|
||||
|
||||
protected void EnsureWhiteSpace(WriteTo to)
|
||||
{
|
||||
if ((to & WriteTo.Source) != 0)
|
||||
{
|
||||
if (!hasSourceWhiteSpace)
|
||||
{
|
||||
sourceWriter.WriteLine();
|
||||
hasSourceWhiteSpace = true;
|
||||
}
|
||||
}
|
||||
if ((to & WriteTo.CS) != 0)
|
||||
{
|
||||
if (!hasCSWhiteSpace)
|
||||
{
|
||||
csWriter.WriteLine();
|
||||
hasCSWhiteSpace = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<configuration>
|
||||
<dllmap dll="libbulletc" os="windows" cpu="x86" target="libbulletc-windows-x86.dll"/>
|
||||
<dllmap dll="libbulletc" os="windows" cpu="x86-64" target="libbulletc-windows-x64.dll"/>
|
||||
<dllmap dll="libbulletc" os="linux" cpu="x86" target="libbulletc-linux-x86.so"/>
|
||||
<dllmap dll="libbulletc" os="linux" cpu="x86-64" target="libbulletc-linux-x64.so"/>
|
||||
<dllmap dll="libbulletc" os="linux" cpu="arm" target="libbulletc-linux-arm.so"/>
|
||||
</configuration>
|
|
@ -0,0 +1,241 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{76FDED5B-2C12-453E-B499-CB669E55AD5B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BulletSharp</RootNamespace>
|
||||
<AssemblyName>BulletSharp</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.XML" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Collision\ActivatingCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\Box2DBox2DCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\Box2DShape.cs" />
|
||||
<Compile Include="Collision\BoxBoxCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\BoxBoxDetector.cs" />
|
||||
<Compile Include="Collision\CollisionConfiguration.cs" />
|
||||
<Compile Include="Collision\CollisionCreateFunc.cs" />
|
||||
<Compile Include="Collision\CollisionDispatcher.cs" />
|
||||
<Compile Include="Collision\CollisionObject.cs" />
|
||||
<Compile Include="Collision\CompoundCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\CompoundCompoundCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\ContinuousConvexCollision.cs" />
|
||||
<Compile Include="Collision\Convex2DConvex2DAlgorithm.cs" />
|
||||
<Compile Include="Collision\ConvexCast.cs" />
|
||||
<Compile Include="Collision\ConvexConcaveCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\ConvexConvexAlgorithm.cs" />
|
||||
<Compile Include="Collision\ConvexPlaneCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\ConvexPointCloudShape.cs" />
|
||||
<Compile Include="Collision\ConvexTriangleMeshShape.cs" />
|
||||
<Compile Include="Collision\Dbvt.cs" />
|
||||
<Compile Include="Collision\EmptyCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\EmptyShape.cs" />
|
||||
<Compile Include="Collision\GImpact\CompoundFromGImpact.cs" />
|
||||
<Compile Include="Collision\GImpact\GImpactQuantizedBvh.cs" />
|
||||
<Compile Include="Collision\GImpact\TriangleShapeEx.cs" />
|
||||
<Compile Include="Collision\GjkConvexCast.cs" />
|
||||
<Compile Include="Collision\GjkEpaPenetrationDepthSolver.cs" />
|
||||
<Compile Include="Collision\HeightfieldTerrainShape.cs" />
|
||||
<Compile Include="Collision\ManifoldResult.cs" />
|
||||
<Compile Include="Collision\MinkowskiSumShape.cs" />
|
||||
<Compile Include="Collision\MultimaterialTriangleMeshShape.cs" />
|
||||
<Compile Include="Collision\OptimizedBvh.cs" />
|
||||
<Compile Include="Collision\QuantizedBvh.cs" />
|
||||
<Compile Include="Collision\RaycastCallback.cs" />
|
||||
<Compile Include="Collision\SimpleBroadphase.cs" />
|
||||
<Compile Include="Collision\SoftBodyConcaveCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\SoftRigidCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\SoftSoftCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\SphereBoxCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\SphereSphereCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\SphereTriangleCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\SphereTriangleDetector.cs" />
|
||||
<Compile Include="Collision\TriangleBuffer.cs" />
|
||||
<Compile Include="Collision\TriangleCallback.cs" />
|
||||
<Compile Include="Collision\TriangleIndexVertexMaterialArray.cs" />
|
||||
<Compile Include="Collision\TriangleInfoMap.cs" />
|
||||
<Compile Include="Collision\TriangleShape.cs" />
|
||||
<Compile Include="Collision\UniformScalingShape.cs" />
|
||||
<Compile Include="Collision\UnionFind.cs" />
|
||||
<Compile Include="Dynamics\ContactConstraint.cs" />
|
||||
<Compile Include="Dynamics\DantzigSolver.cs" />
|
||||
<Compile Include="Dynamics\Featherstone\MultiBody.cs" />
|
||||
<Compile Include="Dynamics\Featherstone\MultiBodyConstraint.cs" />
|
||||
<Compile Include="Dynamics\Featherstone\MultiBodyConstraintSolver.cs" />
|
||||
<Compile Include="Dynamics\Featherstone\MultiBodyDynamicsWorld.cs" />
|
||||
<Compile Include="Dynamics\Featherstone\MultiBodyJointLimitConstraint.cs" />
|
||||
<Compile Include="Dynamics\Featherstone\MultiBodyJointMotor.cs" />
|
||||
<Compile Include="Dynamics\Featherstone\MultiBodyLink.cs" />
|
||||
<Compile Include="Dynamics\Featherstone\MultiBodyLinkCollider.cs" />
|
||||
<Compile Include="Dynamics\Featherstone\MultiBodyPoint2Point.cs" />
|
||||
<Compile Include="Dynamics\Featherstone\MultiBodySolverConstraint.cs" />
|
||||
<Compile Include="Dynamics\FixedConstraint.cs" />
|
||||
<Compile Include="Dynamics\IAction.cs" />
|
||||
<Compile Include="Dynamics\ICharacterController.cs" />
|
||||
<Compile Include="Dynamics\MlcpSolver.cs" />
|
||||
<Compile Include="Dynamics\MlcpSolverInterface.cs" />
|
||||
<Compile Include="Dynamics\NncgConstraintSolver.cs" />
|
||||
<Compile Include="Extras\BulletReader.cs" />
|
||||
<Compile Include="Extras\BulletWriter.cs" />
|
||||
<Compile Include="Extras\Chunk.cs" />
|
||||
<Compile Include="Extras\Dna.cs" />
|
||||
<Compile Include="Extras\BulletDna.cs" />
|
||||
<Compile Include="Extras\Hacd.cs" />
|
||||
<Compile Include="LinearMath\AlignedManifoldArray.cs" />
|
||||
<Compile Include="Collision\AxisSweep3.cs" />
|
||||
<Compile Include="Collision\BoxShape.cs" />
|
||||
<Compile Include="Collision\BroadphaseInterface.cs" />
|
||||
<Compile Include="Collision\BroadphaseProxy.cs" />
|
||||
<Compile Include="Collision\BvhTriangleMeshShape.cs" />
|
||||
<Compile Include="Collision\CollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\CollisionObjectWrapper.cs" />
|
||||
<Compile Include="Collision\CollisionShape.cs" />
|
||||
<Compile Include="Collision\CollisionWorld.cs" />
|
||||
<Compile Include="Collision\CapsuleShape.cs" />
|
||||
<Compile Include="Collision\CompoundShape.cs" />
|
||||
<Compile Include="Collision\ConcaveShape.cs" />
|
||||
<Compile Include="Collision\ConeShape.cs" />
|
||||
<Compile Include="Collision\Convex2DShape.cs" />
|
||||
<Compile Include="Collision\ConvexHullShape.cs" />
|
||||
<Compile Include="Collision\ConvexInternalShape.cs" />
|
||||
<Compile Include="Collision\ConvexPenetrationDepthSolver.cs" />
|
||||
<Compile Include="Collision\ConvexPolyhedron.cs" />
|
||||
<Compile Include="Collision\ConvexShape.cs" />
|
||||
<Compile Include="Collision\CylinderShape.cs" />
|
||||
<Compile Include="Collision\DefaultCollisionConfiguration.cs" />
|
||||
<Compile Include="Collision\DiscreteCollisionDetectorInterface.cs" />
|
||||
<Compile Include="Collision\GhostObject.cs" />
|
||||
<Compile Include="Collision\GImpact\BoxCollision.cs" />
|
||||
<Compile Include="Collision\GImpact\GImpactBvh.cs" />
|
||||
<Compile Include="Collision\GImpact\GImpactCollisionAlgorithm.cs" />
|
||||
<Compile Include="Collision\GImpact\GImpactShape.cs" />
|
||||
<Compile Include="Collision\GjkPairDetector.cs" />
|
||||
<Compile Include="Collision\ManifoldPoint.cs" />
|
||||
<Compile Include="Collision\MinkowskiPenetrationDepthSolver.cs" />
|
||||
<Compile Include="Collision\MultiSphereShape.cs" />
|
||||
<Compile Include="Collision\OverlappingPairCache.cs" />
|
||||
<Compile Include="Collision\OverlappingPairCallback.cs" />
|
||||
<Compile Include="Collision\PersistentManifold.cs" />
|
||||
<Compile Include="Collision\PointCollector.cs" />
|
||||
<Compile Include="Collision\ScaledBvhTriangleMeshShape.cs" />
|
||||
<Compile Include="Collision\ShapeHull.cs" />
|
||||
<Compile Include="Collision\SimulationIslandManager.cs" />
|
||||
<Compile Include="Collision\SphereShape.cs" />
|
||||
<Compile Include="Collision\DbvtBroadphase.cs" />
|
||||
<Compile Include="Collision\Dispatcher.cs" />
|
||||
<Compile Include="Collision\PolyhedralConvexShape.cs" />
|
||||
<Compile Include="Collision\StaticPlaneShape.cs" />
|
||||
<Compile Include="Collision\StridingMeshInterface.cs" />
|
||||
<Compile Include="Collision\TetrahedronShape.cs" />
|
||||
<Compile Include="Collision\TriangleIndexVertexArray.cs" />
|
||||
<Compile Include="Collision\TriangleMesh.cs" />
|
||||
<Compile Include="Collision\TriangleMeshShape.cs" />
|
||||
<Compile Include="Collision\VoronoiSimplexSolver.cs" />
|
||||
<Compile Include="Dynamics\ConeTwistConstraint.cs" />
|
||||
<Compile Include="Dynamics\ConstraintSolver.cs" />
|
||||
<Compile Include="Dynamics\ContactSolverInfo.cs" />
|
||||
<Compile Include="Dynamics\DiscreteDynamicsWorld.cs" />
|
||||
<Compile Include="Dynamics\DynamicsWorld.cs" />
|
||||
<Compile Include="Dynamics\GearConstraint.cs" />
|
||||
<Compile Include="Dynamics\Generic6DofConstraint.cs" />
|
||||
<Compile Include="Dynamics\Generic6DofSpringConstraint.cs" />
|
||||
<Compile Include="Dynamics\Hinge2Constraint.cs" />
|
||||
<Compile Include="Dynamics\HingeConstraint.cs" />
|
||||
<Compile Include="Dynamics\KinematicCharacterController.cs" />
|
||||
<Compile Include="Dynamics\Point2PointConstraint.cs" />
|
||||
<Compile Include="Dynamics\RaycastVehicle.cs" />
|
||||
<Compile Include="Dynamics\RigidBody.cs" />
|
||||
<Compile Include="Dynamics\RigidBodyConstructionInfo.cs" />
|
||||
<Compile Include="Dynamics\SequentialImpulseConstraintSolver.cs" />
|
||||
<Compile Include="Dynamics\SliderConstraint.cs" />
|
||||
<Compile Include="Dynamics\TypedConstraint.cs" />
|
||||
<Compile Include="Dynamics\UniversalConstraint.cs" />
|
||||
<Compile Include="Dynamics\VehicleRaycaster.cs" />
|
||||
<Compile Include="Dynamics\WheelInfo.cs" />
|
||||
<Compile Include="Extras\bFile.cs" />
|
||||
<Compile Include="Extras\BulletFile.cs" />
|
||||
<Compile Include="Extras\BulletWorldImporter.cs" />
|
||||
<Compile Include="Extras\BulletXmlWorldImporter.cs" />
|
||||
<Compile Include="Extras\WorldImporter.cs" />
|
||||
<Compile Include="LinearMath\AlignedBroadphasePairArray.cs" />
|
||||
<Compile Include="LinearMath\AlignedCollisionObjectArray.cs" />
|
||||
<Compile Include="LinearMath\AlignedVector3Array.cs" />
|
||||
<Compile Include="LinearMath\Collections.cs" />
|
||||
<Compile Include="LinearMath\AlignedIndexedMeshArray.cs" />
|
||||
<Compile Include="LinearMath\DebugDraw.cs" />
|
||||
<Compile Include="LinearMath\DefaultMotionState.cs" />
|
||||
<Compile Include="LinearMath\GeometryUtil.cs" />
|
||||
<Compile Include="LinearMath\IDebugDraw.cs" />
|
||||
<Compile Include="LinearMath\MotionState.cs" />
|
||||
<Compile Include="LinearMath\PolarDecomposition.cs" />
|
||||
<Compile Include="LinearMath\Serializer.cs" />
|
||||
<Compile Include="LinearMath\TransformUtil.cs" />
|
||||
<Compile Include="MathUtil.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Math\Matrix.cs" />
|
||||
<Compile Include="Math\Quaternion.cs" />
|
||||
<Compile Include="Math\Vector3.cs" />
|
||||
<Compile Include="Math\Vector4.cs" />
|
||||
<Compile Include="Native.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SoftBody\AlignedJointArray.cs" />
|
||||
<Compile Include="SoftBody\AlignedMaterialArray.cs" />
|
||||
<Compile Include="SoftBody\AlignedNodeArray.cs" />
|
||||
<Compile Include="SoftBody\AlignedClusterArray.cs" />
|
||||
<Compile Include="SoftBody\AlignedSoftBodyArray.cs" />
|
||||
<Compile Include="SoftBody\Collections.cs" />
|
||||
<Compile Include="SoftBody\AlignedTetraArray.cs" />
|
||||
<Compile Include="SoftBody\AlignedFaceArray.cs" />
|
||||
<Compile Include="SoftBody\AlignedLinkArray.cs" />
|
||||
<Compile Include="SoftBody\DefaultSoftBodySolver.cs" />
|
||||
<Compile Include="SoftBody\SoftBody.cs" />
|
||||
<Compile Include="SoftBody\SoftBodyHelpers.cs" />
|
||||
<Compile Include="SoftBody\SoftBodyRigidBodyCollisionConfiguration.cs" />
|
||||
<Compile Include="SoftBody\SoftBodySolver.cs" />
|
||||
<Compile Include="SoftBody\SoftRigidDynamicsWorld.cs" />
|
||||
<Compile Include="SoftBody\SparseSdf.cs" />
|
||||
<Compile Include="Utilities.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BulletSharpPInvoke", "BulletSharpPInvoke.csproj", "{76FDED5B-2C12-453E-B499-CB669E55AD5B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{76FDED5B-2C12-453E-B499-CB669E55AD5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{76FDED5B-2C12-453E-B499-CB669E55AD5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{76FDED5B-2C12-453E-B499-CB669E55AD5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{76FDED5B-2C12-453E-B499-CB669E55AD5B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public abstract class ActivatingCollisionAlgorithm : CollisionAlgorithm
|
||||
{
|
||||
internal ActivatingCollisionAlgorithm(IntPtr native, bool preventDelete = false)
|
||||
: base(native, preventDelete)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,306 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class AxisSweep3 : BroadphaseInterface
|
||||
{
|
||||
private OverlappingPairCallback _overlappingPairUserCallback;
|
||||
|
||||
public AxisSweep3(ref Vector3 worldAabbMin, ref Vector3 worldAabbMax)
|
||||
: base(btAxisSweep3_new(ref worldAabbMin, ref worldAabbMax))
|
||||
{
|
||||
_pairCache = new HashedOverlappingPairCache(btBroadphaseInterface_getOverlappingPairCache(_native), true);
|
||||
}
|
||||
|
||||
public AxisSweep3(Vector3 worldAabbMin, Vector3 worldAabbMax)
|
||||
: this(ref worldAabbMin, ref worldAabbMax)
|
||||
{
|
||||
}
|
||||
|
||||
public AxisSweep3(ref Vector3 worldAabbMin, ref Vector3 worldAabbMax, ushort maxHandles)
|
||||
: base(btAxisSweep3_new2(ref worldAabbMin, ref worldAabbMax, maxHandles))
|
||||
{
|
||||
_pairCache = new HashedOverlappingPairCache(btBroadphaseInterface_getOverlappingPairCache(_native), true);
|
||||
}
|
||||
|
||||
public AxisSweep3(Vector3 worldAabbMin, Vector3 worldAabbMax, ushort maxHandles)
|
||||
: this(ref worldAabbMin, ref worldAabbMax, maxHandles)
|
||||
{
|
||||
}
|
||||
|
||||
public AxisSweep3(ref Vector3 worldAabbMin, ref Vector3 worldAabbMax, ushort maxHandles, OverlappingPairCache pairCache)
|
||||
: base(btAxisSweep3_new3(ref worldAabbMin, ref worldAabbMax, maxHandles,
|
||||
(pairCache != null) ? pairCache._native : IntPtr.Zero))
|
||||
{
|
||||
_pairCache = (pairCache != null) ? pairCache : new HashedOverlappingPairCache(
|
||||
btBroadphaseInterface_getOverlappingPairCache(_native), true);
|
||||
}
|
||||
|
||||
public AxisSweep3(Vector3 worldAabbMin, Vector3 worldAabbMax, ushort maxHandles, OverlappingPairCache pairCache)
|
||||
: this(ref worldAabbMin, ref worldAabbMax, maxHandles, pairCache)
|
||||
{
|
||||
}
|
||||
|
||||
public AxisSweep3(ref Vector3 worldAabbMin, ref Vector3 worldAabbMax, ushort maxHandles, OverlappingPairCache pairCache, bool disableRaycastAccelerator)
|
||||
: base(btAxisSweep3_new4(ref worldAabbMin, ref worldAabbMax, maxHandles,
|
||||
(pairCache != null) ? pairCache._native : IntPtr.Zero, disableRaycastAccelerator))
|
||||
{
|
||||
_pairCache = (pairCache != null) ? pairCache : new HashedOverlappingPairCache(
|
||||
btBroadphaseInterface_getOverlappingPairCache(_native), true);
|
||||
}
|
||||
|
||||
public AxisSweep3(Vector3 worldAabbMin, Vector3 worldAabbMax, ushort maxHandles, OverlappingPairCache pairCache, bool disableRaycastAccelerator)
|
||||
: this(ref worldAabbMin, ref worldAabbMax, maxHandles, pairCache, disableRaycastAccelerator)
|
||||
{
|
||||
}
|
||||
|
||||
ushort AddHandle(ref Vector3 aabbMin, ref Vector3 aabbMax, IntPtr owner, short collisionFilterGroup,
|
||||
short collisionFilterMask, Dispatcher dispatcher, IntPtr multiSapProxy)
|
||||
{
|
||||
return btAxisSweep3_addHandle(_native, ref aabbMin, ref aabbMax, owner, collisionFilterGroup, collisionFilterMask, dispatcher._native, multiSapProxy);
|
||||
}
|
||||
|
||||
ushort AddHandle(ref Vector3 aabbMin, ref Vector3 aabbMax, IntPtr owner, CollisionFilterGroups collisionFilterGroup,
|
||||
CollisionFilterGroups collisionFilterMask, Dispatcher dispatcher, IntPtr multiSapProxy)
|
||||
{
|
||||
return AddHandle(ref aabbMin, ref aabbMax, owner, collisionFilterGroup, collisionFilterMask, dispatcher, multiSapProxy);
|
||||
}
|
||||
/*
|
||||
Handle GetHandle(ushort index)
|
||||
{
|
||||
return new Handle(btAxisSweep3_getHandle(_native, index._native), true);
|
||||
}
|
||||
|
||||
void ProcessAllOverlappingPairs(OverlapCallback callback)
|
||||
{
|
||||
btAxisSweep3_processAllOverlappingPairs(_native, callback._native);
|
||||
}
|
||||
*/
|
||||
void Quantize(out ushort o, ref Vector3 point, int isMax)
|
||||
{
|
||||
btAxisSweep3_quantize(_native, out o, ref point, isMax);
|
||||
}
|
||||
|
||||
void RemoveHandle(ushort handle, Dispatcher dispatcher)
|
||||
{
|
||||
btAxisSweep3_removeHandle(_native, handle, dispatcher._native);
|
||||
}
|
||||
|
||||
bool TestAabbOverlap(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
|
||||
{
|
||||
return btAxisSweep3_testAabbOverlap(_native, proxy0._native, proxy1._native);
|
||||
}
|
||||
|
||||
void UnQuantize(BroadphaseProxy proxy, Vector3 aabbMin, Vector3 aabbMax)
|
||||
{
|
||||
btAxisSweep3_unQuantize(_native, proxy._native, out aabbMin, out aabbMax);
|
||||
}
|
||||
|
||||
void UpdateHandle(ushort handle, Vector3 aabbMin, Vector3 aabbMax, Dispatcher dispatcher)
|
||||
{
|
||||
btAxisSweep3_updateHandle(_native, handle, ref aabbMin, ref aabbMax, dispatcher._native);
|
||||
}
|
||||
|
||||
public ushort NumHandles
|
||||
{
|
||||
get { return btAxisSweep3_getNumHandles(_native); }
|
||||
}
|
||||
|
||||
public OverlappingPairCallback OverlappingPairUserCallback
|
||||
{
|
||||
get
|
||||
{
|
||||
return _overlappingPairUserCallback;
|
||||
}
|
||||
set
|
||||
{
|
||||
_overlappingPairUserCallback = value;
|
||||
btAxisSweep3_setOverlappingPairUserCallback(_native, (value != null) ? value._native : IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btAxisSweep3_new([In] ref Vector3 worldAabbMin, [In] ref Vector3 worldAabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btAxisSweep3_new2([In] ref Vector3 worldAabbMin, [In] ref Vector3 worldAabbMax, ushort maxHandles);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btAxisSweep3_new3([In] ref Vector3 worldAabbMin, [In] ref Vector3 worldAabbMax, ushort maxHandles, IntPtr pairCache);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btAxisSweep3_new4([In] ref Vector3 worldAabbMin, [In] ref Vector3 worldAabbMax, ushort maxHandles, IntPtr pairCache, bool disableRaycastAccelerator);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern ushort btAxisSweep3_addHandle(IntPtr obj, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax, IntPtr pOwner, short collisionFilterGroup, short collisionFilterMask, IntPtr dispatcher, IntPtr multiSapProxy);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btAxisSweep3_getHandle(IntPtr obj, ushort index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern ushort btAxisSweep3_getNumHandles(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btAxisSweep3_getOverlappingPairUserCallback(IntPtr obj);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern void btAxisSweep3_processAllOverlappingPairs(IntPtr obj, IntPtr callback);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAxisSweep3_quantize(IntPtr obj, [Out] out ushort o, [In] ref Vector3 point, int isMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAxisSweep3_removeHandle(IntPtr obj, ushort handle, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAxisSweep3_setOverlappingPairUserCallback(IntPtr obj, IntPtr pairCallback);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern bool btAxisSweep3_testAabbOverlap(IntPtr obj, IntPtr proxy0, IntPtr proxy1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAxisSweep3_unQuantize(IntPtr obj, IntPtr proxy, [Out] out Vector3 aabbMin, [Out] out Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAxisSweep3_updateHandle(IntPtr obj, ushort handle, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax, IntPtr dispatcher);
|
||||
|
||||
}
|
||||
|
||||
public class AxisSweep3_32Bit : BroadphaseInterface
|
||||
{
|
||||
private OverlappingPairCallback _overlappingPairUserCallback;
|
||||
|
||||
public AxisSweep3_32Bit(ref Vector3 worldAabbMin, ref Vector3 worldAabbMax)
|
||||
: base(bt32BitAxisSweep3_new(ref worldAabbMin, ref worldAabbMax))
|
||||
{
|
||||
_pairCache = new HashedOverlappingPairCache(btBroadphaseInterface_getOverlappingPairCache(_native), true);
|
||||
}
|
||||
|
||||
public AxisSweep3_32Bit(Vector3 worldAabbMin, Vector3 worldAabbMax)
|
||||
: this(ref worldAabbMin, ref worldAabbMax)
|
||||
{
|
||||
}
|
||||
|
||||
public AxisSweep3_32Bit(ref Vector3 worldAabbMin, ref Vector3 worldAabbMax, uint maxHandles)
|
||||
: base(bt32BitAxisSweep3_new2(ref worldAabbMin, ref worldAabbMax, maxHandles))
|
||||
{
|
||||
_pairCache = new HashedOverlappingPairCache(btBroadphaseInterface_getOverlappingPairCache(_native), true);
|
||||
}
|
||||
|
||||
public AxisSweep3_32Bit(Vector3 worldAabbMin, Vector3 worldAabbMax, uint maxHandles)
|
||||
: this(ref worldAabbMin, ref worldAabbMax, maxHandles)
|
||||
{
|
||||
}
|
||||
|
||||
public AxisSweep3_32Bit(ref Vector3 worldAabbMin, ref Vector3 worldAabbMax, uint maxHandles, OverlappingPairCache pairCache)
|
||||
: base(bt32BitAxisSweep3_new3(ref worldAabbMin, ref worldAabbMax, maxHandles,
|
||||
(pairCache != null) ? pairCache._native : IntPtr.Zero))
|
||||
{
|
||||
_pairCache = (pairCache != null) ? pairCache : new HashedOverlappingPairCache(
|
||||
btBroadphaseInterface_getOverlappingPairCache(_native), true);
|
||||
}
|
||||
|
||||
public AxisSweep3_32Bit(Vector3 worldAabbMin, Vector3 worldAabbMax, uint maxHandles, OverlappingPairCache pairCache)
|
||||
: this(ref worldAabbMin, ref worldAabbMax, maxHandles, pairCache)
|
||||
{
|
||||
}
|
||||
|
||||
public AxisSweep3_32Bit(ref Vector3 worldAabbMin, ref Vector3 worldAabbMax, uint maxHandles, OverlappingPairCache pairCache, bool disableRaycastAccelerator)
|
||||
: base(bt32BitAxisSweep3_new4(ref worldAabbMin, ref worldAabbMax, maxHandles,
|
||||
(pairCache != null) ? pairCache._native : IntPtr.Zero, disableRaycastAccelerator))
|
||||
{
|
||||
_pairCache = (pairCache != null) ? pairCache : new HashedOverlappingPairCache(
|
||||
btBroadphaseInterface_getOverlappingPairCache(_native), true);
|
||||
}
|
||||
|
||||
public AxisSweep3_32Bit(Vector3 worldAabbMin, Vector3 worldAabbMax, uint maxHandles, OverlappingPairCache pairCache, bool disableRaycastAccelerator)
|
||||
: this(ref worldAabbMin, ref worldAabbMax, maxHandles, pairCache, disableRaycastAccelerator)
|
||||
{
|
||||
}
|
||||
|
||||
uint AddHandle(ref Vector3 aabbMin, ref Vector3 aabbMax, IntPtr owner, short collisionFilterGroup,
|
||||
short collisionFilterMask, Dispatcher dispatcher, IntPtr multiSapProxy)
|
||||
{
|
||||
return bt32BitAxisSweep3_addHandle(_native, ref aabbMin, ref aabbMax, owner, collisionFilterGroup, collisionFilterMask, dispatcher._native, multiSapProxy);
|
||||
}
|
||||
|
||||
uint AddHandle(ref Vector3 aabbMin, ref Vector3 aabbMax, IntPtr owner, CollisionFilterGroups collisionFilterGroup,
|
||||
CollisionFilterGroups collisionFilterMask, Dispatcher dispatcher, IntPtr multiSapProxy)
|
||||
{
|
||||
return AddHandle(ref aabbMin, ref aabbMax, owner, collisionFilterGroup, collisionFilterMask, dispatcher, multiSapProxy);
|
||||
}
|
||||
/*
|
||||
Handle GetHandle(uint index)
|
||||
{
|
||||
return new Handle(bt32BitAxisSweep3_getHandle(_native, index._native), true);
|
||||
}
|
||||
|
||||
void ProcessAllOverlappingPairs(OverlapCallback callback)
|
||||
{
|
||||
bt32BitAxisSweep3_processAllOverlappingPairs(_native, callback._native);
|
||||
}
|
||||
*/
|
||||
void Quantize(out uint o, ref Vector3 point, int isMax)
|
||||
{
|
||||
bt32BitAxisSweep3_quantize(_native, out o, ref point, isMax);
|
||||
}
|
||||
|
||||
void RemoveHandle(uint handle, Dispatcher dispatcher)
|
||||
{
|
||||
bt32BitAxisSweep3_removeHandle(_native, handle, dispatcher._native);
|
||||
}
|
||||
|
||||
bool TestAabbOverlap(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
|
||||
{
|
||||
return bt32BitAxisSweep3_testAabbOverlap(_native, proxy0._native, proxy1._native);
|
||||
}
|
||||
|
||||
void UnQuantize(BroadphaseProxy proxy, Vector3 aabbMin, Vector3 aabbMax)
|
||||
{
|
||||
bt32BitAxisSweep3_unQuantize(_native, proxy._native, out aabbMin, out aabbMax);
|
||||
}
|
||||
|
||||
void UpdateHandle(uint handle, Vector3 aabbMin, Vector3 aabbMax, Dispatcher dispatcher)
|
||||
{
|
||||
bt32BitAxisSweep3_updateHandle(_native, handle, ref aabbMin, ref aabbMax, dispatcher._native);
|
||||
}
|
||||
|
||||
public uint NumHandles
|
||||
{
|
||||
get { return bt32BitAxisSweep3_getNumHandles(_native); }
|
||||
}
|
||||
|
||||
public OverlappingPairCallback OverlappingPairUserCallback
|
||||
{
|
||||
get
|
||||
{
|
||||
return _overlappingPairUserCallback;
|
||||
}
|
||||
set
|
||||
{
|
||||
_overlappingPairUserCallback = value;
|
||||
bt32BitAxisSweep3_setOverlappingPairUserCallback(_native, (value != null) ? value._native : IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr bt32BitAxisSweep3_new([In] ref Vector3 worldAabbMin, [In] ref Vector3 worldAabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr bt32BitAxisSweep3_new2([In] ref Vector3 worldAabbMin, [In] ref Vector3 worldAabbMax, uint maxHandles);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr bt32BitAxisSweep3_new3([In] ref Vector3 worldAabbMin, [In] ref Vector3 worldAabbMax, uint maxHandles, IntPtr pairCache);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr bt32BitAxisSweep3_new4([In] ref Vector3 worldAabbMin, [In] ref Vector3 worldAabbMax, uint maxHandles, IntPtr pairCache, bool disableRaycastAccelerator);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern uint bt32BitAxisSweep3_addHandle(IntPtr obj, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax, IntPtr pOwner, short collisionFilterGroup, short collisionFilterMask, IntPtr dispatcher, IntPtr multiSapProxy);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr bt32BitAxisSweep3_getHandle(IntPtr obj, uint index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern uint bt32BitAxisSweep3_getNumHandles(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr bt32BitAxisSweep3_getOverlappingPairUserCallback(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern void bt32BitAxisSweep3_processAllOverlappingPairs(IntPtr obj, IntPtr callback);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void bt32BitAxisSweep3_quantize(IntPtr obj, [Out] out uint o, [In] ref Vector3 point, int isMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void bt32BitAxisSweep3_removeHandle(IntPtr obj, uint handle, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void bt32BitAxisSweep3_setOverlappingPairUserCallback(IntPtr obj, IntPtr pairCallback);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern bool bt32BitAxisSweep3_testAabbOverlap(IntPtr obj, IntPtr proxy0, IntPtr proxy1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void bt32BitAxisSweep3_unQuantize(IntPtr obj, IntPtr proxy, [Out] out Vector3 aabbMin, [Out] out Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void bt32BitAxisSweep3_updateHandle(IntPtr obj, uint handle, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax, IntPtr dispatcher);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class Box2DBox2DCollisionAlgorithm : ActivatingCollisionAlgorithm
|
||||
{
|
||||
public class CreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
public CreateFunc()
|
||||
: base(btBox2dBox2dCollisionAlgorithm_CreateFunc_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBox2dBox2dCollisionAlgorithm_CreateFunc_new();
|
||||
}
|
||||
|
||||
public Box2DBox2DCollisionAlgorithm(CollisionAlgorithmConstructionInfo ci)
|
||||
: base(btBox2dBox2dCollisionAlgorithm_new(ci._native))
|
||||
{
|
||||
}
|
||||
|
||||
public Box2DBox2DCollisionAlgorithm(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap)
|
||||
: base(btBox2dBox2dCollisionAlgorithm_new2(mf._native, ci._native, body0Wrap._native, body1Wrap._native))
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBox2dBox2dCollisionAlgorithm_new(IntPtr ci);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBox2dBox2dCollisionAlgorithm_new2(IntPtr mf, IntPtr ci, IntPtr body0Wrap, IntPtr body1Wrap);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class Box2DShape : PolyhedralConvexShape
|
||||
{
|
||||
private Vector3Array _normals;
|
||||
private Vector3Array _vertices;
|
||||
|
||||
public Box2DShape(ref Vector3 boxHalfExtents)
|
||||
: base(btBox2dShape_new(ref boxHalfExtents))
|
||||
{
|
||||
}
|
||||
|
||||
public Box2DShape(Vector3 boxHalfExtents)
|
||||
: this(ref boxHalfExtents)
|
||||
{
|
||||
}
|
||||
|
||||
public Box2DShape(float boxHalfExtent)
|
||||
: base(btBox2dShape_new2(boxHalfExtent))
|
||||
{
|
||||
}
|
||||
|
||||
public Box2DShape(float boxHalfExtentX, float boxHalfExtentY, float boxHalfExtentZ)
|
||||
: base(btBox2dShape_new3(boxHalfExtentX, boxHalfExtentY, boxHalfExtentZ))
|
||||
{
|
||||
}
|
||||
|
||||
public void GetPlaneEquation(out Vector4 plane, int i)
|
||||
{
|
||||
btBox2dShape_getPlaneEquation(_native, out plane, i);
|
||||
}
|
||||
|
||||
public Vector3 Centroid
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btBox2dShape_getCentroid(_native, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 HalfExtentsWithMargin
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btBox2dShape_getHalfExtentsWithMargin(_native, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 HalfExtentsWithoutMargin
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btBox2dShape_getHalfExtentsWithoutMargin(_native, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3Array Normals
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_normals == null)
|
||||
{
|
||||
_normals = new Vector3Array(btBox2dShape_getNormals(_native), 4);
|
||||
}
|
||||
return _normals;
|
||||
}
|
||||
}
|
||||
|
||||
public int VertexCount
|
||||
{
|
||||
get { return btBox2dShape_getVertexCount(_native); }
|
||||
}
|
||||
|
||||
public Vector3Array Vertices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_vertices == null)
|
||||
{
|
||||
_vertices = new Vector3Array(btBox2dShape_getVertices(_native), 4);
|
||||
}
|
||||
return _vertices;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBox2dShape_new([In] ref Vector3 boxHalfExtents);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBox2dShape_new2(float boxHalfExtent);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBox2dShape_new3(float boxHalfExtentX, float boxHalfExtentY, float boxHalfExtentZ);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBox2dShape_getCentroid(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBox2dShape_getHalfExtentsWithMargin(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBox2dShape_getHalfExtentsWithoutMargin(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBox2dShape_getNormals(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBox2dShape_getPlaneEquation(IntPtr obj, [Out] out Vector4 plane, int i);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btBox2dShape_getVertexCount(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBox2dShape_getVertices(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class BoxBoxCollisionAlgorithm : ActivatingCollisionAlgorithm
|
||||
{
|
||||
public class CreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
public CreateFunc()
|
||||
: base(btBoxBoxCollisionAlgorithm_CreateFunc_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBoxBoxCollisionAlgorithm_CreateFunc_new();
|
||||
}
|
||||
|
||||
public BoxBoxCollisionAlgorithm(CollisionAlgorithmConstructionInfo ci)
|
||||
: base(btBoxBoxCollisionAlgorithm_new(ci._native))
|
||||
{
|
||||
}
|
||||
|
||||
public BoxBoxCollisionAlgorithm(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap)
|
||||
: base(btBoxBoxCollisionAlgorithm_new2(mf._native, ci._native, body0Wrap._native, body1Wrap._native))
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBoxBoxCollisionAlgorithm_new(IntPtr ci);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBoxBoxCollisionAlgorithm_new2(IntPtr mf, IntPtr ci, IntPtr body0Wrap, IntPtr body1Wrap);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class BoxBoxDetector : DiscreteCollisionDetectorInterface
|
||||
{
|
||||
private BoxShape _box1;
|
||||
private BoxShape _box2;
|
||||
|
||||
public BoxBoxDetector(BoxShape box1, BoxShape box2)
|
||||
: base(btBoxBoxDetector_new(box1._native, box2._native))
|
||||
{
|
||||
_box1 = box1;
|
||||
_box2 = box2;
|
||||
}
|
||||
|
||||
public BoxShape Box1
|
||||
{
|
||||
get { return _box1; }
|
||||
set
|
||||
{
|
||||
btBoxBoxDetector_setBox1(_native, value._native);
|
||||
_box1 = value;
|
||||
}
|
||||
}
|
||||
|
||||
public BoxShape Box2
|
||||
{
|
||||
get { return _box2; }
|
||||
set
|
||||
{
|
||||
btBoxBoxDetector_setBox2(_native, value._native);
|
||||
_box2 = value;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBoxBoxDetector_new(IntPtr box1, IntPtr box2);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBoxBoxDetector_getBox1(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBoxBoxDetector_getBox2(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBoxBoxDetector_setBox1(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBoxBoxDetector_setBox2(IntPtr obj, IntPtr value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class BoxShape : PolyhedralConvexShape
|
||||
{
|
||||
public BoxShape(ref Vector3 boxHalfExtents)
|
||||
: base(btBoxShape_new(ref boxHalfExtents))
|
||||
{
|
||||
}
|
||||
|
||||
public BoxShape(Vector3 boxHalfExtents)
|
||||
: this(ref boxHalfExtents)
|
||||
{
|
||||
}
|
||||
|
||||
public BoxShape(float boxHalfExtent)
|
||||
: base(btBoxShape_new2(boxHalfExtent))
|
||||
{
|
||||
}
|
||||
|
||||
public BoxShape(float boxHalfExtentX, float boxHalfExtentY, float boxHalfExtentZ)
|
||||
: base(btBoxShape_new3(boxHalfExtentX, boxHalfExtentY, boxHalfExtentZ))
|
||||
{
|
||||
}
|
||||
|
||||
public void GetPlaneEquation(out Vector4 plane, out int i)
|
||||
{
|
||||
btBoxShape_getPlaneEquation(_native, out plane, out i);
|
||||
}
|
||||
|
||||
public Vector3 HalfExtentsWithMargin
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btBoxShape_getHalfExtentsWithMargin(_native, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 HalfExtentsWithoutMargin
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btBoxShape_getHalfExtentsWithoutMargin(_native, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBoxShape_new([In] ref Vector3 boxHalfExtents);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBoxShape_new2(float boxHalfExtent);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBoxShape_new3(float boxHalfExtentX, float boxHalfExtentY, float boxHalfExtentZ);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBoxShape_getHalfExtentsWithMargin(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBoxShape_getHalfExtentsWithoutMargin(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBoxShape_getPlaneEquation(IntPtr obj, [Out] out Vector4 plane, [Out] out int i);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,272 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public abstract class BroadphaseAabbCallback : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
[UnmanagedFunctionPointer(Native.Conv)]
|
||||
internal delegate bool ProcessUnmanagedDelegate(IntPtr proxy);
|
||||
|
||||
internal ProcessUnmanagedDelegate _process;
|
||||
|
||||
internal BroadphaseAabbCallback(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
_process = ProcessUnmanaged;
|
||||
}
|
||||
|
||||
protected BroadphaseAabbCallback()
|
||||
{
|
||||
_process = ProcessUnmanaged;
|
||||
_native = btBroadphaseAabbCallbackWrapper_new(
|
||||
Marshal.GetFunctionPointerForDelegate(_process));
|
||||
}
|
||||
|
||||
private bool ProcessUnmanaged(IntPtr proxy)
|
||||
{
|
||||
return Process(BroadphaseProxy.GetManaged(proxy));
|
||||
}
|
||||
|
||||
public abstract bool Process(BroadphaseProxy proxy);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btBroadphaseAabbCallback_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~BroadphaseAabbCallback()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphaseAabbCallbackWrapper_new(IntPtr process);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseAabbCallback_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public abstract class BroadphaseRayCallback : BroadphaseAabbCallback
|
||||
{
|
||||
private UIntArray _signs;
|
||||
|
||||
protected BroadphaseRayCallback()
|
||||
: base(IntPtr.Zero)
|
||||
{
|
||||
_native = btBroadphaseRayCallbackWrapper_new(
|
||||
Marshal.GetFunctionPointerForDelegate(_process));
|
||||
}
|
||||
|
||||
public float LambdaMax
|
||||
{
|
||||
get { return btBroadphaseRayCallback_getLambda_max(_native); }
|
||||
set { btBroadphaseRayCallback_setLambda_max(_native, value); }
|
||||
}
|
||||
|
||||
public Vector3 RayDirectionInverse
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btBroadphaseRayCallback_getRayDirectionInverse(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btBroadphaseRayCallback_setRayDirectionInverse(_native, ref value); }
|
||||
}
|
||||
|
||||
public UIntArray Signs
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_signs == null)
|
||||
{
|
||||
_signs = new UIntArray(btBroadphaseRayCallback_getSigns(_native), 3);
|
||||
}
|
||||
return _signs;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphaseRayCallbackWrapper_new(IntPtr process);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btBroadphaseRayCallback_getLambda_max(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseRayCallback_getRayDirectionInverse(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphaseRayCallback_getSigns(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseRayCallback_setLambda_max(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseRayCallback_setRayDirectionInverse(IntPtr obj, [In] ref Vector3 value);
|
||||
}
|
||||
|
||||
public class BroadphaseInterface : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
protected OverlappingPairCache _pairCache;
|
||||
internal List<CollisionWorld> _worldRefs = new List<CollisionWorld>(1);
|
||||
internal bool _worldDeferredCleanup;
|
||||
|
||||
internal BroadphaseInterface(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public void AabbTest(ref Vector3 aabbMin, ref Vector3 aabbMax, BroadphaseAabbCallback callback)
|
||||
{
|
||||
btBroadphaseInterface_aabbTest(_native, ref aabbMin, ref aabbMax, callback._native);
|
||||
}
|
||||
|
||||
public void AabbTest(Vector3 aabbMin, Vector3 aabbMax, BroadphaseAabbCallback callback)
|
||||
{
|
||||
btBroadphaseInterface_aabbTest(_native, ref aabbMin, ref aabbMax, callback._native);
|
||||
}
|
||||
|
||||
public void CalculateOverlappingPairs(Dispatcher dispatcher)
|
||||
{
|
||||
btBroadphaseInterface_calculateOverlappingPairs(_native, dispatcher._native);
|
||||
}
|
||||
|
||||
public BroadphaseProxy CreateProxy(ref Vector3 aabbMin, ref Vector3 aabbMax, int shapeType, IntPtr userPtr, short collisionFilterGroup, short collisionFilterMask, Dispatcher dispatcher, IntPtr multiSapProxy)
|
||||
{
|
||||
return new BroadphaseProxy(btBroadphaseInterface_createProxy(_native, ref aabbMin, ref aabbMax, shapeType, userPtr, collisionFilterGroup, collisionFilterMask, dispatcher._native, multiSapProxy));
|
||||
}
|
||||
|
||||
public BroadphaseProxy CreateProxy(Vector3 aabbMin, Vector3 aabbMax, int shapeType, IntPtr userPtr, short collisionFilterGroup, short collisionFilterMask, Dispatcher dispatcher, IntPtr multiSapProxy)
|
||||
{
|
||||
return new BroadphaseProxy(btBroadphaseInterface_createProxy(_native, ref aabbMin, ref aabbMax, shapeType, userPtr, collisionFilterGroup, collisionFilterMask, dispatcher._native, multiSapProxy));
|
||||
}
|
||||
|
||||
public void DestroyProxy(BroadphaseProxy proxy, Dispatcher dispatcher)
|
||||
{
|
||||
btBroadphaseInterface_destroyProxy(_native, proxy._native, dispatcher._native);
|
||||
}
|
||||
|
||||
public void GetAabb(BroadphaseProxy proxy, out Vector3 aabbMin, out Vector3 aabbMax)
|
||||
{
|
||||
btBroadphaseInterface_getAabb(_native, proxy._native, out aabbMin, out aabbMax);
|
||||
}
|
||||
|
||||
public void GetBroadphaseAabb(out Vector3 aabbMin, out Vector3 aabbMax)
|
||||
{
|
||||
btBroadphaseInterface_getBroadphaseAabb(_native, out aabbMin, out aabbMax);
|
||||
}
|
||||
|
||||
public void PrintStats()
|
||||
{
|
||||
btBroadphaseInterface_printStats(_native);
|
||||
}
|
||||
|
||||
public void RayTest(ref Vector3 rayFrom, ref Vector3 rayTo, BroadphaseRayCallback rayCallback)
|
||||
{
|
||||
btBroadphaseInterface_rayTest(_native, ref rayFrom, ref rayTo, rayCallback._native);
|
||||
}
|
||||
|
||||
public void RayTest(Vector3 rayFrom, Vector3 rayTo, BroadphaseRayCallback rayCallback)
|
||||
{
|
||||
btBroadphaseInterface_rayTest(_native, ref rayFrom, ref rayTo, rayCallback._native);
|
||||
}
|
||||
|
||||
public void RayTest(ref Vector3 rayFrom, ref Vector3 rayTo, BroadphaseRayCallback rayCallback, ref Vector3 aabbMin, ref Vector3 aabbMax)
|
||||
{
|
||||
btBroadphaseInterface_rayTest3(_native, ref rayFrom, ref rayTo, rayCallback._native, ref aabbMin, ref aabbMax);
|
||||
}
|
||||
|
||||
public void RayTest(Vector3 rayFrom, Vector3 rayTo, BroadphaseRayCallback rayCallback, Vector3 aabbMin, Vector3 aabbMax)
|
||||
{
|
||||
btBroadphaseInterface_rayTest3(_native, ref rayFrom, ref rayTo, rayCallback._native, ref aabbMin, ref aabbMax);
|
||||
}
|
||||
|
||||
public void ResetPool(Dispatcher dispatcher)
|
||||
{
|
||||
btBroadphaseInterface_resetPool(_native, dispatcher._native);
|
||||
}
|
||||
|
||||
public void SetAabb(BroadphaseProxy proxy, ref Vector3 aabbMin, ref Vector3 aabbMax, Dispatcher dispatcher)
|
||||
{
|
||||
btBroadphaseInterface_setAabb(_native, proxy._native, ref aabbMin, ref aabbMax, dispatcher._native);
|
||||
}
|
||||
|
||||
public void SetAabb(BroadphaseProxy proxy, Vector3 aabbMin, Vector3 aabbMax, Dispatcher dispatcher)
|
||||
{
|
||||
SetAabb(proxy, ref aabbMin, ref aabbMax, dispatcher);
|
||||
}
|
||||
|
||||
public OverlappingPairCache OverlappingPairCache
|
||||
{
|
||||
get { return _pairCache; }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
if (_worldRefs.Count == 0)
|
||||
{
|
||||
btBroadphaseInterface_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Can't delete broadphase, because it is referenced by a world,
|
||||
// tell the world to clean up the broadphase later.
|
||||
_worldDeferredCleanup = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~BroadphaseInterface()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseInterface_aabbTest(IntPtr obj, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax, IntPtr callback);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseInterface_calculateOverlappingPairs(IntPtr obj, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphaseInterface_createProxy(IntPtr obj, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax, int shapeType, IntPtr userPtr, short collisionFilterGroup, short collisionFilterMask, IntPtr dispatcher, IntPtr multiSapProxy);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseInterface_destroyProxy(IntPtr obj, IntPtr proxy, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseInterface_getAabb(IntPtr obj, IntPtr proxy, [Out] out Vector3 aabbMin, [Out] out Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseInterface_getBroadphaseAabb(IntPtr obj, [Out] out Vector3 aabbMin, [Out] out Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
internal static extern IntPtr btBroadphaseInterface_getOverlappingPairCache(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseInterface_printStats(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseInterface_rayTest(IntPtr obj, [In] ref Vector3 rayFrom, [In] ref Vector3 rayTo, IntPtr rayCallback);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseInterface_rayTest3(IntPtr obj, [In] ref Vector3 rayFrom, [In] ref Vector3 rayTo, IntPtr rayCallback, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseInterface_resetPool(IntPtr obj, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseInterface_setAabb(IntPtr obj, IntPtr proxy, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseInterface_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,373 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public enum BroadphaseNativeType
|
||||
{
|
||||
// polyhedral convex shapes
|
||||
BoxShape,
|
||||
TriangleShape,
|
||||
TetrahedralShape,
|
||||
ConvexTriangleMeshShape,
|
||||
ConvexHullShape,
|
||||
CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE,
|
||||
CUSTOM_POLYHEDRAL_SHAPE_TYPE,
|
||||
//implicit convex shapes
|
||||
IMPLICIT_CONVEX_SHAPES_START_HERE,
|
||||
SphereShape,
|
||||
MultiSphereShape,
|
||||
CapsuleShape,
|
||||
ConeShape,
|
||||
ConvexShape,
|
||||
CylinderShape,
|
||||
UniformScalingShape,
|
||||
MinkowskiSumShape,
|
||||
MinkowskiDifferenceShape,
|
||||
Box2DShape,
|
||||
Convex2DShape,
|
||||
CUSTOM_CONVEX_SHAPE_TYPE,
|
||||
//concave shapes
|
||||
CONCAVE_SHAPES_START_HERE,
|
||||
//keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
|
||||
TriangleMeshShape,
|
||||
SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE,
|
||||
///used for demo integration FAST/Swift collision library and Bullet
|
||||
FAST_CONCAVE_MESH_PROXYTYPE,
|
||||
//terrain
|
||||
TerrainShape,
|
||||
///Used for GIMPACT Trimesh integration
|
||||
GImpactShape,
|
||||
///Multimaterial mesh
|
||||
MultiMaterialTriangleMesh,
|
||||
|
||||
EmptyShape,
|
||||
StaticPlane,
|
||||
CUSTOM_CONCAVE_SHAPE_TYPE,
|
||||
CONCAVE_SHAPES_END_HERE,
|
||||
|
||||
CompoundShape,
|
||||
|
||||
SoftBodyShape,
|
||||
HFFLUID_SHAPE_PROXYTYPE,
|
||||
HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE,
|
||||
INVALID_SHAPE_PROXYTYPE,
|
||||
|
||||
MAX_BROADPHASE_COLLISION_TYPES
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum CollisionFilterGroups
|
||||
{
|
||||
None = 0,
|
||||
DefaultFilter = 1,
|
||||
StaticFilter = 2,
|
||||
KinematicFilter = 4,
|
||||
DebrisFilter = 8,
|
||||
SensorTrigger = 16,
|
||||
CharacterFilter = 32,
|
||||
AllFilter = -1
|
||||
}
|
||||
|
||||
public class BroadphaseProxy
|
||||
{
|
||||
internal IntPtr _native;
|
||||
private Object _clientObject;
|
||||
|
||||
internal BroadphaseProxy(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
internal static BroadphaseProxy GetManaged(IntPtr native)
|
||||
{
|
||||
if (native == IntPtr.Zero)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IntPtr clientObjectPtr = btBroadphaseProxy_getClientObject(native);
|
||||
if (clientObjectPtr != IntPtr.Zero) {
|
||||
CollisionObject clientObject = CollisionObject.GetManaged(clientObjectPtr);
|
||||
return clientObject.BroadphaseHandle;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Unknown broadphase proxy!");
|
||||
//return new BroadphaseProxy(native);
|
||||
}
|
||||
/*
|
||||
public BroadphaseProxy()
|
||||
{
|
||||
_native = btBroadphaseProxy_new();
|
||||
}
|
||||
|
||||
public BroadphaseProxy(ref Vector3 aabbMin, ref Vector3 aabbMax, IntPtr userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask)
|
||||
{
|
||||
_native = btBroadphaseProxy_new2(ref aabbMin, ref aabbMax, userPtr, (short)collisionFilterGroup, (short)collisionFilterMask);
|
||||
}
|
||||
|
||||
public BroadphaseProxy(Vector3 aabbMin, Vector3 aabbMax, IntPtr userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask)
|
||||
: this(ref aabbMin, ref aabbMax, userPtr, collisionFilterGroup, collisionFilterMask)
|
||||
{
|
||||
}
|
||||
|
||||
public BroadphaseProxy(ref Vector3 aabbMin, ref Vector3 aabbMax, IntPtr userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IntPtr multiSapParentProxy)
|
||||
{
|
||||
_native = btBroadphaseProxy_new3(ref aabbMin, ref aabbMax, userPtr, (short)collisionFilterGroup, (short)collisionFilterMask, multiSapParentProxy);
|
||||
}
|
||||
|
||||
public BroadphaseProxy(Vector3 aabbMin, Vector3 aabbMax, IntPtr userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IntPtr multiSapParentProxy)
|
||||
: this(ref aabbMin, ref aabbMax, userPtr, collisionFilterGroup, collisionFilterMask, multiSapParentProxy)
|
||||
{
|
||||
}
|
||||
*/
|
||||
public static bool IsCompound(BroadphaseNativeType proxyType)
|
||||
{
|
||||
return btBroadphaseProxy_isCompound(proxyType);
|
||||
}
|
||||
|
||||
public static bool IsConcave(BroadphaseNativeType proxyType)
|
||||
{
|
||||
return btBroadphaseProxy_isConcave(proxyType);
|
||||
}
|
||||
|
||||
public static bool IsConvex(BroadphaseNativeType proxyType)
|
||||
{
|
||||
return btBroadphaseProxy_isConvex(proxyType);
|
||||
}
|
||||
|
||||
public static bool IsConvex2D(BroadphaseNativeType proxyType)
|
||||
{
|
||||
return btBroadphaseProxy_isConvex2d(proxyType);
|
||||
}
|
||||
|
||||
public static bool IsInfinite(BroadphaseNativeType proxyType)
|
||||
{
|
||||
return btBroadphaseProxy_isInfinite(proxyType);
|
||||
}
|
||||
|
||||
public static bool IsNonMoving(BroadphaseNativeType proxyType)
|
||||
{
|
||||
return btBroadphaseProxy_isNonMoving(proxyType);
|
||||
}
|
||||
|
||||
public static bool IsPolyhedral(BroadphaseNativeType proxyType)
|
||||
{
|
||||
return btBroadphaseProxy_isPolyhedral(proxyType);
|
||||
}
|
||||
|
||||
public static bool IsSoftBody(BroadphaseNativeType proxyType)
|
||||
{
|
||||
return btBroadphaseProxy_isSoftBody(proxyType);
|
||||
}
|
||||
|
||||
public Vector3 AabbMax
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btBroadphaseProxy_getAabbMax(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btBroadphaseProxy_setAabbMax(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 AabbMin
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btBroadphaseProxy_getAabbMin(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btBroadphaseProxy_setAabbMin(_native, ref value); }
|
||||
}
|
||||
|
||||
public Object ClientObject
|
||||
{
|
||||
get
|
||||
{
|
||||
IntPtr clientObjectPtr = btBroadphaseProxy_getClientObject(_native);
|
||||
if (clientObjectPtr != IntPtr.Zero)
|
||||
{
|
||||
_clientObject = CollisionObject.GetManaged(clientObjectPtr);
|
||||
}
|
||||
return _clientObject;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value is CollisionObject)
|
||||
{
|
||||
btBroadphaseProxy_setClientObject(_native, (value as CollisionObject)._native);
|
||||
}
|
||||
else if (value == null)
|
||||
{
|
||||
btBroadphaseProxy_setClientObject(_native, IntPtr.Zero);
|
||||
}
|
||||
_clientObject = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CollisionFilterGroups CollisionFilterGroup
|
||||
{
|
||||
get { return (CollisionFilterGroups)btBroadphaseProxy_getCollisionFilterGroup(_native); }
|
||||
set { btBroadphaseProxy_setCollisionFilterGroup(_native, (short)value); }
|
||||
}
|
||||
|
||||
public CollisionFilterGroups CollisionFilterMask
|
||||
{
|
||||
get { return (CollisionFilterGroups)btBroadphaseProxy_getCollisionFilterMask(_native); }
|
||||
set { btBroadphaseProxy_setCollisionFilterMask(_native, (short)value); }
|
||||
}
|
||||
|
||||
public IntPtr MultiSapParentProxy
|
||||
{
|
||||
get { return btBroadphaseProxy_getMultiSapParentProxy(_native); }
|
||||
set { btBroadphaseProxy_setMultiSapParentProxy(_native, value); }
|
||||
}
|
||||
|
||||
public int Uid
|
||||
{
|
||||
get { return btBroadphaseProxy_getUid(_native); }
|
||||
}
|
||||
|
||||
public int UniqueId
|
||||
{
|
||||
get { return btBroadphaseProxy_getUniqueId(_native); }
|
||||
set { btBroadphaseProxy_setUniqueId(_native, value); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphaseProxy_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphaseProxy_new2([In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax, IntPtr userPtr, short collisionFilterGroup, short collisionFilterMask);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphaseProxy_new3([In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax, IntPtr userPtr, short collisionFilterGroup, short collisionFilterMask, IntPtr multiSapParentProxy);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseProxy_getAabbMax(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseProxy_getAabbMin(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphaseProxy_getClientObject(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern short btBroadphaseProxy_getCollisionFilterGroup(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern short btBroadphaseProxy_getCollisionFilterMask(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphaseProxy_getMultiSapParentProxy(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btBroadphaseProxy_getUid(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btBroadphaseProxy_getUniqueId(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btBroadphaseProxy_isCompound(BroadphaseNativeType proxyType);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btBroadphaseProxy_isConcave(BroadphaseNativeType proxyType);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btBroadphaseProxy_isConvex(BroadphaseNativeType proxyType);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btBroadphaseProxy_isConvex2d(BroadphaseNativeType proxyType);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btBroadphaseProxy_isInfinite(BroadphaseNativeType proxyType);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btBroadphaseProxy_isNonMoving(BroadphaseNativeType proxyType);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btBroadphaseProxy_isPolyhedral(BroadphaseNativeType proxyType);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btBroadphaseProxy_isSoftBody(BroadphaseNativeType proxyType);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseProxy_setAabbMax(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseProxy_setAabbMin(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseProxy_setClientObject(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseProxy_setCollisionFilterGroup(IntPtr obj, short value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseProxy_setCollisionFilterMask(IntPtr obj, short value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseProxy_setMultiSapParentProxy(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseProxy_setUniqueId(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphaseProxy_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class BroadphasePair
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal BroadphasePair(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
/*
|
||||
public BroadphasePair()
|
||||
{
|
||||
_native = btBroadphasePair_new();
|
||||
}
|
||||
|
||||
public BroadphasePair(BroadphasePair other)
|
||||
{
|
||||
_native = btBroadphasePair_new2(other._native);
|
||||
}
|
||||
|
||||
public BroadphasePair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
|
||||
{
|
||||
_native = btBroadphasePair_new3(proxy0._native, proxy1._native);
|
||||
}
|
||||
*/
|
||||
public CollisionAlgorithm Algorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
IntPtr valuePtr = btBroadphasePair_getAlgorithm(_native);
|
||||
return (valuePtr == IntPtr.Zero) ? null : new CollisionAlgorithm(valuePtr, true);
|
||||
}
|
||||
set { btBroadphasePair_setAlgorithm(_native, (value._native == IntPtr.Zero) ? IntPtr.Zero : value._native); }
|
||||
}
|
||||
|
||||
public BroadphaseProxy Proxy0
|
||||
{
|
||||
get { return BroadphaseProxy.GetManaged(btBroadphasePair_getPProxy0(_native)); }
|
||||
set { btBroadphasePair_setPProxy0(_native, value._native); }
|
||||
}
|
||||
|
||||
public BroadphaseProxy Proxy1
|
||||
{
|
||||
get { return BroadphaseProxy.GetManaged(btBroadphasePair_getPProxy1(_native)); }
|
||||
set { btBroadphasePair_setPProxy1(_native, value._native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphasePair_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphasePair_new2(IntPtr other);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphasePair_new3(IntPtr proxy0, IntPtr proxy1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphasePair_getAlgorithm(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphasePair_getPProxy0(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBroadphasePair_getPProxy1(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphasePair_setAlgorithm(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphasePair_setPProxy0(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphasePair_setPProxy1(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBroadphasePair_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class BvhTriangleMeshShape : TriangleMeshShape
|
||||
{
|
||||
private OptimizedBvh _optimizedBvh;
|
||||
private TriangleInfoMap _triangleInfoMap;
|
||||
|
||||
internal BvhTriangleMeshShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public BvhTriangleMeshShape(StridingMeshInterface meshInterface, bool useQuantizedAabbCompression)
|
||||
: base(btBvhTriangleMeshShape_new(meshInterface._native, useQuantizedAabbCompression))
|
||||
{
|
||||
_meshInterface = meshInterface;
|
||||
}
|
||||
|
||||
public BvhTriangleMeshShape(StridingMeshInterface meshInterface, bool useQuantizedAabbCompression, bool buildBvh)
|
||||
: base(btBvhTriangleMeshShape_new2(meshInterface._native, useQuantizedAabbCompression, buildBvh))
|
||||
{
|
||||
_meshInterface = meshInterface;
|
||||
}
|
||||
|
||||
public BvhTriangleMeshShape(StridingMeshInterface meshInterface, bool useQuantizedAabbCompression, Vector3 bvhAabbMin, Vector3 bvhAabbMax)
|
||||
: base(btBvhTriangleMeshShape_new3(meshInterface._native, useQuantizedAabbCompression, ref bvhAabbMin, ref bvhAabbMax))
|
||||
{
|
||||
_meshInterface = meshInterface;
|
||||
}
|
||||
|
||||
public BvhTriangleMeshShape(StridingMeshInterface meshInterface, bool useQuantizedAabbCompression, Vector3 bvhAabbMin, Vector3 bvhAabbMax, bool buildBvh)
|
||||
: base(btBvhTriangleMeshShape_new4(meshInterface._native, useQuantizedAabbCompression, ref bvhAabbMin, ref bvhAabbMax, buildBvh))
|
||||
{
|
||||
_meshInterface = meshInterface;
|
||||
}
|
||||
|
||||
public void BuildOptimizedBvh()
|
||||
{
|
||||
btBvhTriangleMeshShape_buildOptimizedBvh(_native);
|
||||
}
|
||||
|
||||
public void PartialRefitTree(ref Vector3 aabbMin, ref Vector3 aabbMax)
|
||||
{
|
||||
btBvhTriangleMeshShape_partialRefitTree(_native, ref aabbMin, ref aabbMax);
|
||||
}
|
||||
|
||||
public void PartialRefitTree(Vector3 aabbMin, Vector3 aabbMax)
|
||||
{
|
||||
PartialRefitTree(ref aabbMin, ref aabbMax);
|
||||
}
|
||||
|
||||
public void PerformConvexcast(TriangleCallback callback, Vector3 boxSource, Vector3 boxTarget, Vector3 boxMin, Vector3 boxMax)
|
||||
{
|
||||
btBvhTriangleMeshShape_performConvexcast(_native, callback._native, ref boxSource, ref boxTarget, ref boxMin, ref boxMax);
|
||||
}
|
||||
|
||||
public void PerformRaycast(TriangleCallback callback, Vector3 raySource, Vector3 rayTarget)
|
||||
{
|
||||
btBvhTriangleMeshShape_performRaycast(_native, callback._native, ref raySource, ref rayTarget);
|
||||
}
|
||||
|
||||
public void RefitTree(ref Vector3 aabbMin, ref Vector3 aabbMax)
|
||||
{
|
||||
btBvhTriangleMeshShape_refitTree(_native, ref aabbMin, ref aabbMax);
|
||||
}
|
||||
|
||||
public void RefitTree(Vector3 aabbMin, Vector3 aabbMax)
|
||||
{
|
||||
RefitTree(ref aabbMin, ref aabbMax);
|
||||
}
|
||||
|
||||
public void SerializeSingleBvh(Serializer serializer)
|
||||
{
|
||||
btBvhTriangleMeshShape_serializeSingleBvh(_native, serializer._native);
|
||||
}
|
||||
|
||||
public void SerializeSingleTriangleInfoMap(Serializer serializer)
|
||||
{
|
||||
btBvhTriangleMeshShape_serializeSingleTriangleInfoMap(_native, serializer._native);
|
||||
}
|
||||
|
||||
public void SetOptimizedBvh(OptimizedBvh bvh, Vector3 localScaling)
|
||||
{
|
||||
btBvhTriangleMeshShape_setOptimizedBvh2(_native, (bvh != null) ? bvh._native : IntPtr.Zero, ref localScaling);
|
||||
_optimizedBvh = bvh;
|
||||
}
|
||||
|
||||
public OptimizedBvh OptimizedBvh
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_optimizedBvh == null)
|
||||
{
|
||||
IntPtr optimizedBvhPtr = btBvhTriangleMeshShape_getOptimizedBvh(_native);
|
||||
if (optimizedBvhPtr != IntPtr.Zero)
|
||||
{
|
||||
_optimizedBvh = new OptimizedBvh(optimizedBvhPtr);
|
||||
}
|
||||
}
|
||||
return _optimizedBvh;
|
||||
}
|
||||
set
|
||||
{
|
||||
btBvhTriangleMeshShape_setOptimizedBvh(_native, (value != null) ? value._native : IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
public bool OwnsBvh
|
||||
{
|
||||
get { return btBvhTriangleMeshShape_getOwnsBvh(_native); }
|
||||
}
|
||||
|
||||
public TriangleInfoMap TriangleInfoMap
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_triangleInfoMap == null)
|
||||
{
|
||||
IntPtr triangleInfoMap = btBvhTriangleMeshShape_getTriangleInfoMap(_native);
|
||||
if (triangleInfoMap != IntPtr.Zero)
|
||||
{
|
||||
_triangleInfoMap = new TriangleInfoMap(triangleInfoMap, true);
|
||||
}
|
||||
}
|
||||
return _triangleInfoMap;
|
||||
}
|
||||
set
|
||||
{
|
||||
_triangleInfoMap = value;
|
||||
btBvhTriangleMeshShape_setTriangleInfoMap(_native, (value != null) ? value._native : IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
public bool UsesQuantizedAabbCompression
|
||||
{
|
||||
get { return btBvhTriangleMeshShape_usesQuantizedAabbCompression(_native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhTriangleMeshShape_new(IntPtr meshInterface, bool useQuantizedAabbCompression);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhTriangleMeshShape_new2(IntPtr meshInterface, bool useQuantizedAabbCompression, bool buildBvh);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhTriangleMeshShape_new3(IntPtr meshInterface, bool useQuantizedAabbCompression, [In] ref Vector3 bvhAabbMin, [In] ref Vector3 bvhAabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhTriangleMeshShape_new4(IntPtr meshInterface, bool useQuantizedAabbCompression, [In] ref Vector3 bvhAabbMin, [In] ref Vector3 bvhAabbMax, bool buildBvh);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTriangleMeshShape_buildOptimizedBvh(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhTriangleMeshShape_getOptimizedBvh(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btBvhTriangleMeshShape_getOwnsBvh(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhTriangleMeshShape_getTriangleInfoMap(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTriangleMeshShape_partialRefitTree(IntPtr obj, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTriangleMeshShape_performConvexcast(IntPtr obj, IntPtr callback, [In] ref Vector3 boxSource, [In] ref Vector3 boxTarget, [In] ref Vector3 boxMin, [In] ref Vector3 boxMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTriangleMeshShape_performRaycast(IntPtr obj, IntPtr callback, [In] ref Vector3 raySource, [In] ref Vector3 rayTarget);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTriangleMeshShape_refitTree(IntPtr obj, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTriangleMeshShape_serializeSingleBvh(IntPtr obj, IntPtr serializer);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTriangleMeshShape_serializeSingleTriangleInfoMap(IntPtr obj, IntPtr serializer);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTriangleMeshShape_setOptimizedBvh(IntPtr obj, IntPtr bvh);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTriangleMeshShape_setOptimizedBvh2(IntPtr obj, IntPtr bvh, [In] ref Vector3 localScaling);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTriangleMeshShape_setTriangleInfoMap(IntPtr obj, IntPtr triangleInfoMap);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btBvhTriangleMeshShape_usesQuantizedAabbCompression(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class CapsuleShape : ConvexInternalShape
|
||||
{
|
||||
internal CapsuleShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public CapsuleShape(float radius, float height)
|
||||
: base(btCapsuleShape_new(radius, height))
|
||||
{
|
||||
}
|
||||
|
||||
public float HalfHeight
|
||||
{
|
||||
get { return btCapsuleShape_getHalfHeight(_native); }
|
||||
}
|
||||
|
||||
public float Radius
|
||||
{
|
||||
get { return btCapsuleShape_getRadius(_native); }
|
||||
}
|
||||
|
||||
public int UpAxis
|
||||
{
|
||||
get { return btCapsuleShape_getUpAxis(_native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCapsuleShape_new(float radius, float height);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCapsuleShape_getHalfHeight(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCapsuleShape_getRadius(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btCapsuleShape_getUpAxis(IntPtr obj);
|
||||
}
|
||||
|
||||
public class CapsuleShapeX : CapsuleShape
|
||||
{
|
||||
public CapsuleShapeX(float radius, float height)
|
||||
: base(btCapsuleShapeX_new(radius, height))
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCapsuleShapeX_new(float radius, float height);
|
||||
}
|
||||
|
||||
public class CapsuleShapeZ : CapsuleShape
|
||||
{
|
||||
public CapsuleShapeZ(float radius, float height)
|
||||
: base(btCapsuleShapeZ_new(radius, height))
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCapsuleShapeZ_new(float radius, float height);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class CollisionAlgorithmConstructionInfo : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
private Dispatcher _dispatcher;
|
||||
private PersistentManifold _manifold;
|
||||
|
||||
public CollisionAlgorithmConstructionInfo()
|
||||
{
|
||||
_native = btCollisionAlgorithmConstructionInfo_new();
|
||||
}
|
||||
|
||||
public CollisionAlgorithmConstructionInfo(Dispatcher dispatcher, int temp)
|
||||
{
|
||||
_dispatcher = dispatcher;
|
||||
_native = btCollisionAlgorithmConstructionInfo_new2((dispatcher != null) ? dispatcher._native : IntPtr.Zero, temp);
|
||||
}
|
||||
|
||||
public Dispatcher Dispatcher
|
||||
{
|
||||
get { return _dispatcher; }
|
||||
set
|
||||
{
|
||||
_dispatcher = value;
|
||||
btCollisionAlgorithmConstructionInfo_setDispatcher1(_native, (value != null) ? value._native : IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
public PersistentManifold Manifold
|
||||
{
|
||||
get { return _manifold; }
|
||||
set
|
||||
{
|
||||
_manifold = value;
|
||||
btCollisionAlgorithmConstructionInfo_setManifold(_native, (value != null) ? value._native : IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btCollisionAlgorithmConstructionInfo_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~CollisionAlgorithmConstructionInfo()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionAlgorithmConstructionInfo_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionAlgorithmConstructionInfo_new2(IntPtr dispatcher, int temp);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btCollisionAlgorithmConstructionInfo_getDispatcher1(IntPtr obj);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btCollisionAlgorithmConstructionInfo_getManifold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionAlgorithmConstructionInfo_setDispatcher1(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionAlgorithmConstructionInfo_setManifold(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionAlgorithmConstructionInfo_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class CollisionAlgorithm : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
private readonly bool _preventDelete;
|
||||
|
||||
internal CollisionAlgorithm(IntPtr native, bool preventDelete = false)
|
||||
{
|
||||
_native = native;
|
||||
_preventDelete = preventDelete;
|
||||
}
|
||||
|
||||
public float CalculateTimeOfImpact(CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo, ManifoldResult resultOut)
|
||||
{
|
||||
return btCollisionAlgorithm_calculateTimeOfImpact(_native, body0._native, body1._native, dispatchInfo._native, resultOut._native);
|
||||
}
|
||||
|
||||
public void GetAllContactManifolds(AlignedManifoldArray manifoldArray)
|
||||
{
|
||||
btCollisionAlgorithm_getAllContactManifolds(_native, manifoldArray._native);
|
||||
}
|
||||
|
||||
public void ProcessCollision(CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, DispatcherInfo dispatchInfo, ManifoldResult resultOut)
|
||||
{
|
||||
btCollisionAlgorithm_processCollision(_native, body0Wrap._native, body1Wrap._native, dispatchInfo._native, resultOut._native);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
if (!_preventDelete)
|
||||
{
|
||||
btCollisionAlgorithm_delete(_native);
|
||||
}
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~CollisionAlgorithm()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionAlgorithm_calculateTimeOfImpact(IntPtr obj, IntPtr body0, IntPtr body1, IntPtr dispatchInfo, IntPtr resultOut);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionAlgorithm_getAllContactManifolds(IntPtr obj, IntPtr manifoldArray);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionAlgorithm_processCollision(IntPtr obj, IntPtr body0Wrap, IntPtr body1Wrap, IntPtr dispatchInfo, IntPtr resultOut);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionAlgorithm_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class CollisionConfiguration : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal CollisionConfiguration(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public CollisionAlgorithmCreateFunc GetCollisionAlgorithmCreateFunc(int proxyType0, int proxyType1)
|
||||
{
|
||||
return new CollisionAlgorithmCreateFunc(btCollisionConfiguration_getCollisionAlgorithmCreateFunc(_native, proxyType0, proxyType1));
|
||||
}
|
||||
/*
|
||||
public PoolAllocator CollisionAlgorithmPool
|
||||
{
|
||||
get { return btCollisionConfiguration_getCollisionAlgorithmPool(_native); }
|
||||
}
|
||||
|
||||
public PoolAllocator PersistentManifoldPool
|
||||
{
|
||||
get { return btCollisionConfiguration_getPersistentManifoldPool(_native); }
|
||||
}
|
||||
*/
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btCollisionConfiguration_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~CollisionConfiguration()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionConfiguration_getCollisionAlgorithmCreateFunc(IntPtr obj, int proxyType0, int proxyType1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionConfiguration_getCollisionAlgorithmPool(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionConfiguration_getPersistentManifoldPool(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionConfiguration_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class CollisionAlgorithmCreateFunc : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal CollisionAlgorithmCreateFunc(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public CollisionAlgorithmCreateFunc()
|
||||
{
|
||||
_native = btCollisionAlgorithmCreateFunc_new();
|
||||
}
|
||||
|
||||
public CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo __unnamed0, CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap)
|
||||
{
|
||||
return new CollisionAlgorithm(btCollisionAlgorithmCreateFunc_CreateCollisionAlgorithm(_native, __unnamed0._native, body0Wrap._native, body1Wrap._native));
|
||||
}
|
||||
|
||||
public bool Swapped
|
||||
{
|
||||
get { return btCollisionAlgorithmCreateFunc_getSwapped(_native); }
|
||||
set { btCollisionAlgorithmCreateFunc_setSwapped(_native, value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btCollisionAlgorithmCreateFunc_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~CollisionAlgorithmCreateFunc()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionAlgorithmCreateFunc_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionAlgorithmCreateFunc_CreateCollisionAlgorithm(IntPtr obj, IntPtr __unnamed0, IntPtr body0Wrap, IntPtr body1Wrap);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionAlgorithmCreateFunc_getSwapped(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionAlgorithmCreateFunc_setSwapped(IntPtr obj, bool value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionAlgorithmCreateFunc_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public enum DispatcherFlags
|
||||
{
|
||||
StaticStaticReported = 1,
|
||||
UseRelativeContactBreakingThreshold = 2,
|
||||
DisableContactPoolDynamicAllocation = 4
|
||||
}
|
||||
|
||||
public delegate void NearCallback(BroadphasePair collisionPair, CollisionDispatcher dispatcher, DispatcherInfo dispatchInfo);
|
||||
|
||||
public class CollisionDispatcher : Dispatcher
|
||||
{
|
||||
[UnmanagedFunctionPointer(Native.Conv)]
|
||||
private delegate void NearCallbackUnmanagedDelegate(IntPtr collisionPair, IntPtr dispatcher, IntPtr dispatchInfo);
|
||||
|
||||
protected CollisionConfiguration _collisionConfiguration;
|
||||
private List<CollisionAlgorithmCreateFunc> _collisionCreateFuncs;
|
||||
private NearCallback _nearCallback;
|
||||
private NearCallbackUnmanagedDelegate _nearCallbackUnmanaged;
|
||||
private IntPtr _nearCallbackUnmanagedPtr;
|
||||
|
||||
internal CollisionDispatcher(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public CollisionDispatcher(CollisionConfiguration collisionConfiguration)
|
||||
: base(btCollisionDispatcher_new(collisionConfiguration._native))
|
||||
{
|
||||
_collisionConfiguration = collisionConfiguration;
|
||||
}
|
||||
|
||||
public static void DefaultNearCallback(BroadphasePair collisionPair, CollisionDispatcher dispatcher, DispatcherInfo dispatchInfo)
|
||||
{
|
||||
btCollisionDispatcher_defaultNearCallback(collisionPair._native, dispatcher._native, dispatchInfo._native);
|
||||
}
|
||||
|
||||
public void NearCallbackUnmanaged(IntPtr collisionPair, IntPtr dispatcher, IntPtr dispatchInfo)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(dispatcher == _native);
|
||||
|
||||
_nearCallback(new BroadphasePair(collisionPair), this, new DispatcherInfo(dispatchInfo, true));
|
||||
}
|
||||
|
||||
public void RegisterCollisionCreateFunc(BroadphaseNativeType proxyType0, BroadphaseNativeType proxyType1, CollisionAlgorithmCreateFunc createFunc)
|
||||
{
|
||||
if (_collisionCreateFuncs == null)
|
||||
{
|
||||
_collisionCreateFuncs = new List<CollisionAlgorithmCreateFunc>();
|
||||
}
|
||||
_collisionCreateFuncs.Add(createFunc);
|
||||
|
||||
btCollisionDispatcher_registerCollisionCreateFunc(_native, proxyType0, proxyType1, createFunc._native);
|
||||
}
|
||||
|
||||
public CollisionConfiguration CollisionConfiguration
|
||||
{
|
||||
get { return _collisionConfiguration; }
|
||||
set
|
||||
{
|
||||
_collisionConfiguration = value;
|
||||
btCollisionDispatcher_setCollisionConfiguration(_native, value._native);
|
||||
}
|
||||
}
|
||||
|
||||
public DispatcherFlags DispatcherFlags
|
||||
{
|
||||
get { return btCollisionDispatcher_getDispatcherFlags(_native); }
|
||||
set { btCollisionDispatcher_setDispatcherFlags(_native, value); }
|
||||
}
|
||||
|
||||
public NearCallback NearCallback
|
||||
{
|
||||
get { return _nearCallback; }
|
||||
set
|
||||
{
|
||||
_nearCallback = value;
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
btCollisionDispatcher_setNearCallback(_native, IntPtr.Zero);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_nearCallbackUnmanaged == null)
|
||||
{
|
||||
_nearCallbackUnmanaged = new NearCallbackUnmanagedDelegate(NearCallbackUnmanaged);
|
||||
_nearCallbackUnmanagedPtr = Marshal.GetFunctionPointerForDelegate(_nearCallbackUnmanaged);
|
||||
}
|
||||
btCollisionDispatcher_setNearCallback(_native, _nearCallbackUnmanagedPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionDispatcher_new(IntPtr collisionConfiguration);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionDispatcher_defaultNearCallback(IntPtr collisionPair, IntPtr dispatcher, IntPtr dispatchInfo);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionDispatcher_getCollisionConfiguration(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern DispatcherFlags btCollisionDispatcher_getDispatcherFlags(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionDispatcher_getNearCallback(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionDispatcher_registerCollisionCreateFunc(IntPtr obj, BroadphaseNativeType proxyType0, BroadphaseNativeType proxyType1, IntPtr createFunc);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionDispatcher_setCollisionConfiguration(IntPtr obj, IntPtr config);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionDispatcher_setDispatcherFlags(IntPtr obj, DispatcherFlags flags);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionDispatcher_setNearCallback(IntPtr obj, IntPtr nearCallback);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,594 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public enum ActivationState
|
||||
{
|
||||
Undefined = 0,
|
||||
ActiveTag = 1,
|
||||
IslandSleeping = 2,
|
||||
WantsDeactivation = 3,
|
||||
DisableDeactivation = 4,
|
||||
DisableSimulation = 5
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum AnisotropicFrictionFlags
|
||||
{
|
||||
AnisotropicFrictionDisabled = 0,
|
||||
AnisotropicFriction = 1,
|
||||
AnisotropicRollingFriction = 2
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum CollisionFlags
|
||||
{
|
||||
StaticObject = 1,
|
||||
KinematicObject = 2,
|
||||
NoContactResponse = 4,
|
||||
CustomMaterialCallback = 8,
|
||||
CharacterObject = 16,
|
||||
DisableVisualizeObject = 32,
|
||||
DisableSpuCollisionProcessing = 64
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum CollisionObjectTypes
|
||||
{
|
||||
CollisionObject = 1,
|
||||
RigidBody = 2,
|
||||
GhostObject = 4,
|
||||
SoftBody = 8,
|
||||
HFFluid = 16,
|
||||
UserType = 32
|
||||
}
|
||||
|
||||
public class CollisionObject : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
internal bool _preventDelete;
|
||||
private bool _isDisposed;
|
||||
private BroadphaseProxy _broadphaseHandle;
|
||||
protected CollisionShape _collisionShape;
|
||||
|
||||
internal static CollisionObject GetManaged(IntPtr obj)
|
||||
{
|
||||
if (obj == IntPtr.Zero)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IntPtr userPtr = btCollisionObject_getUserPointer(obj);
|
||||
if (userPtr != IntPtr.Zero)
|
||||
{
|
||||
return GCHandle.FromIntPtr(userPtr).Target as CollisionObject;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Unknown collision object!");
|
||||
}
|
||||
|
||||
internal CollisionObject(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
GCHandle handle = GCHandle.Alloc(this, GCHandleType.Weak);
|
||||
btCollisionObject_setUserPointer(_native, GCHandle.ToIntPtr(handle));
|
||||
}
|
||||
|
||||
public CollisionObject()
|
||||
: this(btCollisionObject_new())
|
||||
{
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
btCollisionObject_activate(_native);
|
||||
}
|
||||
|
||||
public void Activate(bool forceActivation)
|
||||
{
|
||||
btCollisionObject_activate2(_native, forceActivation);
|
||||
}
|
||||
|
||||
public int CalculateSerializeBufferSize()
|
||||
{
|
||||
return btCollisionObject_calculateSerializeBufferSize(_native);
|
||||
}
|
||||
|
||||
public bool CheckCollideWith(CollisionObject co)
|
||||
{
|
||||
return btCollisionObject_checkCollideWith(_native, co._native);
|
||||
}
|
||||
|
||||
public bool CheckCollideWithOverride(CollisionObject co)
|
||||
{
|
||||
return btCollisionObject_checkCollideWithOverride(_native, co._native);
|
||||
}
|
||||
|
||||
public void ForceActivationState(ActivationState newState)
|
||||
{
|
||||
btCollisionObject_forceActivationState(_native, newState);
|
||||
}
|
||||
|
||||
public void GetWorldTransform(out Matrix transform)
|
||||
{
|
||||
btCollisionObject_getWorldTransform(_native, out transform);
|
||||
}
|
||||
|
||||
public bool HasAnisotropicFriction()
|
||||
{
|
||||
return btCollisionObject_hasAnisotropicFriction(_native);
|
||||
}
|
||||
|
||||
public bool HasAnisotropicFriction(AnisotropicFrictionFlags frictionMode)
|
||||
{
|
||||
return btCollisionObject_hasAnisotropicFriction2(_native, frictionMode);
|
||||
}
|
||||
|
||||
public IntPtr InternalGetExtensionPointer()
|
||||
{
|
||||
return btCollisionObject_internalGetExtensionPointer(_native);
|
||||
}
|
||||
|
||||
public void InternalSetExtensionPointer(IntPtr pointer)
|
||||
{
|
||||
btCollisionObject_internalSetExtensionPointer(_native, pointer);
|
||||
}
|
||||
|
||||
public bool MergesSimulationIslands()
|
||||
{
|
||||
return btCollisionObject_mergesSimulationIslands(_native);
|
||||
}
|
||||
|
||||
public string Serialize(IntPtr dataBuffer, Serializer serializer)
|
||||
{
|
||||
return Marshal.PtrToStringAnsi(btCollisionObject_serialize(_native, dataBuffer, serializer._native));
|
||||
}
|
||||
|
||||
public void SerializeSingleObject(Serializer serializer)
|
||||
{
|
||||
btCollisionObject_serializeSingleObject(_native, serializer._native);
|
||||
}
|
||||
|
||||
public void SetAnisotropicFriction(ref Vector3 anisotropicFriction)
|
||||
{
|
||||
btCollisionObject_setAnisotropicFriction(_native, ref anisotropicFriction);
|
||||
}
|
||||
|
||||
public void SetAnisotropicFriction(Vector3 anisotropicFriction)
|
||||
{
|
||||
btCollisionObject_setAnisotropicFriction(_native, ref anisotropicFriction);
|
||||
}
|
||||
|
||||
public void SetAnisotropicFriction(ref Vector3 anisotropicFriction, AnisotropicFrictionFlags frictionMode)
|
||||
{
|
||||
btCollisionObject_setAnisotropicFriction2(_native, ref anisotropicFriction, frictionMode);
|
||||
}
|
||||
|
||||
public void SetAnisotropicFriction(Vector3 anisotropicFriction, AnisotropicFrictionFlags frictionMode)
|
||||
{
|
||||
btCollisionObject_setAnisotropicFriction2(_native, ref anisotropicFriction, frictionMode);
|
||||
}
|
||||
|
||||
public void SetIgnoreCollisionCheck(CollisionObject co, bool ignoreCollisionCheck)
|
||||
{
|
||||
btCollisionObject_setIgnoreCollisionCheck(_native, co._native, ignoreCollisionCheck);
|
||||
}
|
||||
|
||||
public ActivationState ActivationState
|
||||
{
|
||||
get { return btCollisionObject_getActivationState(_native); }
|
||||
set { btCollisionObject_setActivationState(_native, value); }
|
||||
}
|
||||
|
||||
public Vector3 AnisotropicFriction
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btCollisionObject_getAnisotropicFriction(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btCollisionObject_setAnisotropicFriction(_native, ref value); }
|
||||
}
|
||||
|
||||
public BroadphaseProxy BroadphaseHandle
|
||||
{
|
||||
get { return _broadphaseHandle; }
|
||||
set
|
||||
{
|
||||
_broadphaseHandle = value;
|
||||
btCollisionObject_setBroadphaseHandle(_native, (value != null) ? value._native : IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
public float CcdMotionThreshold
|
||||
{
|
||||
get { return btCollisionObject_getCcdMotionThreshold(_native); }
|
||||
set { btCollisionObject_setCcdMotionThreshold(_native, value); }
|
||||
}
|
||||
|
||||
public float CcdSquareMotionThreshold
|
||||
{
|
||||
get { return btCollisionObject_getCcdSquareMotionThreshold(_native); }
|
||||
}
|
||||
|
||||
public float CcdSweptSphereRadius
|
||||
{
|
||||
get { return btCollisionObject_getCcdSweptSphereRadius(_native); }
|
||||
set { btCollisionObject_setCcdSweptSphereRadius(_native, value); }
|
||||
}
|
||||
|
||||
public CollisionFlags CollisionFlags
|
||||
{
|
||||
get { return btCollisionObject_getCollisionFlags(_native); }
|
||||
set { btCollisionObject_setCollisionFlags(_native, value); }
|
||||
}
|
||||
|
||||
public CollisionShape CollisionShape
|
||||
{
|
||||
get { return _collisionShape; }
|
||||
set
|
||||
{
|
||||
btCollisionObject_setCollisionShape(_native, value._native);
|
||||
_collisionShape = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int CompanionId
|
||||
{
|
||||
get { return btCollisionObject_getCompanionId(_native); }
|
||||
set { btCollisionObject_setCompanionId(_native, value); }
|
||||
}
|
||||
|
||||
public float ContactProcessingThreshold
|
||||
{
|
||||
get { return btCollisionObject_getContactProcessingThreshold(_native); }
|
||||
set { btCollisionObject_setContactProcessingThreshold(_native, value); }
|
||||
}
|
||||
|
||||
public float DeactivationTime
|
||||
{
|
||||
get { return btCollisionObject_getDeactivationTime(_native); }
|
||||
set { btCollisionObject_setDeactivationTime(_native, value); }
|
||||
}
|
||||
|
||||
public float Friction
|
||||
{
|
||||
get { return btCollisionObject_getFriction(_native); }
|
||||
set { btCollisionObject_setFriction(_native, value); }
|
||||
}
|
||||
|
||||
public bool HasContactResponse
|
||||
{
|
||||
get { return btCollisionObject_hasContactResponse(_native); }
|
||||
}
|
||||
|
||||
public float HitFraction
|
||||
{
|
||||
get { return btCollisionObject_getHitFraction(_native); }
|
||||
set { btCollisionObject_setHitFraction(_native, value); }
|
||||
}
|
||||
|
||||
public CollisionObjectTypes InternalType
|
||||
{
|
||||
get { return btCollisionObject_getInternalType(_native); }
|
||||
}
|
||||
|
||||
public Vector3 InterpolationAngularVelocity
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btCollisionObject_getInterpolationAngularVelocity(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btCollisionObject_setInterpolationAngularVelocity(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 InterpolationLinearVelocity
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btCollisionObject_getInterpolationLinearVelocity(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btCollisionObject_setInterpolationLinearVelocity(_native, ref value); }
|
||||
}
|
||||
|
||||
public Matrix InterpolationWorldTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix value;
|
||||
btCollisionObject_getInterpolationWorldTransform(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btCollisionObject_setInterpolationWorldTransform(_native, ref value); }
|
||||
}
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get { return btCollisionObject_isActive(_native); }
|
||||
}
|
||||
|
||||
public bool IsKinematicObject
|
||||
{
|
||||
get { return btCollisionObject_isKinematicObject(_native); }
|
||||
}
|
||||
|
||||
public int IslandTag
|
||||
{
|
||||
get { return btCollisionObject_getIslandTag(_native); }
|
||||
set { btCollisionObject_setIslandTag(_native, value); }
|
||||
}
|
||||
|
||||
public bool IsStaticObject
|
||||
{
|
||||
get { return btCollisionObject_isStaticObject(_native); }
|
||||
}
|
||||
|
||||
public bool IsStaticOrKinematicObject
|
||||
{
|
||||
get { return btCollisionObject_isStaticOrKinematicObject(_native); }
|
||||
}
|
||||
|
||||
public float Restitution
|
||||
{
|
||||
get { return btCollisionObject_getRestitution(_native); }
|
||||
set { btCollisionObject_setRestitution(_native, value); }
|
||||
}
|
||||
|
||||
public float RollingFriction
|
||||
{
|
||||
get { return btCollisionObject_getRollingFriction(_native); }
|
||||
set { btCollisionObject_setRollingFriction(_native, value); }
|
||||
}
|
||||
|
||||
public object UserObject { get; set; }
|
||||
|
||||
public int UserIndex
|
||||
{
|
||||
get { return btCollisionObject_getUserIndex(_native); }
|
||||
set { btCollisionObject_setUserIndex(_native, value); }
|
||||
}
|
||||
|
||||
public Matrix WorldTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix value;
|
||||
btCollisionObject_getWorldTransform(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btCollisionObject_setWorldTransform(_native, ref value); }
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
CollisionObject colObj = obj as CollisionObject;
|
||||
if (colObj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return _native == colObj._native;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _native.ToInt32();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
{
|
||||
if (!_preventDelete)
|
||||
{
|
||||
// Is the object added to a world?
|
||||
if (btCollisionObject_getBroadphaseHandle(_native) != IntPtr.Zero)
|
||||
{
|
||||
BroadphaseHandle = null;
|
||||
//System.Diagnostics.Debugger.Break();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_isDisposed = true;
|
||||
|
||||
IntPtr userPtr = btCollisionObject_getUserPointer(_native);
|
||||
GCHandle.FromIntPtr(userPtr).Free();
|
||||
btCollisionObject_delete(_native);
|
||||
}
|
||||
}
|
||||
|
||||
~CollisionObject()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionObject_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_activate(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_activate2(IntPtr obj, bool forceActivation);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btCollisionObject_calculateSerializeBufferSize(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionObject_checkCollideWith(IntPtr obj, IntPtr co);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionObject_checkCollideWithOverride(IntPtr obj, IntPtr co);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_forceActivationState(IntPtr obj, ActivationState newState);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern ActivationState btCollisionObject_getActivationState(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_getAnisotropicFriction(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionObject_getBroadphaseHandle(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionObject_getCcdMotionThreshold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionObject_getCcdSquareMotionThreshold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionObject_getCcdSweptSphereRadius(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern CollisionFlags btCollisionObject_getCollisionFlags(IntPtr obj);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btCollisionObject_getCollisionShape(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btCollisionObject_getCompanionId(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionObject_getContactProcessingThreshold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionObject_getDeactivationTime(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionObject_getFriction(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionObject_getHitFraction(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern CollisionObjectTypes btCollisionObject_getInternalType(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_getInterpolationAngularVelocity(IntPtr obj, [Out] out Vector3 angvel);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_getInterpolationLinearVelocity(IntPtr obj, [Out] out Vector3 linvel);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_getInterpolationWorldTransform(IntPtr obj, [Out] out Matrix trans);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btCollisionObject_getIslandTag(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionObject_getRestitution(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionObject_getRollingFriction(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btCollisionObject_getUserIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionObject_getUserPointer(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_getWorldTransform(IntPtr obj, [Out] out Matrix worldTrans);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionObject_hasAnisotropicFriction(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionObject_hasAnisotropicFriction2(IntPtr obj, AnisotropicFrictionFlags frictionMode);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionObject_hasContactResponse(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionObject_internalGetExtensionPointer(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_internalSetExtensionPointer(IntPtr obj, IntPtr pointer);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionObject_isActive(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionObject_isKinematicObject(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionObject_isStaticObject(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionObject_isStaticOrKinematicObject(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionObject_mergesSimulationIslands(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionObject_serialize(IntPtr obj, IntPtr dataBuffer, IntPtr serializer);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_serializeSingleObject(IntPtr obj, IntPtr serializer);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setActivationState(IntPtr obj, ActivationState newState);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setAnisotropicFriction(IntPtr obj, [In] ref Vector3 anisotropicFriction);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setAnisotropicFriction2(IntPtr obj, [In] ref Vector3 anisotropicFriction, AnisotropicFrictionFlags frictionMode);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setBroadphaseHandle(IntPtr obj, IntPtr handle);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setCcdMotionThreshold(IntPtr obj, float ccdMotionThreshold);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setCcdSweptSphereRadius(IntPtr obj, float radius);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setCollisionFlags(IntPtr obj, CollisionFlags flags);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setCollisionShape(IntPtr obj, IntPtr collisionShape);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setCompanionId(IntPtr obj, int id);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setContactProcessingThreshold(IntPtr obj, float contactProcessingThreshold);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setDeactivationTime(IntPtr obj, float time);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setFriction(IntPtr obj, float frict);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setHitFraction(IntPtr obj, float hitFraction);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setIgnoreCollisionCheck(IntPtr obj, IntPtr co, bool ignoreCollisionCheck);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setInterpolationAngularVelocity(IntPtr obj, [In] ref Vector3 angvel);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setInterpolationLinearVelocity(IntPtr obj, [In] ref Vector3 linvel);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setInterpolationWorldTransform(IntPtr obj, [In] ref Matrix trans);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setIslandTag(IntPtr obj, int tag);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setRestitution(IntPtr obj, float rest);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setRollingFriction(IntPtr obj, float frict);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setUserIndex(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setUserPointer(IntPtr obj, IntPtr userPointer);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_setWorldTransform(IntPtr obj, [In] ref Matrix worldTrans);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObject_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct CollisionObjectFloatData
|
||||
{
|
||||
public IntPtr BroadphaseHandle;
|
||||
public IntPtr CollisionShape;
|
||||
public IntPtr RootCollisionShape;
|
||||
public IntPtr Name;
|
||||
public TransformFloatData WorldTransform;
|
||||
public TransformFloatData InterpolationWorldTransform;
|
||||
public Vector3FloatData InterpolationLinearVelocity;
|
||||
public Vector3FloatData InterpolationAngularVelocity;
|
||||
public Vector3FloatData AnisotropicFriction;
|
||||
public float ContactProcessingThreshold;
|
||||
public float DeactivationTime;
|
||||
public float Friction;
|
||||
public float RollingFriction;
|
||||
public float Restitution;
|
||||
public float HitFraction;
|
||||
public float CcdSweptSphereRadius;
|
||||
public float CcdMotionThreshold;
|
||||
public int HasAnisotropicFriction;
|
||||
public int CollisionFlags;
|
||||
public int IslandTag1;
|
||||
public int CompanionId;
|
||||
public int ActivationState1;
|
||||
public int InternalType;
|
||||
public int CheckCollideWith;
|
||||
public int Padding;
|
||||
|
||||
public static int Offset(string fieldName) { return Marshal.OffsetOf(typeof(CollisionObjectFloatData), fieldName).ToInt32(); }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class CollisionObjectWrapper
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal CollisionObjectWrapper(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public CollisionObject CollisionObject
|
||||
{
|
||||
get { return CollisionObject.GetManaged(btCollisionObjectWrapper_getCollisionObject(_native)); }
|
||||
set { btCollisionObjectWrapper_setCollisionObject(_native, value._native); }
|
||||
}
|
||||
|
||||
public CollisionShape CollisionShape
|
||||
{
|
||||
get { return CollisionShape.GetManaged(btCollisionObjectWrapper_getCollisionShape(_native)); }
|
||||
set { btCollisionObjectWrapper_setShape(_native, value._native); }
|
||||
}
|
||||
|
||||
public int Index
|
||||
{
|
||||
get { return btCollisionObjectWrapper_getIndex(_native); }
|
||||
set { btCollisionObjectWrapper_setIndex(_native, value); }
|
||||
}
|
||||
|
||||
public CollisionObjectWrapper Parent
|
||||
{
|
||||
get { return new CollisionObjectWrapper(btCollisionObjectWrapper_getParent(_native)); }
|
||||
set { btCollisionObjectWrapper_setParent(_native, value._native); }
|
||||
}
|
||||
|
||||
public int PartId
|
||||
{
|
||||
get { return btCollisionObjectWrapper_getPartId(_native); }
|
||||
set { btCollisionObjectWrapper_setPartId(_native, value); }
|
||||
}
|
||||
|
||||
public Matrix WorldTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix value;
|
||||
btCollisionObjectWrapper_getWorldTransform(_native, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionObjectWrapper_getCollisionObject(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionObjectWrapper_getCollisionShape(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btCollisionObjectWrapper_getIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionObjectWrapper_getParent(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btCollisionObjectWrapper_getPartId(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObjectWrapper_getWorldTransform(IntPtr obj, [Out] out Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObjectWrapper_setCollisionObject(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObjectWrapper_setIndex(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObjectWrapper_setParent(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObjectWrapper_setPartId(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionObjectWrapper_setShape(IntPtr obj, IntPtr value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,320 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class CollisionShape : IDisposable
|
||||
{
|
||||
internal readonly IntPtr _native;
|
||||
private bool _preventDelete;
|
||||
private bool _isDisposed;
|
||||
|
||||
internal static CollisionShape GetManaged(IntPtr obj)
|
||||
{
|
||||
if (obj == IntPtr.Zero)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IntPtr userPtr = btCollisionShape_getUserPointer(obj);
|
||||
return GCHandle.FromIntPtr(userPtr).Target as CollisionShape;
|
||||
}
|
||||
|
||||
internal CollisionShape(IntPtr native, bool preventDelete = false)
|
||||
{
|
||||
_native = native;
|
||||
if (preventDelete)
|
||||
{
|
||||
_preventDelete = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
GCHandle handle = GCHandle.Alloc(this, GCHandleType.Weak);
|
||||
btCollisionShape_setUserPointer(native, GCHandle.ToIntPtr(handle));
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 CalculateLocalInertia(float mass)
|
||||
{
|
||||
Vector3 inertia;
|
||||
btCollisionShape_calculateLocalInertia(_native, mass, out inertia);
|
||||
return inertia;
|
||||
}
|
||||
|
||||
public void CalculateLocalInertia(float mass, out Vector3 inertia)
|
||||
{
|
||||
btCollisionShape_calculateLocalInertia(_native, mass, out inertia);
|
||||
}
|
||||
|
||||
public int CalculateSerializeBufferSize()
|
||||
{
|
||||
return btCollisionShape_calculateSerializeBufferSize(_native);
|
||||
}
|
||||
|
||||
public void CalculateTemporalAabb(ref Matrix curTrans, ref Vector3 linvel, ref Vector3 angvel, float timeStep, out Vector3 temporalAabbMin, out Vector3 temporalAabbMax)
|
||||
{
|
||||
btCollisionShape_calculateTemporalAabb(_native, ref curTrans, ref linvel, ref angvel, timeStep, out temporalAabbMin, out temporalAabbMax);
|
||||
}
|
||||
|
||||
public void CalculateTemporalAabb(Matrix curTrans, Vector3 linvel, Vector3 angvel, float timeStep, out Vector3 temporalAabbMin, out Vector3 temporalAabbMax)
|
||||
{
|
||||
btCollisionShape_calculateTemporalAabb(_native, ref curTrans, ref linvel, ref angvel, timeStep, out temporalAabbMin, out temporalAabbMax);
|
||||
}
|
||||
|
||||
public void GetAabb(ref Matrix t, out Vector3 aabbMin, out Vector3 aabbMax)
|
||||
{
|
||||
btCollisionShape_getAabb(_native, ref t, out aabbMin, out aabbMax);
|
||||
}
|
||||
|
||||
public void GetAabb(Matrix t, out Vector3 aabbMin, out Vector3 aabbMax)
|
||||
{
|
||||
btCollisionShape_getAabb(_native, ref t, out aabbMin, out aabbMax);
|
||||
}
|
||||
|
||||
public void GetBoundingSphere(out Vector3 center, out float radius)
|
||||
{
|
||||
btCollisionShape_getBoundingSphere(_native, out center, out radius);
|
||||
}
|
||||
|
||||
public float GetContactBreakingThreshold(float defaultContactThresholdFactor)
|
||||
{
|
||||
return btCollisionShape_getContactBreakingThreshold(_native, defaultContactThresholdFactor);
|
||||
}
|
||||
|
||||
public virtual string Serialize(IntPtr dataBuffer, Serializer serializer)
|
||||
{
|
||||
return Marshal.PtrToStringAnsi(btCollisionShape_serialize(_native, dataBuffer, serializer._native));
|
||||
/*
|
||||
IntPtr name = serializer.FindNameForPointer(_native);
|
||||
IntPtr namePtr = serializer.GetUniquePointer(name);
|
||||
Marshal.WriteIntPtr(dataBuffer, namePtr);
|
||||
if (namePtr != IntPtr.Zero)
|
||||
{
|
||||
serializer.SerializeName(name);
|
||||
}
|
||||
Marshal.WriteInt32(dataBuffer, IntPtr.Size, (int)ShapeType);
|
||||
//Marshal.WriteInt32(dataBuffer, IntPtr.Size + sizeof(int), 0); //padding
|
||||
return "btCollisionShapeData";
|
||||
*/
|
||||
}
|
||||
|
||||
public void SerializeSingleShape(Serializer serializer)
|
||||
{
|
||||
int len = CalculateSerializeBufferSize();
|
||||
Chunk chunk = serializer.Allocate((uint)len, 1);
|
||||
string structType = Serialize(chunk.OldPtr, serializer);
|
||||
serializer.FinalizeChunk(chunk, structType, DnaID.Shape, _native);
|
||||
}
|
||||
|
||||
public float AngularMotionDisc
|
||||
{
|
||||
get { return btCollisionShape_getAngularMotionDisc(_native); }
|
||||
}
|
||||
|
||||
public Vector3 AnisotropicRollingFrictionDirection
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btCollisionShape_getAnisotropicRollingFrictionDirection(_native, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsCompound
|
||||
{
|
||||
get { return btCollisionShape_isCompound(_native); }
|
||||
}
|
||||
|
||||
public bool IsConcave
|
||||
{
|
||||
get { return btCollisionShape_isConcave(_native); }
|
||||
}
|
||||
|
||||
public bool IsConvex
|
||||
{
|
||||
get { return btCollisionShape_isConvex(_native); }
|
||||
}
|
||||
|
||||
public bool IsConvex2D
|
||||
{
|
||||
get { return btCollisionShape_isConvex2d(_native); }
|
||||
}
|
||||
|
||||
public bool IsDisposed
|
||||
{
|
||||
get { return _isDisposed; }
|
||||
}
|
||||
|
||||
public bool IsInfinite
|
||||
{
|
||||
get { return btCollisionShape_isInfinite(_native); }
|
||||
}
|
||||
|
||||
public bool IsNonMoving
|
||||
{
|
||||
get { return btCollisionShape_isNonMoving(_native); }
|
||||
}
|
||||
|
||||
public bool IsPolyhedral
|
||||
{
|
||||
get { return btCollisionShape_isPolyhedral(_native); }
|
||||
}
|
||||
|
||||
public bool IsSoftBody
|
||||
{
|
||||
get { return btCollisionShape_isSoftBody(_native); }
|
||||
}
|
||||
|
||||
public Vector3 LocalScaling
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btCollisionShape_getLocalScaling(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btCollisionShape_setLocalScaling(_native, ref value); }
|
||||
}
|
||||
|
||||
public float Margin
|
||||
{
|
||||
get { return btCollisionShape_getMargin(_native); }
|
||||
set { btCollisionShape_setMargin(_native, value); }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return Marshal.PtrToStringAnsi(btCollisionShape_getName(_native)); }
|
||||
}
|
||||
|
||||
public BroadphaseNativeType ShapeType
|
||||
{
|
||||
get { return btCollisionShape_getShapeType(_native); }
|
||||
}
|
||||
|
||||
public Object UserObject { get; set; }
|
||||
|
||||
public int UserIndex
|
||||
{
|
||||
get { return btCollisionShape_getUserIndex(_native); }
|
||||
set { btCollisionShape_setUserIndex(_native, value); }
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return object.ReferenceEquals(this, obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _native.ToInt32();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
{
|
||||
_isDisposed = true;
|
||||
|
||||
if (!_preventDelete)
|
||||
{
|
||||
IntPtr userPtr = btCollisionShape_getUserPointer(_native);
|
||||
GCHandle.FromIntPtr(userPtr).Free();
|
||||
|
||||
btCollisionShape_delete(_native);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~CollisionShape()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionShape_calculateLocalInertia(IntPtr obj, float mass, [Out] out Vector3 inertia);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btCollisionShape_calculateSerializeBufferSize(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionShape_calculateTemporalAabb(IntPtr obj, [In] ref Matrix curTrans, [In] ref Vector3 linvel, [In] ref Vector3 angvel, float timeStep, [Out] out Vector3 temporalAabbMin, [Out] out Vector3 temporalAabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionShape_getAabb(IntPtr obj, [In] ref Matrix t, [Out] out Vector3 aabbMin, [Out] out Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionShape_getAngularMotionDisc(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionShape_getAnisotropicRollingFrictionDirection(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionShape_getBoundingSphere(IntPtr obj, [Out] out Vector3 center, [Out] out float radius);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionShape_getContactBreakingThreshold(IntPtr obj, float defaultContactThresholdFactor);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionShape_getLocalScaling(IntPtr obj, [Out] out Vector3 scaling);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCollisionShape_getMargin(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionShape_getName(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern BroadphaseNativeType btCollisionShape_getShapeType(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btCollisionShape_getUserIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionShape_getUserPointer(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionShape_isCompound(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionShape_isConcave(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionShape_isConvex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionShape_isConvex2d(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionShape_isInfinite(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionShape_isNonMoving(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionShape_isPolyhedral(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btCollisionShape_isSoftBody(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCollisionShape_serialize(IntPtr obj, IntPtr dataBuffer, IntPtr serializer);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionShape_serializeSingleShape(IntPtr obj, IntPtr serializer);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionShape_setLocalScaling(IntPtr obj, [In] ref Vector3 scaling);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionShape_setMargin(IntPtr obj, float margin);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionShape_setUserIndex(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionShape_setUserPointer(IntPtr obj, IntPtr userPtr);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCollisionShape_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct CollisionShapeFloatData
|
||||
{
|
||||
public IntPtr Name;
|
||||
public int ShapeType;
|
||||
public int Padding;
|
||||
|
||||
public static int Offset(string fieldName) { return Marshal.OffsetOf(typeof(CollisionShapeFloatData), fieldName).ToInt32(); }
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class CompoundCollisionAlgorithm : ActivatingCollisionAlgorithm
|
||||
{
|
||||
public class CreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
public CreateFunc()
|
||||
: base(btCompoundCollisionAlgorithm_CreateFunc_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundCollisionAlgorithm_CreateFunc_new();
|
||||
}
|
||||
|
||||
public class SwappedCreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
public SwappedCreateFunc()
|
||||
: base(btCompoundCollisionAlgorithm_SwappedCreateFunc_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundCollisionAlgorithm_SwappedCreateFunc_new();
|
||||
}
|
||||
|
||||
internal CompoundCollisionAlgorithm(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public CompoundCollisionAlgorithm(CollisionAlgorithmConstructionInfo ci, CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, bool isSwapped)
|
||||
: base(btCompoundCollisionAlgorithm_new(ci._native, body0Wrap._native, body1Wrap._native, isSwapped))
|
||||
{
|
||||
}
|
||||
|
||||
public CollisionAlgorithm GetChildAlgorithm(int n)
|
||||
{
|
||||
return new CollisionAlgorithm(btCompoundCollisionAlgorithm_getChildAlgorithm(_native, n));
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundCollisionAlgorithm_new(IntPtr ci, IntPtr body0Wrap, IntPtr body1Wrap, bool isSwapped);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundCollisionAlgorithm_getChildAlgorithm(IntPtr obj, int n);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class CompoundCompoundCollisionAlgorithm : CompoundCollisionAlgorithm
|
||||
{
|
||||
public new class CreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
public CreateFunc()
|
||||
: base(btCompoundCompoundCollisionAlgorithm_CreateFunc_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundCompoundCollisionAlgorithm_CreateFunc_new();
|
||||
}
|
||||
|
||||
public new class SwappedCreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
public SwappedCreateFunc()
|
||||
: base(btCompoundCompoundCollisionAlgorithm_SwappedCreateFunc_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundCompoundCollisionAlgorithm_SwappedCreateFunc_new();
|
||||
}
|
||||
|
||||
public CompoundCompoundCollisionAlgorithm(CollisionAlgorithmConstructionInfo ci, CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, bool isSwapped)
|
||||
: base(btCompoundCompoundCollisionAlgorithm_new(ci._native, body0Wrap._native, body1Wrap._native, isSwapped))
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundCompoundCollisionAlgorithm_new(IntPtr ci, IntPtr body0Wrap, IntPtr body1Wrap, bool isSwapped);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class CompoundShapeChild
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
private CollisionShape _childShape;
|
||||
|
||||
internal CompoundShapeChild(IntPtr native, CollisionShape childShape)
|
||||
{
|
||||
_native = native;
|
||||
_childShape = childShape;
|
||||
}
|
||||
|
||||
public float ChildMargin
|
||||
{
|
||||
get { return btCompoundShapeChild_getChildMargin(_native); }
|
||||
set { btCompoundShapeChild_setChildMargin(_native, value); }
|
||||
}
|
||||
|
||||
public CollisionShape ChildShape
|
||||
{
|
||||
get { return _childShape; }
|
||||
set
|
||||
{
|
||||
_childShape = value;
|
||||
btCompoundShapeChild_setChildShape(_native, value._native);
|
||||
}
|
||||
}
|
||||
|
||||
public BroadphaseNativeType ChildShapeType
|
||||
{
|
||||
get { return btCompoundShapeChild_getChildShapeType(_native); }
|
||||
set { btCompoundShapeChild_setChildShapeType(_native, value); }
|
||||
}
|
||||
|
||||
public DbvtNode Node
|
||||
{
|
||||
get
|
||||
{
|
||||
IntPtr ptr = btCompoundShapeChild_getNode(_native);
|
||||
return (ptr != IntPtr.Zero) ? new DbvtNode(ptr) : null;
|
||||
}
|
||||
set { btCompoundShapeChild_setNode(_native, (value != null) ? value._native : IntPtr.Zero); }
|
||||
}
|
||||
|
||||
public Matrix Transform
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix value;
|
||||
btCompoundShapeChild_getTransform(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btCompoundShapeChild_setTransform(_native, ref value); }
|
||||
}
|
||||
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btCompoundShapeChild_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCompoundShapeChild_getChildMargin(IntPtr obj);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btCompoundShapeChild_getChildShape(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern BroadphaseNativeType btCompoundShapeChild_getChildShapeType(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundShapeChild_getNode(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCompoundShapeChild_getTransform(IntPtr obj, [Out] out Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCompoundShapeChild_setChildMargin(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCompoundShapeChild_setChildShape(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCompoundShapeChild_setChildShapeType(IntPtr obj, BroadphaseNativeType value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCompoundShapeChild_setNode(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCompoundShapeChild_setTransform(IntPtr obj, [In] ref Matrix value);
|
||||
}
|
||||
|
||||
public class CompoundShape : CollisionShape
|
||||
{
|
||||
private CompoundShapeChildArray _childList;
|
||||
|
||||
public CompoundShape()
|
||||
: base(btCompoundShape_new())
|
||||
{
|
||||
_childList = new CompoundShapeChildArray(_native);
|
||||
}
|
||||
|
||||
public CompoundShape(bool enableDynamicAabbTree)
|
||||
: base(btCompoundShape_new2(enableDynamicAabbTree))
|
||||
{
|
||||
_childList = new CompoundShapeChildArray(_native);
|
||||
}
|
||||
|
||||
public void AddChildShape(ref Matrix localTransform, CollisionShape shape)
|
||||
{
|
||||
_childList.AddChildShape(ref localTransform, shape);
|
||||
}
|
||||
|
||||
public void AddChildShape(Matrix localTransform, CollisionShape shape)
|
||||
{
|
||||
_childList.AddChildShape(ref localTransform, shape);
|
||||
}
|
||||
|
||||
public void CalculatePrincipalAxisTransform(float[] masses, ref Matrix principal, ref Vector3 inertia)
|
||||
{
|
||||
btCompoundShape_calculatePrincipalAxisTransform(_native, masses, ref principal, ref inertia);
|
||||
}
|
||||
|
||||
public void CalculatePrincipalAxisTransform(float[] masses, Matrix principal, Vector3 inertia)
|
||||
{
|
||||
btCompoundShape_calculatePrincipalAxisTransform(_native, masses, ref principal, ref inertia);
|
||||
}
|
||||
|
||||
public void CreateAabbTreeFromChildren()
|
||||
{
|
||||
btCompoundShape_createAabbTreeFromChildren(_native);
|
||||
}
|
||||
|
||||
public CollisionShape GetChildShape(int index)
|
||||
{
|
||||
return _childList[index].ChildShape;
|
||||
}
|
||||
|
||||
public void GetChildTransform(int index, out Matrix value)
|
||||
{
|
||||
btCompoundShape_getChildTransform(_native, index, out value);
|
||||
}
|
||||
|
||||
public Matrix GetChildTransform(int index)
|
||||
{
|
||||
Matrix value;
|
||||
btCompoundShape_getChildTransform(_native, index, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public void RecalculateLocalAabb()
|
||||
{
|
||||
btCompoundShape_recalculateLocalAabb(_native);
|
||||
}
|
||||
|
||||
public void RemoveChildShape(CollisionShape shape)
|
||||
{
|
||||
_childList.RemoveChildShape(shape);
|
||||
}
|
||||
|
||||
public void RemoveChildShapeByIndex(int childShapeIndex)
|
||||
{
|
||||
_childList.RemoveChildShapeByIndex(childShapeIndex);
|
||||
}
|
||||
|
||||
public void UpdateChildTransform(int childIndex, Matrix newChildTransform)
|
||||
{
|
||||
btCompoundShape_updateChildTransform(_native, childIndex, ref newChildTransform);
|
||||
}
|
||||
|
||||
public void UpdateChildTransform(int childIndex, Matrix newChildTransform, bool shouldRecalculateLocalAabb)
|
||||
{
|
||||
btCompoundShape_updateChildTransform2(_native, childIndex, ref newChildTransform, shouldRecalculateLocalAabb);
|
||||
}
|
||||
|
||||
public CompoundShapeChildArray ChildList
|
||||
{
|
||||
get { return _childList; }
|
||||
}
|
||||
|
||||
public Dbvt DynamicAabbTree
|
||||
{
|
||||
get { return new Dbvt(btCompoundShape_getDynamicAabbTree(_native), true); }
|
||||
}
|
||||
|
||||
public int NumChildShapes
|
||||
{
|
||||
get { return _childList.Count; }
|
||||
}
|
||||
|
||||
public int UpdateRevision
|
||||
{
|
||||
get { return btCompoundShape_getUpdateRevision(_native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundShape_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundShape_new2(bool enableDynamicAabbTree);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCompoundShape_calculatePrincipalAxisTransform(IntPtr obj, float[] masses, [In] ref Matrix principal, [In] ref Vector3 inertia);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCompoundShape_createAabbTreeFromChildren(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundShape_getChildList(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundShape_getChildShape(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCompoundShape_getChildTransform(IntPtr obj, int index, [Out] out Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCompoundShape_getDynamicAabbTree(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btCompoundShape_getUpdateRevision(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCompoundShape_recalculateLocalAabb(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCompoundShape_updateChildTransform(IntPtr obj, int childIndex, [In] ref Matrix newChildTransform);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCompoundShape_updateChildTransform2(IntPtr obj, int childIndex, [In] ref Matrix newChildTransform, bool shouldRecalculateLocalAabb);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct CompoundShapeFloatData
|
||||
{
|
||||
public CollisionShapeFloatData CollisionShapeData;
|
||||
public IntPtr ChildShapePtr;
|
||||
public int NumChildShapes;
|
||||
public float CollisionMargin;
|
||||
|
||||
public static int Offset(string fieldName) { return Marshal.OffsetOf(typeof(CompoundShapeFloatData), fieldName).ToInt32(); }
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct CompoundShapeChildFloatData
|
||||
{
|
||||
public TransformFloatData Transform;
|
||||
public IntPtr ChildShape;
|
||||
public int ChildShapeType;
|
||||
public float ChildMargin;
|
||||
|
||||
public static int Offset(string fieldName) { return Marshal.OffsetOf(typeof(CompoundShapeChildFloatData), fieldName).ToInt32(); }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public enum PhyScalarType
|
||||
{
|
||||
Float = 0,
|
||||
Double = 1,
|
||||
Integer = 2,
|
||||
Short = 3,
|
||||
FixedPoint88 = 4,
|
||||
UChar = 5
|
||||
}
|
||||
|
||||
public class ConcaveShape : CollisionShape
|
||||
{
|
||||
internal ConcaveShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public void ProcessAllTriangles(TriangleCallback callback, Vector3 aabbMin, Vector3 aabbMax)
|
||||
{
|
||||
btConcaveShape_processAllTriangles(_native, callback._native, ref aabbMin, ref aabbMax);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConcaveShape_processAllTriangles(IntPtr obj, IntPtr callback, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ConeShape : ConvexInternalShape
|
||||
{
|
||||
internal ConeShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public ConeShape(float radius, float height)
|
||||
: base(btConeShape_new(radius, height))
|
||||
{
|
||||
}
|
||||
|
||||
public int ConeUpIndex
|
||||
{
|
||||
get { return btConeShape_getConeUpIndex(_native); }
|
||||
set { btConeShape_setConeUpIndex(_native, value); }
|
||||
}
|
||||
|
||||
public float Height
|
||||
{
|
||||
get { return btConeShape_getHeight(_native); }
|
||||
}
|
||||
|
||||
public float Radius
|
||||
{
|
||||
get { return btConeShape_getRadius(_native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConeShape_new(float radius, float height);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btConeShape_getConeUpIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btConeShape_getHeight(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btConeShape_getRadius(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConeShape_setConeUpIndex(IntPtr obj, int upIndex);
|
||||
}
|
||||
|
||||
public class ConeShapeX : ConeShape
|
||||
{
|
||||
public ConeShapeX(float radius, float height)
|
||||
: base(btConeShapeX_new(radius, height))
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConeShapeX_new(float radius, float height);
|
||||
}
|
||||
|
||||
public class ConeShapeZ : ConeShape
|
||||
{
|
||||
public ConeShapeZ(float radius, float height)
|
||||
: base(btConeShapeZ_new(radius, height))
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConeShapeZ_new(float radius, float height);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ContinuousConvexCollision : ConvexCast
|
||||
{
|
||||
public ContinuousConvexCollision(ConvexShape shapeA, ConvexShape shapeB, VoronoiSimplexSolver simplexSolver, ConvexPenetrationDepthSolver penetrationDepthSolver)
|
||||
: base(btContinuousConvexCollision_new(shapeA._native, shapeB._native, simplexSolver._native, penetrationDepthSolver._native))
|
||||
{
|
||||
}
|
||||
|
||||
public ContinuousConvexCollision(ConvexShape shapeA, StaticPlaneShape plane)
|
||||
: base(btContinuousConvexCollision_new2(shapeA._native, plane._native))
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btContinuousConvexCollision_new(IntPtr shapeA, IntPtr shapeB, IntPtr simplexSolver, IntPtr penetrationDepthSolver);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btContinuousConvexCollision_new2(IntPtr shapeA, IntPtr plane);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class Convex2DConvex2DAlgorithm : ActivatingCollisionAlgorithm
|
||||
{
|
||||
public class CreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
VoronoiSimplexSolver _simplexSolver;
|
||||
ConvexPenetrationDepthSolver _pdSolver;
|
||||
|
||||
public CreateFunc(VoronoiSimplexSolver simplexSolver, ConvexPenetrationDepthSolver pdSolver)
|
||||
: base(btConvex2dConvex2dAlgorithm_CreateFunc_new(simplexSolver._native, pdSolver._native))
|
||||
{
|
||||
_simplexSolver = simplexSolver;
|
||||
_pdSolver = pdSolver;
|
||||
}
|
||||
|
||||
public int MinimumPointsPerturbationThreshold
|
||||
{
|
||||
get { return btConvex2dConvex2dAlgorithm_CreateFunc_getMinimumPointsPerturbationThreshold(_native); }
|
||||
set { btConvex2dConvex2dAlgorithm_CreateFunc_setMinimumPointsPerturbationThreshold(_native, value); }
|
||||
}
|
||||
|
||||
public int NumPerturbationIterations
|
||||
{
|
||||
get { return btConvex2dConvex2dAlgorithm_CreateFunc_getNumPerturbationIterations(_native); }
|
||||
set { btConvex2dConvex2dAlgorithm_CreateFunc_setNumPerturbationIterations(_native, value); }
|
||||
}
|
||||
|
||||
public ConvexPenetrationDepthSolver PdSolver
|
||||
{
|
||||
get { return _pdSolver; }
|
||||
set
|
||||
{
|
||||
_pdSolver = value;
|
||||
btConvex2dConvex2dAlgorithm_CreateFunc_setPdSolver(_native, value._native);
|
||||
}
|
||||
}
|
||||
|
||||
public VoronoiSimplexSolver SimplexSolver
|
||||
{
|
||||
get { return _simplexSolver; }
|
||||
set
|
||||
{
|
||||
_simplexSolver = value;
|
||||
btConvex2dConvex2dAlgorithm_CreateFunc_setSimplexSolver(_native, value._native);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvex2dConvex2dAlgorithm_CreateFunc_new(IntPtr simplexSolver, IntPtr pdSolver);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btConvex2dConvex2dAlgorithm_CreateFunc_getMinimumPointsPerturbationThreshold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btConvex2dConvex2dAlgorithm_CreateFunc_getNumPerturbationIterations(IntPtr obj);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btConvex2dConvex2dAlgorithm_CreateFunc_getPdSolver(IntPtr obj);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btConvex2dConvex2dAlgorithm_CreateFunc_getSimplexSolver(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvex2dConvex2dAlgorithm_CreateFunc_setMinimumPointsPerturbationThreshold(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvex2dConvex2dAlgorithm_CreateFunc_setNumPerturbationIterations(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvex2dConvex2dAlgorithm_CreateFunc_setPdSolver(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvex2dConvex2dAlgorithm_CreateFunc_setSimplexSolver(IntPtr obj, IntPtr value);
|
||||
}
|
||||
|
||||
public Convex2DConvex2DAlgorithm(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, VoronoiSimplexSolver simplexSolver, ConvexPenetrationDepthSolver pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold)
|
||||
: base(btConvex2dConvex2dAlgorithm_new(mf._native, ci._native, body0Wrap._native, body1Wrap._native, simplexSolver._native, pdSolver._native, numPerturbationIterations, minimumPointsPerturbationThreshold))
|
||||
{
|
||||
}
|
||||
|
||||
public void SetLowLevelOfDetail(bool useLowLevel)
|
||||
{
|
||||
btConvex2dConvex2dAlgorithm_setLowLevelOfDetail(_native, useLowLevel);
|
||||
}
|
||||
|
||||
public PersistentManifold Manifold
|
||||
{
|
||||
get { return new PersistentManifold(btConvex2dConvex2dAlgorithm_getManifold(_native), true); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvex2dConvex2dAlgorithm_new(IntPtr mf, IntPtr ci, IntPtr body0Wrap, IntPtr body1Wrap, IntPtr simplexSolver, IntPtr pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvex2dConvex2dAlgorithm_getManifold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvex2dConvex2dAlgorithm_setLowLevelOfDetail(IntPtr obj, bool useLowLevel);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class Convex2DShape : ConvexShape
|
||||
{
|
||||
private ConvexShape _childShape;
|
||||
|
||||
public Convex2DShape(ConvexShape convexChildShape)
|
||||
: base(btConvex2dShape_new(convexChildShape._native))
|
||||
{
|
||||
_childShape = convexChildShape;
|
||||
}
|
||||
|
||||
public ConvexShape ChildShape
|
||||
{
|
||||
get { return _childShape; }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvex2dShape_new(IntPtr convexChildShape);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btConvex2dShape_getChildShape(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ConvexCast : IDisposable
|
||||
{
|
||||
public class CastResult : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal CastResult(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public CastResult()
|
||||
{
|
||||
_native = btConvexCast_CastResult_new();
|
||||
}
|
||||
|
||||
public void DebugDraw(float fraction)
|
||||
{
|
||||
btConvexCast_CastResult_DebugDraw(_native, fraction);
|
||||
}
|
||||
|
||||
public void DrawCoordSystem(Matrix trans)
|
||||
{
|
||||
btConvexCast_CastResult_drawCoordSystem(_native, ref trans);
|
||||
}
|
||||
|
||||
public void ReportFailure(int errNo, int numIterations)
|
||||
{
|
||||
btConvexCast_CastResult_reportFailure(_native, errNo, numIterations);
|
||||
}
|
||||
|
||||
public float AllowedPenetration
|
||||
{
|
||||
get { return btConvexCast_CastResult_getAllowedPenetration(_native); }
|
||||
set { btConvexCast_CastResult_setAllowedPenetration(_native, value); }
|
||||
}
|
||||
|
||||
public IDebugDraw DebugDrawer
|
||||
{
|
||||
get { return BulletSharp.DebugDraw.GetManaged(btConvexCast_CastResult_getDebugDrawer(_native)); }
|
||||
set { btConvexCast_CastResult_setDebugDrawer(_native, BulletSharp.DebugDraw.GetUnmanaged(value)); }
|
||||
}
|
||||
|
||||
public float Fraction
|
||||
{
|
||||
get { return btConvexCast_CastResult_getFraction(_native); }
|
||||
set { btConvexCast_CastResult_setFraction(_native, value); }
|
||||
}
|
||||
|
||||
public Vector3 HitPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexCast_CastResult_getHitPoint(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btConvexCast_CastResult_setHitPoint(_native, ref value); }
|
||||
}
|
||||
|
||||
public Matrix HitTransformA
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix value;
|
||||
btConvexCast_CastResult_getHitTransformA(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btConvexCast_CastResult_setHitTransformA(_native, ref value); }
|
||||
}
|
||||
|
||||
public Matrix HitTransformB
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix value;
|
||||
btConvexCast_CastResult_getHitTransformB(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btConvexCast_CastResult_setHitTransformB(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 Normal
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexCast_CastResult_getNormal(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btConvexCast_CastResult_setNormal(_native, ref value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btConvexCast_CastResult_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~CastResult()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexCast_CastResult_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_DebugDraw(IntPtr obj, float fraction);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_drawCoordSystem(IntPtr obj, [In] ref Matrix trans);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btConvexCast_CastResult_getAllowedPenetration(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexCast_CastResult_getDebugDrawer(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btConvexCast_CastResult_getFraction(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_getHitPoint(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_getHitTransformA(IntPtr obj, [Out] out Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_getHitTransformB(IntPtr obj, [Out] out Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_getNormal(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_reportFailure(IntPtr obj, int errNo, int numIterations);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_setAllowedPenetration(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_setDebugDrawer(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_setFraction(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_setHitPoint(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_setHitTransformA(IntPtr obj, [In] ref Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_setHitTransformB(IntPtr obj, [In] ref Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_setNormal(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_CastResult_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
internal IntPtr _native;
|
||||
|
||||
internal ConvexCast(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public bool CalcTimeOfImpact(Matrix fromA, Matrix toA, Matrix fromB, Matrix toB, CastResult result)
|
||||
{
|
||||
return btConvexCast_calcTimeOfImpact(_native, ref fromA, ref toA, ref fromB, ref toB, result._native);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btConvexCast_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~ConvexCast()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btConvexCast_calcTimeOfImpact(IntPtr obj, [In] ref Matrix fromA, [In] ref Matrix toA, [In] ref Matrix fromB, [In] ref Matrix toB, IntPtr result);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexCast_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{/*
|
||||
public class ConvexTriangleCallback : TriangleCallback
|
||||
{
|
||||
internal ConvexTriangleCallback(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public ConvexTriangleCallback(Dispatcher dispatcher, CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, bool isSwapped)
|
||||
: base(btConvexTriangleCallback_new(dispatcher._native, body0Wrap._native, body1Wrap._native, isSwapped))
|
||||
{
|
||||
}
|
||||
|
||||
public void ClearCache()
|
||||
{
|
||||
btConvexTriangleCallback_clearCache(_native);
|
||||
}
|
||||
|
||||
public void ClearWrapperData()
|
||||
{
|
||||
btConvexTriangleCallback_clearWrapperData(_native);
|
||||
}
|
||||
|
||||
public void SetTimeStepAndCounters(float collisionMarginTriangle, DispatcherInfo dispatchInfo, CollisionObjectWrapper convexBodyWrap, CollisionObjectWrapper triBodyWrap, ManifoldResult resultOut)
|
||||
{
|
||||
btConvexTriangleCallback_setTimeStepAndCounters(_native, collisionMarginTriangle, dispatchInfo._native, convexBodyWrap._native, triBodyWrap._native, resultOut._native);
|
||||
}
|
||||
|
||||
public Vector3 AabbMax
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexTriangleCallback_getAabbMax(_native, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 AabbMin
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexTriangleCallback_getAabbMin(_native, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public PersistentManifold ManifoldPtr
|
||||
{
|
||||
get { return btConvexTriangleCallback_getManifoldPtr(_native); }
|
||||
set { btConvexTriangleCallback_setManifoldPtr(_native, value._native); }
|
||||
}
|
||||
|
||||
public int TriangleCount
|
||||
{
|
||||
get { return btConvexTriangleCallback_getTriangleCount(_native); }
|
||||
set { btConvexTriangleCallback_setTriangleCount(_native, value); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexTriangleCallback_new(IntPtr dispatcher, IntPtr body0Wrap, IntPtr body1Wrap, bool isSwapped);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexTriangleCallback_clearCache(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexTriangleCallback_clearWrapperData(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexTriangleCallback_getAabbMax(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexTriangleCallback_getAabbMin(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexTriangleCallback_getManifoldPtr(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btConvexTriangleCallback_getTriangleCount(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexTriangleCallback_setManifoldPtr(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexTriangleCallback_setTimeStepAndCounters(IntPtr obj, float collisionMarginTriangle, IntPtr dispatchInfo, IntPtr convexBodyWrap, IntPtr triBodyWrap, IntPtr resultOut);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexTriangleCallback_setTriangleCount(IntPtr obj, int value);
|
||||
}
|
||||
*/
|
||||
public class ConvexConcaveCollisionAlgorithm : ActivatingCollisionAlgorithm
|
||||
{
|
||||
public class CreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
public CreateFunc()
|
||||
: base(btConvexConcaveCollisionAlgorithm_CreateFunc_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexConcaveCollisionAlgorithm_CreateFunc_new();
|
||||
}
|
||||
|
||||
public class SwappedCreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
public SwappedCreateFunc()
|
||||
: base(btConvexConcaveCollisionAlgorithm_SwappedCreateFunc_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexConcaveCollisionAlgorithm_SwappedCreateFunc_new();
|
||||
}
|
||||
|
||||
public ConvexConcaveCollisionAlgorithm(CollisionAlgorithmConstructionInfo ci, CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, bool isSwapped)
|
||||
: base(btConvexConcaveCollisionAlgorithm_new(ci._native, body0Wrap._native, body1Wrap._native, isSwapped))
|
||||
{
|
||||
}
|
||||
|
||||
public void ClearCache()
|
||||
{
|
||||
btConvexConcaveCollisionAlgorithm_clearCache(_native);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexConcaveCollisionAlgorithm_new(IntPtr ci, IntPtr body0Wrap, IntPtr body1Wrap, bool isSwapped);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexConcaveCollisionAlgorithm_clearCache(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ConvexConvexAlgorithm : ActivatingCollisionAlgorithm
|
||||
{
|
||||
public class CreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
public CreateFunc(VoronoiSimplexSolver simplexSolver, ConvexPenetrationDepthSolver pdSolver)
|
||||
: base(btConvexConvexAlgorithm_CreateFunc_new(simplexSolver._native, pdSolver._native))
|
||||
{
|
||||
}
|
||||
|
||||
public int MinimumPointsPerturbationThreshold
|
||||
{
|
||||
get { return btConvexConvexAlgorithm_CreateFunc_getMinimumPointsPerturbationThreshold(_native); }
|
||||
set { btConvexConvexAlgorithm_CreateFunc_setMinimumPointsPerturbationThreshold(_native, value); }
|
||||
}
|
||||
|
||||
public int NumPerturbationIterations
|
||||
{
|
||||
get { return btConvexConvexAlgorithm_CreateFunc_getNumPerturbationIterations(_native); }
|
||||
set { btConvexConvexAlgorithm_CreateFunc_setNumPerturbationIterations(_native, value); }
|
||||
}
|
||||
|
||||
public ConvexPenetrationDepthSolver PdSolver
|
||||
{
|
||||
get { return new ConvexPenetrationDepthSolver(btConvexConvexAlgorithm_CreateFunc_getPdSolver(_native)); }
|
||||
set { btConvexConvexAlgorithm_CreateFunc_setPdSolver(_native, value._native); }
|
||||
}
|
||||
|
||||
public VoronoiSimplexSolver SimplexSolver
|
||||
{
|
||||
get { return new VoronoiSimplexSolver(btConvexConvexAlgorithm_CreateFunc_getSimplexSolver(_native), true); }
|
||||
set { btConvexConvexAlgorithm_CreateFunc_setSimplexSolver(_native, value._native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexConvexAlgorithm_CreateFunc_new(IntPtr simplexSolver, IntPtr pdSolver);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btConvexConvexAlgorithm_CreateFunc_getMinimumPointsPerturbationThreshold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btConvexConvexAlgorithm_CreateFunc_getNumPerturbationIterations(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexConvexAlgorithm_CreateFunc_getPdSolver(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexConvexAlgorithm_CreateFunc_getSimplexSolver(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexConvexAlgorithm_CreateFunc_setMinimumPointsPerturbationThreshold(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexConvexAlgorithm_CreateFunc_setNumPerturbationIterations(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexConvexAlgorithm_CreateFunc_setPdSolver(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexConvexAlgorithm_CreateFunc_setSimplexSolver(IntPtr obj, IntPtr value);
|
||||
}
|
||||
|
||||
public ConvexConvexAlgorithm(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, VoronoiSimplexSolver simplexSolver, ConvexPenetrationDepthSolver pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold)
|
||||
: base(btConvexConvexAlgorithm_new(mf._native, ci._native, body0Wrap._native, body1Wrap._native, simplexSolver._native, pdSolver._native, numPerturbationIterations, minimumPointsPerturbationThreshold))
|
||||
{
|
||||
}
|
||||
|
||||
public void SetLowLevelOfDetail(bool useLowLevel)
|
||||
{
|
||||
btConvexConvexAlgorithm_setLowLevelOfDetail(_native, useLowLevel);
|
||||
}
|
||||
|
||||
public PersistentManifold Manifold
|
||||
{
|
||||
get { return new PersistentManifold(btConvexConvexAlgorithm_getManifold(_native)); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexConvexAlgorithm_new(IntPtr mf, IntPtr ci, IntPtr body0Wrap, IntPtr body1Wrap, IntPtr simplexSolver, IntPtr pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexConvexAlgorithm_getManifold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexConvexAlgorithm_setLowLevelOfDetail(IntPtr obj, bool useLowLevel);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Collections.Generic;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ConvexHullShape : PolyhedralConvexAabbCachingShape
|
||||
{
|
||||
private Vector3Array _points;
|
||||
private Vector3Array _unscaledPoints;
|
||||
|
||||
public ConvexHullShape()
|
||||
: base(btConvexHullShape_new())
|
||||
{
|
||||
}
|
||||
|
||||
public ConvexHullShape(float[] points)
|
||||
: this(points, points.Length, 3)
|
||||
{
|
||||
}
|
||||
|
||||
public ConvexHullShape(float[] points, int numPoints)
|
||||
: this(points, numPoints, 3)
|
||||
{
|
||||
}
|
||||
|
||||
public ConvexHullShape(float[] points, int numPoints, int stride)
|
||||
: base(btConvexHullShape_new4(points, numPoints, stride))
|
||||
{
|
||||
}
|
||||
|
||||
public ConvexHullShape(IEnumerable<Vector3> points, int numPoints)
|
||||
: base(btConvexHullShape_new())
|
||||
{
|
||||
int i = 0;
|
||||
foreach (Vector3 v in points)
|
||||
{
|
||||
Vector3 viter = v;
|
||||
btConvexHullShape_addPoint(_native, ref viter);
|
||||
i++;
|
||||
if (i == numPoints)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
RecalcLocalAabb();
|
||||
}
|
||||
|
||||
public ConvexHullShape(IEnumerable<Vector3> points)
|
||||
: base(btConvexHullShape_new())
|
||||
{
|
||||
foreach (Vector3 v in points)
|
||||
{
|
||||
Vector3 viter = v;
|
||||
btConvexHullShape_addPoint(_native, ref viter);
|
||||
}
|
||||
RecalcLocalAabb();
|
||||
}
|
||||
|
||||
public void AddPoint(ref Vector3 point)
|
||||
{
|
||||
btConvexHullShape_addPoint(_native, ref point);
|
||||
}
|
||||
|
||||
public void AddPoint(Vector3 point)
|
||||
{
|
||||
btConvexHullShape_addPoint(_native, ref point);
|
||||
}
|
||||
|
||||
public void AddPoint(ref Vector3 point, bool recalculateLocalAabb)
|
||||
{
|
||||
btConvexHullShape_addPoint2(_native, ref point, recalculateLocalAabb);
|
||||
}
|
||||
|
||||
public void AddPoint(Vector3 point, bool recalculateLocalAabb)
|
||||
{
|
||||
btConvexHullShape_addPoint2(_native, ref point, recalculateLocalAabb);
|
||||
}
|
||||
|
||||
public void GetScaledPoint(int i, out Vector3 value)
|
||||
{
|
||||
btConvexHullShape_getScaledPoint(_native, i, out value);
|
||||
}
|
||||
|
||||
public Vector3 GetScaledPoint(int i)
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexHullShape_getScaledPoint(_native, i, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public void Project(ref Matrix trans, ref Vector3 dir, out float minProj, out float maxProj, out Vector3 witnesPtMin, out Vector3 witnesPtMax)
|
||||
{
|
||||
btConvexHullShape_project(_native, ref trans, ref dir, out minProj, out maxProj, out witnesPtMin, out witnesPtMax);
|
||||
}
|
||||
|
||||
public void Project(Matrix trans, Vector3 dir, out float minProj, out float maxProj, out Vector3 witnesPtMin, out Vector3 witnesPtMax)
|
||||
{
|
||||
btConvexHullShape_project(_native, ref trans, ref dir, out minProj, out maxProj, out witnesPtMin, out witnesPtMax);
|
||||
}
|
||||
|
||||
public int NumPoints
|
||||
{
|
||||
get { return btConvexHullShape_getNumPoints(_native); }
|
||||
}
|
||||
|
||||
public Vector3Array Points
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_points == null || _points.Count != NumPoints)
|
||||
{
|
||||
_points = new Vector3Array(btConvexHullShape_getPoints(_native), NumPoints);
|
||||
}
|
||||
return _points;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3Array UnscaledPoints
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_unscaledPoints == null || _unscaledPoints.Count != NumPoints)
|
||||
{
|
||||
_unscaledPoints = new Vector3Array(btConvexHullShape_getUnscaledPoints(_native), NumPoints);
|
||||
}
|
||||
return _unscaledPoints;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexHullShape_new();
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btConvexHullShape_new2(Vector3[] points);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btConvexHullShape_new3(Vector3[] points, int numPoints);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexHullShape_new4(float[] points, int numPoints, int stride);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btConvexHullShape_new4(Vector3[] points, int numPoints, int stride);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexHullShape_addPoint(IntPtr obj, [In] ref Vector3 point);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexHullShape_addPoint2(IntPtr obj, [In] ref Vector3 point, bool recalculateLocalAabb);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btConvexHullShape_getNumPoints(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexHullShape_getPoints(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexHullShape_getScaledPoint(IntPtr obj, int i, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexHullShape_getUnscaledPoints(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexHullShape_project(IntPtr obj, [In] ref Matrix trans, [In] ref Vector3 dir, [Out] out float minProj, [Out] out float maxProj, [Out] out Vector3 witnesPtMin, [Out] out Vector3 witnesPtMax);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct ConvexHullShapeFloatData
|
||||
{
|
||||
public ConvexInternalShapeFloatData ConvexInternalShapeData;
|
||||
public IntPtr UnscaledPointsFloatPtr;
|
||||
public IntPtr UnscaledPointsDoublePtr;
|
||||
public int NumUnscaledPoints;
|
||||
public int Padding;
|
||||
|
||||
public static int Offset(string fieldName) { return Marshal.OffsetOf(typeof(ConvexHullShapeFloatData), fieldName).ToInt32(); }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ConvexInternalShape : ConvexShape
|
||||
{
|
||||
internal ConvexInternalShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetSafeMargin(float minDimension)
|
||||
{
|
||||
btConvexInternalShape_setSafeMargin(_native, minDimension);
|
||||
}
|
||||
|
||||
public void SetSafeMargin(float minDimension, float defaultMarginMultiplier)
|
||||
{
|
||||
btConvexInternalShape_setSafeMargin2(_native, minDimension, defaultMarginMultiplier);
|
||||
}
|
||||
|
||||
public void SetSafeMargin(ref Vector3 halfExtents)
|
||||
{
|
||||
btConvexInternalShape_setSafeMargin3(_native, ref halfExtents);
|
||||
}
|
||||
|
||||
public void SetSafeMargin(Vector3 halfExtents)
|
||||
{
|
||||
btConvexInternalShape_setSafeMargin3(_native, ref halfExtents);
|
||||
}
|
||||
|
||||
public void SetSafeMargin(ref Vector3 halfExtents, float defaultMarginMultiplier)
|
||||
{
|
||||
btConvexInternalShape_setSafeMargin4(_native, ref halfExtents, defaultMarginMultiplier);
|
||||
}
|
||||
|
||||
public void SetSafeMargin(Vector3 halfExtents, float defaultMarginMultiplier)
|
||||
{
|
||||
btConvexInternalShape_setSafeMargin4(_native, ref halfExtents, defaultMarginMultiplier);
|
||||
}
|
||||
|
||||
public Vector3 ImplicitShapeDimensions
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexInternalShape_getImplicitShapeDimensions(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btConvexInternalShape_setImplicitShapeDimensions(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 LocalScalingNV
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexInternalShape_getLocalScalingNV(_native, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public float MarginNV
|
||||
{
|
||||
get { return btConvexInternalShape_getMarginNV(_native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexInternalShape_getImplicitShapeDimensions(IntPtr obj, [Out] out Vector3 dimensions);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexInternalShape_getLocalScalingNV(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btConvexInternalShape_getMarginNV(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexInternalShape_setImplicitShapeDimensions(IntPtr obj, [In] ref Vector3 dimensions);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexInternalShape_setSafeMargin(IntPtr obj, float minDimension);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexInternalShape_setSafeMargin2(IntPtr obj, float minDimension, float defaultMarginMultiplier);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexInternalShape_setSafeMargin3(IntPtr obj, [In] ref Vector3 halfExtents);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexInternalShape_setSafeMargin4(IntPtr obj, [In] ref Vector3 halfExtents, float defaultMarginMultiplier);
|
||||
}
|
||||
|
||||
public class ConvexInternalAabbCachingShape : ConvexInternalShape
|
||||
{
|
||||
internal ConvexInternalAabbCachingShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public void RecalcLocalAabb()
|
||||
{
|
||||
btConvexInternalAabbCachingShape_recalcLocalAabb(_native);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexInternalAabbCachingShape_recalcLocalAabb(IntPtr obj);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct ConvexInternalShapeFloatData
|
||||
{
|
||||
public CollisionShapeFloatData CollisionShapeData;
|
||||
public Vector3FloatData LocalScaling;
|
||||
public Vector3FloatData ImplicitShapeDimensions;
|
||||
public float CollisionMargin;
|
||||
public int Padding;
|
||||
|
||||
public static int Offset(string fieldName) { return Marshal.OffsetOf(typeof(ConvexInternalShapeFloatData), fieldName).ToInt32(); }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ConvexPenetrationDepthSolver : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal ConvexPenetrationDepthSolver(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public bool CalcPenDepth(VoronoiSimplexSolver simplexSolver, ConvexShape convexA, ConvexShape convexB, Matrix transA, Matrix transB, out Vector3 v, out Vector3 pa, out Vector3 pb, IDebugDraw debugDraw)
|
||||
{
|
||||
return btConvexPenetrationDepthSolver_calcPenDepth(_native, simplexSolver._native, convexA._native, convexB._native, ref transA, ref transB, out v, out pa, out pb, DebugDraw.GetUnmanaged(debugDraw));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btConvexPenetrationDepthSolver_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~ConvexPenetrationDepthSolver()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btConvexPenetrationDepthSolver_calcPenDepth(IntPtr obj, IntPtr simplexSolver, IntPtr convexA, IntPtr convexB, [In] ref Matrix transA, [In] ref Matrix transB, [Out] out Vector3 v, [Out] out Vector3 pa, [Out] out Vector3 pb, IntPtr debugDraw);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPenetrationDepthSolver_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ConvexPlaneCollisionAlgorithm : CollisionAlgorithm
|
||||
{
|
||||
public class CreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
public CreateFunc()
|
||||
: base(btConvexPlaneCollisionAlgorithm_CreateFunc_new())
|
||||
{
|
||||
}
|
||||
|
||||
public int MinimumPointsPerturbationThreshold
|
||||
{
|
||||
get { return btConvexPlaneCollisionAlgorithm_CreateFunc_getMinimumPointsPerturbationThreshold(_native); }
|
||||
set { btConvexPlaneCollisionAlgorithm_CreateFunc_setMinimumPointsPerturbationThreshold(_native, value); }
|
||||
}
|
||||
|
||||
public int NumPerturbationIterations
|
||||
{
|
||||
get { return btConvexPlaneCollisionAlgorithm_CreateFunc_getNumPerturbationIterations(_native); }
|
||||
set { btConvexPlaneCollisionAlgorithm_CreateFunc_setNumPerturbationIterations(_native, value); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexPlaneCollisionAlgorithm_CreateFunc_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btConvexPlaneCollisionAlgorithm_CreateFunc_getMinimumPointsPerturbationThreshold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btConvexPlaneCollisionAlgorithm_CreateFunc_getNumPerturbationIterations(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPlaneCollisionAlgorithm_CreateFunc_setMinimumPointsPerturbationThreshold(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPlaneCollisionAlgorithm_CreateFunc_setNumPerturbationIterations(IntPtr obj, int value);
|
||||
}
|
||||
|
||||
internal ConvexPlaneCollisionAlgorithm(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public ConvexPlaneCollisionAlgorithm(PersistentManifold mf, CollisionAlgorithmConstructionInfo ci, CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, bool isSwapped, int numPerturbationIterations, int minimumPointsPerturbationThreshold)
|
||||
: base(btConvexPlaneCollisionAlgorithm_new(mf._native, ci._native, body0Wrap._native, body1Wrap._native, isSwapped, numPerturbationIterations, minimumPointsPerturbationThreshold))
|
||||
{
|
||||
}
|
||||
|
||||
public void CollideSingleContact(Quaternion perturbeRot, CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, DispatcherInfo dispatchInfo, ManifoldResult resultOut)
|
||||
{
|
||||
btConvexPlaneCollisionAlgorithm_collideSingleContact(_native, ref perturbeRot, body0Wrap._native, body1Wrap._native, dispatchInfo._native, resultOut._native);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexPlaneCollisionAlgorithm_new(IntPtr mf, IntPtr ci, IntPtr body0Wrap, IntPtr body1Wrap, bool isSwapped, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPlaneCollisionAlgorithm_collideSingleContact(IntPtr obj, [In] ref Quaternion perturbeRot, IntPtr body0Wrap, IntPtr body1Wrap, IntPtr dispatchInfo, IntPtr resultOut);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ConvexPointCloudShape : PolyhedralConvexAabbCachingShape
|
||||
{
|
||||
private Vector3Array _unscaledPoints;
|
||||
|
||||
public ConvexPointCloudShape()
|
||||
: base(btConvexPointCloudShape_new())
|
||||
{
|
||||
}
|
||||
|
||||
public ConvexPointCloudShape(Vector3Array points, int numPoints, ref Vector3 localScaling)
|
||||
: base(btConvexPointCloudShape_new2(points._native, numPoints, ref localScaling))
|
||||
{
|
||||
_unscaledPoints = points;
|
||||
}
|
||||
|
||||
public ConvexPointCloudShape(Vector3Array points, int numPoints, Vector3 localScaling)
|
||||
: this(points, numPoints, ref localScaling)
|
||||
{
|
||||
}
|
||||
|
||||
public ConvexPointCloudShape(Vector3Array points, int numPoints, ref Vector3 localScaling, bool computeAabb)
|
||||
: base(btConvexPointCloudShape_new3(points._native, numPoints, ref localScaling, computeAabb))
|
||||
{
|
||||
_unscaledPoints = points;
|
||||
}
|
||||
|
||||
public ConvexPointCloudShape(Vector3Array points, int numPoints, Vector3 localScaling, bool computeAabb)
|
||||
: this(points, numPoints, ref localScaling, computeAabb)
|
||||
{
|
||||
}
|
||||
|
||||
public void GetScaledPoint(int index, out Vector3 value)
|
||||
{
|
||||
btConvexPointCloudShape_getScaledPoint(_native, index, out value);
|
||||
}
|
||||
|
||||
public Vector3 GetScaledPoint(int index)
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexPointCloudShape_getScaledPoint(_native, index, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public void SetPoints(Vector3Array points, int numPoints)
|
||||
{
|
||||
_unscaledPoints = points;
|
||||
btConvexPointCloudShape_setPoints(_native, points._native, numPoints);
|
||||
}
|
||||
|
||||
public void SetPoints(Vector3Array points, int numPoints, bool computeAabb)
|
||||
{
|
||||
_unscaledPoints = points;
|
||||
btConvexPointCloudShape_setPoints2(_native, points._native, numPoints, computeAabb);
|
||||
}
|
||||
|
||||
public void SetPoints(Vector3Array points, int numPoints, bool computeAabb, ref Vector3 localScaling)
|
||||
{
|
||||
_unscaledPoints = points;
|
||||
btConvexPointCloudShape_setPoints3(_native, points._native, numPoints, computeAabb, ref localScaling);
|
||||
}
|
||||
|
||||
public void SetPoints(Vector3Array points, int numPoints, bool computeAabb, Vector3 localScaling)
|
||||
{
|
||||
_unscaledPoints = points;
|
||||
btConvexPointCloudShape_setPoints3(_native, points._native, numPoints, computeAabb, ref localScaling);
|
||||
}
|
||||
|
||||
public int NumPoints
|
||||
{
|
||||
get { return btConvexPointCloudShape_getNumPoints(_native); }
|
||||
}
|
||||
|
||||
public Vector3Array UnscaledPoints
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_unscaledPoints == null || _unscaledPoints.Count != NumPoints)
|
||||
{
|
||||
IntPtr unscaledPointsPtr = btConvexPointCloudShape_getUnscaledPoints(_native);
|
||||
if (unscaledPointsPtr != IntPtr.Zero)
|
||||
{
|
||||
_unscaledPoints = new Vector3Array(unscaledPointsPtr, NumPoints);
|
||||
}
|
||||
}
|
||||
return _unscaledPoints;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetPoints(value, value.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexPointCloudShape_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexPointCloudShape_new2(IntPtr points, int numPoints, [In] ref Vector3 localScaling);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexPointCloudShape_new3(IntPtr points, int numPoints, [In] ref Vector3 localScaling, bool computeAabb);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btConvexPointCloudShape_getNumPoints(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPointCloudShape_getScaledPoint(IntPtr obj, int index, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexPointCloudShape_getUnscaledPoints(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPointCloudShape_setPoints(IntPtr obj, IntPtr points, int numPoints);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPointCloudShape_setPoints2(IntPtr obj, IntPtr points, int numPoints, bool computeAabb);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPointCloudShape_setPoints3(IntPtr obj, IntPtr points, int numPoints, bool computeAabb, [In] ref Vector3 localScaling);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,241 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class Face : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal Face(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public Face()
|
||||
{
|
||||
_native = btFace_new();
|
||||
}
|
||||
/*
|
||||
public AlignedIntArray Indices
|
||||
{
|
||||
get { return new AlignedIntArray(btFace_getIndices(_native)); }
|
||||
}
|
||||
|
||||
public ScalarArray Plane
|
||||
{
|
||||
get { return new ScalarArray(btFace_getPlane(_native)); }
|
||||
}
|
||||
*/
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btFace_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~Face()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btFace_new();
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btFace_getIndices(IntPtr obj);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btFace_getPlane(IntPtr obj);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern void btFace_setIndices(IntPtr obj, AlignedObjectArray value);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern void btFace_setPlane(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btFace_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class ConvexPolyhedron : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
//AlignedFaceArray _faces;
|
||||
AlignedVector3Array _uniqueEdges;
|
||||
AlignedVector3Array _vertices;
|
||||
|
||||
internal ConvexPolyhedron(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public ConvexPolyhedron()
|
||||
{
|
||||
_native = btConvexPolyhedron_new();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
btConvexPolyhedron_initialize(_native);
|
||||
}
|
||||
|
||||
public void Project(ref Matrix trans, ref Vector3 dir, out float minProj, out float maxProj, out Vector3 witnesPtMin, out Vector3 witnesPtMax)
|
||||
{
|
||||
btConvexPolyhedron_project(_native, ref trans, ref dir, out minProj, out maxProj, out witnesPtMin, out witnesPtMax);
|
||||
}
|
||||
|
||||
public void Project(Matrix trans, Vector3 dir, out float minProj, out float maxProj, out Vector3 witnesPtMin, out Vector3 witnesPtMax)
|
||||
{
|
||||
btConvexPolyhedron_project(_native, ref trans, ref dir, out minProj, out maxProj, out witnesPtMin, out witnesPtMax);
|
||||
}
|
||||
|
||||
public bool TestContainment()
|
||||
{
|
||||
return btConvexPolyhedron_testContainment(_native);
|
||||
}
|
||||
|
||||
public Vector3 Extents
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexPolyhedron_getExtents(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btConvexPolyhedron_setExtents(_native, ref value); }
|
||||
}
|
||||
/*
|
||||
public AlignedFaceArray Faces
|
||||
{
|
||||
get { return btConvexPolyhedron_getFaces(_native); }
|
||||
}
|
||||
*/
|
||||
public Vector3 LocalCenter
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexPolyhedron_getLocalCenter(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btConvexPolyhedron_setLocalCenter(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 C
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexPolyhedron_getMC(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btConvexPolyhedron_setMC(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 E
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexPolyhedron_getME(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btConvexPolyhedron_setME(_native, ref value); }
|
||||
}
|
||||
|
||||
public float Radius
|
||||
{
|
||||
get { return btConvexPolyhedron_getRadius(_native); }
|
||||
set { btConvexPolyhedron_setRadius(_native, value); }
|
||||
}
|
||||
|
||||
public AlignedVector3Array UniqueEdges
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_uniqueEdges == null)
|
||||
{
|
||||
_uniqueEdges = new AlignedVector3Array(btConvexPolyhedron_getUniqueEdges(_native));
|
||||
}
|
||||
return _uniqueEdges;
|
||||
}
|
||||
}
|
||||
|
||||
public AlignedVector3Array Vertices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_vertices == null)
|
||||
{
|
||||
_vertices = new AlignedVector3Array(btConvexPolyhedron_getVertices(_native));
|
||||
}
|
||||
return _vertices;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btConvexPolyhedron_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~ConvexPolyhedron()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexPolyhedron_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPolyhedron_getExtents(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexPolyhedron_getFaces(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPolyhedron_getLocalCenter(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPolyhedron_getMC(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPolyhedron_getME(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btConvexPolyhedron_getRadius(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexPolyhedron_getUniqueEdges(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexPolyhedron_getVertices(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPolyhedron_initialize(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPolyhedron_project(IntPtr obj, [In] ref Matrix trans, [In] ref Vector3 dir, [Out] out float minProj, [Out] out float maxProj, [Out] out Vector3 witnesPtMin, [Out] out Vector3 witnesPtMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPolyhedron_setExtents(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPolyhedron_setLocalCenter(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPolyhedron_setMC(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPolyhedron_setME(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPolyhedron_setRadius(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btConvexPolyhedron_testContainment(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexPolyhedron_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ConvexShape : CollisionShape
|
||||
{
|
||||
internal ConvexShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
/*
|
||||
public void BatchedUnitVectorGetSupportingVertexWithoutMargin(Vector3 vectors, Vector3 supportVerticesOut, int numVectors)
|
||||
{
|
||||
btConvexShape_batchedUnitVectorGetSupportingVertexWithoutMargin(_native, vectors._native, supportVerticesOut._native, numVectors);
|
||||
}
|
||||
*/
|
||||
|
||||
public void GetAabbNonVirtual(ref Matrix t, out Vector3 aabbMin, out Vector3 aabbMax)
|
||||
{
|
||||
btConvexShape_getAabbNonVirtual(_native, ref t, out aabbMin, out aabbMax);
|
||||
}
|
||||
|
||||
public void GetAabbNonVirtual(Matrix t, out Vector3 aabbMin, out Vector3 aabbMax)
|
||||
{
|
||||
btConvexShape_getAabbNonVirtual(_native, ref t, out aabbMin, out aabbMax);
|
||||
}
|
||||
|
||||
public void GetAabbSlow(ref Matrix t, out Vector3 aabbMin, out Vector3 aabbMax)
|
||||
{
|
||||
btConvexShape_getAabbSlow(_native, ref t, out aabbMin, out aabbMax);
|
||||
}
|
||||
|
||||
public void GetAabbSlow(Matrix t, out Vector3 aabbMin, out Vector3 aabbMax)
|
||||
{
|
||||
btConvexShape_getAabbSlow(_native, ref t, out aabbMin, out aabbMax);
|
||||
}
|
||||
|
||||
public void GetPreferredPenetrationDirection(int index, out Vector3 penetrationVector)
|
||||
{
|
||||
btConvexShape_getPreferredPenetrationDirection(_native, index, out penetrationVector);
|
||||
}
|
||||
|
||||
public Vector3 LocalGetSupportingVertex(ref Vector3 vec)
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexShape_localGetSupportingVertex(_native, ref vec, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Vector3 LocalGetSupportingVertex(Vector3 vec)
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexShape_localGetSupportingVertex(_native, ref vec, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Vector3 LocalGetSupportingVertexWithoutMargin(ref Vector3 vec)
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexShape_localGetSupportingVertexWithoutMargin(_native, ref vec, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Vector3 LocalGetSupportingVertexWithoutMargin(Vector3 vec)
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexShape_localGetSupportingVertexWithoutMargin(_native, ref vec, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Vector3 LocalGetSupportVertexNonVirtual(ref Vector3 vec)
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexShape_localGetSupportVertexNonVirtual(_native, ref vec, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Vector3 LocalGetSupportVertexNonVirtual(Vector3 vec)
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexShape_localGetSupportVertexNonVirtual(_native, ref vec, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Vector3 LocalGetSupportVertexWithoutMarginNonVirtual(ref Vector3 vec)
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexShape_localGetSupportVertexWithoutMarginNonVirtual(_native, ref vec, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Vector3 LocalGetSupportVertexWithoutMarginNonVirtual(Vector3 vec)
|
||||
{
|
||||
Vector3 value;
|
||||
btConvexShape_localGetSupportVertexWithoutMarginNonVirtual(_native, ref vec, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public void Project(Matrix trans, Vector3 dir, out float min, out float max)
|
||||
{
|
||||
btConvexShape_project(_native, ref trans, ref dir, out min, out max);
|
||||
}
|
||||
|
||||
public float MarginNonVirtual
|
||||
{
|
||||
get { return btConvexShape_getMarginNonVirtual(_native); }
|
||||
}
|
||||
|
||||
public int NumPreferredPenetrationDirections
|
||||
{
|
||||
get { return btConvexShape_getNumPreferredPenetrationDirections(_native); }
|
||||
}
|
||||
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern void btConvexShape_batchedUnitVectorGetSupportingVertexWithoutMargin(IntPtr obj, IntPtr vectors, IntPtr supportVerticesOut, int numVectors);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexShape_getAabbNonVirtual(IntPtr obj, [In] ref Matrix t, [Out] out Vector3 aabbMin, [Out] out Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexShape_getAabbSlow(IntPtr obj, [In] ref Matrix t, [Out] out Vector3 aabbMin, [Out] out Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btConvexShape_getMarginNonVirtual(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btConvexShape_getNumPreferredPenetrationDirections(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexShape_getPreferredPenetrationDirection(IntPtr obj, int index, [Out] out Vector3 penetrationVector);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexShape_localGetSupportingVertex(IntPtr obj, [In] ref Vector3 vec, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexShape_localGetSupportingVertexWithoutMargin(IntPtr obj, [In] ref Vector3 vec, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexShape_localGetSupportVertexNonVirtual(IntPtr obj, [In] ref Vector3 vec, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexShape_localGetSupportVertexWithoutMarginNonVirtual(IntPtr obj, [In] ref Vector3 vec, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexShape_project(IntPtr obj, [In] ref Matrix trans, [In] ref Vector3 dir, [Out] out float min, [Out] out float max);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ConvexTriangleMeshShape : PolyhedralConvexAabbCachingShape
|
||||
{
|
||||
StridingMeshInterface _meshInterface;
|
||||
|
||||
internal ConvexTriangleMeshShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public ConvexTriangleMeshShape(StridingMeshInterface meshInterface)
|
||||
: base(btConvexTriangleMeshShape_new(meshInterface._native))
|
||||
{
|
||||
_meshInterface = meshInterface;
|
||||
}
|
||||
|
||||
public ConvexTriangleMeshShape(StridingMeshInterface meshInterface, bool calcAabb)
|
||||
: base(btConvexTriangleMeshShape_new2(meshInterface._native, calcAabb))
|
||||
{
|
||||
_meshInterface = meshInterface;
|
||||
}
|
||||
|
||||
public void CalculatePrincipalAxisTransform(ref Matrix principal, out Vector3 inertia, out float volume)
|
||||
{
|
||||
btConvexTriangleMeshShape_calculatePrincipalAxisTransform(_native, ref principal, out inertia, out volume);
|
||||
}
|
||||
|
||||
public StridingMeshInterface MeshInterface
|
||||
{
|
||||
get { return _meshInterface; }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexTriangleMeshShape_new(IntPtr meshInterface);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexTriangleMeshShape_new2(IntPtr meshInterface, bool calcAabb);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConvexTriangleMeshShape_calculatePrincipalAxisTransform(IntPtr obj, [In, Out] ref Matrix principal, [Out] out Vector3 inertia, [Out] out float volume);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConvexTriangleMeshShape_getMeshInterface(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class CylinderShape : ConvexInternalShape
|
||||
{
|
||||
internal CylinderShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public CylinderShape(Vector3 halfExtents)
|
||||
: base(btCylinderShape_new(ref halfExtents))
|
||||
{
|
||||
}
|
||||
|
||||
public CylinderShape(float halfExtentX, float halfExtentY, float halfExtentZ)
|
||||
: base(btCylinderShape_new2(halfExtentX, halfExtentY, halfExtentZ))
|
||||
{
|
||||
}
|
||||
|
||||
public Vector3 HalfExtentsWithMargin
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btCylinderShape_getHalfExtentsWithMargin(_native, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 HalfExtentsWithoutMargin
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btCylinderShape_getHalfExtentsWithoutMargin(_native, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public float Radius
|
||||
{
|
||||
get { return btCylinderShape_getRadius(_native); }
|
||||
}
|
||||
|
||||
public int UpAxis
|
||||
{
|
||||
get { return btCylinderShape_getUpAxis(_native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCylinderShape_new([In] ref Vector3 halfExtents);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCylinderShape_new2(float halfExtentX, float halfExtentY, float halfExtentZ);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCylinderShape_getHalfExtentsWithMargin(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btCylinderShape_getHalfExtentsWithoutMargin(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btCylinderShape_getRadius(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btCylinderShape_getUpAxis(IntPtr obj);
|
||||
}
|
||||
|
||||
public class CylinderShapeX : CylinderShape
|
||||
{
|
||||
public CylinderShapeX(Vector3 halfExtents)
|
||||
: base(btCylinderShapeX_new(ref halfExtents))
|
||||
{
|
||||
}
|
||||
|
||||
public CylinderShapeX(float halfExtentX, float halfExtentY, float halfExtentZ)
|
||||
: base(btCylinderShapeX_new2(halfExtentX, halfExtentY, halfExtentZ))
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCylinderShapeX_new([In] ref Vector3 halfExtents);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCylinderShapeX_new2(float halfExtentX, float halfExtentY, float halfExtentZ);
|
||||
}
|
||||
|
||||
public class CylinderShapeZ : CylinderShape
|
||||
{
|
||||
public CylinderShapeZ(Vector3 halfExtents)
|
||||
: base(btCylinderShapeZ_new(ref halfExtents))
|
||||
{
|
||||
}
|
||||
|
||||
public CylinderShapeZ(float halfExtentX, float halfExtentY, float halfExtentZ)
|
||||
: base(btCylinderShapeZ_new2(halfExtentX, halfExtentY, halfExtentZ))
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCylinderShapeZ_new([In] ref Vector3 halfExtents);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btCylinderShapeZ_new2(float halfExtentX, float halfExtentY, float halfExtentZ);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct CylinderShapeFloatData
|
||||
{
|
||||
public ConvexInternalShapeFloatData ConvexInternalShapeData;
|
||||
public int UpAxis;
|
||||
public int Padding;
|
||||
|
||||
public static int Offset(string fieldName) { return Marshal.OffsetOf(typeof(CylinderShapeFloatData), fieldName).ToInt32(); }
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,324 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class DbvtProxy : BroadphaseProxy
|
||||
{
|
||||
internal DbvtProxy(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public DbvtProxy(ref Vector3 aabbMin, ref Vector3 aabbMax, IntPtr userPtr, short collisionFilterGroup, short collisionFilterMask)
|
||||
: base(btDbvtProxy_new(ref aabbMin, ref aabbMax, userPtr, collisionFilterGroup, collisionFilterMask))
|
||||
{
|
||||
}
|
||||
|
||||
public DbvtProxy(Vector3 aabbMin, Vector3 aabbMax, IntPtr userPtr, short collisionFilterGroup, short collisionFilterMask)
|
||||
: this(ref aabbMin, ref aabbMax, userPtr, collisionFilterGroup, collisionFilterMask)
|
||||
{
|
||||
}
|
||||
|
||||
public DbvtNode Leaf
|
||||
{
|
||||
get
|
||||
{
|
||||
IntPtr ptr = btDbvtProxy_getLeaf(_native);
|
||||
return (ptr != IntPtr.Zero) ? new DbvtNode(ptr) : null;
|
||||
}
|
||||
set { btDbvtProxy_setLeaf(_native, (value != null) ? value._native : IntPtr.Zero); }
|
||||
}
|
||||
/*
|
||||
public DbvtProxyArray Links
|
||||
{
|
||||
get { return btDbvtProxy_getLinks(_native); }
|
||||
}
|
||||
*/
|
||||
public int Stage
|
||||
{
|
||||
get { return btDbvtProxy_getStage(_native); }
|
||||
set { btDbvtProxy_setStage(_native, value); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDbvtProxy_new([In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax, IntPtr userPtr, short collisionFilterGroup, short collisionFilterMask);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDbvtProxy_getLeaf(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDbvtProxy_getLinks(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDbvtProxy_getStage(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtProxy_setLeaf(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtProxy_setStage(IntPtr obj, int value);
|
||||
}
|
||||
|
||||
public class DbvtBroadphase : BroadphaseInterface
|
||||
{
|
||||
public DbvtBroadphase()
|
||||
: base(btDbvtBroadphase_new())
|
||||
{
|
||||
_pairCache = new HashedOverlappingPairCache(btBroadphaseInterface_getOverlappingPairCache(_native), true);
|
||||
}
|
||||
|
||||
public DbvtBroadphase(OverlappingPairCache pairCache)
|
||||
: base(btDbvtBroadphase_new2((pairCache != null) ? pairCache._native : IntPtr.Zero))
|
||||
{
|
||||
_pairCache = (pairCache != null) ? pairCache : new HashedOverlappingPairCache(
|
||||
btBroadphaseInterface_getOverlappingPairCache(_native), true);
|
||||
}
|
||||
|
||||
public static void Benchmark(BroadphaseInterface broadphase)
|
||||
{
|
||||
btDbvtBroadphase_benchmark(broadphase._native);
|
||||
}
|
||||
|
||||
public void Collide(Dispatcher dispatcher)
|
||||
{
|
||||
btDbvtBroadphase_collide(_native, dispatcher._native);
|
||||
}
|
||||
|
||||
public void Optimize()
|
||||
{
|
||||
btDbvtBroadphase_optimize(_native);
|
||||
}
|
||||
|
||||
public void PerformDeferredRemoval(Dispatcher dispatcher)
|
||||
{
|
||||
btDbvtBroadphase_performDeferredRemoval(_native, dispatcher._native);
|
||||
}
|
||||
|
||||
public void SetAabbForceUpdate(BroadphaseProxy absproxy, ref Vector3 aabbMin, ref Vector3 aabbMax, Dispatcher __unnamed3)
|
||||
{
|
||||
btDbvtBroadphase_setAabbForceUpdate(_native, absproxy._native, ref aabbMin, ref aabbMax, __unnamed3._native);
|
||||
}
|
||||
|
||||
public void SetAabbForceUpdate(BroadphaseProxy absproxy, Vector3 aabbMin, Vector3 aabbMax, Dispatcher __unnamed3)
|
||||
{
|
||||
btDbvtBroadphase_setAabbForceUpdate(_native, absproxy._native, ref aabbMin, ref aabbMax, __unnamed3._native);
|
||||
}
|
||||
|
||||
public int CId
|
||||
{
|
||||
get { return btDbvtBroadphase_getCid(_native); }
|
||||
set { btDbvtBroadphase_setCid(_native, value); }
|
||||
}
|
||||
|
||||
public int CUpdates
|
||||
{
|
||||
get { return btDbvtBroadphase_getCupdates(_native); }
|
||||
set { btDbvtBroadphase_setCupdates(_native, value); }
|
||||
}
|
||||
|
||||
public bool DeferredCollide
|
||||
{
|
||||
get { return btDbvtBroadphase_getDeferedcollide(_native); }
|
||||
set { btDbvtBroadphase_setDeferedcollide(_native, value); }
|
||||
}
|
||||
|
||||
public int DUpdates
|
||||
{
|
||||
get { return btDbvtBroadphase_getDupdates(_native); }
|
||||
set { btDbvtBroadphase_setDupdates(_native, value); }
|
||||
}
|
||||
|
||||
public int FixedLeft
|
||||
{
|
||||
get { return btDbvtBroadphase_getFixedleft(_native); }
|
||||
set { btDbvtBroadphase_setFixedleft(_native, value); }
|
||||
}
|
||||
|
||||
public int FUpdates
|
||||
{
|
||||
get { return btDbvtBroadphase_getFupdates(_native); }
|
||||
set { btDbvtBroadphase_setFupdates(_native, value); }
|
||||
}
|
||||
|
||||
public int GId
|
||||
{
|
||||
get { return btDbvtBroadphase_getGid(_native); }
|
||||
set { btDbvtBroadphase_setGid(_native, value); }
|
||||
}
|
||||
|
||||
public bool NeedCleanup
|
||||
{
|
||||
get { return btDbvtBroadphase_getNeedcleanup(_native); }
|
||||
set { btDbvtBroadphase_setNeedcleanup(_native, value); }
|
||||
}
|
||||
|
||||
public int NewPairs
|
||||
{
|
||||
get { return btDbvtBroadphase_getNewpairs(_native); }
|
||||
set { btDbvtBroadphase_setNewpairs(_native, value); }
|
||||
}
|
||||
|
||||
public OverlappingPairCache PairCache
|
||||
{
|
||||
get
|
||||
{
|
||||
return OverlappingPairCache;
|
||||
}
|
||||
set
|
||||
{
|
||||
_pairCache = value;
|
||||
btDbvtBroadphase_setPaircache(_native, value._native);
|
||||
}
|
||||
}
|
||||
|
||||
public int PId
|
||||
{
|
||||
get { return btDbvtBroadphase_getPid(_native); }
|
||||
set { btDbvtBroadphase_setPid(_native, value); }
|
||||
}
|
||||
|
||||
public float Prediction
|
||||
{
|
||||
get { return btDbvtBroadphase_getPrediction(_native); }
|
||||
set { btDbvtBroadphase_setPrediction(_native, value); }
|
||||
}
|
||||
|
||||
public bool ReleasePairCache
|
||||
{
|
||||
get { return btDbvtBroadphase_getReleasepaircache(_native); }
|
||||
set { btDbvtBroadphase_setReleasepaircache(_native, value); }
|
||||
}
|
||||
/*
|
||||
public DbvtArray Sets
|
||||
{
|
||||
get { return btDbvtBroadphase_getSets(_native); }
|
||||
}
|
||||
*/
|
||||
public int StageCurrent
|
||||
{
|
||||
get { return btDbvtBroadphase_getStageCurrent(_native); }
|
||||
set { btDbvtBroadphase_setStageCurrent(_native, value); }
|
||||
}
|
||||
/*
|
||||
public DbvtProxyPtrArray StageRoots
|
||||
{
|
||||
get { return btDbvtBroadphase_getStageRoots(_native); }
|
||||
}
|
||||
*/
|
||||
public uint UpdatesCall
|
||||
{
|
||||
get { return btDbvtBroadphase_getUpdates_call(_native); }
|
||||
set { btDbvtBroadphase_setUpdates_call(_native, value); }
|
||||
}
|
||||
|
||||
public uint UpdatesDone
|
||||
{
|
||||
get { return btDbvtBroadphase_getUpdates_done(_native); }
|
||||
set { btDbvtBroadphase_setUpdates_done(_native, value); }
|
||||
}
|
||||
|
||||
public float UpdatesRatio
|
||||
{
|
||||
get { return btDbvtBroadphase_getUpdates_ratio(_native); }
|
||||
set { btDbvtBroadphase_setUpdates_ratio(_native, value); }
|
||||
}
|
||||
|
||||
public float VelocityPrediction
|
||||
{
|
||||
get { return btDbvtBroadphase_getVelocityPrediction(_native); }
|
||||
set { btDbvtBroadphase_setVelocityPrediction(_native, value); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDbvtBroadphase_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDbvtBroadphase_new2(IntPtr paircache);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_benchmark(IntPtr __unnamed0);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_collide(IntPtr obj, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDbvtBroadphase_getCid(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDbvtBroadphase_getCupdates(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btDbvtBroadphase_getDeferedcollide(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDbvtBroadphase_getDupdates(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDbvtBroadphase_getFixedleft(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDbvtBroadphase_getFupdates(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDbvtBroadphase_getGid(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btDbvtBroadphase_getNeedcleanup(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDbvtBroadphase_getNewpairs(IntPtr obj);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btDbvtBroadphase_getPaircache(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDbvtBroadphase_getPid(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btDbvtBroadphase_getPrediction(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btDbvtBroadphase_getReleasepaircache(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDbvtBroadphase_getSets(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDbvtBroadphase_getStageCurrent(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDbvtBroadphase_getStageRoots(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern uint btDbvtBroadphase_getUpdates_call(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern uint btDbvtBroadphase_getUpdates_done(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btDbvtBroadphase_getUpdates_ratio(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btDbvtBroadphase_getVelocityPrediction(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_optimize(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_performDeferredRemoval(IntPtr obj, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setAabbForceUpdate(IntPtr obj, IntPtr absproxy, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax, IntPtr __unnamed3);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setCid(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setCupdates(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setDeferedcollide(IntPtr obj, bool value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setDupdates(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setFixedleft(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setFupdates(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setGid(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setNeedcleanup(IntPtr obj, bool value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setNewpairs(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setPaircache(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setPid(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setPrediction(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setReleasepaircache(IntPtr obj, bool value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setStageCurrent(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setUpdates_call(IntPtr obj, uint value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setUpdates_done(IntPtr obj, uint value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setUpdates_ratio(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDbvtBroadphase_setVelocityPrediction(IntPtr obj, float prediction);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,182 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class DefaultCollisionConstructionInfo : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
public DefaultCollisionConstructionInfo()
|
||||
{
|
||||
_native = btDefaultCollisionConstructionInfo_new();
|
||||
}
|
||||
/*
|
||||
public PoolAllocator CollisionAlgorithmPool
|
||||
{
|
||||
get { return btDefaultCollisionConstructionInfo_getCollisionAlgorithmPool(_native); }
|
||||
set { btDefaultCollisionConstructionInfo_setCollisionAlgorithmPool(_native, value._native); }
|
||||
}
|
||||
*/
|
||||
public int CustomCollisionAlgorithmMaxElementSize
|
||||
{
|
||||
get { return btDefaultCollisionConstructionInfo_getCustomCollisionAlgorithmMaxElementSize(_native); }
|
||||
set { btDefaultCollisionConstructionInfo_setCustomCollisionAlgorithmMaxElementSize(_native, value); }
|
||||
}
|
||||
|
||||
public int DefaultMaxCollisionAlgorithmPoolSize
|
||||
{
|
||||
get { return btDefaultCollisionConstructionInfo_getDefaultMaxCollisionAlgorithmPoolSize(_native); }
|
||||
set { btDefaultCollisionConstructionInfo_setDefaultMaxCollisionAlgorithmPoolSize(_native, value); }
|
||||
}
|
||||
|
||||
public int DefaultMaxPersistentManifoldPoolSize
|
||||
{
|
||||
get { return btDefaultCollisionConstructionInfo_getDefaultMaxPersistentManifoldPoolSize(_native); }
|
||||
set { btDefaultCollisionConstructionInfo_setDefaultMaxPersistentManifoldPoolSize(_native, value); }
|
||||
}
|
||||
/*
|
||||
public PoolAllocator PersistentManifoldPool
|
||||
{
|
||||
get { return btDefaultCollisionConstructionInfo_getPersistentManifoldPool(_native); }
|
||||
set { btDefaultCollisionConstructionInfo_setPersistentManifoldPool(_native, value._native); }
|
||||
}
|
||||
*/
|
||||
public int UseEpaPenetrationAlgorithm
|
||||
{
|
||||
get { return btDefaultCollisionConstructionInfo_getUseEpaPenetrationAlgorithm(_native); }
|
||||
set { btDefaultCollisionConstructionInfo_setUseEpaPenetrationAlgorithm(_native, value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btDefaultCollisionConstructionInfo_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~DefaultCollisionConstructionInfo()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDefaultCollisionConstructionInfo_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDefaultCollisionConstructionInfo_getCollisionAlgorithmPool(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDefaultCollisionConstructionInfo_getCustomCollisionAlgorithmMaxElementSize(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDefaultCollisionConstructionInfo_getDefaultMaxCollisionAlgorithmPoolSize(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDefaultCollisionConstructionInfo_getDefaultMaxPersistentManifoldPoolSize(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDefaultCollisionConstructionInfo_getPersistentManifoldPool(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDefaultCollisionConstructionInfo_getUseEpaPenetrationAlgorithm(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConstructionInfo_setCollisionAlgorithmPool(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConstructionInfo_setCustomCollisionAlgorithmMaxElementSize(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConstructionInfo_setDefaultMaxCollisionAlgorithmPoolSize(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConstructionInfo_setDefaultMaxPersistentManifoldPoolSize(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConstructionInfo_setPersistentManifoldPool(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConstructionInfo_setUseEpaPenetrationAlgorithm(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConstructionInfo_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class DefaultCollisionConfiguration : CollisionConfiguration
|
||||
{
|
||||
private VoronoiSimplexSolver _simplexSolver;
|
||||
|
||||
internal DefaultCollisionConfiguration(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public DefaultCollisionConfiguration()
|
||||
: base(btDefaultCollisionConfiguration_new())
|
||||
{
|
||||
}
|
||||
|
||||
public DefaultCollisionConfiguration(DefaultCollisionConstructionInfo constructionInfo)
|
||||
: base(btDefaultCollisionConfiguration_new2(constructionInfo._native))
|
||||
{
|
||||
}
|
||||
|
||||
public void SetConvexConvexMultipointIterations()
|
||||
{
|
||||
btDefaultCollisionConfiguration_setConvexConvexMultipointIterations(_native);
|
||||
}
|
||||
|
||||
public void SetConvexConvexMultipointIterations(int numPerturbationIterations)
|
||||
{
|
||||
btDefaultCollisionConfiguration_setConvexConvexMultipointIterations2(_native, numPerturbationIterations);
|
||||
}
|
||||
|
||||
public void SetConvexConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
|
||||
{
|
||||
btDefaultCollisionConfiguration_setConvexConvexMultipointIterations3(_native, numPerturbationIterations, minimumPointsPerturbationThreshold);
|
||||
}
|
||||
|
||||
public void SetPlaneConvexMultipointIterations()
|
||||
{
|
||||
btDefaultCollisionConfiguration_setPlaneConvexMultipointIterations(_native);
|
||||
}
|
||||
|
||||
public void SetPlaneConvexMultipointIterations(int numPerturbationIterations)
|
||||
{
|
||||
btDefaultCollisionConfiguration_setPlaneConvexMultipointIterations2(_native, numPerturbationIterations);
|
||||
}
|
||||
|
||||
public void SetPlaneConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
|
||||
{
|
||||
btDefaultCollisionConfiguration_setPlaneConvexMultipointIterations3(_native, numPerturbationIterations, minimumPointsPerturbationThreshold);
|
||||
}
|
||||
|
||||
public VoronoiSimplexSolver SimplexSolver
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_simplexSolver == null)
|
||||
{
|
||||
_simplexSolver = new VoronoiSimplexSolver(btDefaultCollisionConfiguration_getSimplexSolver(_native), true);
|
||||
}
|
||||
return _simplexSolver;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDefaultCollisionConfiguration_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDefaultCollisionConfiguration_new2(IntPtr constructionInfo);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDefaultCollisionConfiguration_getSimplexSolver(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConfiguration_setConvexConvexMultipointIterations(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConfiguration_setConvexConvexMultipointIterations2(IntPtr obj, int numPerturbationIterations);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConfiguration_setConvexConvexMultipointIterations3(IntPtr obj, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConfiguration_setPlaneConvexMultipointIterations(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConfiguration_setPlaneConvexMultipointIterations2(IntPtr obj, int numPerturbationIterations);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDefaultCollisionConfiguration_setPlaneConvexMultipointIterations3(IntPtr obj, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,239 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class DiscreteCollisionDetectorInterface : IDisposable
|
||||
{
|
||||
public class ClosestPointInput : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
public ClosestPointInput()
|
||||
{
|
||||
_native = btDiscreteCollisionDetectorInterface_ClosestPointInput_new();
|
||||
}
|
||||
|
||||
public float MaximumDistanceSquared
|
||||
{
|
||||
get { return btDiscreteCollisionDetectorInterface_ClosestPointInput_getMaximumDistanceSquared(_native); }
|
||||
set { btDiscreteCollisionDetectorInterface_ClosestPointInput_setMaximumDistanceSquared(_native, value); }
|
||||
}
|
||||
|
||||
public Matrix TransformA
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix value;
|
||||
btDiscreteCollisionDetectorInterface_ClosestPointInput_getTransformA(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btDiscreteCollisionDetectorInterface_ClosestPointInput_setTransformA(_native, ref value); }
|
||||
}
|
||||
|
||||
public Matrix TransformB
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix value;
|
||||
btDiscreteCollisionDetectorInterface_ClosestPointInput_getTransformB(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btDiscreteCollisionDetectorInterface_ClosestPointInput_setTransformB(_native, ref value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btDiscreteCollisionDetectorInterface_ClosestPointInput_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~ClosestPointInput()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDiscreteCollisionDetectorInterface_ClosestPointInput_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btDiscreteCollisionDetectorInterface_ClosestPointInput_getMaximumDistanceSquared(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_ClosestPointInput_getTransformA(IntPtr obj, [Out] out Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_ClosestPointInput_getTransformB(IntPtr obj, [Out] out Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_ClosestPointInput_setMaximumDistanceSquared(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_ClosestPointInput_setTransformA(IntPtr obj, [In] ref Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_ClosestPointInput_setTransformB(IntPtr obj, [In] ref Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_ClosestPointInput_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class Result : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal Result(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public void AddContactPoint(Vector3 normalOnBInWorld, Vector3 pointInWorld, float depth)
|
||||
{
|
||||
btDiscreteCollisionDetectorInterface_Result_addContactPoint(_native, ref normalOnBInWorld, ref pointInWorld, depth);
|
||||
}
|
||||
|
||||
public void SetShapeIdentifiersA(int partId0, int index0)
|
||||
{
|
||||
btDiscreteCollisionDetectorInterface_Result_setShapeIdentifiersA(_native, partId0, index0);
|
||||
}
|
||||
|
||||
public void SetShapeIdentifiersB(int partId1, int index1)
|
||||
{
|
||||
btDiscreteCollisionDetectorInterface_Result_setShapeIdentifiersB(_native, partId1, index1);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btDiscreteCollisionDetectorInterface_Result_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~Result()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_Result_addContactPoint(IntPtr obj, [In] ref Vector3 normalOnBInWorld, [In] ref Vector3 pointInWorld, float depth);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_Result_setShapeIdentifiersA(IntPtr obj, int partId0, int index0);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_Result_setShapeIdentifiersB(IntPtr obj, int partId1, int index1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_Result_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
internal IntPtr _native;
|
||||
|
||||
internal DiscreteCollisionDetectorInterface(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public void GetClosestPoints(ClosestPointInput input, Result output, IDebugDraw debugDraw)
|
||||
{
|
||||
btDiscreteCollisionDetectorInterface_getClosestPoints(_native, input._native, output._native, DebugDraw.GetUnmanaged(debugDraw));
|
||||
}
|
||||
|
||||
public void GetClosestPoints(ClosestPointInput input, Result output, IDebugDraw debugDraw, bool swapResults)
|
||||
{
|
||||
btDiscreteCollisionDetectorInterface_getClosestPoints2(_native, input._native, output._native, DebugDraw.GetUnmanaged(debugDraw), swapResults);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btDiscreteCollisionDetectorInterface_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~DiscreteCollisionDetectorInterface()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_getClosestPoints(IntPtr obj, IntPtr input, IntPtr output, IntPtr debugDraw);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_getClosestPoints2(IntPtr obj, IntPtr input, IntPtr output, IntPtr debugDraw, bool swapResults);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDiscreteCollisionDetectorInterface_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class StorageResult : DiscreteCollisionDetectorInterface.Result
|
||||
{
|
||||
internal StorageResult(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public StorageResult()
|
||||
: base(btStorageResult_new())
|
||||
{
|
||||
}
|
||||
|
||||
public Vector3 ClosestPointInB
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btStorageResult_getClosestPointInB(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btStorageResult_setClosestPointInB(_native, ref value); }
|
||||
}
|
||||
|
||||
public float Distance
|
||||
{
|
||||
get { return btStorageResult_getDistance(_native); }
|
||||
set { btStorageResult_setDistance(_native, value); }
|
||||
}
|
||||
|
||||
public Vector3 NormalOnSurfaceB
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btStorageResult_getNormalOnSurfaceB(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btStorageResult_setNormalOnSurfaceB(_native, ref value); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btStorageResult_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btStorageResult_getClosestPointInB(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btStorageResult_getDistance(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btStorageResult_getNormalOnSurfaceB(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btStorageResult_setClosestPointInB(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btStorageResult_setDistance(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btStorageResult_setNormalOnSurfaceB(IntPtr obj, [In] ref Vector3 value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,328 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public enum DispatchFunc
|
||||
{
|
||||
Discrete = 1,
|
||||
Continuous
|
||||
}
|
||||
|
||||
public class DispatcherInfo : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
private readonly bool _preventDelete;
|
||||
|
||||
internal DispatcherInfo(IntPtr native, bool preventDelete)
|
||||
{
|
||||
_native = native;
|
||||
_preventDelete = preventDelete;
|
||||
}
|
||||
|
||||
public DispatcherInfo()
|
||||
{
|
||||
_native = btDispatcherInfo_new();
|
||||
}
|
||||
|
||||
public float AllowedCcdPenetration
|
||||
{
|
||||
get { return btDispatcherInfo_getAllowedCcdPenetration(_native); }
|
||||
set { btDispatcherInfo_setAllowedCcdPenetration(_native, value); }
|
||||
}
|
||||
|
||||
public float ConvexConservativeDistanceThreshold
|
||||
{
|
||||
get { return btDispatcherInfo_getConvexConservativeDistanceThreshold(_native); }
|
||||
set { btDispatcherInfo_setConvexConservativeDistanceThreshold(_native, value); }
|
||||
}
|
||||
|
||||
public IDebugDraw DebugDraw
|
||||
{
|
||||
get { return BulletSharp.DebugDraw.GetManaged(btDispatcherInfo_getDebugDraw(_native)); }
|
||||
set { btDispatcherInfo_setDebugDraw(_native, BulletSharp.DebugDraw.GetUnmanaged(value)); }
|
||||
}
|
||||
|
||||
public DispatchFunc DispatchFunc
|
||||
{
|
||||
get { return btDispatcherInfo_getDispatchFunc(_native); }
|
||||
set { btDispatcherInfo_setDispatchFunc(_native, value); }
|
||||
}
|
||||
|
||||
public bool EnableSatConvex
|
||||
{
|
||||
get { return btDispatcherInfo_getEnableSatConvex(_native); }
|
||||
set { btDispatcherInfo_setEnableSatConvex(_native, value); }
|
||||
}
|
||||
|
||||
public bool EnableSpu
|
||||
{
|
||||
get { return btDispatcherInfo_getEnableSPU(_native); }
|
||||
set { btDispatcherInfo_setEnableSPU(_native, value); }
|
||||
}
|
||||
|
||||
public int StepCount
|
||||
{
|
||||
get { return btDispatcherInfo_getStepCount(_native); }
|
||||
set { btDispatcherInfo_setStepCount(_native, value); }
|
||||
}
|
||||
|
||||
public float TimeOfImpact
|
||||
{
|
||||
get { return btDispatcherInfo_getTimeOfImpact(_native); }
|
||||
set { btDispatcherInfo_setTimeOfImpact(_native, value); }
|
||||
}
|
||||
|
||||
public float TimeStep
|
||||
{
|
||||
get { return btDispatcherInfo_getTimeStep(_native); }
|
||||
set { btDispatcherInfo_setTimeStep(_native, value); }
|
||||
}
|
||||
|
||||
public bool UseContinuous
|
||||
{
|
||||
get { return btDispatcherInfo_getUseContinuous(_native); }
|
||||
set { btDispatcherInfo_setUseContinuous(_native, value); }
|
||||
}
|
||||
|
||||
public bool UseConvexConservativeDistanceUtil
|
||||
{
|
||||
get { return btDispatcherInfo_getUseConvexConservativeDistanceUtil(_native); }
|
||||
set { btDispatcherInfo_setUseConvexConservativeDistanceUtil(_native, value); }
|
||||
}
|
||||
|
||||
public bool UseEpa
|
||||
{
|
||||
get { return btDispatcherInfo_getUseEpa(_native); }
|
||||
set { btDispatcherInfo_setUseEpa(_native, value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
if (!_preventDelete)
|
||||
{
|
||||
btDispatcherInfo_delete(_native);
|
||||
}
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~DispatcherInfo()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDispatcherInfo_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btDispatcherInfo_getAllowedCcdPenetration(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btDispatcherInfo_getConvexConservativeDistanceThreshold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDispatcherInfo_getDebugDraw(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern DispatchFunc btDispatcherInfo_getDispatchFunc(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btDispatcherInfo_getEnableSatConvex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btDispatcherInfo_getEnableSPU(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDispatcherInfo_getStepCount(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btDispatcherInfo_getTimeOfImpact(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btDispatcherInfo_getTimeStep(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btDispatcherInfo_getUseContinuous(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btDispatcherInfo_getUseConvexConservativeDistanceUtil(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btDispatcherInfo_getUseEpa(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_setAllowedCcdPenetration(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_setConvexConservativeDistanceThreshold(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_setDebugDraw(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_setDispatchFunc(IntPtr obj, DispatchFunc value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_setEnableSatConvex(IntPtr obj, bool value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_setEnableSPU(IntPtr obj, bool value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_setStepCount(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_setTimeOfImpact(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_setTimeStep(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_setUseContinuous(IntPtr obj, bool value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_setUseConvexConservativeDistanceUtil(IntPtr obj, bool value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_setUseEpa(IntPtr obj, bool value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcherInfo_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class Dispatcher : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal List<CollisionWorld> _worldRefs = new List<CollisionWorld>(1);
|
||||
internal bool _worldDeferredCleanup;
|
||||
|
||||
internal Dispatcher(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public IntPtr AllocateCollisionAlgorithm(int size)
|
||||
{
|
||||
return btDispatcher_allocateCollisionAlgorithm(_native, size);
|
||||
}
|
||||
|
||||
public void ClearManifold(PersistentManifold manifold)
|
||||
{
|
||||
btDispatcher_clearManifold(_native, manifold._native);
|
||||
}
|
||||
|
||||
public void DispatchAllCollisionPairs(OverlappingPairCache pairCache, DispatcherInfo dispatchInfo, Dispatcher dispatcher)
|
||||
{
|
||||
btDispatcher_dispatchAllCollisionPairs(_native, pairCache._native, dispatchInfo._native, dispatcher._native);
|
||||
}
|
||||
|
||||
public CollisionAlgorithm FindAlgorithm(CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap)
|
||||
{
|
||||
return new CollisionAlgorithm(btDispatcher_findAlgorithm(_native, body0Wrap._native, body1Wrap._native));
|
||||
}
|
||||
|
||||
public CollisionAlgorithm FindAlgorithm(CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, PersistentManifold sharedManifold)
|
||||
{
|
||||
return new CollisionAlgorithm(btDispatcher_findAlgorithm2(_native, body0Wrap._native, body1Wrap._native, sharedManifold._native));
|
||||
}
|
||||
|
||||
public void FreeCollisionAlgorithm(IntPtr ptr)
|
||||
{
|
||||
btDispatcher_freeCollisionAlgorithm(_native, ptr);
|
||||
}
|
||||
|
||||
public PersistentManifold GetManifoldByIndexInternal(int index)
|
||||
{
|
||||
return new PersistentManifold(btDispatcher_getManifoldByIndexInternal(_native, index), true);
|
||||
}
|
||||
|
||||
public PersistentManifold GetNewManifold(CollisionObject b0, CollisionObject b1)
|
||||
{
|
||||
return new PersistentManifold(btDispatcher_getNewManifold(_native, b0._native, b1._native), true);
|
||||
}
|
||||
|
||||
public bool NeedsCollision(CollisionObject body0, CollisionObject body1)
|
||||
{
|
||||
return btDispatcher_needsCollision(_native, body0._native, body1._native);
|
||||
}
|
||||
|
||||
public bool NeedsResponse(CollisionObject body0, CollisionObject body1)
|
||||
{
|
||||
return btDispatcher_needsResponse(_native, body0._native, body1._native);
|
||||
}
|
||||
|
||||
public void ReleaseManifold(PersistentManifold manifold)
|
||||
{
|
||||
btDispatcher_releaseManifold(_native, manifold._native);
|
||||
}
|
||||
/*
|
||||
public PersistentManifold InternalManifoldPointer
|
||||
{
|
||||
get { return btDispatcher_getInternalManifoldPointer(_native); }
|
||||
}
|
||||
|
||||
public btPoolAllocator InternalManifoldPool
|
||||
{
|
||||
get { return btDispatcher_getInternalManifoldPool(_native); }
|
||||
}
|
||||
*/
|
||||
public int NumManifolds
|
||||
{
|
||||
get { return btDispatcher_getNumManifolds(_native); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
if (_worldRefs.Count == 0)
|
||||
{
|
||||
btDispatcher_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Can't delete dispatcher, because it is referenced by a world,
|
||||
// tell the world to clean up the broadphase later.
|
||||
_worldDeferredCleanup = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~Dispatcher()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDispatcher_allocateCollisionAlgorithm(IntPtr obj, int size);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcher_clearManifold(IntPtr obj, IntPtr manifold);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcher_dispatchAllCollisionPairs(IntPtr obj, IntPtr pairCache, IntPtr dispatchInfo, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDispatcher_findAlgorithm(IntPtr obj, IntPtr body0Wrap, IntPtr body1Wrap);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDispatcher_findAlgorithm2(IntPtr obj, IntPtr body0Wrap, IntPtr body1Wrap, IntPtr sharedManifold);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcher_freeCollisionAlgorithm(IntPtr obj, IntPtr ptr);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDispatcher_getInternalManifoldPointer(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDispatcher_getInternalManifoldPool(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDispatcher_getManifoldByIndexInternal(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btDispatcher_getNewManifold(IntPtr obj, IntPtr b0, IntPtr b1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btDispatcher_getNumManifolds(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btDispatcher_needsCollision(IntPtr obj, IntPtr body0, IntPtr body1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btDispatcher_needsResponse(IntPtr obj, IntPtr body0, IntPtr body1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcher_releaseManifold(IntPtr obj, IntPtr manifold);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btDispatcher_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class EmptyAlgorithm : CollisionAlgorithm
|
||||
{
|
||||
public class CreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
public CreateFunc()
|
||||
: base(btEmptyAlgorithm_CreateFunc_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btEmptyAlgorithm_CreateFunc_new();
|
||||
}
|
||||
|
||||
public EmptyAlgorithm(CollisionAlgorithmConstructionInfo ci)
|
||||
: base(btEmptyAlgorithm_new(ci._native))
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btEmptyAlgorithm_new(IntPtr ci);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class EmptyShape : ConcaveShape
|
||||
{
|
||||
public EmptyShape()
|
||||
: base(btEmptyShape_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btEmptyShape_new();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,351 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class BoxBoxTransformCache
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal BoxBoxTransformCache(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public BoxBoxTransformCache()
|
||||
{
|
||||
_native = BT_BOX_BOX_TRANSFORM_CACHE_new();
|
||||
}
|
||||
|
||||
public void CalcAbsoluteMatrix()
|
||||
{
|
||||
BT_BOX_BOX_TRANSFORM_CACHE_calc_absolute_matrix(_native);
|
||||
}
|
||||
|
||||
public void CalcFromFullInvert(ref Matrix trans0, ref Matrix trans1)
|
||||
{
|
||||
BT_BOX_BOX_TRANSFORM_CACHE_calc_from_full_invert(_native, ref trans0, ref trans1);
|
||||
}
|
||||
|
||||
public void CalcFromHomogenic(ref Matrix trans0, ref Matrix trans1)
|
||||
{
|
||||
BT_BOX_BOX_TRANSFORM_CACHE_calc_from_homogenic(_native, ref trans0, ref trans1);
|
||||
}
|
||||
|
||||
public Vector3 Transform(ref Vector3 point)
|
||||
{
|
||||
Vector3 value;
|
||||
BT_BOX_BOX_TRANSFORM_CACHE_transform(_native, ref point, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Matrix AR
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix value;
|
||||
BT_BOX_BOX_TRANSFORM_CACHE_getAR(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { BT_BOX_BOX_TRANSFORM_CACHE_setAR(_native, ref value); }
|
||||
}
|
||||
|
||||
public Matrix R1To0
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix value;
|
||||
BT_BOX_BOX_TRANSFORM_CACHE_getR1to0(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { BT_BOX_BOX_TRANSFORM_CACHE_setR1to0(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 T1To0
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
BT_BOX_BOX_TRANSFORM_CACHE_getT1to0(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { BT_BOX_BOX_TRANSFORM_CACHE_setT1to0(_native, ref value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
BT_BOX_BOX_TRANSFORM_CACHE_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~BoxBoxTransformCache()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr BT_BOX_BOX_TRANSFORM_CACHE_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_BOX_BOX_TRANSFORM_CACHE_calc_absolute_matrix(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_BOX_BOX_TRANSFORM_CACHE_calc_from_full_invert(IntPtr obj, [In] ref Matrix trans0, [In] ref Matrix trans1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_BOX_BOX_TRANSFORM_CACHE_calc_from_homogenic(IntPtr obj, [In] ref Matrix trans0, [In] ref Matrix trans1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_BOX_BOX_TRANSFORM_CACHE_getAR(IntPtr obj, [Out] out Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_BOX_BOX_TRANSFORM_CACHE_getR1to0(IntPtr obj, [Out] out Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_BOX_BOX_TRANSFORM_CACHE_getT1to0(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_BOX_BOX_TRANSFORM_CACHE_setAR(IntPtr obj, [In] ref Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_BOX_BOX_TRANSFORM_CACHE_setR1to0(IntPtr obj, [In] ref Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_BOX_BOX_TRANSFORM_CACHE_setT1to0(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_BOX_BOX_TRANSFORM_CACHE_transform(IntPtr obj, [In] ref Vector3 point, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_BOX_BOX_TRANSFORM_CACHE_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class Aabb : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
private readonly bool _preventDelete;
|
||||
|
||||
internal Aabb(IntPtr native, bool preventDelete)
|
||||
{
|
||||
_native = native;
|
||||
_preventDelete = preventDelete;
|
||||
}
|
||||
|
||||
public Aabb()
|
||||
{
|
||||
_native = btAABB_new();
|
||||
}
|
||||
|
||||
public Aabb(Vector3 v1, Vector3 v2, Vector3 v3)
|
||||
{
|
||||
_native = btAABB_new2(ref v1, ref v2, ref v3);
|
||||
}
|
||||
|
||||
public Aabb(Vector3 v1, Vector3 v2, Vector3 v3, float margin)
|
||||
{
|
||||
_native = btAABB_new3(ref v1, ref v2, ref v3, margin);
|
||||
}
|
||||
|
||||
public Aabb(Aabb other)
|
||||
{
|
||||
_native = btAABB_new4(other._native);
|
||||
}
|
||||
|
||||
public Aabb(Aabb other, float margin)
|
||||
{
|
||||
_native = btAABB_new5(other._native, margin);
|
||||
}
|
||||
|
||||
public void ApplyTransform(ref Matrix trans)
|
||||
{
|
||||
btAABB_appy_transform(_native, ref trans);
|
||||
}
|
||||
|
||||
public void ApplyTransformTransCache(BoxBoxTransformCache trans)
|
||||
{
|
||||
btAABB_appy_transform_trans_cache(_native, trans._native);
|
||||
}
|
||||
|
||||
public bool CollidePlane(ref Vector4 plane)
|
||||
{
|
||||
return btAABB_collide_plane(_native, ref plane);
|
||||
}
|
||||
|
||||
public bool CollideRay(ref Vector3 vorigin, ref Vector3 vdir)
|
||||
{
|
||||
return btAABB_collide_ray(_native, ref vorigin, ref vdir);
|
||||
}
|
||||
|
||||
public bool CollideTriangleExact(ref Vector3 p1, ref Vector3 p2, ref Vector3 p3, ref Vector4 trianglePlane)
|
||||
{
|
||||
return btAABB_collide_triangle_exact(_native, ref p1, ref p2, ref p3, ref trianglePlane);
|
||||
}
|
||||
|
||||
public void CopyWithMargin(Aabb other, float margin)
|
||||
{
|
||||
btAABB_copy_with_margin(_native, other._native, margin);
|
||||
}
|
||||
|
||||
public void FindIntersection(Aabb other, Aabb intersection)
|
||||
{
|
||||
btAABB_find_intersection(_native, other._native, intersection._native);
|
||||
}
|
||||
|
||||
public void GetCenterExtend(out Vector3 center, out Vector3 extend)
|
||||
{
|
||||
btAABB_get_center_extend(_native, out center, out extend);
|
||||
}
|
||||
|
||||
public bool HasCollision(Aabb other)
|
||||
{
|
||||
return btAABB_has_collision(_native, other._native);
|
||||
}
|
||||
|
||||
public void IncrementMargin(float margin)
|
||||
{
|
||||
btAABB_increment_margin(_native, margin);
|
||||
}
|
||||
|
||||
public void Invalidate()
|
||||
{
|
||||
btAABB_invalidate(_native);
|
||||
}
|
||||
|
||||
public void Merge(Aabb box)
|
||||
{
|
||||
btAABB_merge(_native, box._native);
|
||||
}
|
||||
|
||||
public bool OverlappingTransCache(Aabb box, BoxBoxTransformCache transcache, bool fulltest)
|
||||
{
|
||||
return btAABB_overlapping_trans_cache(_native, box._native, transcache._native, fulltest);
|
||||
}
|
||||
|
||||
public bool OverlappingTransConservative(Aabb box, ref Matrix trans1To0)
|
||||
{
|
||||
return btAABB_overlapping_trans_conservative(_native, box._native, ref trans1To0);
|
||||
}
|
||||
|
||||
public bool OverlappingTransConservative2(Aabb box, BoxBoxTransformCache trans1To0)
|
||||
{
|
||||
return btAABB_overlapping_trans_conservative2(_native, box._native, trans1To0._native);
|
||||
}
|
||||
/*
|
||||
public eBT_PLANE_INTERSECTION_TYPE PlaneClassify(Vector4 plane)
|
||||
{
|
||||
return btAABB_plane_classify(_native, ref plane);
|
||||
}
|
||||
*/
|
||||
public void ProjectionInterval(ref Vector3 direction, out float vmin, out float vmax)
|
||||
{
|
||||
btAABB_projection_interval(_native, ref direction, out vmin, out vmax);
|
||||
}
|
||||
|
||||
public Vector3 Max
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btAABB_getMax(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btAABB_setMax(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 Min
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btAABB_getMin(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btAABB_setMin(_native, ref value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
if (!_preventDelete)
|
||||
{
|
||||
btAABB_delete(_native);
|
||||
}
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~Aabb()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btAABB_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btAABB_new2([In] ref Vector3 V1, [In] ref Vector3 V2, [In] ref Vector3 V3);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btAABB_new3([In] ref Vector3 V1, [In] ref Vector3 V2, [In] ref Vector3 V3, float margin);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btAABB_new4(IntPtr other);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btAABB_new5(IntPtr other, float margin);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_appy_transform(IntPtr obj, [In] ref Matrix trans);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_appy_transform_trans_cache(IntPtr obj, IntPtr trans);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btAABB_collide_plane(IntPtr obj, [In] ref Vector4 plane);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btAABB_collide_ray(IntPtr obj, [In] ref Vector3 vorigin, [In] ref Vector3 vdir);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btAABB_collide_triangle_exact(IntPtr obj, [In] ref Vector3 p1, [In] ref Vector3 p2, [In] ref Vector3 p3, [In] ref Vector4 triangle_plane);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_copy_with_margin(IntPtr obj, IntPtr other, float margin);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_find_intersection(IntPtr obj, IntPtr other, IntPtr intersection);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_get_center_extend(IntPtr obj, [Out] out Vector3 center, [Out] out Vector3 extend);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_getMax(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_getMin(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btAABB_has_collision(IntPtr obj, IntPtr other);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_increment_margin(IntPtr obj, float margin);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_invalidate(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_merge(IntPtr obj, IntPtr box);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btAABB_overlapping_trans_cache(IntPtr obj, IntPtr box, IntPtr transcache, bool fulltest);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btAABB_overlapping_trans_conservative(IntPtr obj, IntPtr box, [In] ref Matrix trans1_to_0);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btAABB_overlapping_trans_conservative2(IntPtr obj, IntPtr box, IntPtr trans1_to_0);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern eBT_PLANE_INTERSECTION_TYPE btAABB_plane_classify(IntPtr obj, IntPtr plane);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_projection_interval(IntPtr obj, [In] ref Vector3 direction, [Out] out float vmin, [Out] out float vmax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_setMax(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_setMin(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btAABB_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
class MyCallback : TriangleRaycastCallback
|
||||
{
|
||||
int _ignorePart;
|
||||
int _ignoreTriangleIndex;
|
||||
|
||||
public MyCallback(ref Vector3 from, ref Vector3 to, int ignorePart, int ignoreTriangleIndex)
|
||||
: base(ref from, ref to)
|
||||
{
|
||||
_ignorePart = ignorePart;
|
||||
_ignoreTriangleIndex = ignoreTriangleIndex;
|
||||
}
|
||||
|
||||
public override float ReportHit(ref Vector3 hitNormalLocal, float hitFraction, int partId, int triangleIndex)
|
||||
{
|
||||
if (partId != _ignorePart || triangleIndex != _ignoreTriangleIndex)
|
||||
{
|
||||
if (hitFraction < HitFraction)
|
||||
return hitFraction;
|
||||
}
|
||||
|
||||
return HitFraction;
|
||||
}
|
||||
}
|
||||
|
||||
class MyInternalTriangleIndexCallback : InternalTriangleIndexCallback
|
||||
{
|
||||
private CompoundShape _colShape;
|
||||
private float _depth;
|
||||
private GImpactMeshShape _meshShape;
|
||||
|
||||
public MyInternalTriangleIndexCallback(CompoundShape colShape, GImpactMeshShape meshShape, float depth)
|
||||
{
|
||||
_colShape = colShape;
|
||||
_depth = depth;
|
||||
_meshShape = meshShape;
|
||||
}
|
||||
|
||||
public override void InternalProcessTriangleIndex(ref Vector3 vertex0, ref Vector3 vertex1, ref Vector3 vertex2, int partId, int triangleIndex)
|
||||
{
|
||||
Vector3 scale = _meshShape.LocalScaling;
|
||||
Vector3 v0=vertex0*scale;
|
||||
Vector3 v1=vertex1*scale;
|
||||
Vector3 v2=vertex2*scale;
|
||||
|
||||
Vector3 centroid = (v0+v1+v2)/3;
|
||||
Vector3 normal = (v1-v0).Cross(v2-v0);
|
||||
normal.Normalize();
|
||||
Vector3 rayFrom = centroid;
|
||||
Vector3 rayTo = centroid-normal*_depth;
|
||||
|
||||
MyCallback cb = new MyCallback(ref rayFrom, ref rayTo, partId, triangleIndex);
|
||||
|
||||
_meshShape.ProcessAllTrianglesRay(cb, ref rayFrom, ref rayTo);
|
||||
if (cb.HitFraction < 1)
|
||||
{
|
||||
rayTo = Vector3.Lerp(cb.From, cb.To, cb.HitFraction);
|
||||
//rayTo = cb.From;
|
||||
//gDebugDraw.drawLine(tr(centroid),tr(centroid+normal),btVector3(1,0,0));
|
||||
}
|
||||
|
||||
BuSimplex1To4 tet = new BuSimplex1To4(v0,v1,v2,rayTo);
|
||||
_colShape.AddChildShape(Matrix.Identity, tet);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CompoundFromGImpact
|
||||
{
|
||||
private CompoundFromGImpact()
|
||||
{
|
||||
}
|
||||
|
||||
public static CompoundShape Create(GImpactMeshShape gImpactMesh, float depth)
|
||||
{
|
||||
CompoundShape colShape = new CompoundShape();
|
||||
using (MyInternalTriangleIndexCallback cb = new MyInternalTriangleIndexCallback(colShape, gImpactMesh, depth))
|
||||
{
|
||||
Vector3 aabbMin, aabbMax;
|
||||
gImpactMesh.GetAabb(Matrix.Identity, out aabbMin, out aabbMax);
|
||||
gImpactMesh.MeshInterface.InternalProcessAllTriangles(cb, aabbMin, aabbMax);
|
||||
}
|
||||
return colShape;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,671 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class GimPair
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal GimPair(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public GimPair()
|
||||
{
|
||||
_native = GIM_PAIR_new();
|
||||
}
|
||||
|
||||
public GimPair(GimPair p)
|
||||
{
|
||||
_native = GIM_PAIR_new2(p._native);
|
||||
}
|
||||
|
||||
public GimPair(int index1, int index2)
|
||||
{
|
||||
_native = GIM_PAIR_new3(index1, index2);
|
||||
}
|
||||
|
||||
public int Index1
|
||||
{
|
||||
get { return GIM_PAIR_getIndex1(_native); }
|
||||
set { GIM_PAIR_setIndex1(_native, value); }
|
||||
}
|
||||
|
||||
public int Index2
|
||||
{
|
||||
get { return GIM_PAIR_getIndex2(_native); }
|
||||
set { GIM_PAIR_setIndex2(_native, value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
GIM_PAIR_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~GimPair()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_PAIR_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_PAIR_new2(IntPtr p);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_PAIR_new3(int index1, int index2);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int GIM_PAIR_getIndex1(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int GIM_PAIR_getIndex2(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_PAIR_setIndex1(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_PAIR_setIndex2(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_PAIR_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class PairSet
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal PairSet(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
/*
|
||||
public PairSet()
|
||||
{
|
||||
_native = btPairSet_new();
|
||||
}
|
||||
*/
|
||||
public void PushPair(int index1, int index2)
|
||||
{
|
||||
btPairSet_push_pair(_native, index1, index2);
|
||||
}
|
||||
|
||||
public void PushPairInv(int index1, int index2)
|
||||
{
|
||||
btPairSet_push_pair_inv(_native, index1, index2);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btPairSet_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPairSet_push_pair(IntPtr obj, int index1, int index2);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPairSet_push_pair_inv(IntPtr obj, int index1, int index2);
|
||||
}
|
||||
|
||||
public class GimBvhData
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal GimBvhData(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public GimBvhData()
|
||||
{
|
||||
_native = GIM_BVH_DATA_new();
|
||||
}
|
||||
|
||||
public Aabb Bound
|
||||
{
|
||||
get { return new Aabb(GIM_BVH_DATA_getBound(_native), true); }
|
||||
}
|
||||
|
||||
public int Data
|
||||
{
|
||||
get { return GIM_BVH_DATA_getData(_native); }
|
||||
set { GIM_BVH_DATA_setData(_native, value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
GIM_BVH_DATA_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~GimBvhData()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_BVH_DATA_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_BVH_DATA_getBound(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int GIM_BVH_DATA_getData(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_BVH_DATA_setData(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_BVH_DATA_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class GimBvhTreeNode : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal GimBvhTreeNode(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public GimBvhTreeNode()
|
||||
{
|
||||
_native = GIM_BVH_TREE_NODE_new();
|
||||
}
|
||||
|
||||
public Aabb Bound
|
||||
{
|
||||
get { return new Aabb(GIM_BVH_TREE_NODE_getBound(_native), true); }
|
||||
}
|
||||
|
||||
public int DataIndex
|
||||
{
|
||||
get { return GIM_BVH_TREE_NODE_getDataIndex(_native); }
|
||||
set { GIM_BVH_TREE_NODE_setDataIndex(_native, value); }
|
||||
}
|
||||
|
||||
public int EscapeIndex
|
||||
{
|
||||
get { return GIM_BVH_TREE_NODE_getEscapeIndex(_native); }
|
||||
set { GIM_BVH_TREE_NODE_setEscapeIndex(_native, value); }
|
||||
}
|
||||
|
||||
public bool IsLeafNode
|
||||
{
|
||||
get { return GIM_BVH_TREE_NODE_isLeafNode(_native); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
GIM_BVH_TREE_NODE_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~GimBvhTreeNode()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_BVH_TREE_NODE_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_BVH_TREE_NODE_getBound(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int GIM_BVH_TREE_NODE_getDataIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int GIM_BVH_TREE_NODE_getEscapeIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool GIM_BVH_TREE_NODE_isLeafNode(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_BVH_TREE_NODE_setDataIndex(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_BVH_TREE_NODE_setEscapeIndex(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_BVH_TREE_NODE_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class GimBvhDataArray
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal GimBvhDataArray(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
/*
|
||||
public GimBvhDataArray()
|
||||
{
|
||||
_native = GIM_BVH_DATA_ARRAY_new();
|
||||
}
|
||||
*/
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_BVH_DATA_ARRAY_new();
|
||||
}
|
||||
|
||||
public class GimBvhTreeNodeArray
|
||||
{
|
||||
private IntPtr _native;
|
||||
|
||||
internal GimBvhTreeNodeArray(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public GimBvhTreeNodeArray()
|
||||
{
|
||||
_native = GIM_BVH_TREE_NODE_ARRAY_new();
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_BVH_TREE_NODE_ARRAY_new();
|
||||
}
|
||||
|
||||
public class BvhTree : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal BvhTree(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public BvhTree()
|
||||
{
|
||||
_native = btBvhTree_new();
|
||||
}
|
||||
|
||||
public void Build_tree(GimBvhDataArray primitiveBoxes)
|
||||
{
|
||||
btBvhTree_build_tree(_native, primitiveBoxes._native);
|
||||
}
|
||||
|
||||
public void ClearNodes()
|
||||
{
|
||||
btBvhTree_clearNodes(_native);
|
||||
}
|
||||
|
||||
public GimBvhTreeNode GetNodePointer()
|
||||
{
|
||||
return new GimBvhTreeNode(btBvhTree_get_node_pointer(_native));
|
||||
}
|
||||
|
||||
public GimBvhTreeNode GetNodePointer(int index)
|
||||
{
|
||||
return new GimBvhTreeNode(btBvhTree_get_node_pointer2(_native, index));
|
||||
}
|
||||
|
||||
public int GetEscapeNodeIndex(int nodeindex)
|
||||
{
|
||||
return btBvhTree_getEscapeNodeIndex(_native, nodeindex);
|
||||
}
|
||||
|
||||
public int GetLeftNode(int nodeindex)
|
||||
{
|
||||
return btBvhTree_getLeftNode(_native, nodeindex);
|
||||
}
|
||||
|
||||
public void GetNodeBound(int nodeindex, Aabb bound)
|
||||
{
|
||||
btBvhTree_getNodeBound(_native, nodeindex, bound._native);
|
||||
}
|
||||
|
||||
public int GetNodeData(int nodeindex)
|
||||
{
|
||||
return btBvhTree_getNodeData(_native, nodeindex);
|
||||
}
|
||||
|
||||
public int GetRightNode(int nodeindex)
|
||||
{
|
||||
return btBvhTree_getRightNode(_native, nodeindex);
|
||||
}
|
||||
|
||||
public bool IsLeafNode(int nodeindex)
|
||||
{
|
||||
return btBvhTree_isLeafNode(_native, nodeindex);
|
||||
}
|
||||
|
||||
public void SetNodeBound(int nodeindex, Aabb bound)
|
||||
{
|
||||
btBvhTree_setNodeBound(_native, nodeindex, bound._native);
|
||||
}
|
||||
|
||||
public int NodeCount
|
||||
{
|
||||
get { return btBvhTree_getNodeCount(_native); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btBvhTree_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~BvhTree()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhTree_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTree_build_tree(IntPtr obj, IntPtr primitive_boxes);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTree_clearNodes(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhTree_get_node_pointer(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhTree_get_node_pointer2(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btBvhTree_getEscapeNodeIndex(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btBvhTree_getLeftNode(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTree_getNodeBound(IntPtr obj, int nodeindex, IntPtr bound);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btBvhTree_getNodeCount(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btBvhTree_getNodeData(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btBvhTree_getRightNode(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btBvhTree_isLeafNode(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTree_setNodeBound(IntPtr obj, int nodeindex, IntPtr bound);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhTree_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class PrimitiveManagerBase : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal PrimitiveManagerBase(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public void GetPrimitiveBox(int primIndex, Aabb primbox)
|
||||
{
|
||||
btPrimitiveManagerBase_get_primitive_box(_native, primIndex, primbox._native);
|
||||
}
|
||||
/*
|
||||
public void GetPrimitiveTriangle(int primIndex, PrimitiveTriangle triangle)
|
||||
{
|
||||
btPrimitiveManagerBase_get_primitive_triangle(_native, primIndex, triangle._native);
|
||||
}
|
||||
*/
|
||||
public bool IsTrimesh
|
||||
{
|
||||
get { return btPrimitiveManagerBase_is_trimesh(_native); }
|
||||
}
|
||||
|
||||
public int PrimitiveCount
|
||||
{
|
||||
get { return btPrimitiveManagerBase_get_primitive_count(_native); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btPrimitiveManagerBase_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~PrimitiveManagerBase()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPrimitiveManagerBase_get_primitive_box(IntPtr obj, int prim_index, IntPtr primbox);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btPrimitiveManagerBase_get_primitive_count(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPrimitiveManagerBase_get_primitive_triangle(IntPtr obj, int prim_index, IntPtr triangle);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btPrimitiveManagerBase_is_trimesh(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPrimitiveManagerBase_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class GImpactBvh : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal GImpactBvh(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public GImpactBvh()
|
||||
{
|
||||
_native = btGImpactBvh_new();
|
||||
}
|
||||
|
||||
public GImpactBvh(PrimitiveManagerBase primitiveManager)
|
||||
{
|
||||
_native = btGImpactBvh_new2(primitiveManager._native);
|
||||
}
|
||||
/*
|
||||
public bool BoxQuery(Aabb box, AlignedIntArray collidedResults)
|
||||
{
|
||||
return btGImpactBvh_boxQuery(_native, box._native, collidedResults._native);
|
||||
}
|
||||
|
||||
public bool BoxQueryTrans(Aabb box, Matrix transform, AlignedIntArray collidedResults)
|
||||
{
|
||||
return btGImpactBvh_boxQueryTrans(_native, box._native, ref transform, collidedResults._native);
|
||||
}
|
||||
*/
|
||||
public void BuildSet()
|
||||
{
|
||||
btGImpactBvh_buildSet(_native);
|
||||
}
|
||||
|
||||
public static void FindCollision(GImpactBvh boxset1, Matrix trans1, GImpactBvh boxset2, Matrix trans2, PairSet collisionPairs)
|
||||
{
|
||||
btGImpactBvh_find_collision(boxset1._native, ref trans1, boxset2._native, ref trans2, collisionPairs._native);
|
||||
}
|
||||
|
||||
public GimBvhTreeNode GetNodePointer()
|
||||
{
|
||||
return new GimBvhTreeNode(btGImpactBvh_get_node_pointer(_native));
|
||||
}
|
||||
|
||||
public GimBvhTreeNode GetNodePointer(int index)
|
||||
{
|
||||
return new GimBvhTreeNode(btGImpactBvh_get_node_pointer2(_native, index));
|
||||
}
|
||||
|
||||
public int GetEscapeNodeIndex(int nodeindex)
|
||||
{
|
||||
return btGImpactBvh_getEscapeNodeIndex(_native, nodeindex);
|
||||
}
|
||||
|
||||
public int GetLeftNode(int nodeindex)
|
||||
{
|
||||
return btGImpactBvh_getLeftNode(_native, nodeindex);
|
||||
}
|
||||
|
||||
public void GetNodeBound(int nodeindex, Aabb bound)
|
||||
{
|
||||
btGImpactBvh_getNodeBound(_native, nodeindex, bound._native);
|
||||
}
|
||||
|
||||
public int GetNodeData(int nodeindex)
|
||||
{
|
||||
return btGImpactBvh_getNodeData(_native, nodeindex);
|
||||
}
|
||||
/*
|
||||
public void GetNodeTriangle(int nodeindex, PrimitiveTriangle triangle)
|
||||
{
|
||||
btGImpactBvh_getNodeTriangle(_native, nodeindex, triangle._native);
|
||||
}
|
||||
*/
|
||||
public int GetRightNode(int nodeindex)
|
||||
{
|
||||
return btGImpactBvh_getRightNode(_native, nodeindex);
|
||||
}
|
||||
|
||||
public bool IsLeafNode(int nodeindex)
|
||||
{
|
||||
return btGImpactBvh_isLeafNode(_native, nodeindex);
|
||||
}
|
||||
/*
|
||||
public bool RayQuery(Vector3 rayDir, Vector3 rayOrigin, AlignedIntArray collidedResults)
|
||||
{
|
||||
return btGImpactBvh_rayQuery(_native, ref rayDir, ref rayOrigin, collidedResults._native);
|
||||
}
|
||||
*/
|
||||
public void SetNodeBound(int nodeindex, Aabb bound)
|
||||
{
|
||||
btGImpactBvh_setNodeBound(_native, nodeindex, bound._native);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
btGImpactBvh_update(_native);
|
||||
}
|
||||
|
||||
public Aabb GlobalBox
|
||||
{
|
||||
get { return new Aabb(btGImpactBvh_getGlobalBox(_native), true); }
|
||||
}
|
||||
|
||||
public bool HasHierarchy
|
||||
{
|
||||
get { return btGImpactBvh_hasHierarchy(_native); }
|
||||
}
|
||||
|
||||
public bool IsTrimesh
|
||||
{
|
||||
get { return btGImpactBvh_isTrimesh(_native); }
|
||||
}
|
||||
|
||||
public int NodeCount
|
||||
{
|
||||
get { return btGImpactBvh_getNodeCount(_native); }
|
||||
}
|
||||
|
||||
public PrimitiveManagerBase PrimitiveManager
|
||||
{
|
||||
get { return new PrimitiveManagerBase(btGImpactBvh_getPrimitiveManager(_native)); }
|
||||
set { btGImpactBvh_setPrimitiveManager(_native, value._native); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btGImpactBvh_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~GImpactBvh()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactBvh_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactBvh_new2(IntPtr primitive_manager);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactBvh_boxQuery(IntPtr obj, IntPtr box, IntPtr collided_results);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactBvh_boxQueryTrans(IntPtr obj, IntPtr box, [In] ref Matrix transform, IntPtr collided_results);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactBvh_buildSet(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactBvh_find_collision(IntPtr boxset1, [In] ref Matrix trans1, IntPtr boxset2, [In] ref Matrix trans2, IntPtr collision_pairs);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactBvh_get_node_pointer(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactBvh_get_node_pointer2(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactBvh_getEscapeNodeIndex(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactBvh_getGlobalBox(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactBvh_getLeftNode(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactBvh_getNodeBound(IntPtr obj, int nodeindex, IntPtr bound);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactBvh_getNodeCount(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactBvh_getNodeData(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactBvh_getNodeTriangle(IntPtr obj, int nodeindex, IntPtr triangle);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactBvh_getPrimitiveManager(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactBvh_getRightNode(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactBvh_hasHierarchy(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactBvh_isLeafNode(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactBvh_isTrimesh(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactBvh_rayQuery(IntPtr obj, [In] ref Vector3 ray_dir, [In] ref Vector3 ray_origin, IntPtr collided_results);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactBvh_setNodeBound(IntPtr obj, int nodeindex, IntPtr bound);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactBvh_setPrimitiveManager(IntPtr obj, IntPtr primitive_manager);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactBvh_update(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactBvh_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class GImpactCollisionAlgorithm : ActivatingCollisionAlgorithm
|
||||
{
|
||||
public class CreateFunc : CollisionAlgorithmCreateFunc
|
||||
{
|
||||
internal CreateFunc(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public CreateFunc()
|
||||
: base(btGImpactCollisionAlgorithm_CreateFunc_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactCollisionAlgorithm_CreateFunc_new();
|
||||
}
|
||||
|
||||
internal GImpactCollisionAlgorithm(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public GImpactCollisionAlgorithm(CollisionAlgorithmConstructionInfo ci, CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap)
|
||||
: base(btGImpactCollisionAlgorithm_new(ci._native, body0Wrap._native, body1Wrap._native))
|
||||
{
|
||||
}
|
||||
|
||||
public void GimpactVsCompoundshape(CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, GImpactShapeInterface shape0, CompoundShape shape1, bool swapped)
|
||||
{
|
||||
btGImpactCollisionAlgorithm_gimpact_vs_compoundshape(_native, body0Wrap._native, body1Wrap._native, shape0._native, shape1._native, swapped);
|
||||
}
|
||||
|
||||
public void GimpactVsConcave(CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, GImpactShapeInterface shape0, ConcaveShape shape1, bool swapped)
|
||||
{
|
||||
btGImpactCollisionAlgorithm_gimpact_vs_concave(_native, body0Wrap._native, body1Wrap._native, shape0._native, shape1._native, swapped);
|
||||
}
|
||||
|
||||
public void GimpactVsGimpact(CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, GImpactShapeInterface shape0, GImpactShapeInterface shape1)
|
||||
{
|
||||
btGImpactCollisionAlgorithm_gimpact_vs_gimpact(_native, body0Wrap._native, body1Wrap._native, shape0._native, shape1._native);
|
||||
}
|
||||
|
||||
public void GimpactVsShape(CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap, GImpactShapeInterface shape0, CollisionShape shape1, bool swapped)
|
||||
{
|
||||
btGImpactCollisionAlgorithm_gimpact_vs_shape(_native, body0Wrap._native, body1Wrap._native, shape0._native, shape1._native, swapped);
|
||||
}
|
||||
|
||||
public ManifoldResult InternalGetResultOut()
|
||||
{
|
||||
return new ManifoldResult(btGImpactCollisionAlgorithm_internalGetResultOut(_native));
|
||||
}
|
||||
|
||||
public static void RegisterAlgorithm(CollisionDispatcher dispatcher)
|
||||
{
|
||||
btGImpactCollisionAlgorithm_registerAlgorithm(dispatcher._native);
|
||||
}
|
||||
|
||||
public int Face0
|
||||
{
|
||||
get { return btGImpactCollisionAlgorithm_getFace0(_native); }
|
||||
set { btGImpactCollisionAlgorithm_setFace0(_native, value); }
|
||||
}
|
||||
|
||||
public int Face1
|
||||
{
|
||||
get { return btGImpactCollisionAlgorithm_getFace1(_native); }
|
||||
set { btGImpactCollisionAlgorithm_setFace1(_native, value); }
|
||||
}
|
||||
|
||||
public int Part0
|
||||
{
|
||||
get { return btGImpactCollisionAlgorithm_getPart0(_native); }
|
||||
set { btGImpactCollisionAlgorithm_setPart0(_native, value); }
|
||||
}
|
||||
|
||||
public int Part1
|
||||
{
|
||||
get { return btGImpactCollisionAlgorithm_getPart1(_native); }
|
||||
set { btGImpactCollisionAlgorithm_setPart1(_native, value); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactCollisionAlgorithm_new(IntPtr ci, IntPtr body0Wrap, IntPtr body1Wrap);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactCollisionAlgorithm_getFace0(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactCollisionAlgorithm_getFace1(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactCollisionAlgorithm_getPart0(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactCollisionAlgorithm_getPart1(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactCollisionAlgorithm_gimpact_vs_compoundshape(IntPtr obj, IntPtr body0Wrap, IntPtr body1Wrap, IntPtr shape0, IntPtr shape1, bool swapped);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactCollisionAlgorithm_gimpact_vs_concave(IntPtr obj, IntPtr body0Wrap, IntPtr body1Wrap, IntPtr shape0, IntPtr shape1, bool swapped);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactCollisionAlgorithm_gimpact_vs_gimpact(IntPtr obj, IntPtr body0Wrap, IntPtr body1Wrap, IntPtr shape0, IntPtr shape1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactCollisionAlgorithm_gimpact_vs_shape(IntPtr obj, IntPtr body0Wrap, IntPtr body1Wrap, IntPtr shape0, IntPtr shape1, bool swapped);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactCollisionAlgorithm_internalGetResultOut(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactCollisionAlgorithm_registerAlgorithm(IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactCollisionAlgorithm_setFace0(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactCollisionAlgorithm_setFace1(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactCollisionAlgorithm_setPart0(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactCollisionAlgorithm_setPart1(IntPtr obj, int value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,475 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class GImpactQuantizedBvhNode : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal GImpactQuantizedBvhNode(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public GImpactQuantizedBvhNode()
|
||||
{
|
||||
_native = BT_QUANTIZED_BVH_NODE_new();
|
||||
}
|
||||
|
||||
public bool TestQuantizedBoxOverlapp(ushort[] quantizedMin, ushort[] quantizedMax)
|
||||
{
|
||||
return BT_QUANTIZED_BVH_NODE_testQuantizedBoxOverlapp(_native, quantizedMin, quantizedMax);
|
||||
}
|
||||
|
||||
public int DataIndex
|
||||
{
|
||||
get { return BT_QUANTIZED_BVH_NODE_getDataIndex(_native); }
|
||||
set { BT_QUANTIZED_BVH_NODE_setDataIndex(_native, value); }
|
||||
}
|
||||
|
||||
public int EscapeIndex
|
||||
{
|
||||
get { return BT_QUANTIZED_BVH_NODE_getEscapeIndex(_native); }
|
||||
set { BT_QUANTIZED_BVH_NODE_setEscapeIndex(_native, value); }
|
||||
}
|
||||
|
||||
public int EscapeIndexOrDataIndex
|
||||
{
|
||||
get { return BT_QUANTIZED_BVH_NODE_getEscapeIndexOrDataIndex(_native); }
|
||||
set { BT_QUANTIZED_BVH_NODE_setEscapeIndexOrDataIndex(_native, value); }
|
||||
}
|
||||
|
||||
public bool IsLeafNode
|
||||
{
|
||||
get { return BT_QUANTIZED_BVH_NODE_isLeafNode(_native); }
|
||||
}
|
||||
/*
|
||||
public UShortArray QuantizedAabbMax
|
||||
{
|
||||
get { return BT_QUANTIZED_BVH_NODE_getQuantizedAabbMax(_native); }
|
||||
}
|
||||
|
||||
public UShortArray QuantizedAabbMin
|
||||
{
|
||||
get { return BT_QUANTIZED_BVH_NODE_getQuantizedAabbMin(_native); }
|
||||
}
|
||||
*/
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
BT_QUANTIZED_BVH_NODE_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~GImpactQuantizedBvhNode()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr BT_QUANTIZED_BVH_NODE_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int BT_QUANTIZED_BVH_NODE_getDataIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int BT_QUANTIZED_BVH_NODE_getEscapeIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int BT_QUANTIZED_BVH_NODE_getEscapeIndexOrDataIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr BT_QUANTIZED_BVH_NODE_getQuantizedAabbMax(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr BT_QUANTIZED_BVH_NODE_getQuantizedAabbMin(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool BT_QUANTIZED_BVH_NODE_isLeafNode(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_QUANTIZED_BVH_NODE_setDataIndex(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_QUANTIZED_BVH_NODE_setEscapeIndex(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_QUANTIZED_BVH_NODE_setEscapeIndexOrDataIndex(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool BT_QUANTIZED_BVH_NODE_testQuantizedBoxOverlapp(IntPtr obj, ushort[] quantizedMin, ushort[] quantizedMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void BT_QUANTIZED_BVH_NODE_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class GimGImpactQuantizedBvhNodeArray
|
||||
{
|
||||
private IntPtr _native;
|
||||
|
||||
internal GimGImpactQuantizedBvhNodeArray(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public GimGImpactQuantizedBvhNodeArray()
|
||||
{
|
||||
_native = GIM_QUANTIZED_BVH_NODE_ARRAY_new();
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_QUANTIZED_BVH_NODE_ARRAY_new();
|
||||
}
|
||||
|
||||
public class QuantizedBvhTree : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal QuantizedBvhTree(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public QuantizedBvhTree()
|
||||
{
|
||||
_native = btQuantizedBvhTree_new();
|
||||
}
|
||||
|
||||
public void BuildTree(GimBvhDataArray primitiveBoxes)
|
||||
{
|
||||
btQuantizedBvhTree_build_tree(_native, primitiveBoxes._native);
|
||||
}
|
||||
|
||||
public void ClearNodes()
|
||||
{
|
||||
btQuantizedBvhTree_clearNodes(_native);
|
||||
}
|
||||
/*
|
||||
public GImpactQuantizedBvhNode GetNodePointer()
|
||||
{
|
||||
return btQuantizedBvhTree_get_node_pointer(_native);
|
||||
}
|
||||
|
||||
public GImpactQuantizedBvhNode GetNodePointer(int index)
|
||||
{
|
||||
return btQuantizedBvhTree_get_node_pointer2(_native, index);
|
||||
}
|
||||
*/
|
||||
public int GetEscapeNodeIndex(int nodeindex)
|
||||
{
|
||||
return btQuantizedBvhTree_getEscapeNodeIndex(_native, nodeindex);
|
||||
}
|
||||
|
||||
public int GetLeftNode(int nodeindex)
|
||||
{
|
||||
return btQuantizedBvhTree_getLeftNode(_native, nodeindex);
|
||||
}
|
||||
|
||||
public void GetNodeBound(int nodeindex, Aabb bound)
|
||||
{
|
||||
btQuantizedBvhTree_getNodeBound(_native, nodeindex, bound._native);
|
||||
}
|
||||
|
||||
public int GetNodeData(int nodeindex)
|
||||
{
|
||||
return btQuantizedBvhTree_getNodeData(_native, nodeindex);
|
||||
}
|
||||
|
||||
public int GetRightNode(int nodeindex)
|
||||
{
|
||||
return btQuantizedBvhTree_getRightNode(_native, nodeindex);
|
||||
}
|
||||
|
||||
public bool IsLeafNode(int nodeindex)
|
||||
{
|
||||
return btQuantizedBvhTree_isLeafNode(_native, nodeindex);
|
||||
}
|
||||
|
||||
public void QuantizePoint(ushort[] quantizedpoint, Vector3 point)
|
||||
{
|
||||
btQuantizedBvhTree_quantizePoint(_native, quantizedpoint, ref point);
|
||||
}
|
||||
|
||||
public void SetNodeBound(int nodeindex, Aabb bound)
|
||||
{
|
||||
btQuantizedBvhTree_setNodeBound(_native, nodeindex, bound._native);
|
||||
}
|
||||
|
||||
public bool TestQuantizedBoxOverlap(int nodeIndex, ushort[] quantizedMin, ushort[] quantizedMax)
|
||||
{
|
||||
return btQuantizedBvhTree_testQuantizedBoxOverlapp(_native, nodeIndex, quantizedMin, quantizedMax);
|
||||
}
|
||||
|
||||
public int NodeCount
|
||||
{
|
||||
get { return btQuantizedBvhTree_getNodeCount(_native); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btQuantizedBvhTree_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~QuantizedBvhTree()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btQuantizedBvhTree_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvhTree_build_tree(IntPtr obj, IntPtr primitive_boxes);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvhTree_clearNodes(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btQuantizedBvhTree_get_node_pointer(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btQuantizedBvhTree_get_node_pointer2(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btQuantizedBvhTree_getEscapeNodeIndex(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btQuantizedBvhTree_getLeftNode(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvhTree_getNodeBound(IntPtr obj, int nodeindex, IntPtr bound);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btQuantizedBvhTree_getNodeCount(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btQuantizedBvhTree_getNodeData(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btQuantizedBvhTree_getRightNode(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btQuantizedBvhTree_isLeafNode(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvhTree_quantizePoint(IntPtr obj, ushort[] quantizedpoint, [In] ref Vector3 point);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvhTree_setNodeBound(IntPtr obj, int nodeindex, IntPtr bound);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btQuantizedBvhTree_testQuantizedBoxOverlapp(IntPtr obj, int node_index, ushort[] quantizedMin, ushort[] quantizedMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvhTree_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class GImpactQuantizedBvh : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
private PrimitiveManagerBase _primitiveManager;
|
||||
|
||||
internal GImpactQuantizedBvh(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public GImpactQuantizedBvh()
|
||||
{
|
||||
_native = btGImpactQuantizedBvh_new();
|
||||
}
|
||||
|
||||
public GImpactQuantizedBvh(PrimitiveManagerBase primitiveManager)
|
||||
{
|
||||
_primitiveManager = primitiveManager;
|
||||
_native = btGImpactQuantizedBvh_new2(primitiveManager._native);
|
||||
}
|
||||
/*
|
||||
public bool BoxQuery(Aabb box, AlignedIntArray collidedResults)
|
||||
{
|
||||
return btGImpactQuantizedBvh_boxQuery(_native, box._native, collidedResults._native);
|
||||
}
|
||||
|
||||
public bool BoxQueryTrans(Aabb box, Matrix transform, AlignedIntArray collidedResults)
|
||||
{
|
||||
return btGImpactQuantizedBvh_boxQueryTrans(_native, box._native, ref transform, collidedResults._native);
|
||||
}
|
||||
*/
|
||||
public void BuildSet()
|
||||
{
|
||||
btGImpactQuantizedBvh_buildSet(_native);
|
||||
}
|
||||
|
||||
public static void FindCollision(GImpactQuantizedBvh boxset1, Matrix trans1, GImpactQuantizedBvh boxset2, Matrix trans2, PairSet collisionPairs)
|
||||
{
|
||||
btGImpactQuantizedBvh_find_collision(boxset1._native, ref trans1, boxset2._native, ref trans2, collisionPairs._native);
|
||||
}
|
||||
/*
|
||||
public GImpactQuantizedBvhNode GetNodePointer()
|
||||
{
|
||||
return btGImpactQuantizedBvh_get_node_pointer(_native);
|
||||
}
|
||||
|
||||
public GImpactQuantizedBvhNode GetNodePointer(int index)
|
||||
{
|
||||
return btGImpactQuantizedBvh_get_node_pointer2(_native, index);
|
||||
}
|
||||
*/
|
||||
public int GetEscapeNodeIndex(int nodeindex)
|
||||
{
|
||||
return btGImpactQuantizedBvh_getEscapeNodeIndex(_native, nodeindex);
|
||||
}
|
||||
|
||||
public int GetLeftNode(int nodeindex)
|
||||
{
|
||||
return btGImpactQuantizedBvh_getLeftNode(_native, nodeindex);
|
||||
}
|
||||
|
||||
public void GetNodeBound(int nodeindex, Aabb bound)
|
||||
{
|
||||
btGImpactQuantizedBvh_getNodeBound(_native, nodeindex, bound._native);
|
||||
}
|
||||
|
||||
public int GetNodeData(int nodeindex)
|
||||
{
|
||||
return btGImpactQuantizedBvh_getNodeData(_native, nodeindex);
|
||||
}
|
||||
|
||||
public void GetNodeTriangle(int nodeindex, PrimitiveTriangle triangle)
|
||||
{
|
||||
btGImpactQuantizedBvh_getNodeTriangle(_native, nodeindex, triangle._native);
|
||||
}
|
||||
|
||||
public int GetRightNode(int nodeindex)
|
||||
{
|
||||
return btGImpactQuantizedBvh_getRightNode(_native, nodeindex);
|
||||
}
|
||||
|
||||
public bool IsLeafNode(int nodeindex)
|
||||
{
|
||||
return btGImpactQuantizedBvh_isLeafNode(_native, nodeindex);
|
||||
}
|
||||
/*
|
||||
public bool RayQuery(Vector3 rayDir, Vector3 rayOrigin, AlignedIntArray collidedResults)
|
||||
{
|
||||
return btGImpactQuantizedBvh_rayQuery(_native, ref rayDir, ref rayOrigin, collidedResults._native);
|
||||
}
|
||||
*/
|
||||
public void SetNodeBound(int nodeindex, Aabb bound)
|
||||
{
|
||||
btGImpactQuantizedBvh_setNodeBound(_native, nodeindex, bound._native);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
btGImpactQuantizedBvh_update(_native);
|
||||
}
|
||||
|
||||
public Aabb GlobalBox
|
||||
{
|
||||
get { return new Aabb(btGImpactQuantizedBvh_getGlobalBox(_native), true); }
|
||||
}
|
||||
|
||||
public bool HasHierarchy
|
||||
{
|
||||
get { return btGImpactQuantizedBvh_hasHierarchy(_native); }
|
||||
}
|
||||
|
||||
public bool IsTrimesh
|
||||
{
|
||||
get { return btGImpactQuantizedBvh_isTrimesh(_native); }
|
||||
}
|
||||
|
||||
public int NodeCount
|
||||
{
|
||||
get { return btGImpactQuantizedBvh_getNodeCount(_native); }
|
||||
}
|
||||
|
||||
public PrimitiveManagerBase PrimitiveManager
|
||||
{
|
||||
get { return _primitiveManager; }
|
||||
set
|
||||
{
|
||||
_primitiveManager = value;
|
||||
btGImpactQuantizedBvh_setPrimitiveManager(_native, value._native);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btGImpactQuantizedBvh_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~GImpactQuantizedBvh()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactQuantizedBvh_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactQuantizedBvh_new2(IntPtr primitive_manager);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactQuantizedBvh_boxQuery(IntPtr obj, IntPtr box, IntPtr collided_results);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactQuantizedBvh_boxQueryTrans(IntPtr obj, IntPtr box, [In] ref Matrix transform, IntPtr collided_results);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactQuantizedBvh_buildSet(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactQuantizedBvh_find_collision(IntPtr boxset1, [In] ref Matrix trans1, IntPtr boxset2, [In] ref Matrix trans2, IntPtr collision_pairs);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactQuantizedBvh_get_node_pointer(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactQuantizedBvh_get_node_pointer2(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactQuantizedBvh_getEscapeNodeIndex(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactQuantizedBvh_getGlobalBox(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactQuantizedBvh_getLeftNode(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactQuantizedBvh_getNodeBound(IntPtr obj, int nodeindex, IntPtr bound);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactQuantizedBvh_getNodeCount(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactQuantizedBvh_getNodeData(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactQuantizedBvh_getNodeTriangle(IntPtr obj, int nodeindex, IntPtr triangle);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactQuantizedBvh_getPrimitiveManager(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactQuantizedBvh_getRightNode(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactQuantizedBvh_hasHierarchy(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactQuantizedBvh_isLeafNode(IntPtr obj, int nodeindex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactQuantizedBvh_isTrimesh(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactQuantizedBvh_rayQuery(IntPtr obj, [In] ref Vector3 ray_dir, [In] ref Vector3 ray_origin, IntPtr collided_results);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactQuantizedBvh_setNodeBound(IntPtr obj, int nodeindex, IntPtr bound);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactQuantizedBvh_setPrimitiveManager(IntPtr obj, IntPtr primitive_manager);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactQuantizedBvh_update(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactQuantizedBvh_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,631 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public enum GImpactShapeType
|
||||
{
|
||||
CompoundShape,
|
||||
TrimeshShapePart,
|
||||
TrimeshShape
|
||||
}
|
||||
|
||||
public class TetrahedronShapeEx : BuSimplex1To4
|
||||
{
|
||||
public TetrahedronShapeEx()
|
||||
: base(btTetrahedronShapeEx_new())
|
||||
{
|
||||
}
|
||||
|
||||
public void SetVertices(Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3)
|
||||
{
|
||||
btTetrahedronShapeEx_setVertices(_native, ref v0, ref v1, ref v2, ref v3);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btTetrahedronShapeEx_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btTetrahedronShapeEx_setVertices(IntPtr obj, [In] ref Vector3 v0, [In] ref Vector3 v1, [In] ref Vector3 v2, [In] ref Vector3 v3);
|
||||
}
|
||||
|
||||
public abstract class GImpactShapeInterface : ConcaveShape
|
||||
{
|
||||
protected List<CollisionShape> _childShapes = new List<CollisionShape>();
|
||||
|
||||
internal GImpactShapeInterface(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public void GetBulletTetrahedron(int primIndex, TetrahedronShapeEx tetrahedron)
|
||||
{
|
||||
btGImpactShapeInterface_getBulletTetrahedron(_native, primIndex, tetrahedron._native);
|
||||
}
|
||||
|
||||
public void GetBulletTriangle(int primIndex, TriangleShapeEx triangle)
|
||||
{
|
||||
btGImpactShapeInterface_getBulletTriangle(_native, primIndex, triangle._native);
|
||||
}
|
||||
|
||||
public void GetChildAabb(int childIndex, Matrix t, out Vector3 aabbMin, out Vector3 aabbMax)
|
||||
{
|
||||
btGImpactShapeInterface_getChildAabb(_native, childIndex, ref t, out aabbMin, out aabbMax);
|
||||
}
|
||||
|
||||
public CollisionShape GetChildShape(int index)
|
||||
{
|
||||
return _childShapes[index];
|
||||
}
|
||||
|
||||
public Matrix GetChildTransform(int index)
|
||||
{
|
||||
Matrix value;
|
||||
btGImpactShapeInterface_getChildTransform(_native, index, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public void GetPrimitiveTriangle(int index, PrimitiveTriangle triangle)
|
||||
{
|
||||
btGImpactShapeInterface_getPrimitiveTriangle(_native, index, triangle._native);
|
||||
}
|
||||
|
||||
public void LockChildShapes()
|
||||
{
|
||||
btGImpactShapeInterface_lockChildShapes(_native);
|
||||
}
|
||||
|
||||
public void PostUpdate()
|
||||
{
|
||||
btGImpactShapeInterface_postUpdate(_native);
|
||||
}
|
||||
|
||||
public void ProcessAllTrianglesRay(TriangleCallback cb, ref Vector3 rayFrom, ref Vector3 rayTo)
|
||||
{
|
||||
btGImpactShapeInterface_processAllTrianglesRay(_native, cb._native, ref rayFrom, ref rayTo);
|
||||
}
|
||||
|
||||
public void ProcessAllTrianglesRay(TriangleCallback cb, Vector3 rayFrom, Vector3 rayTo)
|
||||
{
|
||||
btGImpactShapeInterface_processAllTrianglesRay(_native, cb._native, ref rayFrom, ref rayTo);
|
||||
}
|
||||
|
||||
public void RayTest(Vector3 rayFrom, Vector3 rayTo, RayResultCallback resultCallback)
|
||||
{
|
||||
btGImpactShapeInterface_rayTest(_native, ref rayFrom, ref rayTo, resultCallback._native);
|
||||
}
|
||||
|
||||
public void SetChildTransform(int index, Matrix transform)
|
||||
{
|
||||
btGImpactShapeInterface_setChildTransform(_native, index, ref transform);
|
||||
}
|
||||
|
||||
public void UnlockChildShapes()
|
||||
{
|
||||
btGImpactShapeInterface_unlockChildShapes(_native);
|
||||
}
|
||||
|
||||
public void UpdateBound()
|
||||
{
|
||||
btGImpactShapeInterface_updateBound(_native);
|
||||
}
|
||||
/*
|
||||
public GImpactBoxSet BoxSet
|
||||
{
|
||||
get { return btGImpactShapeInterface_getBoxSet(_native); }
|
||||
}
|
||||
*/
|
||||
public bool ChildrenHasTransform
|
||||
{
|
||||
get{return btGImpactShapeInterface_childrenHasTransform(_native);}
|
||||
}
|
||||
|
||||
public GImpactShapeType GImpactShapeType
|
||||
{
|
||||
get { return btGImpactShapeInterface_getGImpactShapeType(_native); }
|
||||
}
|
||||
|
||||
public bool HasBoxSet
|
||||
{
|
||||
get { return btGImpactShapeInterface_hasBoxSet(_native); }
|
||||
}
|
||||
|
||||
public Aabb LocalBox
|
||||
{
|
||||
get { return new Aabb(btGImpactShapeInterface_getLocalBox(_native), true); }
|
||||
}
|
||||
|
||||
public bool NeedsRetrieveTetrahedrons
|
||||
{
|
||||
get { return btGImpactShapeInterface_needsRetrieveTetrahedrons(_native); }
|
||||
}
|
||||
|
||||
public bool NeedsRetrieveTriangles
|
||||
{
|
||||
get { return btGImpactShapeInterface_needsRetrieveTriangles(_native); }
|
||||
}
|
||||
|
||||
public int NumChildShapes
|
||||
{
|
||||
get { return btGImpactShapeInterface_getNumChildShapes(_native); }
|
||||
}
|
||||
|
||||
public abstract PrimitiveManagerBase PrimitiveManager
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactShapeInterface_childrenHasTransform(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactShapeInterface_getBoxSet(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactShapeInterface_getBulletTetrahedron(IntPtr obj, int prim_index, IntPtr tetrahedron);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactShapeInterface_getBulletTriangle(IntPtr obj, int prim_index, IntPtr triangle);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactShapeInterface_getChildAabb(IntPtr obj, int child_index, [In] ref Matrix t, [Out] out Vector3 aabbMin, [Out] out Vector3 aabbMax);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btGImpactShapeInterface_getChildShape(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactShapeInterface_getChildTransform(IntPtr obj, int index, [Out] out Matrix value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern GImpactShapeType btGImpactShapeInterface_getGImpactShapeType(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactShapeInterface_getLocalBox(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactShapeInterface_getNumChildShapes(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactShapeInterface_getPrimitiveManager(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactShapeInterface_getPrimitiveTriangle(IntPtr obj, int index, IntPtr triangle);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactShapeInterface_hasBoxSet(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactShapeInterface_lockChildShapes(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactShapeInterface_needsRetrieveTetrahedrons(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btGImpactShapeInterface_needsRetrieveTriangles(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactShapeInterface_postUpdate(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactShapeInterface_processAllTrianglesRay(IntPtr obj, IntPtr __unnamed0, [In] ref Vector3 __unnamed1, [In] ref Vector3 __unnamed2);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactShapeInterface_rayTest(IntPtr obj, [In] ref Vector3 rayFrom, [In] ref Vector3 rayTo, IntPtr resultCallback);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactShapeInterface_setChildTransform(IntPtr obj, int index, [In] ref Matrix transform);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactShapeInterface_unlockChildShapes(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactShapeInterface_updateBound(IntPtr obj);
|
||||
}
|
||||
|
||||
public class CompoundPrimitiveManager : PrimitiveManagerBase
|
||||
{
|
||||
internal CompoundPrimitiveManager(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public GImpactCompoundShape CompoundShape
|
||||
{
|
||||
get { return CollisionShape.GetManaged(btGImpactCompoundShape_CompoundPrimitiveManager_getCompoundShape(_native)) as GImpactCompoundShape; }
|
||||
set { btGImpactCompoundShape_CompoundPrimitiveManager_setCompoundShape(_native, value._native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactCompoundShape_CompoundPrimitiveManager_getCompoundShape(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactCompoundShape_CompoundPrimitiveManager_setCompoundShape(IntPtr obj, IntPtr value);
|
||||
}
|
||||
|
||||
public class GImpactCompoundShape : GImpactShapeInterface
|
||||
{
|
||||
private CompoundPrimitiveManager _compoundPrimitiveManager;
|
||||
|
||||
internal GImpactCompoundShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public GImpactCompoundShape()
|
||||
: base(btGImpactCompoundShape_new())
|
||||
{
|
||||
}
|
||||
|
||||
public GImpactCompoundShape(bool childrenHasTransform)
|
||||
: base(btGImpactCompoundShape_new2(childrenHasTransform))
|
||||
{
|
||||
}
|
||||
|
||||
public void AddChildShape(Matrix localTransform, CollisionShape shape)
|
||||
{
|
||||
_childShapes.Add(shape);
|
||||
btGImpactCompoundShape_addChildShape(_native, ref localTransform, shape._native);
|
||||
}
|
||||
|
||||
public void AddChildShape(CollisionShape shape)
|
||||
{
|
||||
_childShapes.Add(shape);
|
||||
btGImpactCompoundShape_addChildShape2(_native, shape._native);
|
||||
}
|
||||
|
||||
public override PrimitiveManagerBase PrimitiveManager
|
||||
{
|
||||
get { return CompoundPrimitiveManager; }
|
||||
}
|
||||
|
||||
public CompoundPrimitiveManager CompoundPrimitiveManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_compoundPrimitiveManager == null)
|
||||
{
|
||||
_compoundPrimitiveManager = new CompoundPrimitiveManager(btGImpactCompoundShape_getCompoundPrimitiveManager(_native));
|
||||
}
|
||||
return _compoundPrimitiveManager;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactCompoundShape_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactCompoundShape_new2(bool children_has_transform);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactCompoundShape_addChildShape(IntPtr obj, [In] ref Matrix localTransform, IntPtr shape);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactCompoundShape_addChildShape2(IntPtr obj, IntPtr shape);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactCompoundShape_getCompoundPrimitiveManager(IntPtr obj);
|
||||
}
|
||||
|
||||
public class TrimeshPrimitiveManager : PrimitiveManagerBase
|
||||
{
|
||||
StridingMeshInterface _meshInterface;
|
||||
|
||||
internal TrimeshPrimitiveManager(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public TrimeshPrimitiveManager(StridingMeshInterface meshInterface, int part)
|
||||
: base(btGImpactMeshShapePart_TrimeshPrimitiveManager_new(meshInterface._native, part))
|
||||
{
|
||||
_meshInterface = meshInterface;
|
||||
}
|
||||
|
||||
public TrimeshPrimitiveManager(TrimeshPrimitiveManager manager)
|
||||
: base(btGImpactMeshShapePart_TrimeshPrimitiveManager_new2(manager._native))
|
||||
{
|
||||
}
|
||||
|
||||
public TrimeshPrimitiveManager()
|
||||
: base(btGImpactMeshShapePart_TrimeshPrimitiveManager_new3())
|
||||
{
|
||||
}
|
||||
|
||||
public void GetBulletTriangle(int primIndex, TriangleShapeEx triangle)
|
||||
{
|
||||
btGImpactMeshShapePart_TrimeshPrimitiveManager_get_bullet_triangle(_native, primIndex, triangle._native);
|
||||
}
|
||||
|
||||
public void GetIndices(int faceIndex, out uint i0, out uint i1, out uint i2)
|
||||
{
|
||||
btGImpactMeshShapePart_TrimeshPrimitiveManager_get_indices(_native, faceIndex, out i0, out i1, out i2);
|
||||
}
|
||||
|
||||
public void GetVertex(uint vertexIndex, out Vector3 vertex)
|
||||
{
|
||||
btGImpactMeshShapePart_TrimeshPrimitiveManager_get_vertex(_native, vertexIndex, out vertex);
|
||||
}
|
||||
|
||||
public void Lock()
|
||||
{
|
||||
btGImpactMeshShapePart_TrimeshPrimitiveManager_lock(_native);
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
btGImpactMeshShapePart_TrimeshPrimitiveManager_unlock(_native);
|
||||
}
|
||||
|
||||
public IntPtr IndexBase
|
||||
{
|
||||
get { return btGImpactMeshShapePart_TrimeshPrimitiveManager_getIndexbase(_native); }
|
||||
set { btGImpactMeshShapePart_TrimeshPrimitiveManager_setIndexbase(_native, value); }
|
||||
}
|
||||
|
||||
public int IndexStride
|
||||
{
|
||||
get { return btGImpactMeshShapePart_TrimeshPrimitiveManager_getIndexstride(_native); }
|
||||
set { btGImpactMeshShapePart_TrimeshPrimitiveManager_setIndexstride(_native, value); }
|
||||
}
|
||||
|
||||
public PhyScalarType IndicesType
|
||||
{
|
||||
get { return btGImpactMeshShapePart_TrimeshPrimitiveManager_getIndicestype(_native); }
|
||||
set { btGImpactMeshShapePart_TrimeshPrimitiveManager_setIndicestype(_native, value); }
|
||||
}
|
||||
|
||||
public int LockCount
|
||||
{
|
||||
get { return btGImpactMeshShapePart_TrimeshPrimitiveManager_getLock_count(_native); }
|
||||
set { btGImpactMeshShapePart_TrimeshPrimitiveManager_setLock_count(_native, value); }
|
||||
}
|
||||
|
||||
public float Margin
|
||||
{
|
||||
get { return btGImpactMeshShapePart_TrimeshPrimitiveManager_getMargin(_native); }
|
||||
set { btGImpactMeshShapePart_TrimeshPrimitiveManager_setMargin(_native, value); }
|
||||
}
|
||||
|
||||
public StridingMeshInterface MeshInterface
|
||||
{
|
||||
get { return _meshInterface; }
|
||||
set
|
||||
{
|
||||
_meshInterface = value;
|
||||
btGImpactMeshShapePart_TrimeshPrimitiveManager_setMeshInterface(_native, value._native);
|
||||
}
|
||||
}
|
||||
|
||||
public int Numfaces
|
||||
{
|
||||
get { return btGImpactMeshShapePart_TrimeshPrimitiveManager_getNumfaces(_native); }
|
||||
set { btGImpactMeshShapePart_TrimeshPrimitiveManager_setNumfaces(_native, value); }
|
||||
}
|
||||
|
||||
public int Numverts
|
||||
{
|
||||
get { return btGImpactMeshShapePart_TrimeshPrimitiveManager_getNumverts(_native); }
|
||||
set { btGImpactMeshShapePart_TrimeshPrimitiveManager_setNumverts(_native, value); }
|
||||
}
|
||||
|
||||
public int Part
|
||||
{
|
||||
get { return btGImpactMeshShapePart_TrimeshPrimitiveManager_getPart(_native); }
|
||||
set { btGImpactMeshShapePart_TrimeshPrimitiveManager_setPart(_native, value); }
|
||||
}
|
||||
|
||||
public Vector3 Scale
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btGImpactMeshShapePart_TrimeshPrimitiveManager_getScale(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btGImpactMeshShapePart_TrimeshPrimitiveManager_setScale(_native, ref value); }
|
||||
}
|
||||
|
||||
public int Stride
|
||||
{
|
||||
get { return btGImpactMeshShapePart_TrimeshPrimitiveManager_getStride(_native); }
|
||||
set { btGImpactMeshShapePart_TrimeshPrimitiveManager_setStride(_native, value); }
|
||||
}
|
||||
|
||||
public PhyScalarType Type
|
||||
{
|
||||
get { return btGImpactMeshShapePart_TrimeshPrimitiveManager_getType(_native); }
|
||||
set { btGImpactMeshShapePart_TrimeshPrimitiveManager_setType(_native, value); }
|
||||
}
|
||||
|
||||
public IntPtr VertexBase
|
||||
{
|
||||
get { return btGImpactMeshShapePart_TrimeshPrimitiveManager_getVertexbase(_native); }
|
||||
set { btGImpactMeshShapePart_TrimeshPrimitiveManager_setVertexbase(_native, value); }
|
||||
}
|
||||
|
||||
public int VertexCount
|
||||
{
|
||||
get { return btGImpactMeshShapePart_TrimeshPrimitiveManager_get_vertex_count(_native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactMeshShapePart_TrimeshPrimitiveManager_new(IntPtr meshInterface, int part);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactMeshShapePart_TrimeshPrimitiveManager_new2(IntPtr manager);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactMeshShapePart_TrimeshPrimitiveManager_new3();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_get_bullet_triangle(IntPtr obj, int prim_index, IntPtr triangle);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_get_indices(IntPtr obj, int face_index, [Out] out uint i0, [Out] out uint i1, [Out] out uint i2);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_get_vertex(IntPtr obj, uint vertex_index, [Out] out Vector3 vertex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactMeshShapePart_TrimeshPrimitiveManager_get_vertex_count(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactMeshShapePart_TrimeshPrimitiveManager_getIndexbase(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactMeshShapePart_TrimeshPrimitiveManager_getIndexstride(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern PhyScalarType btGImpactMeshShapePart_TrimeshPrimitiveManager_getIndicestype(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactMeshShapePart_TrimeshPrimitiveManager_getLock_count(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btGImpactMeshShapePart_TrimeshPrimitiveManager_getMargin(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactMeshShapePart_TrimeshPrimitiveManager_getMeshInterface(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactMeshShapePart_TrimeshPrimitiveManager_getNumfaces(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactMeshShapePart_TrimeshPrimitiveManager_getNumverts(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactMeshShapePart_TrimeshPrimitiveManager_getPart(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_getScale(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactMeshShapePart_TrimeshPrimitiveManager_getStride(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern PhyScalarType btGImpactMeshShapePart_TrimeshPrimitiveManager_getType(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactMeshShapePart_TrimeshPrimitiveManager_getVertexbase(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_lock(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setIndexbase(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setIndexstride(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setIndicestype(IntPtr obj, PhyScalarType value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setLock_count(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setMargin(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setMeshInterface(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setNumfaces(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setNumverts(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setPart(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setScale(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setStride(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setType(IntPtr obj, PhyScalarType value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_setVertexbase(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_TrimeshPrimitiveManager_unlock(IntPtr obj);
|
||||
}
|
||||
|
||||
public class GImpactMeshShapePart : GImpactShapeInterface
|
||||
{
|
||||
private TrimeshPrimitiveManager _gImpactTrimeshPrimitiveManager;
|
||||
|
||||
internal GImpactMeshShapePart(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public GImpactMeshShapePart()
|
||||
: base(btGImpactMeshShapePart_new())
|
||||
{
|
||||
}
|
||||
|
||||
public GImpactMeshShapePart(StridingMeshInterface meshInterface, int part)
|
||||
: base(btGImpactMeshShapePart_new2(meshInterface._native, part))
|
||||
{
|
||||
}
|
||||
|
||||
public void GetVertex(int vertexIndex, out Vector3 vertex)
|
||||
{
|
||||
btGImpactMeshShapePart_getVertex(_native, vertexIndex, out vertex);
|
||||
}
|
||||
|
||||
public int Part
|
||||
{
|
||||
get { return btGImpactMeshShapePart_getPart(_native); }
|
||||
}
|
||||
|
||||
public override PrimitiveManagerBase PrimitiveManager
|
||||
{
|
||||
get { return GImpactTrimeshPrimitiveManager; }
|
||||
}
|
||||
|
||||
public TrimeshPrimitiveManager GImpactTrimeshPrimitiveManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_gImpactTrimeshPrimitiveManager == null)
|
||||
{
|
||||
_gImpactTrimeshPrimitiveManager = new TrimeshPrimitiveManager(btGImpactMeshShapePart_getTrimeshPrimitiveManager(_native));
|
||||
}
|
||||
return _gImpactTrimeshPrimitiveManager;
|
||||
}
|
||||
}
|
||||
|
||||
public int VertexCount
|
||||
{
|
||||
get { return btGImpactMeshShapePart_getVertexCount(_native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactMeshShapePart_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactMeshShapePart_new2(IntPtr meshInterface, int part);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactMeshShapePart_getPart(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactMeshShapePart_getTrimeshPrimitiveManager(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGImpactMeshShapePart_getVertex(IntPtr obj, int vertex_index, [Out] out Vector3 vertex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactMeshShapePart_getVertexCount(IntPtr obj);
|
||||
}
|
||||
|
||||
public class GImpactMeshShape : GImpactShapeInterface
|
||||
{
|
||||
StridingMeshInterface _meshInterface;
|
||||
bool _disposeMeshInterface;
|
||||
|
||||
internal GImpactMeshShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public GImpactMeshShape(StridingMeshInterface meshInterface)
|
||||
: base(btGImpactMeshShape_new(meshInterface._native))
|
||||
{
|
||||
_meshInterface = meshInterface;
|
||||
}
|
||||
|
||||
public GImpactMeshShapePart GetMeshPart(int index)
|
||||
{
|
||||
return new GImpactMeshShapePart(btGImpactMeshShape_getMeshPart(_native, index));
|
||||
}
|
||||
|
||||
public StridingMeshInterface MeshInterface
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_meshInterface == null)
|
||||
{
|
||||
_meshInterface = new StridingMeshInterface(btGImpactMeshShape_getMeshInterface(_native));
|
||||
_disposeMeshInterface = true;
|
||||
}
|
||||
return _meshInterface;
|
||||
}
|
||||
}
|
||||
|
||||
public int MeshPartCount
|
||||
{
|
||||
get { return btGImpactMeshShape_getMeshPartCount(_native); }
|
||||
}
|
||||
|
||||
public override PrimitiveManagerBase PrimitiveManager
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && _disposeMeshInterface)
|
||||
{
|
||||
_meshInterface.Dispose();
|
||||
_disposeMeshInterface = false;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactMeshShape_new(IntPtr meshInterface);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactMeshShape_getMeshInterface(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGImpactMeshShape_getMeshPart(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGImpactMeshShape_getMeshPartCount(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,283 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class GimTriangleContact : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal GimTriangleContact(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public GimTriangleContact()
|
||||
{
|
||||
_native = GIM_TRIANGLE_CONTACT_new();
|
||||
}
|
||||
|
||||
public GimTriangleContact(GimTriangleContact other)
|
||||
{
|
||||
_native = GIM_TRIANGLE_CONTACT_new2(other._native);
|
||||
}
|
||||
|
||||
public void CopyFrom(GimTriangleContact other)
|
||||
{
|
||||
GIM_TRIANGLE_CONTACT_copy_from(_native, other._native);
|
||||
}
|
||||
/*
|
||||
public void MergePoints(Vector4 plane, float margin, Vector3 points, int pointCount)
|
||||
{
|
||||
GIM_TRIANGLE_CONTACT_merge_points(_native, ref plane, margin, ref points, pointCount);
|
||||
}
|
||||
*/
|
||||
public float PenetrationDepth
|
||||
{
|
||||
get { return GIM_TRIANGLE_CONTACT_getPenetration_depth(_native); }
|
||||
set { GIM_TRIANGLE_CONTACT_setPenetration_depth(_native, value); }
|
||||
}
|
||||
|
||||
public int PointCount
|
||||
{
|
||||
get { return GIM_TRIANGLE_CONTACT_getPoint_count(_native); }
|
||||
set { GIM_TRIANGLE_CONTACT_setPoint_count(_native, value); }
|
||||
}
|
||||
|
||||
public Vector3Array Points
|
||||
{
|
||||
get { return new Vector3Array(GIM_TRIANGLE_CONTACT_getPoints(_native), 16); }
|
||||
}
|
||||
|
||||
public Vector4 SeparatingNormal
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector4 value;
|
||||
GIM_TRIANGLE_CONTACT_getSeparating_normal(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { GIM_TRIANGLE_CONTACT_setSeparating_normal(_native, ref value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
GIM_TRIANGLE_CONTACT_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~GimTriangleContact()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_TRIANGLE_CONTACT_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_TRIANGLE_CONTACT_new2(IntPtr other);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_TRIANGLE_CONTACT_copy_from(IntPtr obj, IntPtr other);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float GIM_TRIANGLE_CONTACT_getPenetration_depth(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int GIM_TRIANGLE_CONTACT_getPoint_count(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr GIM_TRIANGLE_CONTACT_getPoints(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_TRIANGLE_CONTACT_getSeparating_normal(IntPtr obj, [Out] out Vector4 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_TRIANGLE_CONTACT_merge_points(IntPtr obj, [In] ref Vector4 plane, float margin, [In] ref Vector3 points, int point_count);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_TRIANGLE_CONTACT_setPenetration_depth(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_TRIANGLE_CONTACT_setPoint_count(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_TRIANGLE_CONTACT_setSeparating_normal(IntPtr obj, [In] ref Vector4 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void GIM_TRIANGLE_CONTACT_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class PrimitiveTriangle : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal PrimitiveTriangle(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public PrimitiveTriangle()
|
||||
{
|
||||
_native = btPrimitiveTriangle_new();
|
||||
}
|
||||
|
||||
public void ApplyTransform(Matrix t)
|
||||
{
|
||||
btPrimitiveTriangle_applyTransform(_native, ref t);
|
||||
}
|
||||
|
||||
public void BuildTriPlane()
|
||||
{
|
||||
btPrimitiveTriangle_buildTriPlane(_native);
|
||||
}
|
||||
/*
|
||||
public int ClipTriangle(PrimitiveTriangle other, Vector3 clippedPoints)
|
||||
{
|
||||
return btPrimitiveTriangle_clip_triangle(_native, other._native, ref clippedPoints);
|
||||
}
|
||||
*/
|
||||
public bool FindTriangleCollisionClipMethod(PrimitiveTriangle other, GimTriangleContact contacts)
|
||||
{
|
||||
return btPrimitiveTriangle_find_triangle_collision_clip_method(_native, other._native, contacts._native);
|
||||
}
|
||||
|
||||
public void GetEdgePlane(int edgeIndex, out Vector4 plane)
|
||||
{
|
||||
btPrimitiveTriangle_get_edge_plane(_native, edgeIndex, out plane);
|
||||
}
|
||||
|
||||
public bool OverlapTestConservative(PrimitiveTriangle other)
|
||||
{
|
||||
return btPrimitiveTriangle_overlap_test_conservative(_native, other._native);
|
||||
}
|
||||
|
||||
public float Dummy
|
||||
{
|
||||
get { return btPrimitiveTriangle_getDummy(_native); }
|
||||
set { btPrimitiveTriangle_setDummy(_native, value); }
|
||||
}
|
||||
|
||||
public float Margin
|
||||
{
|
||||
get { return btPrimitiveTriangle_getMargin(_native); }
|
||||
set { btPrimitiveTriangle_setMargin(_native, value); }
|
||||
}
|
||||
|
||||
public Vector4 Plane
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector4 value;
|
||||
btPrimitiveTriangle_getPlane(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btPrimitiveTriangle_setPlane(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3Array Vertices
|
||||
{
|
||||
get { return new Vector3Array(btPrimitiveTriangle_getVertices(_native), 3); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btPrimitiveTriangle_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~PrimitiveTriangle()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btPrimitiveTriangle_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPrimitiveTriangle_applyTransform(IntPtr obj, [In] ref Matrix t);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPrimitiveTriangle_buildTriPlane(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btPrimitiveTriangle_clip_triangle(IntPtr obj, IntPtr other, [Out] out Vector3 clipped_points);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btPrimitiveTriangle_find_triangle_collision_clip_method(IntPtr obj, IntPtr other, IntPtr contacts);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPrimitiveTriangle_get_edge_plane(IntPtr obj, int edge_index, [Out] out Vector4 plane);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btPrimitiveTriangle_getDummy(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btPrimitiveTriangle_getMargin(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPrimitiveTriangle_getPlane(IntPtr obj, [Out] out Vector4 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btPrimitiveTriangle_getVertices(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btPrimitiveTriangle_overlap_test_conservative(IntPtr obj, IntPtr other);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPrimitiveTriangle_setDummy(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPrimitiveTriangle_setMargin(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPrimitiveTriangle_setPlane(IntPtr obj, [In] ref Vector4 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPrimitiveTriangle_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class TriangleShapeEx : TriangleShape
|
||||
{
|
||||
public TriangleShapeEx()
|
||||
: base(btTriangleShapeEx_new())
|
||||
{
|
||||
}
|
||||
|
||||
public TriangleShapeEx(Vector3 p0, Vector3 p1, Vector3 p2)
|
||||
: base(btTriangleShapeEx_new2(ref p0, ref p1, ref p2))
|
||||
{
|
||||
}
|
||||
|
||||
public TriangleShapeEx(TriangleShapeEx other)
|
||||
: base(btTriangleShapeEx_new3(other._native))
|
||||
{
|
||||
}
|
||||
|
||||
public void ApplyTransform(Matrix t)
|
||||
{
|
||||
btTriangleShapeEx_applyTransform(_native, ref t);
|
||||
}
|
||||
|
||||
public void BuildTriPlane(out Vector4 plane)
|
||||
{
|
||||
btTriangleShapeEx_buildTriPlane(_native, out plane);
|
||||
}
|
||||
|
||||
public bool OverlapTestConservative(TriangleShapeEx other)
|
||||
{
|
||||
return btTriangleShapeEx_overlap_test_conservative(_native, other._native);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btTriangleShapeEx_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btTriangleShapeEx_new2([In] ref Vector3 p0, [In] ref Vector3 p1, [In] ref Vector3 p2);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btTriangleShapeEx_new3(IntPtr other);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btTriangleShapeEx_applyTransform(IntPtr obj, [In] ref Matrix t);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btTriangleShapeEx_buildTriPlane(IntPtr obj, [Out] out Vector4 plane);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btTriangleShapeEx_overlap_test_conservative(IntPtr obj, IntPtr other);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,182 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class GhostObject : CollisionObject
|
||||
{
|
||||
AlignedCollisionObjectArray _overlappingPairs;
|
||||
|
||||
internal GhostObject(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public GhostObject()
|
||||
: base(btGhostObject_new())
|
||||
{
|
||||
}
|
||||
|
||||
public void AddOverlappingObjectInternal(BroadphaseProxy otherProxy)
|
||||
{
|
||||
btGhostObject_addOverlappingObjectInternal(_native, otherProxy._native);
|
||||
}
|
||||
|
||||
public void AddOverlappingObjectInternal(BroadphaseProxy otherProxy, BroadphaseProxy thisProxy)
|
||||
{
|
||||
btGhostObject_addOverlappingObjectInternal2(_native, otherProxy._native, thisProxy._native);
|
||||
}
|
||||
|
||||
public void ConvexSweepTest(ConvexShape castShape, ref Matrix convexFromWorld, ref Matrix convexToWorld, ConvexResultCallback resultCallback)
|
||||
{
|
||||
btGhostObject_convexSweepTest(_native, castShape._native, ref convexFromWorld, ref convexToWorld, resultCallback._native);
|
||||
}
|
||||
|
||||
public void ConvexSweepTest(ConvexShape castShape, Matrix convexFromWorld, Matrix convexToWorld, ConvexResultCallback resultCallback)
|
||||
{
|
||||
btGhostObject_convexSweepTest(_native, castShape._native, ref convexFromWorld, ref convexToWorld, resultCallback._native);
|
||||
}
|
||||
|
||||
public void ConvexSweepTest(ConvexShape castShape, ref Matrix convexFromWorld, ref Matrix convexToWorld, ConvexResultCallback resultCallback, float allowedCcdPenetration)
|
||||
{
|
||||
btGhostObject_convexSweepTest2(_native, castShape._native, ref convexFromWorld, ref convexToWorld, resultCallback._native, allowedCcdPenetration);
|
||||
}
|
||||
|
||||
public void ConvexSweepTest(ConvexShape castShape, Matrix convexFromWorld, Matrix convexToWorld, ConvexResultCallback resultCallback, float allowedCcdPenetration)
|
||||
{
|
||||
btGhostObject_convexSweepTest2(_native, castShape._native, ref convexFromWorld, ref convexToWorld, resultCallback._native, allowedCcdPenetration);
|
||||
}
|
||||
|
||||
public CollisionObject GetOverlappingObject(int index)
|
||||
{
|
||||
return CollisionObject.GetManaged(btGhostObject_getOverlappingObject(_native, index));
|
||||
}
|
||||
|
||||
public void RayTest(ref Vector3 rayFromWorld, ref Vector3 rayToWorld, RayResultCallback resultCallback)
|
||||
{
|
||||
btGhostObject_rayTest(_native, ref rayFromWorld, ref rayToWorld, resultCallback._native);
|
||||
}
|
||||
|
||||
public void RayTest(Vector3 rayFromWorld, Vector3 rayToWorld, RayResultCallback resultCallback)
|
||||
{
|
||||
btGhostObject_rayTest(_native, ref rayFromWorld, ref rayToWorld, resultCallback._native);
|
||||
}
|
||||
|
||||
public void RemoveOverlappingObjectInternal(BroadphaseProxy otherProxy, Dispatcher dispatcher)
|
||||
{
|
||||
btGhostObject_removeOverlappingObjectInternal(_native, otherProxy._native, dispatcher._native);
|
||||
}
|
||||
|
||||
public void RemoveOverlappingObjectInternal(BroadphaseProxy otherProxy, Dispatcher dispatcher, BroadphaseProxy thisProxy)
|
||||
{
|
||||
btGhostObject_removeOverlappingObjectInternal2(_native, otherProxy._native, dispatcher._native, thisProxy._native);
|
||||
}
|
||||
|
||||
public static GhostObject Upcast(CollisionObject colObj)
|
||||
{
|
||||
return GetManaged(btGhostObject_upcast(colObj._native)) as GhostObject;
|
||||
}
|
||||
|
||||
public int NumOverlappingObjects
|
||||
{
|
||||
get { return btGhostObject_getNumOverlappingObjects(_native); }
|
||||
}
|
||||
|
||||
public AlignedCollisionObjectArray OverlappingPairs
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_overlappingPairs == null)
|
||||
{
|
||||
_overlappingPairs = new AlignedCollisionObjectArray(btGhostObject_getOverlappingPairs(_native));
|
||||
}
|
||||
return _overlappingPairs;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGhostObject_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGhostObject_addOverlappingObjectInternal(IntPtr obj, IntPtr otherProxy);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGhostObject_addOverlappingObjectInternal2(IntPtr obj, IntPtr otherProxy, IntPtr thisProxy);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGhostObject_convexSweepTest(IntPtr obj, IntPtr castShape, [In] ref Matrix convexFromWorld, [In] ref Matrix convexToWorld, IntPtr resultCallback);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGhostObject_convexSweepTest2(IntPtr obj, IntPtr castShape, [In] ref Matrix convexFromWorld, [In] ref Matrix convexToWorld, IntPtr resultCallback, float allowedCcdPenetration);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGhostObject_getNumOverlappingObjects(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGhostObject_getOverlappingObject(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGhostObject_getOverlappingPairs(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGhostObject_rayTest(IntPtr obj, [In] ref Vector3 rayFromWorld, [In] ref Vector3 rayToWorld, IntPtr resultCallback);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGhostObject_removeOverlappingObjectInternal(IntPtr obj, IntPtr otherProxy, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGhostObject_removeOverlappingObjectInternal2(IntPtr obj, IntPtr otherProxy, IntPtr dispatcher, IntPtr thisProxy);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGhostObject_upcast(IntPtr colObj);
|
||||
}
|
||||
|
||||
public class PairCachingGhostObject : GhostObject
|
||||
{
|
||||
HashedOverlappingPairCache _overlappingPairCache;
|
||||
|
||||
public PairCachingGhostObject()
|
||||
: base(btPairCachingGhostObject_new())
|
||||
{
|
||||
}
|
||||
|
||||
public HashedOverlappingPairCache OverlappingPairCache
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_overlappingPairCache == null)
|
||||
{
|
||||
_overlappingPairCache = new HashedOverlappingPairCache(btPairCachingGhostObject_getOverlappingPairCache(_native), true);
|
||||
}
|
||||
return _overlappingPairCache;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btPairCachingGhostObject_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btPairCachingGhostObject_getOverlappingPairCache(IntPtr obj);
|
||||
}
|
||||
|
||||
public class GhostPairCallback : OverlappingPairCallback
|
||||
{
|
||||
internal GhostPairCallback(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public GhostPairCallback()
|
||||
: base(btGhostPairCallback_new())
|
||||
{
|
||||
}
|
||||
|
||||
public override BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
|
||||
{
|
||||
return new BroadphasePair(btOverlappingPairCallback_addOverlappingPair(_native, proxy0._native, proxy1._native));
|
||||
}
|
||||
|
||||
public override IntPtr RemoveOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, Dispatcher dispatcher)
|
||||
{
|
||||
return btOverlappingPairCallback_removeOverlappingPair(_native, proxy0._native, proxy1._native, dispatcher._native);
|
||||
}
|
||||
|
||||
public override void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy0, Dispatcher dispatcher)
|
||||
{
|
||||
btOverlappingPairCallback_removeOverlappingPairsContainingProxy(_native, proxy0._native, dispatcher._native);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGhostPairCallback_new();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class GjkConvexCast : ConvexCast
|
||||
{
|
||||
public GjkConvexCast(ConvexShape convexA, ConvexShape convexB, VoronoiSimplexSolver simplexSolver)
|
||||
: base(btGjkConvexCast_new(convexA._native, convexB._native, simplexSolver._native))
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGjkConvexCast_new(IntPtr convexA, IntPtr convexB, IntPtr simplexSolver);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class GjkEpaPenetrationDepthSolver : ConvexPenetrationDepthSolver
|
||||
{
|
||||
public GjkEpaPenetrationDepthSolver()
|
||||
: base(btGjkEpaPenetrationDepthSolver_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGjkEpaPenetrationDepthSolver_new();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class GjkPairDetector : DiscreteCollisionDetectorInterface
|
||||
{
|
||||
internal GjkPairDetector(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public GjkPairDetector(ConvexShape objectA, ConvexShape objectB, VoronoiSimplexSolver simplexSolver, ConvexPenetrationDepthSolver penetrationDepthSolver)
|
||||
: base(btGjkPairDetector_new(objectA._native, objectB._native, simplexSolver._native, (penetrationDepthSolver != null) ? penetrationDepthSolver._native : IntPtr.Zero))
|
||||
{
|
||||
}
|
||||
|
||||
public GjkPairDetector(ConvexShape objectA, ConvexShape objectB, int shapeTypeA, int shapeTypeB, float marginA, float marginB, VoronoiSimplexSolver simplexSolver, ConvexPenetrationDepthSolver penetrationDepthSolver)
|
||||
: base(btGjkPairDetector_new2(objectA._native, objectB._native, shapeTypeA, shapeTypeB, marginA, marginB, simplexSolver._native, (penetrationDepthSolver != null) ? penetrationDepthSolver._native : IntPtr.Zero))
|
||||
{
|
||||
}
|
||||
|
||||
public void GetClosestPointsNonVirtual(ClosestPointInput input, Result output, IDebugDraw debugDraw)
|
||||
{
|
||||
btGjkPairDetector_getClosestPointsNonVirtual(_native, input._native, output._native, DebugDraw.GetUnmanaged(debugDraw));
|
||||
}
|
||||
|
||||
public void SetIgnoreMargin(bool ignoreMargin)
|
||||
{
|
||||
btGjkPairDetector_setIgnoreMargin(_native, ignoreMargin);
|
||||
}
|
||||
|
||||
public void SetMinkowskiA(ConvexShape minkA)
|
||||
{
|
||||
btGjkPairDetector_setMinkowskiA(_native, minkA._native);
|
||||
}
|
||||
|
||||
public void SetMinkowskiB(ConvexShape minkB)
|
||||
{
|
||||
btGjkPairDetector_setMinkowskiB(_native, minkB._native);
|
||||
}
|
||||
|
||||
public void SetPenetrationDepthSolver(ConvexPenetrationDepthSolver penetrationDepthSolver)
|
||||
{
|
||||
btGjkPairDetector_setPenetrationDepthSolver(_native, penetrationDepthSolver._native);
|
||||
}
|
||||
|
||||
public Vector3 CachedSeparatingAxis
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btGjkPairDetector_getCachedSeparatingAxis(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btGjkPairDetector_setCachedSeparatingAxis(_native, ref value); }
|
||||
}
|
||||
|
||||
public float CachedSeparatingDistance
|
||||
{
|
||||
get { return btGjkPairDetector_getCachedSeparatingDistance(_native); }
|
||||
}
|
||||
|
||||
public int CatchDegeneracies
|
||||
{
|
||||
get { return btGjkPairDetector_getCatchDegeneracies(_native); }
|
||||
set { btGjkPairDetector_setCatchDegeneracies(_native, value); }
|
||||
}
|
||||
|
||||
public int CurIter
|
||||
{
|
||||
get { return btGjkPairDetector_getCurIter(_native); }
|
||||
set { btGjkPairDetector_setCurIter(_native, value); }
|
||||
}
|
||||
|
||||
public int DegenerateSimplex
|
||||
{
|
||||
get { return btGjkPairDetector_getDegenerateSimplex(_native); }
|
||||
set { btGjkPairDetector_setDegenerateSimplex(_native, value); }
|
||||
}
|
||||
|
||||
public int FixContactNormalDirection
|
||||
{
|
||||
get { return btGjkPairDetector_getFixContactNormalDirection(_native); }
|
||||
set { btGjkPairDetector_setFixContactNormalDirection(_native, value); }
|
||||
}
|
||||
|
||||
public int LastUsedMethod
|
||||
{
|
||||
get { return btGjkPairDetector_getLastUsedMethod(_native); }
|
||||
set { btGjkPairDetector_setLastUsedMethod(_native, value); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGjkPairDetector_new(IntPtr objectA, IntPtr objectB, IntPtr simplexSolver, IntPtr penetrationDepthSolver);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btGjkPairDetector_new2(IntPtr objectA, IntPtr objectB, int shapeTypeA, int shapeTypeB, float marginA, float marginB, IntPtr simplexSolver, IntPtr penetrationDepthSolver);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGjkPairDetector_getCachedSeparatingAxis(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btGjkPairDetector_getCachedSeparatingDistance(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGjkPairDetector_getCatchDegeneracies(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGjkPairDetector_getClosestPointsNonVirtual(IntPtr obj, IntPtr input, IntPtr output, IntPtr debugDraw);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGjkPairDetector_getCurIter(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGjkPairDetector_getDegenerateSimplex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGjkPairDetector_getFixContactNormalDirection(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btGjkPairDetector_getLastUsedMethod(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGjkPairDetector_setCachedSeparatingAxis(IntPtr obj, [In] ref Vector3 seperatingAxis);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGjkPairDetector_setCatchDegeneracies(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGjkPairDetector_setCurIter(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGjkPairDetector_setDegenerateSimplex(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGjkPairDetector_setFixContactNormalDirection(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGjkPairDetector_setIgnoreMargin(IntPtr obj, bool ignoreMargin);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGjkPairDetector_setLastUsedMethod(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGjkPairDetector_setMinkowskiA(IntPtr obj, IntPtr minkA);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGjkPairDetector_setMinkowskiB(IntPtr obj, IntPtr minkB);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btGjkPairDetector_setPenetrationDepthSolver(IntPtr obj, IntPtr penetrationDepthSolver);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class HeightfieldTerrainShape : ConcaveShape
|
||||
{
|
||||
public HeightfieldTerrainShape(int heightStickWidth, int heightStickLength, IntPtr heightfieldData, float heightScale, float minHeight, float maxHeight, int upAxis, PhyScalarType heightDataType, bool flipQuadEdges)
|
||||
: base(btHeightfieldTerrainShape_new(heightStickWidth, heightStickLength, heightfieldData, heightScale, minHeight, maxHeight, upAxis, heightDataType, flipQuadEdges))
|
||||
{
|
||||
}
|
||||
|
||||
public HeightfieldTerrainShape(int heightStickWidth, int heightStickLength, IntPtr heightfieldData, float maxHeight, int upAxis, bool useFloatData, bool flipQuadEdges)
|
||||
: base(btHeightfieldTerrainShape_new2(heightStickWidth, heightStickLength, heightfieldData, maxHeight, upAxis, useFloatData, flipQuadEdges))
|
||||
{
|
||||
}
|
||||
|
||||
public void SetUseDiamondSubdivision()
|
||||
{
|
||||
btHeightfieldTerrainShape_setUseDiamondSubdivision(_native);
|
||||
}
|
||||
|
||||
public void SetUseDiamondSubdivision(bool useDiamondSubdivision)
|
||||
{
|
||||
btHeightfieldTerrainShape_setUseDiamondSubdivision2(_native, useDiamondSubdivision);
|
||||
}
|
||||
|
||||
public void SetUseZigzagSubdivision()
|
||||
{
|
||||
btHeightfieldTerrainShape_setUseZigzagSubdivision(_native);
|
||||
}
|
||||
|
||||
public void SetUseZigzagSubdivision(bool useZigzagSubdivision)
|
||||
{
|
||||
btHeightfieldTerrainShape_setUseZigzagSubdivision2(_native, useZigzagSubdivision);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btHeightfieldTerrainShape_new(int heightStickWidth, int heightStickLength, IntPtr heightfieldData, float heightScale, float minHeight, float maxHeight, int upAxis, PhyScalarType heightDataType, bool flipQuadEdges);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btHeightfieldTerrainShape_new2(int heightStickWidth, int heightStickLength, IntPtr heightfieldData, float maxHeight, int upAxis, bool useFloatData, bool flipQuadEdges);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btHeightfieldTerrainShape_setUseDiamondSubdivision(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btHeightfieldTerrainShape_setUseDiamondSubdivision2(IntPtr obj, bool useDiamondSubdivision);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btHeightfieldTerrainShape_setUseZigzagSubdivision(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btHeightfieldTerrainShape_setUseZigzagSubdivision2(IntPtr obj, bool useZigzagSubdivision);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,527 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ConstraintRow : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal ConstraintRow(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public ConstraintRow()
|
||||
{
|
||||
_native = btConstraintRow_new();
|
||||
}
|
||||
|
||||
public float AccumImpulse
|
||||
{
|
||||
get { return btConstraintRow_getAccumImpulse(_native); }
|
||||
set { btConstraintRow_setAccumImpulse(_native, value); }
|
||||
}
|
||||
|
||||
public float JacDiagInv
|
||||
{
|
||||
get { return btConstraintRow_getJacDiagInv(_native); }
|
||||
set { btConstraintRow_setJacDiagInv(_native, value); }
|
||||
}
|
||||
|
||||
public float LowerLimit
|
||||
{
|
||||
get { return btConstraintRow_getLowerLimit(_native); }
|
||||
set { btConstraintRow_setLowerLimit(_native, value); }
|
||||
}
|
||||
|
||||
public Vector3 Normal
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btConstraintRow_getNormal(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btConstraintRow_setNormal(_native, ref value); }
|
||||
}
|
||||
|
||||
public float Rhs
|
||||
{
|
||||
get { return btConstraintRow_getRhs(_native); }
|
||||
set { btConstraintRow_setRhs(_native, value); }
|
||||
}
|
||||
|
||||
public float UpperLimit
|
||||
{
|
||||
get { return btConstraintRow_getUpperLimit(_native); }
|
||||
set { btConstraintRow_setUpperLimit(_native, value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btConstraintRow_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~ConstraintRow()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btConstraintRow_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btConstraintRow_getAccumImpulse(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btConstraintRow_getJacDiagInv(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btConstraintRow_getLowerLimit(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConstraintRow_getNormal(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btConstraintRow_getRhs(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btConstraintRow_getUpperLimit(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConstraintRow_setAccumImpulse(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConstraintRow_setJacDiagInv(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConstraintRow_setLowerLimit(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConstraintRow_setNormal(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConstraintRow_setRhs(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConstraintRow_setUpperLimit(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btConstraintRow_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public delegate void ContactAddedEventHandler(ManifoldPoint cp, CollisionObjectWrapper colObj0Wrap, int partId0, int index0, CollisionObjectWrapper colObj1Wrap, int partId1, int index1);
|
||||
|
||||
public class ManifoldPoint : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
private readonly bool _preventDelete;
|
||||
|
||||
static ContactAddedEventHandler _contactAdded;
|
||||
static ContactAddedUnmanagedDelegate _contactAddedUnmanaged;
|
||||
static IntPtr _contactAddedUnmanagedPtr;
|
||||
|
||||
[UnmanagedFunctionPointer(Native.Conv)]
|
||||
private delegate bool ContactAddedUnmanagedDelegate(IntPtr cp, IntPtr colObj0Wrap, int partId0, int index0, IntPtr colObj1Wrap, int partId1, int index1);
|
||||
|
||||
static bool ContactAddedUnmanaged(IntPtr cp, IntPtr colObj0Wrap, int partId0, int index0, IntPtr colObj1Wrap, int partId1, int index1)
|
||||
{
|
||||
_contactAdded.Invoke(new ManifoldPoint(cp, true), new CollisionObjectWrapper(colObj0Wrap), partId0, index0, new CollisionObjectWrapper(colObj1Wrap), partId1, index1);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static event ContactAddedEventHandler ContactAdded
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_contactAddedUnmanaged == null)
|
||||
{
|
||||
_contactAddedUnmanaged = new ContactAddedUnmanagedDelegate(ContactAddedUnmanaged);
|
||||
_contactAddedUnmanagedPtr = Marshal.GetFunctionPointerForDelegate(_contactAddedUnmanaged);
|
||||
}
|
||||
setGContactAddedCallback(_contactAddedUnmanagedPtr);
|
||||
_contactAdded += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_contactAdded -= value;
|
||||
if (_contactAdded == null)
|
||||
{
|
||||
setGContactAddedCallback(IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal ManifoldPoint(IntPtr native, bool preventDelete = false)
|
||||
{
|
||||
_native = native;
|
||||
_preventDelete = preventDelete;
|
||||
}
|
||||
|
||||
public ManifoldPoint()
|
||||
{
|
||||
_native = btManifoldPoint_new();
|
||||
}
|
||||
|
||||
public ManifoldPoint(Vector3 pointA, Vector3 pointB, Vector3 normal, float distance)
|
||||
{
|
||||
_native = btManifoldPoint_new2(ref pointA, ref pointB, ref normal, distance);
|
||||
}
|
||||
|
||||
public float AppliedImpulse
|
||||
{
|
||||
get { return btManifoldPoint_getAppliedImpulse(_native); }
|
||||
set { btManifoldPoint_setAppliedImpulse(_native, value); }
|
||||
}
|
||||
|
||||
public float AppliedImpulseLateral1
|
||||
{
|
||||
get { return btManifoldPoint_getAppliedImpulseLateral1(_native); }
|
||||
set { btManifoldPoint_setAppliedImpulseLateral1(_native, value); }
|
||||
}
|
||||
|
||||
public float AppliedImpulseLateral2
|
||||
{
|
||||
get { return btManifoldPoint_getAppliedImpulseLateral2(_native); }
|
||||
set { btManifoldPoint_setAppliedImpulseLateral2(_native, value); }
|
||||
}
|
||||
|
||||
public float CombinedFriction
|
||||
{
|
||||
get { return btManifoldPoint_getCombinedFriction(_native); }
|
||||
set { btManifoldPoint_setCombinedFriction(_native, value); }
|
||||
}
|
||||
|
||||
public float CombinedRestitution
|
||||
{
|
||||
get { return btManifoldPoint_getCombinedRestitution(_native); }
|
||||
set { btManifoldPoint_setCombinedRestitution(_native, value); }
|
||||
}
|
||||
|
||||
public float CombinedRollingFriction
|
||||
{
|
||||
get { return btManifoldPoint_getCombinedRollingFriction(_native); }
|
||||
set { btManifoldPoint_setCombinedRollingFriction(_native, value); }
|
||||
}
|
||||
|
||||
public float ContactCfm1
|
||||
{
|
||||
get { return btManifoldPoint_getContactCFM1(_native); }
|
||||
set { btManifoldPoint_setContactCFM1(_native, value); }
|
||||
}
|
||||
|
||||
public float ContactCfm2
|
||||
{
|
||||
get { return btManifoldPoint_getContactCFM2(_native); }
|
||||
set { btManifoldPoint_setContactCFM2(_native, value); }
|
||||
}
|
||||
|
||||
public float ContactMotion1
|
||||
{
|
||||
get { return btManifoldPoint_getContactMotion1(_native); }
|
||||
set { btManifoldPoint_setContactMotion1(_native, value); }
|
||||
}
|
||||
|
||||
public float ContactMotion2
|
||||
{
|
||||
get { return btManifoldPoint_getContactMotion2(_native); }
|
||||
set { btManifoldPoint_setContactMotion2(_native, value); }
|
||||
}
|
||||
|
||||
public float Distance
|
||||
{
|
||||
get { return btManifoldPoint_getDistance(_native); }
|
||||
set { btManifoldPoint_setDistance(_native, value); }
|
||||
}
|
||||
|
||||
public float Distance1
|
||||
{
|
||||
get { return btManifoldPoint_getDistance1(_native); }
|
||||
set { btManifoldPoint_setDistance1(_native, value); }
|
||||
}
|
||||
|
||||
public int Index0
|
||||
{
|
||||
get { return btManifoldPoint_getIndex0(_native); }
|
||||
set { btManifoldPoint_setIndex0(_native, value); }
|
||||
}
|
||||
|
||||
public int Index1
|
||||
{
|
||||
get { return btManifoldPoint_getIndex1(_native); }
|
||||
set { btManifoldPoint_setIndex1(_native, value); }
|
||||
}
|
||||
|
||||
public Vector3 LateralFrictionDir1
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btManifoldPoint_getLateralFrictionDir1(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btManifoldPoint_setLateralFrictionDir1(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 LateralFrictionDir2
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btManifoldPoint_getLateralFrictionDir2(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btManifoldPoint_setLateralFrictionDir2(_native, ref value); }
|
||||
}
|
||||
|
||||
public bool LateralFrictionInitialized
|
||||
{
|
||||
get { return btManifoldPoint_getLateralFrictionInitialized(_native); }
|
||||
set { btManifoldPoint_setLateralFrictionInitialized(_native, value); }
|
||||
}
|
||||
|
||||
public int LifeTime
|
||||
{
|
||||
get { return btManifoldPoint_getLifeTime(_native); }
|
||||
set { btManifoldPoint_setLifeTime(_native, value); }
|
||||
}
|
||||
|
||||
public Vector3 LocalPointA
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btManifoldPoint_getLocalPointA(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btManifoldPoint_setLocalPointA(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 LocalPointB
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btManifoldPoint_getLocalPointB(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btManifoldPoint_setLocalPointB(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 NormalWorldOnB
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btManifoldPoint_getNormalWorldOnB(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btManifoldPoint_setNormalWorldOnB(_native, ref value); }
|
||||
}
|
||||
|
||||
public int PartId0
|
||||
{
|
||||
get { return btManifoldPoint_getPartId0(_native); }
|
||||
set { btManifoldPoint_setPartId0(_native, value); }
|
||||
}
|
||||
|
||||
public int PartId1
|
||||
{
|
||||
get { return btManifoldPoint_getPartId1(_native); }
|
||||
set { btManifoldPoint_setPartId1(_native, value); }
|
||||
}
|
||||
|
||||
public Vector3 PositionWorldOnA
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btManifoldPoint_getPositionWorldOnA(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btManifoldPoint_setPositionWorldOnA(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 PositionWorldOnB
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btManifoldPoint_getPositionWorldOnB(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btManifoldPoint_setPositionWorldOnB(_native, ref value); }
|
||||
}
|
||||
|
||||
public Object UserPersistentData
|
||||
{
|
||||
get
|
||||
{
|
||||
IntPtr valuePtr = btManifoldPoint_getUserPersistentData(_native);
|
||||
return (valuePtr != IntPtr.Zero) ? GCHandle.FromIntPtr(valuePtr).Target : null;
|
||||
}
|
||||
set
|
||||
{
|
||||
IntPtr prevPtr = btManifoldPoint_getUserPersistentData(_native);
|
||||
if (prevPtr != IntPtr.Zero)
|
||||
{
|
||||
GCHandle prevHandle = GCHandle.FromIntPtr(prevPtr);
|
||||
if (object.ReferenceEquals(value, prevHandle.Target))
|
||||
{
|
||||
return;
|
||||
}
|
||||
prevHandle.Free();
|
||||
}
|
||||
if (value != null)
|
||||
{
|
||||
GCHandle handle = GCHandle.Alloc(value);
|
||||
btManifoldPoint_setUserPersistentData(_native, GCHandle.ToIntPtr(handle));
|
||||
}
|
||||
else
|
||||
{
|
||||
btManifoldPoint_setUserPersistentData(_native, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
if (!_preventDelete)
|
||||
{
|
||||
btManifoldPoint_delete(_native);
|
||||
}
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~ManifoldPoint()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btManifoldPoint_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btManifoldPoint_new2([In] ref Vector3 pointA, [In] ref Vector3 pointB, [In] ref Vector3 normal, float distance);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldPoint_getAppliedImpulse(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldPoint_getAppliedImpulseLateral1(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldPoint_getAppliedImpulseLateral2(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldPoint_getCombinedFriction(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldPoint_getCombinedRestitution(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldPoint_getCombinedRollingFriction(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldPoint_getContactCFM1(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldPoint_getContactCFM2(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldPoint_getContactMotion1(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldPoint_getContactMotion2(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldPoint_getDistance(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldPoint_getDistance1(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btManifoldPoint_getIndex0(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btManifoldPoint_getIndex1(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_getLateralFrictionDir1(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_getLateralFrictionDir2(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btManifoldPoint_getLateralFrictionInitialized(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btManifoldPoint_getLifeTime(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_getLocalPointA(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_getLocalPointB(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_getNormalWorldOnB(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btManifoldPoint_getPartId0(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btManifoldPoint_getPartId1(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_getPositionWorldOnA(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_getPositionWorldOnB(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btManifoldPoint_getUserPersistentData(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setAppliedImpulse(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setAppliedImpulseLateral1(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setAppliedImpulseLateral2(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setCombinedFriction(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setCombinedRestitution(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setCombinedRollingFriction(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setContactCFM1(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setContactCFM2(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setContactMotion1(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setContactMotion2(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setDistance(IntPtr obj, float dist);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setDistance1(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setIndex0(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setIndex1(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setLateralFrictionDir1(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setLateralFrictionDir2(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setLateralFrictionInitialized(IntPtr obj, bool value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setLifeTime(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setLocalPointA(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setLocalPointB(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setNormalWorldOnB(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setPartId0(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setPartId1(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setPositionWorldOnA(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setPositionWorldOnB(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_setUserPersistentData(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldPoint_delete(IntPtr obj);
|
||||
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr getGContactAddedCallback();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void setGContactAddedCallback(IntPtr value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class ManifoldResult : DiscreteCollisionDetectorInterface.Result
|
||||
{
|
||||
internal ManifoldResult(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public ManifoldResult()
|
||||
: base(btManifoldResult_new())
|
||||
{
|
||||
}
|
||||
|
||||
public ManifoldResult(CollisionObjectWrapper body0Wrap, CollisionObjectWrapper body1Wrap)
|
||||
: base(btManifoldResult_new2(body0Wrap._native, body1Wrap._native))
|
||||
{
|
||||
}
|
||||
|
||||
public static float CalculateCombinedFriction(CollisionObject body0, CollisionObject body1)
|
||||
{
|
||||
return btManifoldResult_calculateCombinedFriction(body0._native, body1._native);
|
||||
}
|
||||
|
||||
public static float CalculateCombinedRestitution(CollisionObject body0, CollisionObject body1)
|
||||
{
|
||||
return btManifoldResult_calculateCombinedRestitution(body0._native, body1._native);
|
||||
}
|
||||
|
||||
public void RefreshContactPoints()
|
||||
{
|
||||
btManifoldResult_refreshContactPoints(_native);
|
||||
}
|
||||
|
||||
public CollisionObject Body0Internal
|
||||
{
|
||||
get { return CollisionObject.GetManaged(btManifoldResult_getBody0Internal(_native)); }
|
||||
}
|
||||
|
||||
public CollisionObjectWrapper Body0Wrap
|
||||
{
|
||||
get { return new CollisionObjectWrapper(btManifoldResult_getBody0Wrap(_native)); }
|
||||
set { btManifoldResult_setBody0Wrap(_native, value._native); }
|
||||
}
|
||||
|
||||
public CollisionObject Body1Internal
|
||||
{
|
||||
get { return CollisionObject.GetManaged(btManifoldResult_getBody1Internal(_native)); }
|
||||
}
|
||||
|
||||
public CollisionObjectWrapper Body1Wrap
|
||||
{
|
||||
get { return new CollisionObjectWrapper(btManifoldResult_getBody1Wrap(_native)); }
|
||||
set { btManifoldResult_setBody1Wrap(_native, value._native); }
|
||||
}
|
||||
|
||||
public PersistentManifold PersistentManifold
|
||||
{
|
||||
get { return new PersistentManifold(btManifoldResult_getPersistentManifold(_native)); }
|
||||
set { btManifoldResult_setPersistentManifold(_native, value._native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btManifoldResult_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btManifoldResult_new2(IntPtr body0Wrap, IntPtr body1Wrap);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldResult_calculateCombinedFriction(IntPtr body0, IntPtr body1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btManifoldResult_calculateCombinedRestitution(IntPtr body0, IntPtr body1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btManifoldResult_getBody0Internal(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btManifoldResult_getBody0Wrap(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btManifoldResult_getBody1Internal(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btManifoldResult_getBody1Wrap(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btManifoldResult_getPersistentManifold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldResult_refreshContactPoints(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldResult_setBody0Wrap(IntPtr obj, IntPtr obj0Wrap);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldResult_setBody1Wrap(IntPtr obj, IntPtr obj1Wrap);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btManifoldResult_setPersistentManifold(IntPtr obj, IntPtr manifoldPtr);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class MinkowskiPenetrationDepthSolver : ConvexPenetrationDepthSolver
|
||||
{
|
||||
public MinkowskiPenetrationDepthSolver()
|
||||
: base(btMinkowskiPenetrationDepthSolver_new())
|
||||
{
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btMinkowskiPenetrationDepthSolver_new();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class MinkowskiSumShape : ConvexInternalShape
|
||||
{
|
||||
private ConvexShape _shapeA;
|
||||
private ConvexShape _shapeB;
|
||||
|
||||
public MinkowskiSumShape(ConvexShape shapeA, ConvexShape shapeB)
|
||||
: base(btMinkowskiSumShape_new(shapeA._native, shapeB._native))
|
||||
{
|
||||
_shapeA = shapeA;
|
||||
_shapeB = shapeB;
|
||||
}
|
||||
|
||||
public ConvexShape ShapeA
|
||||
{
|
||||
get { return _shapeA; }
|
||||
}
|
||||
|
||||
public ConvexShape ShapeB
|
||||
{
|
||||
get { return _shapeB; }
|
||||
}
|
||||
|
||||
public Matrix TransformA
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix value;
|
||||
btMinkowskiSumShape_getTransformA(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btMinkowskiSumShape_setTransformA(_native, ref value); }
|
||||
}
|
||||
|
||||
public Matrix TransformB
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix value;
|
||||
btMinkowskiSumShape_GetTransformB(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btMinkowskiSumShape_setTransformB(_native, ref value); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btMinkowskiSumShape_new(IntPtr shapeA, IntPtr shapeB);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btMinkowskiSumShape_getShapeA(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btMinkowskiSumShape_getShapeB(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btMinkowskiSumShape_getTransformA(IntPtr obj, [Out] out Matrix transA);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btMinkowskiSumShape_GetTransformB(IntPtr obj, [Out] out Matrix transB);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btMinkowskiSumShape_setTransformA(IntPtr obj, [In] ref Matrix transA);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btMinkowskiSumShape_setTransformB(IntPtr obj, [In] ref Matrix transB);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class MultiSphereShape : ConvexInternalAabbCachingShape
|
||||
{
|
||||
public MultiSphereShape(Vector3[] positions, float[] radi)
|
||||
: base(btMultiSphereShape_new(positions, radi, (radi.Length < positions.Length) ? radi.Length : positions.Length))
|
||||
{
|
||||
}
|
||||
|
||||
public MultiSphereShape(Vector3Array positions, float[] radi)
|
||||
: base(btMultiSphereShape_new2(positions._native, radi, (radi.Length < positions.Count) ? radi.Length : positions.Count))
|
||||
{
|
||||
}
|
||||
|
||||
public Vector3 GetSpherePosition(int index)
|
||||
{
|
||||
Vector3 value;
|
||||
btMultiSphereShape_getSpherePosition(_native, index, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public float GetSphereRadius(int index)
|
||||
{
|
||||
return btMultiSphereShape_getSphereRadius(_native, index);
|
||||
}
|
||||
/*
|
||||
public unsafe override string Serialize(IntPtr dataBuffer, Serializer serializer)
|
||||
{
|
||||
base.Serialize(dataBuffer, serializer);
|
||||
|
||||
int numElem = SphereCount;
|
||||
if (numElem != 0)
|
||||
{
|
||||
Chunk chunk = serializer.Allocate(16 + sizeof(int), numElem);
|
||||
Marshal.WriteInt64(dataBuffer, 0, serializer.GetUniquePointer(_native + 4));
|
||||
using (UnmanagedMemoryStream stream = new UnmanagedMemoryStream((byte*)chunk.OldPtr.ToPointer(), chunk.Length, chunk.Length, FileAccess.Write))
|
||||
{
|
||||
using (BulletWriter writer = new BulletWriter(stream))
|
||||
{
|
||||
for (int i = 0; i < SphereCount; i++)
|
||||
{
|
||||
writer.Write(GetSpherePosition(i));
|
||||
writer.Write(GetSphereRadius(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
serializer.FinalizeChunk(chunk, "btPositionAndRadius", DnaID.Array, _native + 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
Marshal.WriteInt64(dataBuffer, 0, 0);
|
||||
}
|
||||
Marshal.WriteInt32(dataBuffer, 4, numElem);
|
||||
|
||||
return "btMultiSphereShapeData";
|
||||
}
|
||||
*/
|
||||
public int SphereCount
|
||||
{
|
||||
get { return btMultiSphereShape_getSphereCount(_native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btMultiSphereShape_new(Vector3[] positions, float[] radi, int numSpheres);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btMultiSphereShape_new2(IntPtr positions, float[] radi, int numSpheres);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btMultiSphereShape_getSphereCount(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btMultiSphereShape_getSpherePosition(IntPtr obj, int index, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btMultiSphereShape_getSphereRadius(IntPtr obj, int index);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class MultimaterialTriangleMeshShape : BvhTriangleMeshShape
|
||||
{
|
||||
public MultimaterialTriangleMeshShape(StridingMeshInterface meshInterface, bool useQuantizedAabbCompression)
|
||||
: base(btMultimaterialTriangleMeshShape_new(meshInterface._native, useQuantizedAabbCompression))
|
||||
{
|
||||
}
|
||||
|
||||
public MultimaterialTriangleMeshShape(StridingMeshInterface meshInterface, bool useQuantizedAabbCompression, bool buildBvh)
|
||||
: base(btMultimaterialTriangleMeshShape_new2(meshInterface._native, useQuantizedAabbCompression, buildBvh))
|
||||
{
|
||||
}
|
||||
|
||||
public MultimaterialTriangleMeshShape(StridingMeshInterface meshInterface, bool useQuantizedAabbCompression, Vector3 bvhAabbMin, Vector3 bvhAabbMax)
|
||||
: base(btMultimaterialTriangleMeshShape_new3(meshInterface._native, useQuantizedAabbCompression, ref bvhAabbMin, ref bvhAabbMax))
|
||||
{
|
||||
}
|
||||
|
||||
public MultimaterialTriangleMeshShape(StridingMeshInterface meshInterface, bool useQuantizedAabbCompression, Vector3 bvhAabbMin, Vector3 bvhAabbMax, bool buildBvh)
|
||||
: base(btMultimaterialTriangleMeshShape_new4(meshInterface._native, useQuantizedAabbCompression, ref bvhAabbMin, ref bvhAabbMax, buildBvh))
|
||||
{
|
||||
}
|
||||
/*
|
||||
public BulletMaterial GetMaterialProperties(int partID, int triIndex)
|
||||
{
|
||||
return btMultimaterialTriangleMeshShape_getMaterialProperties(_native, partID, triIndex);
|
||||
}
|
||||
*/
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btMultimaterialTriangleMeshShape_new(IntPtr meshInterface, bool useQuantizedAabbCompression);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btMultimaterialTriangleMeshShape_new2(IntPtr meshInterface, bool useQuantizedAabbCompression, bool buildBvh);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btMultimaterialTriangleMeshShape_new3(IntPtr meshInterface, bool useQuantizedAabbCompression, [In] ref Vector3 bvhAabbMin, [In] ref Vector3 bvhAabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btMultimaterialTriangleMeshShape_new4(IntPtr meshInterface, bool useQuantizedAabbCompression, [In] ref Vector3 bvhAabbMin, [In] ref Vector3 bvhAabbMax, bool buildBvh);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr btMultimaterialTriangleMeshShape_getMaterialProperties(IntPtr obj, int partID, int triIndex);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class OptimizedBvh : QuantizedBvh
|
||||
{
|
||||
internal OptimizedBvh(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public OptimizedBvh()
|
||||
: base(btOptimizedBvh_new())
|
||||
{
|
||||
}
|
||||
|
||||
public void Build(StridingMeshInterface triangles, bool useQuantizedAabbCompression, Vector3 bvhAabbMin, Vector3 bvhAabbMax)
|
||||
{
|
||||
btOptimizedBvh_build(_native, triangles._native, useQuantizedAabbCompression, ref bvhAabbMin, ref bvhAabbMax);
|
||||
}
|
||||
|
||||
public static OptimizedBvh DeSerializeInPlace(IntPtr alignedDataBuffer, uint dataBufferSize, bool swapEndian)
|
||||
{
|
||||
return new OptimizedBvh(btOptimizedBvh_deSerializeInPlace(alignedDataBuffer, dataBufferSize, swapEndian));
|
||||
}
|
||||
|
||||
public void Refit(StridingMeshInterface triangles, Vector3 aabbMin, Vector3 aabbMax)
|
||||
{
|
||||
btOptimizedBvh_refit(_native, triangles._native, ref aabbMin, ref aabbMax);
|
||||
}
|
||||
|
||||
public void RefitPartial(StridingMeshInterface triangles, Vector3 aabbMin, Vector3 aabbMax)
|
||||
{
|
||||
btOptimizedBvh_refitPartial(_native, triangles._native, ref aabbMin, ref aabbMax);
|
||||
}
|
||||
|
||||
public bool SerializeInPlace(IntPtr alignedDataBuffer, uint dataBufferSize, bool swapEndian)
|
||||
{
|
||||
return btOptimizedBvh_serializeInPlace(_native, alignedDataBuffer, dataBufferSize, swapEndian);
|
||||
}
|
||||
|
||||
public void UpdateBvhNodes(StridingMeshInterface meshInterface, int firstNode, int endNode, int index)
|
||||
{
|
||||
btOptimizedBvh_updateBvhNodes(_native, meshInterface._native, firstNode, endNode, index);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btOptimizedBvh_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvh_build(IntPtr obj, IntPtr triangles, bool useQuantizedAabbCompression, [In] ref Vector3 bvhAabbMin, [In] ref Vector3 bvhAabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btOptimizedBvh_deSerializeInPlace(IntPtr i_alignedDataBuffer, uint i_dataBufferSize, bool i_swapEndian);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvh_refit(IntPtr obj, IntPtr triangles, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvh_refitPartial(IntPtr obj, IntPtr triangles, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btOptimizedBvh_serializeInPlace(IntPtr obj, IntPtr o_alignedDataBuffer, uint i_dataBufferSize, bool i_swapEndian);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvh_updateBvhNodes(IntPtr obj, IntPtr meshInterface, int firstNode, int endNode, int index);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,307 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class OverlapCallback : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
public bool ProcessOverlap(BroadphasePair pair)
|
||||
{
|
||||
return btOverlapCallback_processOverlap(_native, pair._native);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btOverlapCallback_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~OverlapCallback()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btOverlapCallback_processOverlap(IntPtr obj, IntPtr pair);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOverlapCallback_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class OverlapFilterCallback : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal OverlapFilterCallback(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public bool NeedBroadphaseCollision(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
|
||||
{
|
||||
return btOverlapFilterCallback_needBroadphaseCollision(_native, proxy0._native, proxy1._native);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btOverlapFilterCallback_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~OverlapFilterCallback()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btOverlapFilterCallback_needBroadphaseCollision(IntPtr obj, IntPtr proxy0, IntPtr proxy1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOverlapFilterCallback_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public abstract class OverlappingPairCache : OverlappingPairCallback
|
||||
{
|
||||
OverlappingPairCallback _ghostPairCallback;
|
||||
AlignedBroadphasePairArray _overlappingPairArray;
|
||||
|
||||
internal OverlappingPairCache(IntPtr native, bool preventDelete)
|
||||
: base(native, preventDelete)
|
||||
{
|
||||
}
|
||||
|
||||
public void CleanOverlappingPair(BroadphasePair pair, Dispatcher dispatcher)
|
||||
{
|
||||
btOverlappingPairCache_cleanOverlappingPair(_native, pair._native, dispatcher._native);
|
||||
}
|
||||
|
||||
public void CleanProxyFromPairs(BroadphaseProxy proxy, Dispatcher dispatcher)
|
||||
{
|
||||
btOverlappingPairCache_cleanProxyFromPairs(_native, proxy._native, dispatcher._native);
|
||||
}
|
||||
|
||||
public BroadphasePair FindPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
|
||||
{
|
||||
return new BroadphasePair(btOverlappingPairCache_findPair(_native, proxy0._native, proxy1._native));
|
||||
}
|
||||
/*
|
||||
public void ProcessAllOverlappingPairs(OverlapCallback __unnamed0, Dispatcher dispatcher)
|
||||
{
|
||||
btOverlappingPairCache_processAllOverlappingPairs(_native, __unnamed0._native, dispatcher._native);
|
||||
}
|
||||
*/
|
||||
public void SetInternalGhostPairCallback(OverlappingPairCallback ghostPairCallback)
|
||||
{
|
||||
_ghostPairCallback = ghostPairCallback;
|
||||
btOverlappingPairCache_setInternalGhostPairCallback(_native, ghostPairCallback._native);
|
||||
}
|
||||
|
||||
public void SetOverlapFilterCallback(OverlapFilterCallback callback)
|
||||
{
|
||||
btOverlappingPairCache_setOverlapFilterCallback(_native, callback._native);
|
||||
}
|
||||
|
||||
public void SortOverlappingPairs(Dispatcher dispatcher)
|
||||
{
|
||||
btOverlappingPairCache_sortOverlappingPairs(_native, dispatcher._native);
|
||||
}
|
||||
|
||||
public bool HasDeferredRemoval
|
||||
{
|
||||
get { return btOverlappingPairCache_hasDeferredRemoval(_native); }
|
||||
}
|
||||
|
||||
public int NumOverlappingPairs
|
||||
{
|
||||
get { return btOverlappingPairCache_getNumOverlappingPairs(_native); }
|
||||
}
|
||||
|
||||
public AlignedBroadphasePairArray OverlappingPairArray
|
||||
{
|
||||
get
|
||||
{
|
||||
IntPtr pairArrayPtr = btOverlappingPairCache_getOverlappingPairArray(_native);
|
||||
if (_overlappingPairArray == null || _overlappingPairArray._native != pairArrayPtr)
|
||||
{
|
||||
_overlappingPairArray = new AlignedBroadphasePairArray(pairArrayPtr);
|
||||
}
|
||||
return _overlappingPairArray;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOverlappingPairCache_cleanOverlappingPair(IntPtr obj, IntPtr pair, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOverlappingPairCache_cleanProxyFromPairs(IntPtr obj, IntPtr proxy, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btOverlappingPairCache_findPair(IntPtr obj, IntPtr proxy0, IntPtr proxy1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btOverlappingPairCache_getNumOverlappingPairs(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btOverlappingPairCache_getOverlappingPairArray(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btOverlappingPairCache_getOverlappingPairArrayPtr(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btOverlappingPairCache_hasDeferredRemoval(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOverlappingPairCache_processAllOverlappingPairs(IntPtr obj, IntPtr __unnamed0, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOverlappingPairCache_setInternalGhostPairCallback(IntPtr obj, IntPtr ghostPairCallback);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOverlappingPairCache_setOverlapFilterCallback(IntPtr obj, IntPtr callback);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOverlappingPairCache_sortOverlappingPairs(IntPtr obj, IntPtr dispatcher);
|
||||
}
|
||||
|
||||
public class HashedOverlappingPairCache : OverlappingPairCache
|
||||
{
|
||||
internal HashedOverlappingPairCache(IntPtr native, bool preventDelete)
|
||||
: base(native, preventDelete)
|
||||
{
|
||||
}
|
||||
|
||||
public HashedOverlappingPairCache()
|
||||
: base(btHashedOverlappingPairCache_new(), false)
|
||||
{
|
||||
}
|
||||
|
||||
public override BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
|
||||
{
|
||||
return new BroadphasePair(btOverlappingPairCallback_addOverlappingPair(_native, proxy0._native, proxy1._native));
|
||||
}
|
||||
|
||||
public bool NeedsBroadphaseCollision(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
|
||||
{
|
||||
return btHashedOverlappingPairCache_needsBroadphaseCollision(_native, proxy0._native, proxy1._native);
|
||||
}
|
||||
|
||||
public override IntPtr RemoveOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, Dispatcher dispatcher)
|
||||
{
|
||||
return btOverlappingPairCallback_removeOverlappingPair(_native, proxy0._native, proxy1._native, dispatcher._native);
|
||||
}
|
||||
|
||||
public override void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy0, Dispatcher dispatcher)
|
||||
{
|
||||
btOverlappingPairCallback_removeOverlappingPairsContainingProxy(_native, proxy0._native, dispatcher._native);
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return btHashedOverlappingPairCache_GetCount(_native); }
|
||||
}
|
||||
|
||||
public OverlapFilterCallback OverlapFilterCallback
|
||||
{
|
||||
get { return new OverlapFilterCallback(btHashedOverlappingPairCache_getOverlapFilterCallback(_native)); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btHashedOverlappingPairCache_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btHashedOverlappingPairCache_GetCount(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btHashedOverlappingPairCache_getOverlapFilterCallback(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btHashedOverlappingPairCache_needsBroadphaseCollision(IntPtr obj, IntPtr proxy0, IntPtr proxy1);
|
||||
}
|
||||
|
||||
public class SortedOverlappingPairCache : OverlappingPairCache
|
||||
{
|
||||
internal SortedOverlappingPairCache(IntPtr native)
|
||||
: base(native, true)
|
||||
{
|
||||
}
|
||||
|
||||
public SortedOverlappingPairCache()
|
||||
: base(btSortedOverlappingPairCache_new(), false)
|
||||
{
|
||||
}
|
||||
|
||||
public override BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
|
||||
{
|
||||
return new BroadphasePair(btOverlappingPairCallback_addOverlappingPair(_native, proxy0._native, proxy1._native));
|
||||
}
|
||||
|
||||
public bool NeedsBroadphaseCollision(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
|
||||
{
|
||||
return btSortedOverlappingPairCache_needsBroadphaseCollision(_native, proxy0._native, proxy1._native);
|
||||
}
|
||||
|
||||
public override IntPtr RemoveOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, Dispatcher dispatcher)
|
||||
{
|
||||
return btOverlappingPairCallback_removeOverlappingPair(_native, proxy0._native, proxy1._native, dispatcher._native);
|
||||
}
|
||||
|
||||
public override void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy0, Dispatcher dispatcher)
|
||||
{
|
||||
btOverlappingPairCallback_removeOverlappingPairsContainingProxy(_native, proxy0._native, dispatcher._native);
|
||||
}
|
||||
|
||||
public OverlapFilterCallback OverlapFilterCallback
|
||||
{
|
||||
get { return new OverlapFilterCallback(btSortedOverlappingPairCache_getOverlapFilterCallback(_native)); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btSortedOverlappingPairCache_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btSortedOverlappingPairCache_getOverlapFilterCallback(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btSortedOverlappingPairCache_needsBroadphaseCollision(IntPtr obj, IntPtr proxy0, IntPtr proxy1);
|
||||
}
|
||||
|
||||
public class NullPairCache : OverlappingPairCache
|
||||
{
|
||||
internal NullPairCache(IntPtr native)
|
||||
: base(native, true)
|
||||
{
|
||||
}
|
||||
|
||||
public NullPairCache()
|
||||
: base(btNullPairCache_new(), false)
|
||||
{
|
||||
}
|
||||
|
||||
public override BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
|
||||
{
|
||||
return new BroadphasePair(btOverlappingPairCallback_addOverlappingPair(_native, proxy0._native, proxy1._native));
|
||||
}
|
||||
|
||||
public override IntPtr RemoveOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, Dispatcher dispatcher)
|
||||
{
|
||||
return btOverlappingPairCallback_removeOverlappingPair(_native, proxy0._native, proxy1._native, dispatcher._native);
|
||||
}
|
||||
|
||||
public override void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy0, Dispatcher dispatcher)
|
||||
{
|
||||
btOverlappingPairCallback_removeOverlappingPairsContainingProxy(_native, proxy0._native, dispatcher._native);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btNullPairCache_new();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public abstract class OverlappingPairCallback : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
private readonly bool _preventDelete;
|
||||
|
||||
internal OverlappingPairCallback(IntPtr native, bool preventDelete = false)
|
||||
{
|
||||
_native = native;
|
||||
_preventDelete = preventDelete;
|
||||
}
|
||||
/*
|
||||
protected OverlappingPairCallback()
|
||||
{
|
||||
_native = btOverlappingPairCallbackWrapper_new();
|
||||
}
|
||||
*/
|
||||
public abstract BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1);
|
||||
public abstract IntPtr RemoveOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, Dispatcher dispatcher);
|
||||
public abstract void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy0, Dispatcher dispatcher);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
if (!_preventDelete)
|
||||
{
|
||||
btOverlappingPairCallback_delete(_native);
|
||||
}
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~OverlappingPairCallback()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
internal static extern IntPtr btOverlappingPairCallback_addOverlappingPair(IntPtr obj, IntPtr proxy0, IntPtr proxy1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
internal static extern IntPtr btOverlappingPairCallback_removeOverlappingPair(IntPtr obj, IntPtr proxy0, IntPtr proxy1, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
internal static extern void btOverlappingPairCallback_removeOverlappingPairsContainingProxy(IntPtr obj, IntPtr proxy0, IntPtr dispatcher);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOverlappingPairCallback_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,295 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public delegate void ContactDestroyedEventHandler(Object userPersistantData);
|
||||
public delegate void ContactProcessedEventHandler(ManifoldPoint cp, CollisionObject body0, CollisionObject body1);
|
||||
|
||||
public class PersistentManifold : IDisposable //: TypedObject
|
||||
{
|
||||
internal IntPtr _native;
|
||||
private bool _preventDelete;
|
||||
|
||||
static ContactDestroyedEventHandler _contactDestroyed;
|
||||
static ContactProcessedEventHandler _contactProcessed;
|
||||
static ContactDestroyedUnmanagedDelegate _contactDestroyedUnmanaged;
|
||||
static ContactProcessedUnmanagedDelegate _contactProcessedUnmanaged;
|
||||
static IntPtr _contactDestroyedUnmanagedPtr;
|
||||
static IntPtr _contactProcessedUnmanagedPtr;
|
||||
|
||||
[UnmanagedFunctionPointer(Native.Conv)]
|
||||
private delegate bool ContactDestroyedUnmanagedDelegate(IntPtr userPersistantData);
|
||||
[UnmanagedFunctionPointer(Native.Conv)]
|
||||
private delegate bool ContactProcessedUnmanagedDelegate(IntPtr cp, IntPtr body0, IntPtr body1);
|
||||
|
||||
static bool ContactDestroyedUnmanaged(IntPtr userPersistentData)
|
||||
{
|
||||
_contactDestroyed.Invoke(GCHandle.FromIntPtr(userPersistentData).Target);
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ContactProcessedUnmanaged(IntPtr cp, IntPtr body0, IntPtr body1)
|
||||
{
|
||||
_contactProcessed.Invoke(new ManifoldPoint(cp, true), CollisionObject.GetManaged(body0), CollisionObject.GetManaged(body1));
|
||||
return false;
|
||||
}
|
||||
|
||||
public static event ContactDestroyedEventHandler ContactDestroyed
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_contactDestroyedUnmanaged == null)
|
||||
{
|
||||
_contactDestroyedUnmanaged = new ContactDestroyedUnmanagedDelegate(ContactDestroyedUnmanaged);
|
||||
_contactDestroyedUnmanagedPtr = Marshal.GetFunctionPointerForDelegate(_contactDestroyedUnmanaged);
|
||||
}
|
||||
setGContactDestroyedCallback(_contactDestroyedUnmanagedPtr);
|
||||
_contactDestroyed += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_contactDestroyed -= value;
|
||||
if (_contactDestroyed == null)
|
||||
{
|
||||
setGContactDestroyedCallback(IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static event ContactProcessedEventHandler ContactProcessed
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_contactProcessedUnmanaged == null)
|
||||
{
|
||||
_contactProcessedUnmanaged = new ContactProcessedUnmanagedDelegate(ContactProcessedUnmanaged);
|
||||
_contactProcessedUnmanagedPtr = Marshal.GetFunctionPointerForDelegate(_contactProcessedUnmanaged);
|
||||
}
|
||||
setGContactProcessedCallback(_contactProcessedUnmanagedPtr);
|
||||
_contactProcessed += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_contactProcessed -= value;
|
||||
if (_contactProcessed == null)
|
||||
{
|
||||
setGContactProcessedCallback(IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal PersistentManifold(IntPtr native, bool preventDelete = false)
|
||||
{
|
||||
_native = native;
|
||||
_preventDelete = preventDelete;
|
||||
}
|
||||
|
||||
public PersistentManifold()
|
||||
{
|
||||
_native = btPersistentManifold_new();
|
||||
}
|
||||
|
||||
public PersistentManifold(CollisionObject body0, CollisionObject body1, int __unnamed2, float contactBreakingThreshold, float contactProcessingThreshold)
|
||||
{
|
||||
_native = btPersistentManifold_new2(body0._native, body1._native, __unnamed2, contactBreakingThreshold, contactProcessingThreshold);
|
||||
}
|
||||
|
||||
public int AddManifoldPoint(ManifoldPoint newPoint)
|
||||
{
|
||||
return btPersistentManifold_addManifoldPoint(_native, newPoint._native);
|
||||
}
|
||||
|
||||
public int AddManifoldPoint(ManifoldPoint newPoint, bool isPredictive)
|
||||
{
|
||||
return btPersistentManifold_addManifoldPoint2(_native, newPoint._native, isPredictive);
|
||||
}
|
||||
|
||||
public void ClearManifold()
|
||||
{
|
||||
btPersistentManifold_clearManifold(_native);
|
||||
}
|
||||
|
||||
public void ClearUserCache(ManifoldPoint pt)
|
||||
{
|
||||
btPersistentManifold_clearUserCache(_native, pt._native);
|
||||
}
|
||||
|
||||
public int GetCacheEntry(ManifoldPoint newPoint)
|
||||
{
|
||||
return btPersistentManifold_getCacheEntry(_native, newPoint._native);
|
||||
}
|
||||
|
||||
public ManifoldPoint GetContactPoint(int index)
|
||||
{
|
||||
return new ManifoldPoint(btPersistentManifold_getContactPoint(_native, index), true);
|
||||
}
|
||||
|
||||
public void RefreshContactPoints(ref Matrix trA, ref Matrix trB)
|
||||
{
|
||||
btPersistentManifold_refreshContactPoints(_native, ref trA, ref trB);
|
||||
}
|
||||
|
||||
public void RefreshContactPoints(Matrix trA, Matrix trB)
|
||||
{
|
||||
btPersistentManifold_refreshContactPoints(_native, ref trA, ref trB);
|
||||
}
|
||||
|
||||
public void RemoveContactPoint(int index)
|
||||
{
|
||||
btPersistentManifold_removeContactPoint(_native, index);
|
||||
}
|
||||
|
||||
public void ReplaceContactPoint(ManifoldPoint newPoint, int insertIndex)
|
||||
{
|
||||
btPersistentManifold_replaceContactPoint(_native, newPoint._native, insertIndex);
|
||||
}
|
||||
|
||||
public void SetBodies(CollisionObject body0, CollisionObject body1)
|
||||
{
|
||||
btPersistentManifold_setBodies(_native, body0._native, body1._native);
|
||||
}
|
||||
|
||||
public bool ValidContactDistance(ManifoldPoint pt)
|
||||
{
|
||||
return btPersistentManifold_validContactDistance(_native, pt._native);
|
||||
}
|
||||
|
||||
public CollisionObject Body0
|
||||
{
|
||||
get { return CollisionObject.GetManaged(btPersistentManifold_getBody0(_native)); }
|
||||
}
|
||||
|
||||
public CollisionObject Body1
|
||||
{
|
||||
get { return CollisionObject.GetManaged(btPersistentManifold_getBody1(_native)); }
|
||||
}
|
||||
|
||||
public int CompanionIdA
|
||||
{
|
||||
get { return btPersistentManifold_getCompanionIdA(_native); }
|
||||
set { btPersistentManifold_setCompanionIdA(_native, value); }
|
||||
}
|
||||
|
||||
public int CompanionIdB
|
||||
{
|
||||
get { return btPersistentManifold_getCompanionIdB(_native); }
|
||||
set { btPersistentManifold_setCompanionIdB(_native, value); }
|
||||
}
|
||||
|
||||
public float ContactBreakingThreshold
|
||||
{
|
||||
get { return btPersistentManifold_getContactBreakingThreshold(_native); }
|
||||
set { btPersistentManifold_setContactBreakingThreshold(_native, value); }
|
||||
}
|
||||
|
||||
public float ContactProcessingThreshold
|
||||
{
|
||||
get { return btPersistentManifold_getContactProcessingThreshold(_native); }
|
||||
set { btPersistentManifold_setContactProcessingThreshold(_native, value); }
|
||||
}
|
||||
|
||||
public int Index1A
|
||||
{
|
||||
get { return btPersistentManifold_getIndex1a(_native); }
|
||||
set { btPersistentManifold_setIndex1a(_native, value); }
|
||||
}
|
||||
|
||||
public int NumContacts
|
||||
{
|
||||
get { return btPersistentManifold_getNumContacts(_native); }
|
||||
set { btPersistentManifold_setNumContacts(_native, value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
if (!_preventDelete)
|
||||
{
|
||||
btPersistentManifold_delete(_native);
|
||||
}
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~PersistentManifold()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btPersistentManifold_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btPersistentManifold_new2(IntPtr body0, IntPtr body1, int __unnamed2, float contactBreakingThreshold, float contactProcessingThreshold);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btPersistentManifold_addManifoldPoint(IntPtr obj, IntPtr newPoint);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btPersistentManifold_addManifoldPoint2(IntPtr obj, IntPtr newPoint, bool isPredictive);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_clearManifold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_clearUserCache(IntPtr obj, IntPtr pt);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btPersistentManifold_getBody0(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btPersistentManifold_getBody1(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btPersistentManifold_getCacheEntry(IntPtr obj, IntPtr newPoint);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btPersistentManifold_getCompanionIdA(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btPersistentManifold_getCompanionIdB(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btPersistentManifold_getContactBreakingThreshold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btPersistentManifold_getContactPoint(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btPersistentManifold_getContactProcessingThreshold(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btPersistentManifold_getIndex1a(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btPersistentManifold_getNumContacts(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_refreshContactPoints(IntPtr obj, [In] ref Matrix trA, [In] ref Matrix trB);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_removeContactPoint(IntPtr obj, int index);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_replaceContactPoint(IntPtr obj, IntPtr newPoint, int insertIndex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_setBodies(IntPtr obj, IntPtr body0, IntPtr body1);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_setCompanionIdA(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_setCompanionIdB(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_setContactBreakingThreshold(IntPtr obj, float contactBreakingThreshold);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_setContactProcessingThreshold(IntPtr obj, float contactProcessingThreshold);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_setIndex1a(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_setNumContacts(IntPtr obj, int cachedPoints);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btPersistentManifold_validContactDistance(IntPtr obj, IntPtr pt);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPersistentManifold_delete(IntPtr obj);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr getGContactDestroyedCallback();
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern IntPtr getGContactProcessedCallback();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void setGContactDestroyedCallback(IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void setGContactProcessedCallback(IntPtr value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class PointCollector : DiscreteCollisionDetectorInterface.Result
|
||||
{
|
||||
public PointCollector()
|
||||
: base(btPointCollector_new())
|
||||
{
|
||||
}
|
||||
|
||||
public float Distance
|
||||
{
|
||||
get { return btPointCollector_getDistance(_native); }
|
||||
set { btPointCollector_setDistance(_native, value); }
|
||||
}
|
||||
|
||||
public bool HasResult
|
||||
{
|
||||
get { return btPointCollector_getHasResult(_native); }
|
||||
set { btPointCollector_setHasResult(_native, value); }
|
||||
}
|
||||
|
||||
public Vector3 NormalOnBInWorld
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btPointCollector_getNormalOnBInWorld(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btPointCollector_setNormalOnBInWorld(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 PointInWorld
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btPointCollector_getPointInWorld(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btPointCollector_setPointInWorld(_native, ref value); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btPointCollector_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern float btPointCollector_getDistance(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btPointCollector_getHasResult(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPointCollector_getNormalOnBInWorld(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPointCollector_getPointInWorld(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPointCollector_setDistance(IntPtr obj, float value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPointCollector_setHasResult(IntPtr obj, bool value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPointCollector_setNormalOnBInWorld(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPointCollector_setPointInWorld(IntPtr obj, [In] ref Vector3 value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class PolyhedralConvexShape : ConvexInternalShape
|
||||
{
|
||||
ConvexPolyhedron _convexPolyhedron;
|
||||
|
||||
internal PolyhedralConvexShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public void GetEdge(int i, out Vector3 pa, out Vector3 pb)
|
||||
{
|
||||
btPolyhedralConvexShape_getEdge(_native, i, out pa, out pb);
|
||||
}
|
||||
|
||||
public void GetPlane(out Vector3 planeNormal, out Vector3 planeSupport, int i)
|
||||
{
|
||||
btPolyhedralConvexShape_getPlane(_native, out planeNormal, out planeSupport, i);
|
||||
}
|
||||
|
||||
public void GetVertex(int i, out Vector3 vtx)
|
||||
{
|
||||
btPolyhedralConvexShape_getVertex(_native, i, out vtx);
|
||||
}
|
||||
|
||||
public bool InitializePolyhedralFeatures()
|
||||
{
|
||||
return btPolyhedralConvexShape_initializePolyhedralFeatures(_native);
|
||||
}
|
||||
|
||||
public bool InitializePolyhedralFeatures(int shiftVerticesByMargin)
|
||||
{
|
||||
return btPolyhedralConvexShape_initializePolyhedralFeatures2(_native, shiftVerticesByMargin);
|
||||
}
|
||||
|
||||
public bool IsInside(ref Vector3 pt, float tolerance)
|
||||
{
|
||||
return btPolyhedralConvexShape_isInside(_native, ref pt, tolerance);
|
||||
}
|
||||
|
||||
public bool IsInside(Vector3 pt, float tolerance)
|
||||
{
|
||||
return btPolyhedralConvexShape_isInside(_native, ref pt, tolerance);
|
||||
}
|
||||
|
||||
public ConvexPolyhedron ConvexPolyhedron
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_convexPolyhedron == null)
|
||||
{
|
||||
IntPtr ptr = btPolyhedralConvexShape_getConvexPolyhedron(_native);
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_convexPolyhedron = new ConvexPolyhedron();
|
||||
}
|
||||
return _convexPolyhedron;
|
||||
}
|
||||
}
|
||||
|
||||
public int NumEdges
|
||||
{
|
||||
get { return btPolyhedralConvexShape_getNumEdges(_native); }
|
||||
}
|
||||
|
||||
public int NumPlanes
|
||||
{
|
||||
get { return btPolyhedralConvexShape_getNumPlanes(_native); }
|
||||
}
|
||||
|
||||
public int NumVertices
|
||||
{
|
||||
get { return btPolyhedralConvexShape_getNumVertices(_native); }
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btPolyhedralConvexShape_getConvexPolyhedron(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPolyhedralConvexShape_getEdge(IntPtr obj, int i, [Out] out Vector3 pa, [Out] out Vector3 pb);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btPolyhedralConvexShape_getNumEdges(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btPolyhedralConvexShape_getNumPlanes(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btPolyhedralConvexShape_getNumVertices(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPolyhedralConvexShape_getPlane(IntPtr obj, [Out] out Vector3 planeNormal, [Out] out Vector3 planeSupport, int i);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPolyhedralConvexShape_getVertex(IntPtr obj, int i, [Out] out Vector3 vtx);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btPolyhedralConvexShape_initializePolyhedralFeatures(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btPolyhedralConvexShape_initializePolyhedralFeatures2(IntPtr obj, int shiftVerticesByMargin);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btPolyhedralConvexShape_isInside(IntPtr obj, [In] ref Vector3 pt, float tolerance);
|
||||
}
|
||||
|
||||
public abstract class PolyhedralConvexAabbCachingShape : PolyhedralConvexShape
|
||||
{
|
||||
internal PolyhedralConvexAabbCachingShape(IntPtr native)
|
||||
: base(native)
|
||||
{
|
||||
}
|
||||
|
||||
public void GetNonvirtualAabb(ref Matrix trans, out Vector3 aabbMin, out Vector3 aabbMax, float margin)
|
||||
{
|
||||
btPolyhedralConvexAabbCachingShape_getNonvirtualAabb(_native, ref trans, out aabbMin, out aabbMax, margin);
|
||||
}
|
||||
|
||||
public void GetNonvirtualAabb(Matrix trans, out Vector3 aabbMin, out Vector3 aabbMax, float margin)
|
||||
{
|
||||
btPolyhedralConvexAabbCachingShape_getNonvirtualAabb(_native, ref trans, out aabbMin, out aabbMax, margin);
|
||||
}
|
||||
|
||||
public void RecalcLocalAabb()
|
||||
{
|
||||
btPolyhedralConvexAabbCachingShape_recalcLocalAabb(_native);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPolyhedralConvexAabbCachingShape_getNonvirtualAabb(IntPtr obj, [In] ref Matrix trans, [Out] out Vector3 aabbMin, [Out] out Vector3 aabbMax, float margin);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btPolyhedralConvexAabbCachingShape_recalcLocalAabb(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,546 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public class QuantizedBvhNode : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal QuantizedBvhNode(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public QuantizedBvhNode()
|
||||
{
|
||||
_native = btQuantizedBvhNode_new();
|
||||
}
|
||||
|
||||
public int EscapeIndex
|
||||
{
|
||||
get { return btQuantizedBvhNode_getEscapeIndex(_native); }
|
||||
}
|
||||
|
||||
public int EscapeIndexOrTriangleIndex
|
||||
{
|
||||
get { return btQuantizedBvhNode_getEscapeIndexOrTriangleIndex(_native); }
|
||||
set { btQuantizedBvhNode_setEscapeIndexOrTriangleIndex(_native, value); }
|
||||
}
|
||||
|
||||
public bool IsLeafNode
|
||||
{
|
||||
get { return btQuantizedBvhNode_isLeafNode(_native); }
|
||||
}
|
||||
|
||||
public int PartId
|
||||
{
|
||||
get { return btQuantizedBvhNode_getPartId(_native); }
|
||||
}
|
||||
/*
|
||||
public UShortArray QuantizedAabbMax
|
||||
{
|
||||
get { return btQuantizedBvhNode_getQuantizedAabbMax(_native); }
|
||||
}
|
||||
|
||||
public UShortArray QuantizedAabbMin
|
||||
{
|
||||
get { return btQuantizedBvhNode_getQuantizedAabbMin(_native); }
|
||||
}
|
||||
*/
|
||||
public int TriangleIndex
|
||||
{
|
||||
get { return btQuantizedBvhNode_getTriangleIndex(_native); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btQuantizedBvhNode_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~QuantizedBvhNode()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btQuantizedBvhNode_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btQuantizedBvhNode_getEscapeIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btQuantizedBvhNode_getEscapeIndexOrTriangleIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btQuantizedBvhNode_getPartId(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btQuantizedBvhNode_getQuantizedAabbMax(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btQuantizedBvhNode_getQuantizedAabbMin(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btQuantizedBvhNode_getTriangleIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btQuantizedBvhNode_isLeafNode(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvhNode_setEscapeIndexOrTriangleIndex(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvhNode_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class OptimizedBvhNode : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal OptimizedBvhNode(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public OptimizedBvhNode()
|
||||
{
|
||||
_native = btOptimizedBvhNode_new();
|
||||
}
|
||||
|
||||
public Vector3 AabbMaxOrg
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btOptimizedBvhNode_getAabbMaxOrg(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btOptimizedBvhNode_setAabbMaxOrg(_native, ref value); }
|
||||
}
|
||||
|
||||
public Vector3 AabbMinOrg
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 value;
|
||||
btOptimizedBvhNode_getAabbMinOrg(_native, out value);
|
||||
return value;
|
||||
}
|
||||
set { btOptimizedBvhNode_setAabbMinOrg(_native, ref value); }
|
||||
}
|
||||
|
||||
public int EscapeIndex
|
||||
{
|
||||
get { return btOptimizedBvhNode_getEscapeIndex(_native); }
|
||||
set { btOptimizedBvhNode_setEscapeIndex(_native, value); }
|
||||
}
|
||||
|
||||
public int SubPart
|
||||
{
|
||||
get { return btOptimizedBvhNode_getSubPart(_native); }
|
||||
set { btOptimizedBvhNode_setSubPart(_native, value); }
|
||||
}
|
||||
|
||||
public int TriangleIndex
|
||||
{
|
||||
get { return btOptimizedBvhNode_getTriangleIndex(_native); }
|
||||
set { btOptimizedBvhNode_setTriangleIndex(_native, value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btOptimizedBvhNode_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~OptimizedBvhNode()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btOptimizedBvhNode_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvhNode_getAabbMaxOrg(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvhNode_getAabbMinOrg(IntPtr obj, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btOptimizedBvhNode_getEscapeIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btOptimizedBvhNode_getPadding(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btOptimizedBvhNode_getSubPart(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btOptimizedBvhNode_getTriangleIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvhNode_setAabbMaxOrg(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvhNode_setAabbMinOrg(IntPtr obj, [In] ref Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvhNode_setEscapeIndex(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvhNode_setPadding(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvhNode_setSubPart(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvhNode_setTriangleIndex(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btOptimizedBvhNode_delete(IntPtr obj);
|
||||
}
|
||||
/*
|
||||
public class BvhSubtreeInfo : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal BvhSubtreeInfo(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public BvhSubtreeInfo()
|
||||
{
|
||||
_native = btBvhSubtreeInfo_new();
|
||||
}
|
||||
|
||||
public void SetAabbFromQuantizeNode(QuantizedBvhNode quantizedNode)
|
||||
{
|
||||
btBvhSubtreeInfo_setAabbFromQuantizeNode(_native, quantizedNode._native);
|
||||
}
|
||||
|
||||
public int Padding
|
||||
{
|
||||
get { return btBvhSubtreeInfo_getPadding(_native); }
|
||||
set { btBvhSubtreeInfo_setPadding(_native, value._native); }
|
||||
}
|
||||
|
||||
public unsigned short QuantizedAabbMax
|
||||
{
|
||||
get { return btBvhSubtreeInfo_getQuantizedAabbMax(_native); }
|
||||
set { btBvhSubtreeInfo_setQuantizedAabbMax(_native, value._native); }
|
||||
}
|
||||
|
||||
public unsigned short QuantizedAabbMin
|
||||
{
|
||||
get { return btBvhSubtreeInfo_getQuantizedAabbMin(_native); }
|
||||
set { btBvhSubtreeInfo_setQuantizedAabbMin(_native, value._native); }
|
||||
}
|
||||
|
||||
public int RootNodeIndex
|
||||
{
|
||||
get { return btBvhSubtreeInfo_getRootNodeIndex(_native); }
|
||||
set { btBvhSubtreeInfo_setRootNodeIndex(_native, value); }
|
||||
}
|
||||
|
||||
public int SubtreeSize
|
||||
{
|
||||
get { return btBvhSubtreeInfo_getSubtreeSize(_native); }
|
||||
set { btBvhSubtreeInfo_setSubtreeSize(_native, value); }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btBvhSubtreeInfo_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~BvhSubtreeInfo()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhSubtreeInfo_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhSubtreeInfo_getPadding(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhSubtreeInfo_getQuantizedAabbMax(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btBvhSubtreeInfo_getQuantizedAabbMin(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btBvhSubtreeInfo_getRootNodeIndex(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btBvhSubtreeInfo_getSubtreeSize(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhSubtreeInfo_setAabbFromQuantizeNode(IntPtr obj, IntPtr quantizedNode);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhSubtreeInfo_setPadding(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhSubtreeInfo_setQuantizedAabbMax(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhSubtreeInfo_setQuantizedAabbMin(IntPtr obj, IntPtr value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhSubtreeInfo_setRootNodeIndex(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhSubtreeInfo_setSubtreeSize(IntPtr obj, int value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btBvhSubtreeInfo_delete(IntPtr obj);
|
||||
}
|
||||
*/
|
||||
public class NodeOverlapCallback : IDisposable
|
||||
{
|
||||
internal IntPtr _native;
|
||||
|
||||
internal NodeOverlapCallback(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public void ProcessNode(int subPart, int triangleIndex)
|
||||
{
|
||||
btNodeOverlapCallback_processNode(_native, subPart, triangleIndex);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btNodeOverlapCallback_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~NodeOverlapCallback()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btNodeOverlapCallback_processNode(IntPtr obj, int subPart, int triangleIndex);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btNodeOverlapCallback_delete(IntPtr obj);
|
||||
}
|
||||
|
||||
public class QuantizedBvh : IDisposable
|
||||
{
|
||||
public enum TraversalMode
|
||||
{
|
||||
Stackless,
|
||||
StacklessCacheFriendly,
|
||||
Recursive
|
||||
}
|
||||
|
||||
internal IntPtr _native;
|
||||
|
||||
internal QuantizedBvh(IntPtr native)
|
||||
{
|
||||
_native = native;
|
||||
}
|
||||
|
||||
public QuantizedBvh()
|
||||
{
|
||||
_native = btQuantizedBvh_new();
|
||||
}
|
||||
|
||||
public void BuildInternal()
|
||||
{
|
||||
btQuantizedBvh_buildInternal(_native);
|
||||
}
|
||||
|
||||
public uint CalculateSerializeBufferSize()
|
||||
{
|
||||
return btQuantizedBvh_calculateSerializeBufferSize(_native);
|
||||
}
|
||||
|
||||
public int CalculateSerializeBufferSizeNew()
|
||||
{
|
||||
return btQuantizedBvh_calculateSerializeBufferSizeNew(_native);
|
||||
}
|
||||
|
||||
public void DeSerializeDouble(IntPtr quantizedBvhDoubleData)
|
||||
{
|
||||
btQuantizedBvh_deSerializeDouble(_native, quantizedBvhDoubleData);
|
||||
}
|
||||
|
||||
public void DeSerializeFloat(IntPtr quantizedBvhFloatData)
|
||||
{
|
||||
btQuantizedBvh_deSerializeFloat(_native, quantizedBvhFloatData);
|
||||
}
|
||||
/*
|
||||
public static QuantizedBvh DeSerializeInPlace(IntPtr alignedDataBuffer, uint dataBufferSize, bool swapEndian)
|
||||
{
|
||||
return btQuantizedBvh_deSerializeInPlace(alignedDataBuffer, dataBufferSize, swapEndian);
|
||||
}
|
||||
|
||||
static public void Quantize(unsigned short out, Vector3 point, int isMax)
|
||||
{
|
||||
btQuantizedBvh_quantize(_native, out._native, ref point, isMax);
|
||||
}
|
||||
|
||||
public void QuantizeWithClamp(unsigned short out, Vector3 point2, int isMax)
|
||||
{
|
||||
btQuantizedBvh_quantizeWithClamp(_native, out._native, ref point2, isMax);
|
||||
}
|
||||
*/
|
||||
public void ReportAabbOverlappingNodex(NodeOverlapCallback nodeCallback, Vector3 aabbMin, Vector3 aabbMax)
|
||||
{
|
||||
btQuantizedBvh_reportAabbOverlappingNodex(_native, nodeCallback._native, ref aabbMin, ref aabbMax);
|
||||
}
|
||||
|
||||
public void ReportBoxCastOverlappingNodex(NodeOverlapCallback nodeCallback, Vector3 raySource, Vector3 rayTarget, Vector3 aabbMin, Vector3 aabbMax)
|
||||
{
|
||||
btQuantizedBvh_reportBoxCastOverlappingNodex(_native, nodeCallback._native, ref raySource, ref rayTarget, ref aabbMin, ref aabbMax);
|
||||
}
|
||||
|
||||
public void ReportRayOverlappingNodex(NodeOverlapCallback nodeCallback, Vector3 raySource, Vector3 rayTarget)
|
||||
{
|
||||
btQuantizedBvh_reportRayOverlappingNodex(_native, nodeCallback._native, ref raySource, ref rayTarget);
|
||||
}
|
||||
|
||||
public bool Serialize(IntPtr alignedDataBuffer, uint dataBufferSize, bool swapEndian)
|
||||
{
|
||||
return btQuantizedBvh_serialize(_native, alignedDataBuffer, dataBufferSize, swapEndian);
|
||||
}
|
||||
|
||||
public string Serialize(IntPtr dataBuffer, Serializer serializer)
|
||||
{
|
||||
return Marshal.PtrToStringAnsi(btQuantizedBvh_serialize2(_native, dataBuffer, serializer._native));
|
||||
}
|
||||
|
||||
public void SetQuantizationValues(Vector3 bvhAabbMin, Vector3 bvhAabbMax)
|
||||
{
|
||||
btQuantizedBvh_setQuantizationValues(_native, ref bvhAabbMin, ref bvhAabbMax);
|
||||
}
|
||||
|
||||
public void SetQuantizationValues(Vector3 bvhAabbMin, Vector3 bvhAabbMax, float quantizationMargin)
|
||||
{
|
||||
btQuantizedBvh_setQuantizationValues2(_native, ref bvhAabbMin, ref bvhAabbMax, quantizationMargin);
|
||||
}
|
||||
|
||||
public void SetTraversalMode(TraversalMode traversalMode)
|
||||
{
|
||||
btQuantizedBvh_setTraversalMode(_native, traversalMode);
|
||||
}
|
||||
/*
|
||||
public Vector3 UnQuantize(unsigned short vecIn)
|
||||
{
|
||||
Vector3 value;
|
||||
btQuantizedBvh_unQuantize(_native, vecIn._native, out value);
|
||||
return value;
|
||||
}
|
||||
*/
|
||||
public static uint AlignmentSerializationPadding
|
||||
{
|
||||
get { return btQuantizedBvh_getAlignmentSerializationPadding(); }
|
||||
}
|
||||
|
||||
public bool IsQuantized
|
||||
{
|
||||
get { return btQuantizedBvh_isQuantized(_native); }
|
||||
}
|
||||
/*
|
||||
public QuantizedNodeArray LeafNodeArray
|
||||
{
|
||||
get { return btQuantizedBvh_getLeafNodeArray(_native); }
|
||||
}
|
||||
|
||||
public QuantizedNodeArray QuantizedNodeArray
|
||||
{
|
||||
get { return btQuantizedBvh_getQuantizedNodeArray(_native); }
|
||||
}
|
||||
|
||||
public BvhSubtreeInfoArray SubtreeInfoArray
|
||||
{
|
||||
get { return btQuantizedBvh_getSubtreeInfoArray(_native); }
|
||||
}
|
||||
*/
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_native != IntPtr.Zero)
|
||||
{
|
||||
btQuantizedBvh_delete(_native);
|
||||
_native = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~QuantizedBvh()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btQuantizedBvh_new();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvh_buildInternal(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern uint btQuantizedBvh_calculateSerializeBufferSize(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern int btQuantizedBvh_calculateSerializeBufferSizeNew(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvh_deSerializeDouble(IntPtr obj, IntPtr quantizedBvhDoubleData);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvh_deSerializeFloat(IntPtr obj, IntPtr quantizedBvhFloatData);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btQuantizedBvh_deSerializeInPlace(IntPtr i_alignedDataBuffer, uint i_dataBufferSize, bool i_swapEndian);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern uint btQuantizedBvh_getAlignmentSerializationPadding();
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btQuantizedBvh_getLeafNodeArray(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btQuantizedBvh_getQuantizedNodeArray(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btQuantizedBvh_getSubtreeInfoArray(IntPtr obj);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btQuantizedBvh_isQuantized(IntPtr obj);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern void btQuantizedBvh_quantize(IntPtr obj, IntPtr out, [In] ref Vector3 point, int isMax);
|
||||
//[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
//static extern void btQuantizedBvh_quantizeWithClamp(IntPtr obj, IntPtr out, [In] ref Vector3 point2, int isMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvh_reportAabbOverlappingNodex(IntPtr obj, IntPtr nodeCallback, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvh_reportBoxCastOverlappingNodex(IntPtr obj, IntPtr nodeCallback, [In] ref Vector3 raySource, [In] ref Vector3 rayTarget, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvh_reportRayOverlappingNodex(IntPtr obj, IntPtr nodeCallback, [In] ref Vector3 raySource, [In] ref Vector3 rayTarget);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
static extern bool btQuantizedBvh_serialize(IntPtr obj, IntPtr o_alignedDataBuffer, uint i_dataBufferSize, bool i_swapEndian);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern IntPtr btQuantizedBvh_serialize2(IntPtr obj, IntPtr dataBuffer, IntPtr serializer);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvh_setQuantizationValues(IntPtr obj, [In] ref Vector3 bvhAabbMin, [In] ref Vector3 bvhAabbMax);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvh_setQuantizationValues2(IntPtr obj, [In] ref Vector3 bvhAabbMin, [In] ref Vector3 bvhAabbMax, float quantizationMargin);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvh_setTraversalMode(IntPtr obj, TraversalMode traversalMode);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvh_unQuantize(IntPtr obj, IntPtr vecIn, [Out] out Vector3 value);
|
||||
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
|
||||
static extern void btQuantizedBvh_delete(IntPtr obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
using System;
|
||||
using BulletSharp.Math;
|
||||
|
||||
namespace BulletSharp
|
||||
{
|
||||
public abstract class TriangleRaycastCallback : TriangleCallback
|
||||
{
|
||||
[Flags]
|
||||
public enum EFlags
|
||||
{
|
||||
None = 0,
|
||||
FilterBackfaces = 1,
|
||||
KeepUnflippedNormal = 2,
|
||||
UseSubSimplexConvexCastRaytest = 4,
|
||||
Terminator = -1
|
||||
};
|
||||
|
||||
public TriangleRaycastCallback(ref Vector3 from, ref Vector3 to, EFlags flags)
|
||||
{
|
||||
HitFraction = 1.0f;
|
||||
}
|
||||
|
||||
public TriangleRaycastCallback(ref Vector3 from, ref Vector3 to)
|
||||
: this(ref from, ref to, EFlags.None)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ProcessTriangle(ref Vector3 point0, ref Vector3 point1, ref Vector3 point2, int partId, int triangleIndex)
|
||||
{
|
||||
Vector3 v10 = point1 - point0;
|
||||
Vector3 v20 = point2 - point0;
|
||||
|
||||
Vector3 triangleNormal = v10.Cross(v20);
|
||||
|
||||
float dist = point0.Dot(ref triangleNormal);
|
||||
float distA = triangleNormal.Dot(From) - dist;
|
||||
float distB = triangleNormal.Dot(To) - dist;
|
||||
|
||||
if (distA * distB >= 0.0f)
|
||||
{
|
||||
return; // same sign
|
||||
}
|
||||
|
||||
if (((Flags & EFlags.FilterBackfaces) != 0) && (distA <= 0.0f))
|
||||
{
|
||||
// Backface, skip check
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
float proj_length = distA - distB;
|
||||
float distance = (distA) / (proj_length);
|
||||
// Now we have the intersection point on the plane, we'll see if it's inside the triangle
|
||||
// Add an epsilon as a tolerance for the raycast,
|
||||
// in case the ray hits exacly on the edge of the triangle.
|
||||
// It must be scaled for the triangle size.
|
||||
|
||||
if (distance < HitFraction)
|
||||
{
|
||||
float edgeTolerance = triangleNormal.LengthSquared;
|
||||
edgeTolerance *= -0.0001f;
|
||||
Vector3 point = Vector3.Lerp(From, To, distance);
|
||||
{
|
||||
Vector3 v0p; v0p = point0 - point;
|
||||
Vector3 v1p; v1p = point1 - point;
|
||||
Vector3 cp0; cp0 = v0p.Cross(v1p);
|
||||
|
||||
if (cp0.Dot(ref triangleNormal) >= edgeTolerance)
|
||||
{
|
||||
Vector3 v2p; v2p = point2 - point;
|
||||
Vector3 cp1;
|
||||
cp1 = v1p.Cross(v2p);
|
||||
if (cp1.Dot(ref triangleNormal) >= edgeTolerance)
|
||||
{
|
||||
Vector3 cp2;
|
||||
cp2 = v2p.Cross(v0p);
|
||||
|
||||
if (cp2.Dot(ref triangleNormal) >= edgeTolerance)
|
||||
{
|
||||
//@BP Mod
|
||||
// Triangle normal isn't normalized
|
||||
triangleNormal.Normalize();
|
||||
|
||||
//@BP Mod - Allow for unflipped normal when raycasting against backfaces
|
||||
if (((Flags & EFlags.KeepUnflippedNormal) == 0) && (distA <= 0.0f))
|
||||
{
|
||||
triangleNormal = -triangleNormal;
|
||||
}
|
||||
HitFraction = ReportHit(ref triangleNormal, distance, partId, triangleIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract float ReportHit(ref Vector3 hitNormalLocal, float hitFraction, int partId, int triangleIndex);
|
||||
|
||||
public EFlags Flags { get; set; }
|
||||
public Vector3 From { get; set; }
|
||||
public float HitFraction { get; set; }
|
||||
public Vector3 To { get; set; }
|
||||
}
|
||||
|
||||
public abstract class TriangleConvexcastCallback : TriangleCallback
|
||||
{
|
||||
public TriangleConvexcastCallback(ConvexShape convexShape, ref Matrix convexShapeFrom, ref Matrix convexShapeTo, ref Matrix triangleToWorld, float triangleCollisionMargin)
|
||||
{
|
||||
ConvexShape = convexShape;
|
||||
ConvexShapeFrom = convexShapeFrom;
|
||||
ConvexShapeTo = convexShapeTo;
|
||||
TriangleToWorld = triangleToWorld;
|
||||
TriangleCollisionMargin = triangleCollisionMargin;
|
||||
|
||||
AllowedPenetration = 0.0f;
|
||||
HitFraction = 1.0f;
|
||||
}
|
||||
|
||||
public override void ProcessTriangle(ref Vector3 point0, ref Vector3 point1, ref Vector3 point2, int partId, int triangleIndex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public abstract float ReportHit(ref Vector3 hitNormalLocal, ref Vector3 hitPointLocal, float hitFraction, int partId, int triangleIndex);
|
||||
|
||||
public float AllowedPenetration { get; set; }
|
||||
public ConvexShape ConvexShape { get; set; }
|
||||
public Matrix ConvexShapeFrom { get; set; }
|
||||
public Matrix ConvexShapeTo { get; set; }
|
||||
public float HitFraction { get; set; }
|
||||
public float TriangleCollisionMargin { get; set; }
|
||||
public Matrix TriangleToWorld { get; set; }
|
||||
}
|
||||
}
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче