retouch ubitode module
parent
ece4088a45
commit
52fb24ade5
|
@ -169,17 +169,14 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
|
||||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UBITODEPhysicsScene")]
|
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UBITODEPhysicsScene")]
|
||||||
public class ODEScene : PhysicsScene, INonSharedRegionModule
|
public class ODEScene : PhysicsScene, INonSharedRegionModule
|
||||||
{
|
{
|
||||||
private readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString());
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
public string LogHeader = "[UbitODE]";
|
|
||||||
private bool m_Enabled = false;
|
|
||||||
|
|
||||||
// private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>();
|
private bool m_Enabled = false;
|
||||||
|
|
||||||
public bool OdeUbitLib = false;
|
public bool OdeUbitLib = false;
|
||||||
public bool m_suportCombine = false; // mega suport not tested
|
public bool m_suportCombine = false; // mega suport not tested
|
||||||
|
|
||||||
// private int threadid = 0;
|
// private int threadid = 0;
|
||||||
// private Random fluidRandomizer = new Random(Environment.TickCount);
|
|
||||||
|
|
||||||
// const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce;
|
// const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce;
|
||||||
|
|
||||||
|
@ -331,6 +328,7 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
#region INonSharedRegionModule
|
#region INonSharedRegionModule
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return "UbitODE"; }
|
get { return "UbitODE"; }
|
||||||
|
@ -350,24 +348,10 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
|
||||||
string physics = config.GetString("physics", string.Empty);
|
string physics = config.GetString("physics", string.Empty);
|
||||||
if (physics == Name)
|
if (physics == Name)
|
||||||
{
|
{
|
||||||
m_Enabled = true;
|
|
||||||
m_config = source;
|
m_config = source;
|
||||||
|
m_Enabled = true;
|
||||||
// We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether
|
|
||||||
// it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports
|
|
||||||
// will find it already loaded later on.
|
|
||||||
//
|
|
||||||
// This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be
|
|
||||||
// controlled in Ode.NET.dll.config
|
|
||||||
if (Util.IsWindows())
|
|
||||||
Util.LoadArchSpecificWindowsDll("ode.dll");
|
|
||||||
|
|
||||||
// Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
|
|
||||||
// http://opensimulator.org/mantis/view.php?id=2750).
|
|
||||||
d.InitODE();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
|
@ -379,43 +363,67 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
|
||||||
if (!m_Enabled)
|
if (!m_Enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EngineType = Name;
|
|
||||||
EngineType = Name;
|
EngineType = Name;
|
||||||
PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName;
|
PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName;
|
||||||
|
|
||||||
scene.RegisterModuleInterface<PhysicsScene>(this);
|
OdeLock = new Object();
|
||||||
|
|
||||||
|
// We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether
|
||||||
|
// it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports
|
||||||
|
// will find it already loaded later on.
|
||||||
|
//
|
||||||
|
// This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be
|
||||||
|
// controlled in Ode.NET.dll.config
|
||||||
|
if (Util.IsWindows())
|
||||||
|
Util.LoadArchSpecificWindowsDll("ode.dll");
|
||||||
|
|
||||||
|
// Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
|
||||||
|
// http://opensimulator.org/mantis/view.php?id=2750).
|
||||||
|
d.InitODE();
|
||||||
|
|
||||||
|
string ode_config = d.GetConfiguration();
|
||||||
|
if (ode_config != null && ode_config != "")
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[UbitODE] ode library configuration: {0}", ode_config);
|
||||||
|
|
||||||
|
if (ode_config.Contains("ODE_Ubit"))
|
||||||
|
{
|
||||||
|
OdeUbitLib = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
|
Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
|
||||||
|
|
||||||
|
mesher = scene.RequestModuleInterface<IMesher>();
|
||||||
|
if (mesher == null)
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[UbitODE] No mesher. module disabled");
|
||||||
|
m_Enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
scene.RegisterModuleInterface<PhysicsScene>(this);
|
||||||
|
|
||||||
Initialization(extent);
|
Initialization(extent);
|
||||||
|
|
||||||
base.Initialise(scene.PhysicsRequestAsset,
|
base.Initialise(scene.PhysicsRequestAsset,
|
||||||
(scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[scene.RegionInfo.RegionSizeX * scene.RegionInfo.RegionSizeY]),
|
(scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[scene.RegionInfo.RegionSizeX * scene.RegionInfo.RegionSizeY]),
|
||||||
(float)scene.RegionInfo.RegionSettings.WaterHeight);
|
(float)scene.RegionInfo.RegionSettings.WaterHeight);
|
||||||
|
|
||||||
|
|
||||||
|
scene.PhysicsEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveRegion(Scene scene)
|
public void RemoveRegion(Scene scene)
|
||||||
{
|
{
|
||||||
if (!m_Enabled)
|
// if (!m_Enabled)
|
||||||
return;
|
// return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegionLoaded(Scene scene)
|
public void RegionLoaded(Scene scene)
|
||||||
{
|
{
|
||||||
if (!m_Enabled)
|
// if (!m_Enabled)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
mesher = scene.RequestModuleInterface<IMesher>();
|
|
||||||
if (mesher == null)
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("{0} No mesher. module disabled", LogHeader);
|
|
||||||
m_Enabled = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
region_loaded();
|
|
||||||
scene.PhysicsEnabled = true;
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -426,16 +434,20 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void Initialization(Vector3 regionExtent)
|
private void Initialization(Vector3 regionExtent)
|
||||||
{
|
{
|
||||||
|
|
||||||
// checkThread();
|
// checkThread();
|
||||||
|
|
||||||
OdeLock = new Object();
|
|
||||||
SimulationLock = new Object();
|
SimulationLock = new Object();
|
||||||
|
|
||||||
nearCallback = near;
|
nearCallback = near;
|
||||||
|
|
||||||
m_rayCastManager = new ODERayCastRequestManager(this);
|
m_rayCastManager = new ODERayCastRequestManager(this);
|
||||||
|
|
||||||
|
WorldExtents.X = regionExtent.X;
|
||||||
|
m_regionWidth = (uint)regionExtent.X;
|
||||||
|
WorldExtents.Y = regionExtent.Y;
|
||||||
|
m_regionHeight = (uint)regionExtent.Y;
|
||||||
|
|
||||||
|
m_suportCombine = false;
|
||||||
|
|
||||||
lock (OdeLock)
|
lock (OdeLock)
|
||||||
{
|
{
|
||||||
// Create the world and the first space
|
// Create the world and the first space
|
||||||
|
@ -506,27 +518,9 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
|
||||||
d.WorldSetAutoDisableFlag(world, false);
|
d.WorldSetAutoDisableFlag(world, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldExtents.X = regionExtent.X;
|
|
||||||
m_regionWidth = (uint)regionExtent.X;
|
|
||||||
WorldExtents.Y = regionExtent.Y;
|
|
||||||
m_regionHeight = (uint)regionExtent.Y;
|
|
||||||
|
|
||||||
m_suportCombine = false;
|
|
||||||
// checkThread();
|
// checkThread();
|
||||||
}
|
|
||||||
|
|
||||||
private void region_loaded()
|
|
||||||
{
|
|
||||||
string ode_config = d.GetConfiguration();
|
|
||||||
if (ode_config != null && ode_config != "")
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("ODE configuration: {0}", ode_config);
|
|
||||||
|
|
||||||
if (ode_config.Contains("ODE_Ubit"))
|
|
||||||
{
|
|
||||||
OdeUbitLib = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
|
|
||||||
|
@ -567,7 +561,6 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
d.WorldSetCFM(world, comumContactCFM);
|
d.WorldSetCFM(world, comumContactCFM);
|
||||||
d.WorldSetERP(world, comumContactERP);
|
d.WorldSetERP(world, comumContactERP);
|
||||||
|
|
||||||
|
@ -2500,7 +2493,6 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void DeleteTerrain()
|
public override void DeleteTerrain()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -2514,66 +2506,7 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
|
||||||
{
|
{
|
||||||
return m_suportCombine;
|
return m_suportCombine;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public override void UnCombine(PhysicsScene pScene)
|
|
||||||
{
|
|
||||||
IntPtr localGround = IntPtr.Zero;
|
|
||||||
// float[] localHeightfield;
|
|
||||||
bool proceed = false;
|
|
||||||
List<IntPtr> geomDestroyList = new List<IntPtr>();
|
|
||||||
|
|
||||||
lock (OdeLock)
|
|
||||||
{
|
|
||||||
if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround))
|
|
||||||
{
|
|
||||||
foreach (IntPtr geom in TerrainHeightFieldHeights.Keys)
|
|
||||||
{
|
|
||||||
if (geom == localGround)
|
|
||||||
{
|
|
||||||
// localHeightfield = TerrainHeightFieldHeights[geom];
|
|
||||||
proceed = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
geomDestroyList.Add(geom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (proceed)
|
|
||||||
{
|
|
||||||
m_worldOffset = Vector3.Zero;
|
|
||||||
WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
|
|
||||||
m_parentScene = null;
|
|
||||||
|
|
||||||
foreach (IntPtr g in geomDestroyList)
|
|
||||||
{
|
|
||||||
// removingHeightField needs to be done or the garbage collector will
|
|
||||||
// collect the terrain data before we tell ODE to destroy it causing
|
|
||||||
// memory corruption
|
|
||||||
if (TerrainHeightFieldHeights.ContainsKey(g))
|
|
||||||
{
|
|
||||||
// float[] removingHeightField = TerrainHeightFieldHeights[g];
|
|
||||||
TerrainHeightFieldHeights.Remove(g);
|
|
||||||
|
|
||||||
if (RegionTerrain.ContainsKey(g))
|
|
||||||
{
|
|
||||||
RegionTerrain.Remove(g);
|
|
||||||
}
|
|
||||||
|
|
||||||
d.GeomDestroy(g);
|
|
||||||
//removingHeightField = new float[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public override void SetWaterLevel(float baseheight)
|
public override void SetWaterLevel(float baseheight)
|
||||||
{
|
{
|
||||||
waterlevel = baseheight;
|
waterlevel = baseheight;
|
||||||
|
|
Loading…
Reference in New Issue