diff options
author | Teravus Ovares | 2008-02-24 04:06:01 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-02-24 04:06:01 +0000 |
commit | 95def8c6361d46d0157c396e16acc874a6643d3b (patch) | |
tree | ad95bb09b1bba734812d4dffc22d168e1da01e87 /OpenSim/Region/Physics | |
parent | * deleted .user file (diff) | |
download | opensim-SC-95def8c6361d46d0157c396e16acc874a6643d3b.zip opensim-SC-95def8c6361d46d0157c396e16acc874a6643d3b.tar.gz opensim-SC-95def8c6361d46d0157c396e16acc874a6643d3b.tar.bz2 opensim-SC-95def8c6361d46d0157c396e16acc874a6643d3b.tar.xz |
* Adds unit test glue to the OdePlugin.
* Adds one unit test. CreateAndDropPhysicalCube.
* More unit tests will be done
* Let me know if this breaks Linux build..
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODETestClass.cs | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODETestClass.cs b/OpenSim/Region/Physics/OdePlugin/ODETestClass.cs new file mode 100644 index 0000000..05ec61d --- /dev/null +++ b/OpenSim/Region/Physics/OdePlugin/ODETestClass.cs | |||
@@ -0,0 +1,99 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Runtime.InteropServices; | ||
4 | using Axiom.Math; | ||
5 | using Ode.NET; | ||
6 | using OpenSim.Framework; | ||
7 | using OpenSim.Framework.Console; | ||
8 | using OpenSim.Region.Physics.Manager; | ||
9 | using NUnit.Framework; | ||
10 | using NUnit.Framework.SyntaxHelpers; | ||
11 | |||
12 | namespace OpenSim.Region.Physics.OdePlugin | ||
13 | { | ||
14 | [TestFixture] | ||
15 | public class ODETestClass | ||
16 | { | ||
17 | private OdePlugin cbt; | ||
18 | private PhysicsScene ps; | ||
19 | private IMeshingPlugin imp; | ||
20 | |||
21 | |||
22 | [SetUp] | ||
23 | public void Initialize() | ||
24 | { | ||
25 | // Loading ODEPlugin | ||
26 | cbt = new OdePlugin(); | ||
27 | // Loading Zero Mesher | ||
28 | imp = new ZeroMesherPlugin(); | ||
29 | // Getting Physics Scene | ||
30 | ps = cbt.GetScene(); | ||
31 | // Initializing Physics Scene. | ||
32 | ps.Initialise(imp.GetMesher()); | ||
33 | float[] _heightmap = new float[256 * 256]; | ||
34 | for (int i = 0; i<(256*256);i++) | ||
35 | { | ||
36 | _heightmap[i] = 21f; | ||
37 | } | ||
38 | ps.SetTerrain(_heightmap); | ||
39 | |||
40 | } | ||
41 | [TearDown] | ||
42 | public void Terminate() | ||
43 | { | ||
44 | ps.DeleteTerrain(); | ||
45 | ps.Dispose(); | ||
46 | |||
47 | } | ||
48 | [Test] | ||
49 | public void CreateAndDropPhysicalCube() | ||
50 | { | ||
51 | PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox(); | ||
52 | PhysicsVector position = new PhysicsVector(128, 128, 128); | ||
53 | PhysicsVector size = new PhysicsVector(0.5f, 0.5f, 0.5f); | ||
54 | Quaternion rot = new Quaternion(1, 0, 0, 0); | ||
55 | PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true); | ||
56 | OdePrim oprim = (OdePrim)prim; | ||
57 | OdeScene pscene = (OdeScene) ps; | ||
58 | |||
59 | Assert.That(oprim.m_taintadd); | ||
60 | |||
61 | prim.LocalID = 5; | ||
62 | |||
63 | |||
64 | |||
65 | for (int i = 0; i < 38; i++) | ||
66 | { | ||
67 | ps.Simulate(0.133f); | ||
68 | |||
69 | Assert.That(oprim.prim_geom != (IntPtr)0); | ||
70 | |||
71 | Assert.That(oprim.m_targetSpace != (IntPtr)0); | ||
72 | |||
73 | //Assert.That(oprim.m_targetSpace == pscene.space); | ||
74 | Console.WriteLine("TargetSpace: " + oprim.m_targetSpace + " - SceneMainSpace: " + pscene.space); | ||
75 | |||
76 | Assert.That(!oprim.m_taintadd); | ||
77 | Console.WriteLine("Prim Position (" + oprim.m_localID + "): " + prim.Position.ToString()); | ||
78 | |||
79 | // Make sure we're above the ground | ||
80 | Assert.That(prim.Position.Z > 20f); | ||
81 | Console.WriteLine("PrimCollisionScore (" + oprim.m_localID + "): " + oprim.m_collisionscore); | ||
82 | |||
83 | // Make sure we've got a Body | ||
84 | Assert.That(oprim.Body != (IntPtr)0); | ||
85 | //Console.WriteLine( | ||
86 | } | ||
87 | |||
88 | // Make sure we're not somewhere above the ground | ||
89 | Assert.That(prim.Position.Z < 21.5f); | ||
90 | |||
91 | ps.RemovePrim(prim); | ||
92 | Assert.That(oprim.m_taintremove); | ||
93 | ps.Simulate(0.133f); | ||
94 | Assert.That(oprim.Body == (IntPtr)0); | ||
95 | } | ||
96 | |||
97 | |||
98 | } | ||
99 | } | ||