BulletSim: move over and port the interface for BulletXNA.
Copied BulletSNPlugin.BulletSimAPI to a new BulletSPlugin.BSAPIXNA.cs and then modifyed the latter to comply with the BSAPITemplate definition. Not totally debugged but the code is all there for an INI variable to select either unmanaged C++ Bullet or the C# version of Bullet.0.7.5-pf-bulletsim
parent
0662d109c2
commit
9d840fd2ee
|
@ -339,10 +339,10 @@ public override bool DeleteCollisionShape(BulletWorld world, BulletShape shape)
|
||||||
return BSAPICPP.DeleteCollisionShape2(worldu.ptr, shapeu.ptr);
|
return BSAPICPP.DeleteCollisionShape2(worldu.ptr, shapeu.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetBodyType(BulletBody obj)
|
public override CollisionObjectTypes GetBodyType(BulletBody obj)
|
||||||
{
|
{
|
||||||
BulletBodyUnman bodyu = obj as BulletBodyUnman;
|
BulletBodyUnman bodyu = obj as BulletBodyUnman;
|
||||||
return BSAPICPP.GetBodyType2(bodyu.ptr);
|
return (CollisionObjectTypes)BSAPICPP.GetBodyType2(bodyu.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BulletBody CreateBodyFromShape(BulletWorld world, BulletShape shape, uint id, Vector3 pos, Quaternion rot)
|
public override BulletBody CreateBodyFromShape(BulletWorld world, BulletShape shape, uint id, Vector3 pos, Quaternion rot)
|
||||||
|
@ -522,9 +522,22 @@ public override void SetForceUpdateAllAabbs(BulletWorld world, bool force)
|
||||||
// btDynamicsWorld entries
|
// btDynamicsWorld entries
|
||||||
public override bool AddObjectToWorld(BulletWorld world, BulletBody obj)
|
public override bool AddObjectToWorld(BulletWorld world, BulletBody obj)
|
||||||
{
|
{
|
||||||
|
// Bullet resets several variables when an object is added to the world.
|
||||||
|
// Gravity is reset to world default depending on the static/dynamic
|
||||||
|
// type. Of course, the collision flags in the broadphase proxy are initialized to default.
|
||||||
BulletWorldUnman worldu = world as BulletWorldUnman;
|
BulletWorldUnman worldu = world as BulletWorldUnman;
|
||||||
BulletBodyUnman bodyu = obj as BulletBodyUnman;
|
BulletBodyUnman bodyu = obj as BulletBodyUnman;
|
||||||
return BSAPICPP.AddObjectToWorld2(worldu.ptr, bodyu.ptr);
|
|
||||||
|
Vector3 origGrav = BSAPICPP.GetGravity2(bodyu.ptr);
|
||||||
|
|
||||||
|
bool ret = BSAPICPP.AddObjectToWorld2(worldu.ptr, bodyu.ptr);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
BSAPICPP.SetGravity2(bodyu.ptr, origGrav);
|
||||||
|
obj.ApplyCollisionMask(world.physicsScene);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj)
|
public override bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj)
|
||||||
|
@ -1061,7 +1074,7 @@ public override Vector3 GetAngularFactor(BulletBody obj)
|
||||||
return BSAPICPP.GetAngularFactor2(bodyu.ptr);
|
return BSAPICPP.GetAngularFactor2(bodyu.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsInWorld(BulletBody obj)
|
public override bool IsInWorld(BulletWorld world, BulletBody obj)
|
||||||
{
|
{
|
||||||
BulletBodyUnman bodyu = obj as BulletBodyUnman;
|
BulletBodyUnman bodyu = obj as BulletBodyUnman;
|
||||||
return BSAPICPP.IsInWorld2(bodyu.ptr);
|
return BSAPICPP.IsInWorld2(bodyu.ptr);
|
||||||
|
@ -1239,7 +1252,6 @@ public override void DumpPhysicsStatistics(BulletWorld world)
|
||||||
BSAPICPP.DumpPhysicsStatistics2(worldu.ptr);
|
BSAPICPP.DumpPhysicsStatistics2(worldu.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -346,10 +346,9 @@ public abstract void RecalculateCompoundShapeLocalAabb(BulletShape cShape);
|
||||||
|
|
||||||
public abstract BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, uint id);
|
public abstract BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, uint id);
|
||||||
|
|
||||||
|
|
||||||
public abstract bool DeleteCollisionShape(BulletWorld world, BulletShape shape);
|
public abstract bool DeleteCollisionShape(BulletWorld world, BulletShape shape);
|
||||||
|
|
||||||
public abstract int GetBodyType(BulletBody obj);
|
public abstract CollisionObjectTypes GetBodyType(BulletBody obj);
|
||||||
|
|
||||||
public abstract BulletBody CreateBodyFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot);
|
public abstract BulletBody CreateBodyFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot);
|
||||||
|
|
||||||
|
@ -416,6 +415,7 @@ public abstract void SetForceUpdateAllAabbs(BulletWorld world, bool force);
|
||||||
|
|
||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
// btDynamicsWorld entries
|
// btDynamicsWorld entries
|
||||||
|
// public abstract bool AddObjectToWorld(BulletWorld world, BulletBody obj, Vector3 pos, Quaternion rot);
|
||||||
public abstract bool AddObjectToWorld(BulletWorld world, BulletBody obj);
|
public abstract bool AddObjectToWorld(BulletWorld world, BulletBody obj);
|
||||||
|
|
||||||
public abstract bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj);
|
public abstract bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj);
|
||||||
|
@ -597,7 +597,7 @@ public abstract void SetAngularFactorV(BulletBody obj, Vector3 factor);
|
||||||
|
|
||||||
public abstract Vector3 GetAngularFactor(BulletBody obj);
|
public abstract Vector3 GetAngularFactor(BulletBody obj);
|
||||||
|
|
||||||
public abstract bool IsInWorld(BulletBody obj);
|
public abstract bool IsInWorld(BulletWorld world, BulletBody obj);
|
||||||
|
|
||||||
public abstract void AddConstraintRef(BulletBody obj, BulletConstraint constrain);
|
public abstract void AddConstraintRef(BulletBody obj, BulletConstraint constrain);
|
||||||
|
|
||||||
|
|
|
@ -898,17 +898,6 @@ public sealed class BSPrim : BSPhysObject
|
||||||
if (PhysBody.HasPhysicalBody)
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody);
|
PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody);
|
||||||
|
|
||||||
// TODO: Fix this. Total kludge because adding object to world resets its gravity to default.
|
|
||||||
// Replace this when the new AddObjectToWorld function is complete.
|
|
||||||
PhysicsScene.PE.SetGravity(PhysBody, ComputeGravity());
|
|
||||||
|
|
||||||
// Collision filter can be set only when the object is in the world
|
|
||||||
if (!PhysBody.ApplyCollisionMask(PhysicsScene))
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("{0} Failed setting object collision mask: id={1}", LogHeader, LocalID);
|
|
||||||
DetailLog("{0},BSPrim.UpdatePhysicalParameters,failedSetMaskGroup,cType={1}", LocalID, PhysBody.collisionType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -309,7 +309,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
ret = new BSAPIUnman(engineName, this);
|
ret = new BSAPIUnman(engineName, this);
|
||||||
break;
|
break;
|
||||||
case "bulletxna":
|
case "bulletxna":
|
||||||
// ret = new BSAPIXNA(engineName, this);
|
ret = new BSAPIXNA(engineName, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,newBody,body={1}", body.ID, body);
|
if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,newBody,body={1}", body.ID, body);
|
||||||
PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.ReferenceBody", delegate()
|
PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.ReferenceBody", delegate()
|
||||||
{
|
{
|
||||||
if (!PhysicsScene.PE.IsInWorld(body))
|
if (!PhysicsScene.PE.IsInWorld(PhysicsScene.World, body))
|
||||||
{
|
{
|
||||||
PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, body);
|
PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, body);
|
||||||
if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body);
|
if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body);
|
||||||
|
@ -166,7 +166,7 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
// If the caller needs to know the old body is going away, pass the event up.
|
// If the caller needs to know the old body is going away, pass the event up.
|
||||||
if (bodyCallback != null) bodyCallback(body);
|
if (bodyCallback != null) bodyCallback(body);
|
||||||
|
|
||||||
if (PhysicsScene.PE.IsInWorld(body))
|
if (PhysicsScene.PE.IsInWorld(PhysicsScene.World, body))
|
||||||
{
|
{
|
||||||
PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body);
|
PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body);
|
||||||
if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body);
|
if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body);
|
||||||
|
|
Loading…
Reference in New Issue