Physics refactoring: all unit tests pass.

0.8.2-post-fixes
Diva Canto 2015-08-31 15:04:10 -07:00
parent 11194209df
commit 50e7e38f45
7 changed files with 55 additions and 22 deletions

View File

@ -93,7 +93,9 @@ namespace OpenSim.Region.PhysicsModule.BasicPhysics
scene.RegisterModuleInterface<PhysicsScene>(this); scene.RegisterModuleInterface<PhysicsScene>(this);
m_regionExtent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ); m_regionExtent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
base.Initialise(scene.PhysicsRequestAsset, scene.Heightmap.GetFloatsSerialised(), (float)scene.RegionInfo.RegionSettings.WaterHeight); base.Initialise(scene.PhysicsRequestAsset,
(scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[Constants.RegionSize * Constants.RegionSize]),
(float)scene.RegionInfo.RegionSettings.WaterHeight);
} }

View File

@ -250,7 +250,9 @@ namespace OpenSim.Region.PhysicsModule.BulletS
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);
Initialise(m_Config, extent); Initialise(m_Config, extent);
base.Initialise(scene.PhysicsRequestAsset, scene.Heightmap.GetFloatsSerialised(), (float)scene.RegionInfo.RegionSettings.WaterHeight); base.Initialise(scene.PhysicsRequestAsset,
(scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[Constants.RegionSize * Constants.RegionSize]),
(float)scene.RegionInfo.RegionSettings.WaterHeight);
} }

View File

@ -81,8 +81,6 @@ public static class BulletSimTestsUtil
Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
//PhysicsScene pScene = physicsPluginManager.GetPhysicsScene(
// "BulletSim", "Meshmerizer", openSimINI, "BSTestRegion", regionExtent);
RegionInfo info = new RegionInfo(); RegionInfo info = new RegionInfo();
info.RegionName = "BSTestRegion"; info.RegionName = "BSTestRegion";
info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize; info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize;

View File

@ -106,7 +106,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
} }
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ODEPhysicsScene")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ODEPhysicsScene")]
public class OdeScene : PhysicsScene public class OdeScene : PhysicsScene, INonSharedRegionModule
{ {
private readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString()); private readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString());
private bool m_Enabled = false; private bool m_Enabled = false;
@ -585,7 +585,9 @@ namespace OpenSim.Region.PhysicsModule.ODE
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);
Initialise(); Initialise();
InitialiseFromConfig(m_config); InitialiseFromConfig(m_config);
base.Initialise(scene.PhysicsRequestAsset, scene.Heightmap.GetFloatsSerialised(), (float)scene.RegionInfo.RegionSettings.WaterHeight); base.Initialise(scene.PhysicsRequestAsset,
(scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[Constants.RegionSize * Constants.RegionSize]),
(float)scene.RegionInfo.RegionSettings.WaterHeight);
} }

View File

@ -32,6 +32,8 @@ using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.ODE; using OpenSim.Region.PhysicsModule.ODE;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Tests.Common; using OpenSim.Tests.Common;
using log4net; using log4net;
using System.Reflection; using System.Reflection;
@ -44,15 +46,39 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
//private OpenSim.Region.PhysicsModule.ODE.OdePlugin cbt; //private OpenSim.Region.PhysicsModule.ODE.OdePlugin cbt;
private PhysicsScene ps; private PhysicsScene pScene;
private IMeshingPlugin imp; private IMeshingPlugin imp;
[SetUp] [SetUp]
public void Initialize() public void Initialize()
{ {
IConfigSource TopConfig = new IniConfigSource(); IConfigSource openSimINI = new IniConfigSource();
IConfig config = TopConfig.AddConfig("Startup"); IConfig startupConfig = openSimINI.AddConfig("Startup");
config.Set("DecodedSculptMapPath","j2kDecodeCache"); startupConfig.Set("physics", "OpenDynamicsEngine");
startupConfig.Set("DecodedSculptMapPath", "j2kDecodeCache");
Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
//PhysicsScene pScene = physicsPluginManager.GetPhysicsScene(
// "BulletSim", "Meshmerizer", openSimINI, "BSTestRegion", regionExtent);
RegionInfo info = new RegionInfo();
info.RegionName = "ODETestRegion";
info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize;
OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info);
//IMesher mesher = new OpenSim.Region.PhysicsModules.Meshing.Meshmerizer();
//INonSharedRegionModule mod = mesher as INonSharedRegionModule;
//mod.Initialise(openSimINI);
//mod.AddRegion(scene);
//mod.RegionLoaded(scene);
pScene = new OdeScene();
Console.WriteLine("HERE " + (pScene == null ? "Null" : "Not null"));
INonSharedRegionModule mod = (pScene as INonSharedRegionModule);
Console.WriteLine("HERE " + (mod == null ? "Null" : "Not null"));
mod.Initialise(openSimINI);
mod.AddRegion(scene);
mod.RegionLoaded(scene);
// Loading ODEPlugin // Loading ODEPlugin
//cbt = new OdePlugin(); //cbt = new OdePlugin();
@ -65,14 +91,14 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests
{ {
_heightmap[i] = 21f; _heightmap[i] = 21f;
} }
ps.SetTerrain(_heightmap); pScene.SetTerrain(_heightmap);
} }
[TearDown] [TearDown]
public void Terminate() public void Terminate()
{ {
ps.DeleteTerrain(); pScene.DeleteTerrain();
ps.Dispose(); pScene.Dispose();
} }
@ -83,9 +109,9 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests
Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f); Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f);
Vector3 size = new Vector3(0.5f, 0.5f, 0.5f); Vector3 size = new Vector3(0.5f, 0.5f, 0.5f);
Quaternion rot = Quaternion.Identity; Quaternion rot = Quaternion.Identity;
PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true, 0); PhysicsActor prim = pScene.AddPrimShape("CoolShape", newcube, position, size, rot, true, 0);
OdePrim oprim = (OdePrim)prim; OdePrim oprim = (OdePrim)prim;
OdeScene pscene = (OdeScene) ps; OdeScene pscene = (OdeScene)pScene;
Assert.That(oprim.m_taintadd); Assert.That(oprim.m_taintadd);
@ -93,7 +119,7 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests
for (int i = 0; i < 58; i++) for (int i = 0; i < 58; i++)
{ {
ps.Simulate(0.133f); pScene.Simulate(0.133f);
Assert.That(oprim.prim_geom != (IntPtr)0); Assert.That(oprim.prim_geom != (IntPtr)0);
@ -117,9 +143,9 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests
// Make sure we're not somewhere above the ground // Make sure we're not somewhere above the ground
Assert.That(prim.Position.Z < 21.5f); Assert.That(prim.Position.Z < 21.5f);
ps.RemovePrim(prim); pScene.RemovePrim(prim);
Assert.That(oprim.m_taintremove); Assert.That(oprim.m_taintremove);
ps.Simulate(0.133f); pScene.Simulate(0.133f);
Assert.That(oprim.Body == (IntPtr)0); Assert.That(oprim.Body == (IntPtr)0);
} }
} }

View File

@ -85,7 +85,9 @@ namespace OpenSim.Region.PhysicsModule.POS
PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName; PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName;
scene.RegisterModuleInterface<PhysicsScene>(this); scene.RegisterModuleInterface<PhysicsScene>(this);
base.Initialise(scene.PhysicsRequestAsset, scene.Heightmap.GetFloatsSerialised(), (float)scene.RegionInfo.RegionSettings.WaterHeight); base.Initialise(scene.PhysicsRequestAsset,
(scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[Constants.RegionSize * Constants.RegionSize]),
(float)scene.RegionInfo.RegionSettings.WaterHeight);
} }

View File

@ -3396,7 +3396,8 @@
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Region.PhysicsModules.SharedBase"/> <Reference name="OpenSim.Region.PhysicsModules.SharedBase"/>
<Reference name="OpenSim.Region.PhysicsModule.Ode" path="../../../../../bin/Physics/"/> <Reference name="OpenSim.Region.PhysicsModule.Ode"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Tests.Common"/> <Reference name="OpenSim.Tests.Common"/>
<Reference name="Ode.NET" path="../../../../../bin/"/> <Reference name="Ode.NET" path="../../../../../bin/"/>
<Reference name="nunit.framework" path="../../../../../bin/"/> <Reference name="nunit.framework" path="../../../../../bin/"/>
@ -3431,9 +3432,9 @@
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Tests.Common"/> <Reference name="OpenSim.Tests.Common"/>
<Reference name="OpenSim.Region.Framework"/> <Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.PhysicsModules.Meshing" path="../../../../../bin/Physics/"/> <Reference name="OpenSim.Region.PhysicsModules.Meshing"/>
<Reference name="OpenSim.Region.PhysicsModules.SharedBase"/> <Reference name="OpenSim.Region.PhysicsModules.SharedBase"/>
<Reference name="OpenSim.Region.PhysicsModule.BulletS" path="../../../../../bin/Physics/"/> <Reference name="OpenSim.Region.PhysicsModule.BulletS"/>
<Files> <Files>
<Match pattern="*.cs" recurse="false"/> <Match pattern="*.cs" recurse="false"/>