mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 17:32:42 +08:00
BulletSim: subclass Bullet[World|Body|Shape|Constraint] for unmanaged
to have pointers and managed to have objects. Initial paste of XNA code. Commented out.
This commit is contained in:
@@ -33,17 +33,23 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||
{
|
||||
// Classes to allow some type checking for the API
|
||||
// These hold pointers to allocated objects in the unmanaged space.
|
||||
// These classes are subclassed by the various physical implementations of
|
||||
// objects. In particular, there is a version for physical instances in
|
||||
// unmanaged memory ("unman") and one for in managed memory ("XNA").
|
||||
|
||||
// Currently, the instances of these classes are a reference to a
|
||||
// physical representation and this has no releationship to other
|
||||
// instances. Someday, refarb the usage of these classes so each instance
|
||||
// refers to a particular physical instance and this class controls reference
|
||||
// counts and such. This should be done along with adding BSShapes.
|
||||
|
||||
// The physics engine controller class created at initialization
|
||||
public class BulletWorld
|
||||
{
|
||||
public BulletWorld(uint worldId, BSScene bss, IntPtr xx)
|
||||
public BulletWorld(uint worldId, BSScene bss)
|
||||
{
|
||||
ptr = xx;
|
||||
worldID = worldId;
|
||||
physicsScene = bss;
|
||||
}
|
||||
public IntPtr ptr;
|
||||
public uint worldID;
|
||||
// The scene is only in here so very low level routines have a handle to print debug/error messages
|
||||
public BSScene physicsScene;
|
||||
@@ -52,27 +58,19 @@ public class BulletWorld
|
||||
// An allocated Bullet btRigidBody
|
||||
public class BulletBody
|
||||
{
|
||||
public BulletBody(uint id) : this(id, IntPtr.Zero)
|
||||
{
|
||||
}
|
||||
public BulletBody(uint id, IntPtr xx)
|
||||
public BulletBody(uint id)
|
||||
{
|
||||
ID = id;
|
||||
ptr = xx;
|
||||
collisionType = CollisionType.Static;
|
||||
}
|
||||
public IntPtr ptr;
|
||||
public uint ID;
|
||||
public CollisionType collisionType;
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
ptr = IntPtr.Zero;
|
||||
}
|
||||
public bool HasPhysicalBody { get { return ptr != IntPtr.Zero; } }
|
||||
public virtual void Clear() { }
|
||||
public virtual bool HasPhysicalBody { get { return false; } }
|
||||
|
||||
// Apply the specificed collision mask into the physical world
|
||||
public bool ApplyCollisionMask(BSScene physicsScene)
|
||||
public virtual bool ApplyCollisionMask(BSScene physicsScene)
|
||||
{
|
||||
// Should assert the body has been added to the physical world.
|
||||
// (The collision masks are stored in the collision proxy cache which only exists for
|
||||
@@ -83,12 +81,9 @@ public class BulletBody
|
||||
}
|
||||
|
||||
// Used for log messages for a unique display of the memory/object allocated to this instance
|
||||
public string AddrString
|
||||
public virtual string AddrString
|
||||
{
|
||||
get
|
||||
{
|
||||
return ptr.ToString("X");
|
||||
}
|
||||
get { return "unknown"; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -108,38 +103,26 @@ public class BulletBody
|
||||
public class BulletShape
|
||||
{
|
||||
public BulletShape()
|
||||
: this(IntPtr.Zero, BSPhysicsShapeType.SHAPE_UNKNOWN)
|
||||
{
|
||||
}
|
||||
public BulletShape(IntPtr xx)
|
||||
: this(xx, BSPhysicsShapeType.SHAPE_UNKNOWN)
|
||||
{
|
||||
}
|
||||
public BulletShape(IntPtr xx, BSPhysicsShapeType typ)
|
||||
{
|
||||
ptr = xx;
|
||||
type = typ;
|
||||
type = BSPhysicsShapeType.SHAPE_UNKNOWN;
|
||||
shapeKey = (System.UInt64)FixedShapeKey.KEY_NONE;
|
||||
isNativeShape = false;
|
||||
}
|
||||
public IntPtr ptr;
|
||||
public BSPhysicsShapeType type;
|
||||
public System.UInt64 shapeKey;
|
||||
public bool isNativeShape;
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
ptr = IntPtr.Zero;
|
||||
}
|
||||
public bool HasPhysicalShape { get { return ptr != IntPtr.Zero; } }
|
||||
public virtual void Clear() { }
|
||||
public virtual bool HasPhysicalShape { get { return false; } }
|
||||
// Make another reference to this physical object.
|
||||
public virtual BulletShape Clone() { return new BulletShape(); }
|
||||
// Return 'true' if this and other refer to the same physical object
|
||||
public virtual bool ReferenceSame(BulletShape xx) { return false; }
|
||||
|
||||
// Used for log messages for a unique display of the memory/object allocated to this instance
|
||||
public string AddrString
|
||||
public virtual string AddrString
|
||||
{
|
||||
get
|
||||
{
|
||||
return ptr.ToString("X");
|
||||
}
|
||||
get { return "unknown"; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -161,25 +144,16 @@ public class BulletShape
|
||||
// An allocated Bullet btConstraint
|
||||
public class BulletConstraint
|
||||
{
|
||||
public BulletConstraint(IntPtr xx)
|
||||
public BulletConstraint()
|
||||
{
|
||||
ptr = xx;
|
||||
}
|
||||
public IntPtr ptr;
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
ptr = IntPtr.Zero;
|
||||
}
|
||||
public bool HasPhysicalConstraint { get { return ptr != IntPtr.Zero; } }
|
||||
public virtual void Clear() { }
|
||||
public virtual bool HasPhysicalConstraint { get { return false; } }
|
||||
|
||||
// Used for log messages for a unique display of the memory/object allocated to this instance
|
||||
public string AddrString
|
||||
public virtual string AddrString
|
||||
{
|
||||
get
|
||||
{
|
||||
return ptr.ToString("X");
|
||||
}
|
||||
get { return "unknown"; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user