diff options
author | Diva Canto | 2015-08-31 15:04:10 -0700 |
---|---|---|
committer | Diva Canto | 2015-08-31 15:04:10 -0700 |
commit | 50e7e38f450599b5755c9ab887b8d9bd9c3d8981 (patch) | |
tree | 28e578fbcb02a15a4a74814f6b56629a995690a9 /OpenSim/Region/PhysicsModules/Ode/Tests | |
parent | First commit where physics work as region module. (diff) | |
download | opensim-SC-50e7e38f450599b5755c9ab887b8d9bd9c3d8981.zip opensim-SC-50e7e38f450599b5755c9ab887b8d9bd9c3d8981.tar.gz opensim-SC-50e7e38f450599b5755c9ab887b8d9bd9c3d8981.tar.bz2 opensim-SC-50e7e38f450599b5755c9ab887b8d9bd9c3d8981.tar.xz |
Physics refactoring: all unit tests pass.
Diffstat (limited to 'OpenSim/Region/PhysicsModules/Ode/Tests')
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs b/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs index eca670c..36b65cf 100644 --- a/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs +++ b/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs | |||
@@ -32,6 +32,8 @@ using OpenMetaverse; | |||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Region.PhysicsModules.SharedBase; | 33 | using OpenSim.Region.PhysicsModules.SharedBase; |
34 | using OpenSim.Region.PhysicsModule.ODE; | 34 | using OpenSim.Region.PhysicsModule.ODE; |
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Tests.Common; | 37 | using OpenSim.Tests.Common; |
36 | using log4net; | 38 | using log4net; |
37 | using System.Reflection; | 39 | using System.Reflection; |
@@ -44,15 +46,39 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests | |||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 47 | ||
46 | //private OpenSim.Region.PhysicsModule.ODE.OdePlugin cbt; | 48 | //private OpenSim.Region.PhysicsModule.ODE.OdePlugin cbt; |
47 | private PhysicsScene ps; | 49 | private PhysicsScene pScene; |
48 | private IMeshingPlugin imp; | 50 | private IMeshingPlugin imp; |
49 | 51 | ||
50 | [SetUp] | 52 | [SetUp] |
51 | public void Initialize() | 53 | public void Initialize() |
52 | { | 54 | { |
53 | IConfigSource TopConfig = new IniConfigSource(); | 55 | IConfigSource openSimINI = new IniConfigSource(); |
54 | IConfig config = TopConfig.AddConfig("Startup"); | 56 | IConfig startupConfig = openSimINI.AddConfig("Startup"); |
55 | config.Set("DecodedSculptMapPath","j2kDecodeCache"); | 57 | startupConfig.Set("physics", "OpenDynamicsEngine"); |
58 | startupConfig.Set("DecodedSculptMapPath", "j2kDecodeCache"); | ||
59 | |||
60 | Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); | ||
61 | |||
62 | //PhysicsScene pScene = physicsPluginManager.GetPhysicsScene( | ||
63 | // "BulletSim", "Meshmerizer", openSimINI, "BSTestRegion", regionExtent); | ||
64 | RegionInfo info = new RegionInfo(); | ||
65 | info.RegionName = "ODETestRegion"; | ||
66 | info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize; | ||
67 | OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info); | ||
68 | |||
69 | //IMesher mesher = new OpenSim.Region.PhysicsModules.Meshing.Meshmerizer(); | ||
70 | //INonSharedRegionModule mod = mesher as INonSharedRegionModule; | ||
71 | //mod.Initialise(openSimINI); | ||
72 | //mod.AddRegion(scene); | ||
73 | //mod.RegionLoaded(scene); | ||
74 | |||
75 | pScene = new OdeScene(); | ||
76 | Console.WriteLine("HERE " + (pScene == null ? "Null" : "Not null")); | ||
77 | INonSharedRegionModule mod = (pScene as INonSharedRegionModule); | ||
78 | Console.WriteLine("HERE " + (mod == null ? "Null" : "Not null")); | ||
79 | mod.Initialise(openSimINI); | ||
80 | mod.AddRegion(scene); | ||
81 | mod.RegionLoaded(scene); | ||
56 | 82 | ||
57 | // Loading ODEPlugin | 83 | // Loading ODEPlugin |
58 | //cbt = new OdePlugin(); | 84 | //cbt = new OdePlugin(); |
@@ -65,14 +91,14 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests | |||
65 | { | 91 | { |
66 | _heightmap[i] = 21f; | 92 | _heightmap[i] = 21f; |
67 | } | 93 | } |
68 | ps.SetTerrain(_heightmap); | 94 | pScene.SetTerrain(_heightmap); |
69 | } | 95 | } |
70 | 96 | ||
71 | [TearDown] | 97 | [TearDown] |
72 | public void Terminate() | 98 | public void Terminate() |
73 | { | 99 | { |
74 | ps.DeleteTerrain(); | 100 | pScene.DeleteTerrain(); |
75 | ps.Dispose(); | 101 | pScene.Dispose(); |
76 | 102 | ||
77 | } | 103 | } |
78 | 104 | ||
@@ -83,9 +109,9 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests | |||
83 | Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f); | 109 | Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f); |
84 | Vector3 size = new Vector3(0.5f, 0.5f, 0.5f); | 110 | Vector3 size = new Vector3(0.5f, 0.5f, 0.5f); |
85 | Quaternion rot = Quaternion.Identity; | 111 | Quaternion rot = Quaternion.Identity; |
86 | PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true, 0); | 112 | PhysicsActor prim = pScene.AddPrimShape("CoolShape", newcube, position, size, rot, true, 0); |
87 | OdePrim oprim = (OdePrim)prim; | 113 | OdePrim oprim = (OdePrim)prim; |
88 | OdeScene pscene = (OdeScene) ps; | 114 | OdeScene pscene = (OdeScene)pScene; |
89 | 115 | ||
90 | Assert.That(oprim.m_taintadd); | 116 | Assert.That(oprim.m_taintadd); |
91 | 117 | ||
@@ -93,7 +119,7 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests | |||
93 | 119 | ||
94 | for (int i = 0; i < 58; i++) | 120 | for (int i = 0; i < 58; i++) |
95 | { | 121 | { |
96 | ps.Simulate(0.133f); | 122 | pScene.Simulate(0.133f); |
97 | 123 | ||
98 | Assert.That(oprim.prim_geom != (IntPtr)0); | 124 | Assert.That(oprim.prim_geom != (IntPtr)0); |
99 | 125 | ||
@@ -117,9 +143,9 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests | |||
117 | // Make sure we're not somewhere above the ground | 143 | // Make sure we're not somewhere above the ground |
118 | Assert.That(prim.Position.Z < 21.5f); | 144 | Assert.That(prim.Position.Z < 21.5f); |
119 | 145 | ||
120 | ps.RemovePrim(prim); | 146 | pScene.RemovePrim(prim); |
121 | Assert.That(oprim.m_taintremove); | 147 | Assert.That(oprim.m_taintremove); |
122 | ps.Simulate(0.133f); | 148 | pScene.Simulate(0.133f); |
123 | Assert.That(oprim.Body == (IntPtr)0); | 149 | Assert.That(oprim.Body == (IntPtr)0); |
124 | } | 150 | } |
125 | } | 151 | } |