public override BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms,
int maxCollisions, ref CollisionDesc[] collisionArray,
int maxUpdates, ref EntityProperties[] updateArray
)
{
// Pin down the memory that will be used to pass object collisions and updates back from unmanaged code
m_paramsHandle = GCHandle.Alloc(parms, GCHandleType.Pinned);
m_collisionArrayPinnedHandle = GCHandle.Alloc(collisionArray, GCHandleType.Pinned);
m_updateArrayPinnedHandle = GCHandle.Alloc(updateArray, GCHandleType.Pinned);
// If Debug logging level, enable logging from the unmanaged code
m_DebugLogCallbackHandle = null;
if (MainConsole.Instance.IsDebugEnabled)
{
MainConsole.Instance.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code",
BSScene.LogHeader);
//if (PhysicsScene.PhysicsLogging.Enabled)
// The handle is saved in a variable to make sure it doesn't get freed after this call
// m_DebugLogCallbackHandle = new BSAPICPP.DebugLogCallback(BulletLoggerPhysLog);
//else
m_DebugLogCallbackHandle = new BSAPICPP.DebugLogCallback(BulletLogger);
}
// Get the version of the DLL
// TODO: this doesn't work yet. Something wrong with marshaling the returned string.
// BulletEngineVersion = BulletSimAPI.GetVersion2();
BulletEngineVersion = "2.82";
// Call the unmanaged code with the buffers and other information
return new BulletWorldUnman(0, PhysicsScene,
BSAPICPP.Initialize2(maxPosition, m_paramsHandle.AddrOfPinnedObject(),
maxCollisions, m_collisionArrayPinnedHandle.AddrOfPinnedObject(),
maxUpdates, m_updateArrayPinnedHandle.AddrOfPinnedObject(),
m_DebugLogCallbackHandle));
}