BulletSim: remove some errors on shutdown by moving terrain destruction until after physical object destruction. TerrainManager also made disposable and that feature used.

0.7.5-pf-bulletsim
Robert Adams 2012-12-15 11:31:26 -08:00
parent ace1f1e931
commit f3b1efd889
2 changed files with 16 additions and 3 deletions

View File

@ -349,8 +349,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// make sure no stepping happens while we're deleting stuff
m_initialized = false;
TerrainManager.ReleaseGroundPlaneAndTerrain();
foreach (KeyValuePair<uint, BSPhysObject> kvp in PhysObjects)
{
kvp.Value.Destroy();
@ -370,6 +368,13 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
Shapes = null;
}
if (TerrainManager != null)
{
TerrainManager.ReleaseGroundPlaneAndTerrain();
TerrainManager.Dispose();
TerrainManager = null;
}
// Anything left in the unmanaged code should be cleaned out
BulletSimAPI.Shutdown2(World.ptr);

View File

@ -67,7 +67,7 @@ public abstract class BSTerrainPhys : IDisposable
}
// ==========================================================================================
public sealed class BSTerrainManager
public sealed class BSTerrainManager : IDisposable
{
static string LogHeader = "[BULLETSIM TERRAIN MANAGER]";
@ -122,6 +122,11 @@ public sealed class BSTerrainManager
MegaRegionParentPhysicsScene = null;
}
public void Dispose()
{
ReleaseGroundPlaneAndTerrain();
}
// Create the initial instance of terrain and the underlying ground plane.
// This is called from the initialization routine so we presume it is
// safe to call Bullet in real time. We hope no one is moving prims around yet.
@ -366,6 +371,9 @@ public sealed class BSTerrainManager
{
PhysicsScene.Logger.ErrorFormat("{0} GetTerrainHeightAtXY: terrain not found: region={1}, x={2}, y={3}",
LogHeader, PhysicsScene.RegionName, tX, tY);
DetailLog("{0},BSTerrainManager.GetTerrainHeightAtXYZ,terrainNotFound,loc={1},base={2}",
BSScene.DetailLogZero, loc, terrainBaseXYZ);
Util.PrintCallStack(); // DEBUG DEBUG DEBUG
}
}
lastHeight = ret;