PhysObjects;
public BSShapeCollection Shapes;
@@ -99,11 +104,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// Pinned memory used to pass step information between managed and unmanaged
internal int m_maxCollisionsPerFrame;
internal CollisionDesc[] m_collisionArray;
- internal GCHandle m_collisionArrayPinnedHandle;
internal int m_maxUpdatesPerFrame;
internal EntityProperties[] m_updateArray;
- internal GCHandle m_updateArrayPinnedHandle;
public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero
public const uint GROUNDPLANE_ID = 1;
@@ -149,12 +152,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// A pointer to an instance if this structure is passed to the C++ code
// Used to pass basic configuration values to the unmanaged code.
internal ConfigurationParameters[] UnmanagedParams;
- GCHandle m_paramsHandle;
-
- // Handle to the callback used by the unmanaged code to call into the managed code.
- // Used for debug logging.
- // Need to store the handle in a persistant variable so it won't be freed.
- private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle;
// Sometimes you just have to log everything.
public Logging.LogWriter PhysicsLogging;
@@ -164,6 +161,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
private int m_physicsLoggingFileMinutes;
private bool m_physicsLoggingDoFlush;
private bool m_physicsPhysicalDumpEnabled;
+ public float PhysicsMetricDumpFrames { get; set; }
// 'true' of the vehicle code is to log lots of details
public bool VehicleLoggingEnabled { get; private set; }
public bool VehiclePhysicalLoggingEnabled { get; private set; }
@@ -187,16 +185,12 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// Allocate pinned memory to pass parameters.
UnmanagedParams = new ConfigurationParameters[1];
- m_paramsHandle = GCHandle.Alloc(UnmanagedParams, GCHandleType.Pinned);
// Set default values for physics parameters plus any overrides from the ini file
GetInitialParameterValues(config);
- // allocate more pinned memory close to the above in an attempt to get the memory all together
- m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame];
- m_collisionArrayPinnedHandle = GCHandle.Alloc(m_collisionArray, GCHandleType.Pinned);
- m_updateArray = new EntityProperties[m_maxUpdatesPerFrame];
- m_updateArrayPinnedHandle = GCHandle.Alloc(m_updateArray, GCHandleType.Pinned);
+ // Get the connection to the physics engine (could be native or one of many DLLs)
+ PE = SelectUnderlyingBulletEngine(BulletEngineName);
// Enable very detailed logging.
// By creating an empty logger when not logging, the log message invocation code
@@ -211,22 +205,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
PhysicsLogging = new Logging.LogWriter();
}
- // If Debug logging level, enable logging from the unmanaged code
- m_DebugLogCallbackHandle = null;
- if (m_log.IsDebugEnabled || PhysicsLogging.Enabled)
- {
- m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader);
- if (PhysicsLogging.Enabled)
- // The handle is saved in a variable to make sure it doesn't get freed after this call
- m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLoggerPhysLog);
- else
- m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger);
- }
-
- // Get the version of the DLL
- // TODO: this doesn't work yet. Something wrong with marshaling the returned string.
- // BulletSimVersion = BulletSimAPI.GetVersion();
- // m_log.WarnFormat("{0}: BulletSim.dll version='{1}'", LogHeader, BulletSimVersion);
+ // Allocate memory for returning of the updates and collisions from the physics engine
+ m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame];
+ m_updateArray = new EntityProperties[m_maxUpdatesPerFrame];
// The bounding box for the simulated world. The origin is 0,0,0 unless we're
// a child in a mega-region.
@@ -234,11 +215,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// area. It tracks active objects no matter where they are.
Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
- // m_log.DebugFormat("{0}: Initialize: Calling BulletSimAPI.Initialize.", LogHeader);
- World = new BulletWorld(0, this, BulletSimAPI.Initialize2(worldExtent, m_paramsHandle.AddrOfPinnedObject(),
- m_maxCollisionsPerFrame, m_collisionArrayPinnedHandle.AddrOfPinnedObject(),
- m_maxUpdatesPerFrame, m_updateArrayPinnedHandle.AddrOfPinnedObject(),
- m_DebugLogCallbackHandle));
+ World = PE.Initialize(worldExtent, Params, m_maxCollisionsPerFrame, ref m_collisionArray, m_maxUpdatesPerFrame, ref m_updateArray);
Constraints = new BSConstraintCollection(World);
@@ -268,6 +245,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
{
BSParam.SetParameterConfigurationValues(this, pConfig);
+ // There are two Bullet implementations to choose from
+ BulletEngineName = pConfig.GetString("BulletEngine", "BulletUnmanaged");
+
// Very detailed logging for physics debugging
// TODO: the boolean values can be moved to the normal parameter processing.
m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false);
@@ -309,16 +289,41 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
return ret;
}
- // Called directly from unmanaged code so don't do much
- private void BulletLogger(string msg)
+ // Select the connection to the actual Bullet implementation.
+ // The main engine selection is the engineName up to the first hypen.
+ // So "Bullet-2.80-OpenCL-Intel" specifies the 'bullet' class here and the whole name
+ // is passed to the engine to do its special selection, etc.
+ private BSAPITemplate SelectUnderlyingBulletEngine(string engineName)
{
- m_log.Debug("[BULLETS UNMANAGED]:" + msg);
- }
+ // For the moment, do a simple switch statement.
+ // Someday do fancyness with looking up the interfaces in the assembly.
+ BSAPITemplate ret = null;
- // Called directly from unmanaged code so don't do much
- private void BulletLoggerPhysLog(string msg)
- {
- DetailLog("[BULLETS UNMANAGED]:" + msg);
+ string selectionName = engineName.ToLower();
+ int hyphenIndex = engineName.IndexOf("-");
+ if (hyphenIndex > 0)
+ selectionName = engineName.ToLower().Substring(0, hyphenIndex - 1);
+
+ switch (selectionName)
+ {
+ case "bulletunmanaged":
+ ret = new BSAPIUnman(engineName, this);
+ break;
+ case "bulletxna":
+ ret = new BSAPIXNA(engineName, this);
+ break;
+ }
+
+ if (ret == null)
+ {
+ m_log.ErrorFormat("{0) COULD NOT SELECT BULLET ENGINE: '[BulletSim]PhysicsEngine' must be either 'BulletUnmanaged-*' or 'BulletXNA-*'", LogHeader);
+ }
+ else
+ {
+ m_log.WarnFormat("{0} Selected bullet engine {1} -> {2}/{3}", LogHeader, engineName, ret.BulletEngineName, ret.BulletEngineVersion);
+ }
+
+ return ret;
}
public override void Dispose()
@@ -355,7 +360,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
}
// Anything left in the unmanaged code should be cleaned out
- BulletSimAPI.Shutdown2(World.ptr);
+ PE.Shutdown(World);
// Not logging any more
PhysicsLogging.Close();
@@ -468,9 +473,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
LastTimeStep = timeStep;
int updatedEntityCount = 0;
- IntPtr updatedEntitiesPtr;
int collidersCount = 0;
- IntPtr collidersPtr;
int beforeTime = 0;
int simTime = 0;
@@ -486,6 +489,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
TriggerPreStepEvent(timeStep);
// the prestep actions might have added taints
+ numTaints += _taintOperations.Count;
ProcessTaints();
InTaintTime = false; // Only used for debugging so locking is not necessary.
@@ -493,23 +497,25 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// The following causes the unmanaged code to output ALL the values found in ALL the objects in the world.
// Only enable this in a limited test world with few objects.
if (m_physicsPhysicalDumpEnabled)
- BulletSimAPI.DumpAllInfo2(World.ptr);
+ PE.DumpAllInfo(World);
// step the physical world one interval
m_simulationStep++;
int numSubSteps = 0;
-
try
{
- if (PhysicsLogging.Enabled) beforeTime = Util.EnvironmentTickCount();
+ if (PhysicsLogging.Enabled)
+ beforeTime = Util.EnvironmentTickCount();
- numSubSteps = BulletSimAPI.PhysicsStep2(World.ptr, timeStep, m_maxSubSteps, m_fixedTimeStep,
- out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr);
+ numSubSteps = PE.PhysicsStep(World, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out collidersCount);
- if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime);
- DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}, objWColl={7}",
- DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps,
- updatedEntityCount, collidersCount, ObjectsWithCollisions.Count);
+ if (PhysicsLogging.Enabled)
+ {
+ simTime = Util.EnvironmentTickCountSubtract(beforeTime);
+ DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}, objWColl={7}",
+ DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps,
+ updatedEntityCount, collidersCount, ObjectsWithCollisions.Count);
+ }
}
catch (Exception e)
{
@@ -521,7 +527,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
collidersCount = 0;
}
- // Don't have to use the pointers passed back since we know it is the same pinned memory we passed in.
+ if ((m_simulationStep % PhysicsMetricDumpFrames) == 0)
+ PE.DumpPhysicsStatistics(World);
// Get a value for 'now' so all the collision and update routines don't have to get their own.
SimulationNowTime = Util.EnvironmentTickCount();
@@ -564,7 +571,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// Objects that are done colliding are removed from the ObjectsWithCollisions list.
// Not done above because it is inside an iteration of ObjectWithCollisions.
// This complex collision processing is required to create an empty collision
- // event call after all collisions have happened on an object. This enables
+ // event call after all real collisions have happened on an object. This enables
// the simulator to generate the 'collision end' event.
if (ObjectsWithNoMoreCollisions.Count > 0)
{
@@ -593,11 +600,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// The following causes the unmanaged code to output ALL the values found in ALL the objects in the world.
// Only enable this in a limited test world with few objects.
if (m_physicsPhysicalDumpEnabled)
- BulletSimAPI.DumpAllInfo2(World.ptr);
+ PE.DumpAllInfo(World);
// The physics engine returns the number of milliseconds it simulated this call.
// These are summed and normalized to one second and divided by 1000 to give the reported physics FPS.
- // Multiply by 55 to give a nominal frame rate of 55.
+ // Multiply by a fixed nominal frame rate to give a rate similar to the simulator (usually 55).
return (float)numSubSteps * m_fixedTimeStep * 1000f * NominalFrameRate;
}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index 4008ff61d5..a7855f0628 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -45,7 +45,7 @@ public sealed class BSShapeCollection : IDisposable
// Description of a Mesh
private struct MeshDesc
{
- public IntPtr ptr;
+ public BulletShape shape;
public int referenceCount;
public DateTime lastReferenced;
public UInt64 shapeKey;
@@ -55,7 +55,7 @@ public sealed class BSShapeCollection : IDisposable
// Meshes and hulls have the same shape hash key but we only need hulls for efficient collision calculations.
private struct HullDesc
{
- public IntPtr ptr;
+ public BulletShape shape;
public int referenceCount;
public DateTime lastReferenced;
public UInt64 shapeKey;
@@ -141,9 +141,9 @@ public sealed class BSShapeCollection : IDisposable
if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,newBody,body={1}", body.ID, body);
PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.ReferenceBody", delegate()
{
- if (!BulletSimAPI.IsInWorld2(body.ptr))
+ if (!PhysicsScene.PE.IsInWorld(PhysicsScene.World, body))
{
- BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, body.ptr);
+ PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, body);
if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body);
}
});
@@ -166,15 +166,15 @@ public sealed class BSShapeCollection : IDisposable
// If the caller needs to know the old body is going away, pass the event up.
if (bodyCallback != null) bodyCallback(body);
- if (BulletSimAPI.IsInWorld2(body.ptr))
+ if (PhysicsScene.PE.IsInWorld(PhysicsScene.World, body))
{
- BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, body.ptr);
+ PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body);
if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body);
}
// Zero any reference to the shape so it is not freed when the body is deleted.
- BulletSimAPI.SetCollisionShape2(PhysicsScene.World.ptr, body.ptr, IntPtr.Zero);
- BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, body.ptr);
+ PhysicsScene.PE.SetCollisionShape(PhysicsScene.World, body, null);
+ PhysicsScene.PE.DestroyObject(PhysicsScene.World, body);
});
}
}
@@ -202,7 +202,7 @@ public sealed class BSShapeCollection : IDisposable
else
{
// This is a new reference to a mesh
- meshDesc.ptr = shape.ptr;
+ meshDesc.shape = shape.Clone();
meshDesc.shapeKey = shape.shapeKey;
// We keep a reference to the underlying IMesh data so a hull can be built
meshDesc.referenceCount = 1;
@@ -225,7 +225,7 @@ public sealed class BSShapeCollection : IDisposable
else
{
// This is a new reference to a hull
- hullDesc.ptr = shape.ptr;
+ hullDesc.shape = shape.Clone();
hullDesc.shapeKey = shape.shapeKey;
hullDesc.referenceCount = 1;
if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceShape,newHull,key={1},cnt={2}",
@@ -259,9 +259,9 @@ public sealed class BSShapeCollection : IDisposable
{
// Native shapes are not tracked and are released immediately
if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,ptr={1},taintTime={2}",
- BSScene.DetailLogZero, shape.ptr.ToString("X"), inTaintTime);
+ BSScene.DetailLogZero, shape.AddrString, inTaintTime);
if (shapeCallback != null) shapeCallback(shape);
- BulletSimAPI.DeleteCollisionShape2(PhysicsScene.World.ptr, shape.ptr);
+ PhysicsScene.PE.DeleteCollisionShape(PhysicsScene.World, shape);
}
else
{
@@ -332,57 +332,56 @@ public sealed class BSShapeCollection : IDisposable
// Called at taint-time.
private void DereferenceCompound(BulletShape shape, ShapeDestructionCallback shapeCallback)
{
- if (!BulletSimAPI.IsCompound2(shape.ptr))
+ if (!PhysicsScene.PE.IsCompound(shape))
{
// Failed the sanity check!!
PhysicsScene.Logger.ErrorFormat("{0} Attempt to free a compound shape that is not compound!! type={1}, ptr={2}",
- LogHeader, shape.type, shape.ptr.ToString("X"));
+ LogHeader, shape.type, shape.AddrString);
if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceCompound,notACompoundShape,type={1},ptr={2}",
- BSScene.DetailLogZero, shape.type, shape.ptr.ToString("X"));
+ BSScene.DetailLogZero, shape.type, shape.AddrString);
return;
}
- int numChildren = BulletSimAPI.GetNumberOfCompoundChildren2(shape.ptr);
+ int numChildren = PhysicsScene.PE.GetNumberOfCompoundChildren(shape);
if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceCompound,shape={1},children={2}", BSScene.DetailLogZero, shape, numChildren);
for (int ii = numChildren - 1; ii >= 0; ii--)
{
- IntPtr childShape = BulletSimAPI.RemoveChildShapeFromCompoundShapeIndex2(shape.ptr, ii);
+ BulletShape childShape = PhysicsScene.PE.RemoveChildShapeFromCompoundShapeIndex(shape, ii);
DereferenceAnonCollisionShape(childShape);
}
- BulletSimAPI.DeleteCollisionShape2(PhysicsScene.World.ptr, shape.ptr);
+ PhysicsScene.PE.DeleteCollisionShape(PhysicsScene.World, shape);
}
// Sometimes we have a pointer to a collision shape but don't know what type it is.
// Figure out type and call the correct dereference routine.
// Called at taint-time.
- private void DereferenceAnonCollisionShape(IntPtr cShape)
+ private void DereferenceAnonCollisionShape(BulletShape shapeInfo)
{
MeshDesc meshDesc;
HullDesc hullDesc;
- BulletShape shapeInfo = new BulletShape(cShape);
- if (TryGetMeshByPtr(cShape, out meshDesc))
+ if (TryGetMeshByPtr(shapeInfo, out meshDesc))
{
shapeInfo.type = BSPhysicsShapeType.SHAPE_MESH;
shapeInfo.shapeKey = meshDesc.shapeKey;
}
else
{
- if (TryGetHullByPtr(cShape, out hullDesc))
+ if (TryGetHullByPtr(shapeInfo, out hullDesc))
{
shapeInfo.type = BSPhysicsShapeType.SHAPE_HULL;
shapeInfo.shapeKey = hullDesc.shapeKey;
}
else
{
- if (BulletSimAPI.IsCompound2(cShape))
+ if (PhysicsScene.PE.IsCompound(shapeInfo))
{
shapeInfo.type = BSPhysicsShapeType.SHAPE_COMPOUND;
}
else
{
- if (BulletSimAPI.IsNativeShape2(cShape))
+ if (PhysicsScene.PE.IsNativeShape(shapeInfo))
{
shapeInfo.isNativeShape = true;
shapeInfo.type = BSPhysicsShapeType.SHAPE_BOX; // (technically, type doesn't matter)
@@ -400,7 +399,7 @@ public sealed class BSShapeCollection : IDisposable
else
{
PhysicsScene.Logger.ErrorFormat("{0} Could not decypher shape type. Region={1}, addr={2}",
- LogHeader, PhysicsScene.RegionName, cShape.ToString("X"));
+ LogHeader, PhysicsScene.RegionName, shapeInfo.AddrString);
}
}
@@ -467,7 +466,7 @@ public sealed class BSShapeCollection : IDisposable
// Get the scale of any existing shape so we can see if the new shape is same native type and same size.
OMV.Vector3 scaleOfExistingShape = OMV.Vector3.Zero;
if (prim.PhysShape.HasPhysicalShape)
- scaleOfExistingShape = BulletSimAPI.GetLocalScaling2(prim.PhysShape.ptr);
+ scaleOfExistingShape = PhysicsScene.PE.GetLocalScaling(prim.PhysShape);
if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,maybeNative,force={1},primScale={2},primSize={3},primShape={4}",
prim.LocalID, forceRebuild, prim.Scale, prim.Size, prim.PhysShape.type);
@@ -570,19 +569,15 @@ public sealed class BSShapeCollection : IDisposable
if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE)
{
- // The proper scale has been calculated in the prim.
- newShape = new BulletShape(
- // Bullet's capsule total height is the passed "height + (radius * 2)" so, the base
- // capsule is radius of 0.5f (1 diameter) and height of two (1.0f + 0.5f * 2)".
- // This must be taken into account when computing the scaling of the capsule.
- BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, prim.Scale)
- , shapeType);
+
+ newShape = PhysicsScene.PE.BuildCapsuleShape(PhysicsScene.World, 1f, 1f, prim.Scale);
if (DDetail) DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale);
}
else
{
// Native shapes are scaled in Bullet so set the scaling to the size
- newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType);
+ newShape = PhysicsScene.PE.BuildNativeShape(PhysicsScene.World, nativeShapeData);
+
}
if (!newShape.HasPhysicalShape)
{
@@ -629,13 +624,14 @@ public sealed class BSShapeCollection : IDisposable
private BulletShape CreatePhysicalMesh(string objName, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod)
{
+ BulletShape newShape = new BulletShape();
IMesh meshData = null;
- IntPtr meshPtr = IntPtr.Zero;
+
MeshDesc meshDesc;
if (Meshes.TryGetValue(newMeshKey, out meshDesc))
{
// If the mesh has already been built just use it.
- meshPtr = meshDesc.ptr;
+ newShape = meshDesc.shape.Clone();
}
else
{
@@ -658,11 +654,10 @@ public sealed class BSShapeCollection : IDisposable
// m_log.DebugFormat("{0}: BSShapeCollection.CreatePhysicalMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}",
// LogHeader, prim.LocalID, newMeshKey, indices.Length, vertices.Count);
- meshPtr = BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr,
+ newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World,
indices.GetLength(0), indices, vertices.Count, verticesAsFloats);
}
}
- BulletShape newShape = new BulletShape(meshPtr, BSPhysicsShapeType.SHAPE_MESH);
newShape.shapeKey = newMeshKey;
return newShape;
@@ -700,12 +695,14 @@ public sealed class BSShapeCollection : IDisposable
private BulletShape CreatePhysicalHull(string objName, System.UInt64 newHullKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod)
{
+ BulletShape newShape = new BulletShape();
IntPtr hullPtr = IntPtr.Zero;
+
HullDesc hullDesc;
if (Hulls.TryGetValue(newHullKey, out hullDesc))
{
// If the hull shape already is created, just use it.
- hullPtr = hullDesc.ptr;
+ newShape = hullDesc.shape.Clone();
}
else
{
@@ -793,11 +790,10 @@ public sealed class BSShapeCollection : IDisposable
}
}
// create the hull data structure in Bullet
- hullPtr = BulletSimAPI.CreateHullShape2(PhysicsScene.World.ptr, hullCount, convHulls);
+ newShape = PhysicsScene.PE.CreateHullShape(PhysicsScene.World, hullCount, convHulls);
}
}
- BulletShape newShape = new BulletShape(hullPtr, BSPhysicsShapeType.SHAPE_HULL);
newShape.shapeKey = newHullKey;
return newShape;
@@ -819,12 +815,12 @@ public sealed class BSShapeCollection : IDisposable
// Don't need to do this as the shape is freed when the new root shape is created below.
// DereferenceShape(prim.PhysShape, true, shapeCallback);
- BulletShape cShape = new BulletShape(
- BulletSimAPI.CreateCompoundShape2(PhysicsScene.World.ptr, false), BSPhysicsShapeType.SHAPE_COMPOUND);
+
+ BulletShape cShape = PhysicsScene.PE.CreateCompoundShape(PhysicsScene.World, false);
// Create the shape for the root prim and add it to the compound shape. Cannot be a native shape.
CreateGeomMeshOrHull(prim, shapeCallback);
- BulletSimAPI.AddChildShapeToCompoundShape2(cShape.ptr, prim.PhysShape.ptr, OMV.Vector3.Zero, OMV.Quaternion.Identity);
+ PhysicsScene.PE.AddChildShapeToCompoundShape(cShape, prim.PhysShape, OMV.Vector3.Zero, OMV.Quaternion.Identity);
if (DDetail) DetailLog("{0},BSShapeCollection.GetReferenceToCompoundShape,addRootPrim,compShape={1},rootShape={2}",
prim.LocalID, cShape, prim.PhysShape);
@@ -932,7 +928,7 @@ public sealed class BSShapeCollection : IDisposable
// If not a solid object, body is a GhostObject. Otherwise a RigidBody.
if (!mustRebuild)
{
- CollisionObjectTypes bodyType = (CollisionObjectTypes)BulletSimAPI.GetBodyType2(prim.PhysBody.ptr);
+ CollisionObjectTypes bodyType = (CollisionObjectTypes)PhysicsScene.PE.GetBodyType(prim.PhysBody);
if (prim.IsSolid && bodyType != CollisionObjectTypes.CO_RIGID_BODY
|| !prim.IsSolid && bodyType != CollisionObjectTypes.CO_GHOST_OBJECT)
{
@@ -947,20 +943,16 @@ public sealed class BSShapeCollection : IDisposable
DereferenceBody(prim.PhysBody, true, bodyCallback);
BulletBody aBody;
- IntPtr bodyPtr = IntPtr.Zero;
if (prim.IsSolid)
{
- bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr,
- prim.LocalID, prim.RawPosition, prim.RawOrientation);
- if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X"));
+ aBody = PhysicsScene.PE.CreateBodyFromShape(sim, shape, prim.LocalID, prim.RawPosition, prim.RawOrientation);
+ if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,mesh,body={1}", prim.LocalID, aBody);
}
else
{
- bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr,
- prim.LocalID, prim.RawPosition, prim.RawOrientation);
- if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X"));
+ aBody = PhysicsScene.PE.CreateGhostFromShape(sim, shape, prim.LocalID, prim.RawPosition, prim.RawOrientation);
+ if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,ghost,body={1}", prim.LocalID, aBody);
}
- aBody = new BulletBody(prim.LocalID, bodyPtr);
ReferenceBody(aBody, true);
@@ -972,13 +964,13 @@ public sealed class BSShapeCollection : IDisposable
return ret;
}
- private bool TryGetMeshByPtr(IntPtr addr, out MeshDesc outDesc)
+ private bool TryGetMeshByPtr(BulletShape shape, out MeshDesc outDesc)
{
bool ret = false;
MeshDesc foundDesc = new MeshDesc();
foreach (MeshDesc md in Meshes.Values)
{
- if (md.ptr == addr)
+ if (md.shape.ReferenceSame(shape))
{
foundDesc = md;
ret = true;
@@ -990,13 +982,13 @@ public sealed class BSShapeCollection : IDisposable
return ret;
}
- private bool TryGetHullByPtr(IntPtr addr, out HullDesc outDesc)
+ private bool TryGetHullByPtr(BulletShape shape, out HullDesc outDesc)
{
bool ret = false;
HullDesc foundDesc = new HullDesc();
foreach (HullDesc hd in Hulls.Values)
{
- if (hd.ptr == addr)
+ if (hd.shape.ReferenceSame(shape))
{
foundDesc = hd;
ret = true;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
index c7885c6781..c75eb9bcb2 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
@@ -91,11 +91,17 @@ public abstract class BSShape
// All shapes have a static call to get a reference to the physical shape
// protected abstract static BSShape GetReference();
+ // Returns a string for debugging that uniquily identifies the memory used by this instance
+ public string AddrString
+ {
+ get { return ptr.ToString("X"); }
+ }
+
public override string ToString()
{
StringBuilder buff = new StringBuilder();
buff.Append("");
@@ -96,34 +100,36 @@ public struct BulletBody
}
}
-public struct BulletShape
+public class BulletShape
{
- public BulletShape(IntPtr xx) : this(xx, BSPhysicsShapeType.SHAPE_UNKNOWN)
+ public BulletShape()
{
- }
- 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()
+ 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 virtual string AddrString
{
- ptr = IntPtr.Zero;
+ get { return "unknown"; }
}
- public bool HasPhysicalShape { get { return ptr != IntPtr.Zero; } }
public override string ToString()
{
StringBuilder buff = new StringBuilder();
buff.Append("
+
diff --git a/share/Schemas/SceneObjectPart0.xsd b/share/Schemas/SceneObjectPart0.xsd
deleted file mode 100644
index 0da7618a73..0000000000
--- a/share/Schemas/SceneObjectPart0.xsd
+++ /dev/null
@@ -1,166 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/share/Schemas/SceneObjectPart1.xsd b/share/Schemas/SceneObjectPart1.xsd
deleted file mode 100644
index 2f380875da..0000000000
--- a/share/Schemas/SceneObjectPart1.xsd
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/share/php/generateUserFunction.php b/share/php/generateUserFunction.php
deleted file mode 100755
index a262bf5f1a..0000000000
--- a/share/php/generateUserFunction.php
+++ /dev/null
@@ -1,46 +0,0 @@
-
\ No newline at end of file