This commit is contained in:
AndresTraks 2016-11-26 14:53:12 +02:00
Родитель 2f250065eb
Коммит 781829ff02
14 изменённых файлов: 137 добавлений и 24 удалений

Просмотреть файл

@ -64,6 +64,18 @@ namespace BulletSharp
proxyType1, createFunc._native);
}
public void RegisterClosestPointsCreateFunc(BroadphaseNativeType proxyType0, BroadphaseNativeType proxyType1, CollisionAlgorithmCreateFunc createFunc)
{
if (_collisionCreateFuncs == null)
{
_collisionCreateFuncs = new List<CollisionAlgorithmCreateFunc>();
}
_collisionCreateFuncs.Add(createFunc);
btCollisionDispatcher_registerClosestPointsCreateFunc(_native, proxyType0,
proxyType1, createFunc._native);
}
public CollisionConfiguration CollisionConfiguration
{
get { return _collisionConfiguration; }
@ -115,7 +127,9 @@ namespace BulletSharp
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]
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btCollisionDispatcher_registerClosestPointsCreateFunc(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);

Просмотреть файл

@ -34,7 +34,8 @@ namespace BulletSharp
CharacterObject = 16,
DisableVisualizeObject = 32,
DisableSpuCollisionProcessing = 64,
HasContactStiffnessDamping = 128
HasContactStiffnessDamping = 128,
HasCustomDebugRenderingColor = 256
}
[Flags]
@ -115,6 +116,11 @@ namespace BulletSharp
btCollisionObject_forceActivationState(_native, newState);
}
public bool GetCustomDebugColor(out Vector3 colorRgb)
{
return btCollisionObject_getCustomDebugColor(_native, out colorRgb);
}
public void GetWorldTransform(out Matrix transform)
{
btCollisionObject_getWorldTransform(_native, out transform);
@ -145,6 +151,11 @@ namespace BulletSharp
return btCollisionObject_mergesSimulationIslands(_native);
}
public void RemoveCustomDebugColor()
{
btCollisionObject_removeCustomDebugColor(_native);
}
public string Serialize(IntPtr dataBuffer, Serializer serializer)
{
return Marshal.PtrToStringAnsi(btCollisionObject_serialize(_native, dataBuffer, serializer._native));
@ -181,6 +192,11 @@ namespace BulletSharp
btCollisionObject_setContactStiffnessAndDamping(_native, stiffness, damping);
}
public void SetCustomDebugColor(Vector3 colorRgb)
{
btCollisionObject_setCustomDebugColor(_native, ref colorRgb);
}
public void SetIgnoreCollisionCheck(CollisionObject co, bool ignoreCollisionCheck)
{
btCollisionObject_setIgnoreCollisionCheck(_native, co._native, ignoreCollisionCheck);
@ -483,6 +499,8 @@ namespace BulletSharp
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern float btCollisionObject_getContactStiffness(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern bool btCollisionObject_getCustomDebugColor(IntPtr obj, out Vector3 colorRGB);
[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);
@ -541,6 +559,8 @@ namespace BulletSharp
[return: MarshalAs(UnmanagedType.I1)]
static extern bool btCollisionObject_mergesSimulationIslands(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btCollisionObject_removeCustomDebugColor(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);
@ -567,6 +587,8 @@ namespace BulletSharp
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btCollisionObject_setContactStiffnessAndDamping(IntPtr obj, float stiffness, float damping);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btCollisionObject_setCustomDebugColor(IntPtr obj, ref Vector3 colorRGB);
[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);

Просмотреть файл

@ -116,6 +116,56 @@ namespace BulletSharp
{
}
public CollisionAlgorithmCreateFunc GetClosestPointsAlgorithmCreateFunc(BroadphaseNativeType proxyType0, BroadphaseNativeType proxyType1)
{
IntPtr createFunc = btCollisionConfiguration_getClosestPointsAlgorithmCreateFunc(_native, (int)proxyType0, (int)proxyType1);
if (proxyType0 == BroadphaseNativeType.BoxShape && proxyType1 == BroadphaseNativeType.BoxShape)
{
return new BoxBoxCollisionAlgorithm.CreateFunc(createFunc);
}
if (proxyType0 == BroadphaseNativeType.SphereShape && proxyType1 == BroadphaseNativeType.SphereShape)
{
return new SphereSphereCollisionAlgorithm.CreateFunc(createFunc);
}
if (proxyType0 == BroadphaseNativeType.SphereShape && proxyType1 == BroadphaseNativeType.TriangleShape)
{
return new SphereTriangleCollisionAlgorithm.CreateFunc(createFunc);
}
if (proxyType0 == BroadphaseNativeType.TriangleShape && proxyType1 == BroadphaseNativeType.SphereShape)
{
return new SphereTriangleCollisionAlgorithm.CreateFunc(createFunc);
}
if (proxyType0 == BroadphaseNativeType.StaticPlaneShape && BroadphaseProxy.IsConvex(proxyType1))
{
return new ConvexPlaneCollisionAlgorithm.CreateFunc(createFunc);
}
if (proxyType1 == BroadphaseNativeType.StaticPlaneShape && BroadphaseProxy.IsConvex(proxyType0))
{
return new ConvexPlaneCollisionAlgorithm.CreateFunc(createFunc);
}
if (BroadphaseProxy.IsConvex(proxyType0) && BroadphaseProxy.IsConvex(proxyType1))
{
return new ConvexConvexAlgorithm.CreateFunc(createFunc);
}
if (BroadphaseProxy.IsConvex(proxyType0) && BroadphaseProxy.IsConcave(proxyType1))
{
return new ConvexConcaveCollisionAlgorithm.CreateFunc(createFunc);
}
if (BroadphaseProxy.IsConvex(proxyType1) && BroadphaseProxy.IsConcave(proxyType0))
{
return new ConvexConcaveCollisionAlgorithm.SwappedCreateFunc(createFunc);
}
if (BroadphaseProxy.IsCompound(proxyType0))
{
return new CompoundCompoundCollisionAlgorithm.CreateFunc(createFunc);
}
if (BroadphaseProxy.IsCompound(proxyType1))
{
return new CompoundCompoundCollisionAlgorithm.SwappedCreateFunc(createFunc);
}
return new EmptyAlgorithm.CreateFunc(createFunc);
}
public override CollisionAlgorithmCreateFunc GetCollisionAlgorithmCreateFunc(BroadphaseNativeType proxyType0, BroadphaseNativeType proxyType1)
{
IntPtr createFunc = btCollisionConfiguration_getCollisionAlgorithmCreateFunc(_native, (int)proxyType0, (int)proxyType1);
@ -207,6 +257,8 @@ namespace BulletSharp
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btDefaultCollisionConfiguration_new2(IntPtr constructionInfo);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
protected static extern IntPtr btCollisionConfiguration_getClosestPointsAlgorithmCreateFunc(IntPtr obj, int proxyType0, int proxyType1);
[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);

Просмотреть файл

@ -11,6 +11,12 @@ namespace BulletSharp
Continuous
}
public enum DispatcherQueryType
{
ContactPointAlgorithms = 1,
ClosestPointAlgorithms = 2
}
public class DispatcherInfo
{
internal IntPtr _native;
@ -177,15 +183,10 @@ namespace BulletSharp
}
public CollisionAlgorithm FindAlgorithm(CollisionObjectWrapper body0Wrap,
CollisionObjectWrapper body1Wrap)
CollisionObjectWrapper body1Wrap, PersistentManifold sharedManifold,
DispatcherQueryType queryType)
{
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));
return new CollisionAlgorithm(btDispatcher_findAlgorithm(_native, body0Wrap._native, body1Wrap._native, sharedManifold._native, queryType));
}
public void FreeCollisionAlgorithm(IntPtr ptr)
@ -269,9 +270,7 @@ namespace BulletSharp
[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);
static extern IntPtr btDispatcher_findAlgorithm(IntPtr obj, IntPtr body0Wrap, IntPtr body1Wrap, IntPtr sharedManifold, DispatcherQueryType queryType);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btDispatcher_freeCollisionAlgorithm(IntPtr obj, IntPtr ptr);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]

Просмотреть файл

@ -2,7 +2,6 @@
using System;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using BulletSharp;
using DemoFramework;

Просмотреть файл

@ -35,6 +35,12 @@ void btCollisionDispatcher_registerCollisionCreateFunc(btCollisionDispatcher* ob
obj->registerCollisionCreateFunc(proxyType0, proxyType1, createFunc);
}
void btCollisionDispatcher_registerClosestPointsCreateFunc(btCollisionDispatcher * obj,
int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc * createFunc)
{
obj->registerCollisionCreateFunc(proxyType0, proxyType1, createFunc);
}
void btCollisionDispatcher_setCollisionConfiguration(btCollisionDispatcher* obj,
btCollisionConfiguration* config)
{

Просмотреть файл

@ -8,6 +8,7 @@ extern "C"
EXPORT int btCollisionDispatcher_getDispatcherFlags(btCollisionDispatcher* obj);
EXPORT btNearCallback btCollisionDispatcher_getNearCallback(btCollisionDispatcher* obj);
EXPORT void btCollisionDispatcher_registerCollisionCreateFunc(btCollisionDispatcher* obj, int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
EXPORT void btCollisionDispatcher_registerClosestPointsCreateFunc(btCollisionDispatcher* obj, int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
EXPORT void btCollisionDispatcher_setCollisionConfiguration(btCollisionDispatcher* obj, btCollisionConfiguration* config);
EXPORT void btCollisionDispatcher_setDispatcherFlags(btCollisionDispatcher* obj, int flags);
EXPORT void btCollisionDispatcher_setNearCallback(btCollisionDispatcher* obj, btNearCallback nearCallback);

Просмотреть файл

@ -101,6 +101,11 @@ btScalar btCollisionObject_getContactStiffness(btCollisionObject* obj)
return obj->getContactStiffness();
}
bool btCollisionObject_getCustomDebugColor(btCollisionObject* obj, btVector3* colorRGB)
{
return obj->getCustomDebugColor(*colorRGB);
}
btScalar btCollisionObject_getDeactivationTime(btCollisionObject* obj)
{
return obj->getDeactivationTime();
@ -226,6 +231,11 @@ bool btCollisionObject_mergesSimulationIslands(btCollisionObject* obj)
return obj->mergesSimulationIslands();
}
void btCollisionObject_removeCustomDebugColor(btCollisionObject * obj)
{
obj->removeCustomDebugColor();
}
const char* btCollisionObject_serialize(btCollisionObject* obj, void* dataBuffer,
btSerializer* serializer)
{
@ -296,6 +306,11 @@ void btCollisionObject_setContactStiffnessAndDamping(btCollisionObject* obj, btS
obj->setContactStiffnessAndDamping(stiffness, damping);
}
void btCollisionObject_setCustomDebugColor(btCollisionObject* obj, const btVector3* colorRGB)
{
obj->setCustomDebugColor(*colorRGB);
}
void btCollisionObject_setDeactivationTime(btCollisionObject* obj, btScalar time)
{
obj->setDeactivationTime(time);

Просмотреть файл

@ -21,6 +21,7 @@ extern "C"
EXPORT btScalar btCollisionObject_getContactDamping(btCollisionObject* obj);
EXPORT btScalar btCollisionObject_getContactProcessingThreshold(btCollisionObject* obj);
EXPORT btScalar btCollisionObject_getContactStiffness(btCollisionObject* obj);
EXPORT bool btCollisionObject_getCustomDebugColor(btCollisionObject* obj, btVector3* colorRGB);
EXPORT btScalar btCollisionObject_getDeactivationTime(btCollisionObject* obj);
EXPORT btScalar btCollisionObject_getFriction(btCollisionObject* obj);
EXPORT btScalar btCollisionObject_getHitFraction(btCollisionObject* obj);
@ -46,6 +47,7 @@ extern "C"
EXPORT bool btCollisionObject_isStaticObject(btCollisionObject* obj);
EXPORT bool btCollisionObject_isStaticOrKinematicObject(btCollisionObject* obj);
EXPORT bool btCollisionObject_mergesSimulationIslands(btCollisionObject* obj);
EXPORT void btCollisionObject_removeCustomDebugColor(btCollisionObject* obj);
EXPORT const char* btCollisionObject_serialize(btCollisionObject* obj, void* dataBuffer, btSerializer* serializer);
EXPORT void btCollisionObject_serializeSingleObject(btCollisionObject* obj, btSerializer* serializer);
EXPORT void btCollisionObject_setActivationState(btCollisionObject* obj, int newState);
@ -59,6 +61,7 @@ extern "C"
EXPORT void btCollisionObject_setCompanionId(btCollisionObject* obj, int id);
EXPORT void btCollisionObject_setContactProcessingThreshold(btCollisionObject* obj, btScalar contactProcessingThreshold);
EXPORT void btCollisionObject_setContactStiffnessAndDamping(btCollisionObject* obj, btScalar stiffness, btScalar damping);
EXPORT void btCollisionObject_setCustomDebugColor(btCollisionObject* obj, const btVector3* colorRGB);
EXPORT void btCollisionObject_setDeactivationTime(btCollisionObject* obj, btScalar time);
EXPORT void btCollisionObject_setFriction(btCollisionObject* obj, btScalar frict);
EXPORT void btCollisionObject_setHitFraction(btCollisionObject* obj, btScalar hitFraction);

Просмотреть файл

@ -92,6 +92,12 @@ btDefaultCollisionConfiguration* btDefaultCollisionConfiguration_new2(const btDe
return new btDefaultCollisionConfiguration(*constructionInfo);
}
btCollisionAlgorithmCreateFunc* btDefaultCollisionConfiguration_getClosestPointsAlgorithmCreateFunc(
btDefaultCollisionConfiguration* obj, int proxyType0, int proxyType1)
{
return obj->getClosestPointsAlgorithmCreateFunc(proxyType0, proxyType1);
}
void btDefaultCollisionConfiguration_setConvexConvexMultipointIterations(btDefaultCollisionConfiguration* obj)
{
obj->setConvexConvexMultipointIterations();

Просмотреть файл

@ -19,6 +19,7 @@ extern "C"
EXPORT btDefaultCollisionConfiguration* btDefaultCollisionConfiguration_new();
EXPORT btDefaultCollisionConfiguration* btDefaultCollisionConfiguration_new2(const btDefaultCollisionConstructionInfo* constructionInfo);
EXPORT btCollisionAlgorithmCreateFunc* btDefaultCollisionConfiguration_getClosestPointsAlgorithmCreateFunc(btDefaultCollisionConfiguration* obj, int proxyType0, int proxyType1);
EXPORT void btDefaultCollisionConfiguration_setConvexConvexMultipointIterations(btDefaultCollisionConfiguration* obj);
EXPORT void btDefaultCollisionConfiguration_setConvexConvexMultipointIterations2(btDefaultCollisionConfiguration* obj, int numPerturbationIterations);
EXPORT void btDefaultCollisionConfiguration_setConvexConvexMultipointIterations3(btDefaultCollisionConfiguration* obj, int numPerturbationIterations, int minimumPointsPerturbationThreshold);

Просмотреть файл

@ -149,15 +149,10 @@ void btDispatcher_dispatchAllCollisionPairs(btDispatcher* obj, btOverlappingPair
}
btCollisionAlgorithm* btDispatcher_findAlgorithm(btDispatcher* obj, const btCollisionObjectWrapper* body0Wrap,
const btCollisionObjectWrapper* body1Wrap)
const btCollisionObjectWrapper* body1Wrap, btPersistentManifold* sharedManifold,
ebtDispatcherQueryType queryType)
{
return obj->findAlgorithm(body0Wrap, body1Wrap);
}
btCollisionAlgorithm* btDispatcher_findAlgorithm2(btDispatcher* obj, const btCollisionObjectWrapper* body0Wrap,
const btCollisionObjectWrapper* body1Wrap, btPersistentManifold* sharedManifold)
{
return obj->findAlgorithm(body0Wrap, body1Wrap, sharedManifold);
return obj->findAlgorithm(body0Wrap, body1Wrap, sharedManifold, queryType);
}
void btDispatcher_freeCollisionAlgorithm(btDispatcher* obj, void* ptr)

Просмотреть файл

@ -30,8 +30,7 @@ extern "C"
EXPORT void* btDispatcher_allocateCollisionAlgorithm(btDispatcher* obj, int size);
EXPORT void btDispatcher_clearManifold(btDispatcher* obj, btPersistentManifold* manifold);
EXPORT void btDispatcher_dispatchAllCollisionPairs(btDispatcher* obj, btOverlappingPairCache* pairCache, const btDispatcherInfo* dispatchInfo, btDispatcher* dispatcher);
EXPORT btCollisionAlgorithm* btDispatcher_findAlgorithm(btDispatcher* obj, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap);
EXPORT btCollisionAlgorithm* btDispatcher_findAlgorithm2(btDispatcher* obj, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, btPersistentManifold* sharedManifold);
EXPORT btCollisionAlgorithm* btDispatcher_findAlgorithm(btDispatcher* obj, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, btPersistentManifold* sharedManifold, ebtDispatcherQueryType queryType);
EXPORT void btDispatcher_freeCollisionAlgorithm(btDispatcher* obj, void* ptr);
EXPORT btPersistentManifold** btDispatcher_getInternalManifoldPointer(btDispatcher* obj);
EXPORT btPoolAllocator* btDispatcher_getInternalManifoldPool(btDispatcher* obj);

Просмотреть файл

@ -349,6 +349,7 @@
#ifndef BT_DISPATCHER_H
#define btDispatcher void
#define btDispatcherInfo void
#define ebtDispatcherQueryType int
#endif
#ifndef BT_DYNAMIC_BOUNDING_VOLUME_TREE_H