diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs')
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs b/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs new file mode 100644 index 0000000..6dc22bd --- /dev/null +++ b/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs | |||
@@ -0,0 +1,151 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using Nini.Config; | ||
30 | using NUnit.Framework; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Region.PhysicsModules.SharedBase; | ||
34 | using OpenSim.Region.PhysicsModule.ODE; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Tests.Common; | ||
38 | using log4net; | ||
39 | using System.Reflection; | ||
40 | |||
41 | namespace OpenSim.Region.PhysicsModule.ODE.Tests | ||
42 | { | ||
43 | [TestFixture] | ||
44 | public class ODETestClass : OpenSimTestCase | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | //private OpenSim.Region.PhysicsModule.ODE.OdePlugin cbt; | ||
49 | private PhysicsScene pScene; | ||
50 | |||
51 | [SetUp] | ||
52 | public void Initialize() | ||
53 | { | ||
54 | IConfigSource openSimINI = new IniConfigSource(); | ||
55 | IConfig startupConfig = openSimINI.AddConfig("Startup"); | ||
56 | startupConfig.Set("physics", "OpenDynamicsEngine"); | ||
57 | startupConfig.Set("DecodedSculptMapPath", "j2kDecodeCache"); | ||
58 | |||
59 | Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); | ||
60 | |||
61 | //PhysicsScene pScene = physicsPluginManager.GetPhysicsScene( | ||
62 | // "BulletSim", "Meshmerizer", openSimINI, "BSTestRegion", regionExtent); | ||
63 | RegionInfo info = new RegionInfo(); | ||
64 | info.RegionName = "ODETestRegion"; | ||
65 | info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize; | ||
66 | OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info); | ||
67 | |||
68 | //IMesher mesher = new OpenSim.Region.PhysicsModules.Meshing.Meshmerizer(); | ||
69 | //INonSharedRegionModule mod = mesher as INonSharedRegionModule; | ||
70 | //mod.Initialise(openSimINI); | ||
71 | //mod.AddRegion(scene); | ||
72 | //mod.RegionLoaded(scene); | ||
73 | |||
74 | pScene = new OdeScene(); | ||
75 | Console.WriteLine("HERE " + (pScene == null ? "Null" : "Not null")); | ||
76 | INonSharedRegionModule mod = (pScene as INonSharedRegionModule); | ||
77 | Console.WriteLine("HERE " + (mod == null ? "Null" : "Not null")); | ||
78 | mod.Initialise(openSimINI); | ||
79 | mod.AddRegion(scene); | ||
80 | mod.RegionLoaded(scene); | ||
81 | |||
82 | // Loading ODEPlugin | ||
83 | //cbt = new OdePlugin(); | ||
84 | // Getting Physics Scene | ||
85 | //ps = cbt.GetScene("test"); | ||
86 | // Initializing Physics Scene. | ||
87 | //ps.Initialise(imp.GetMesher(TopConfig), null, Vector3.Zero); | ||
88 | float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize]; | ||
89 | for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++) | ||
90 | { | ||
91 | _heightmap[i] = 21f; | ||
92 | } | ||
93 | pScene.SetTerrain(_heightmap); | ||
94 | } | ||
95 | |||
96 | [TearDown] | ||
97 | public void Terminate() | ||
98 | { | ||
99 | pScene.DeleteTerrain(); | ||
100 | pScene.Dispose(); | ||
101 | |||
102 | } | ||
103 | |||
104 | [Test] | ||
105 | public void CreateAndDropPhysicalCube() | ||
106 | { | ||
107 | PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox(); | ||
108 | Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f); | ||
109 | Vector3 size = new Vector3(0.5f, 0.5f, 0.5f); | ||
110 | Quaternion rot = Quaternion.Identity; | ||
111 | PhysicsActor prim = pScene.AddPrimShape("CoolShape", newcube, position, size, rot, true, 0); | ||
112 | OdePrim oprim = (OdePrim)prim; | ||
113 | OdeScene pscene = (OdeScene)pScene; | ||
114 | |||
115 | Assert.That(oprim.m_taintadd); | ||
116 | |||
117 | prim.LocalID = 5; | ||
118 | |||
119 | for (int i = 0; i < 58; i++) | ||
120 | { | ||
121 | pScene.Simulate(0.133f); | ||
122 | |||
123 | Assert.That(oprim.prim_geom != (IntPtr)0); | ||
124 | |||
125 | Assert.That(oprim.m_targetSpace != (IntPtr)0); | ||
126 | |||
127 | //Assert.That(oprim.m_targetSpace == pscene.space); | ||
128 | m_log.Info("TargetSpace: " + oprim.m_targetSpace + " - SceneMainSpace: " + pscene.space); | ||
129 | |||
130 | Assert.That(!oprim.m_taintadd); | ||
131 | m_log.Info("Prim Position (" + oprim.LocalID + "): " + prim.Position); | ||
132 | |||
133 | // Make sure we're above the ground | ||
134 | //Assert.That(prim.Position.Z > 20f); | ||
135 | //m_log.Info("PrimCollisionScore (" + oprim.m_localID + "): " + oprim.m_collisionscore); | ||
136 | |||
137 | // Make sure we've got a Body | ||
138 | Assert.That(oprim.Body != (IntPtr)0); | ||
139 | //m_log.Info( | ||
140 | } | ||
141 | |||
142 | // Make sure we're not somewhere above the ground | ||
143 | Assert.That(prim.Position.Z < 21.5f); | ||
144 | |||
145 | pScene.RemovePrim(prim); | ||
146 | Assert.That(oprim.m_taintremove); | ||
147 | pScene.Simulate(0.133f); | ||
148 | Assert.That(oprim.Body == (IntPtr)0); | ||
149 | } | ||
150 | } | ||
151 | } | ||