clockwerk-opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 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.Physics.Manager; |
||
34 | using OpenSim.Region.Physics.OdePlugin; |
||
35 | using OpenSim.Tests.Common; |
||
36 | using log4net; |
||
37 | using System.Reflection; |
||
38 | |||
39 | namespace OpenSim.Region.Physics.OdePlugin.Tests |
||
40 | { |
||
41 | [TestFixture] |
||
42 | public class ODETestClass : OpenSimTestCase |
||
43 | { |
||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
||
45 | |||
46 | private OpenSim.Region.Physics.OdePlugin.OdePlugin cbt; |
||
47 | private PhysicsScene ps; |
||
48 | private IMeshingPlugin imp; |
||
49 | |||
50 | [SetUp] |
||
51 | public void Initialize() |
||
52 | { |
||
53 | IConfigSource TopConfig = new IniConfigSource(); |
||
54 | IConfig config = TopConfig.AddConfig("Startup"); |
||
55 | config.Set("DecodedSculptMapPath","j2kDecodeCache"); |
||
56 | |||
57 | // Loading ODEPlugin |
||
58 | cbt = new OdePlugin(); |
||
59 | // Loading Zero Mesher |
||
60 | imp = new ZeroMesherPlugin(); |
||
61 | // Getting Physics Scene |
||
62 | ps = cbt.GetScene("test"); |
||
63 | // Initializing Physics Scene. |
||
64 | ps.Initialise(imp.GetMesher(TopConfig),null); |
||
65 | float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize]; |
||
66 | for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++) |
||
67 | { |
||
68 | _heightmap[i] = 21f; |
||
69 | } |
||
70 | ps.SetTerrain(_heightmap); |
||
71 | } |
||
72 | |||
73 | [TearDown] |
||
74 | public void Terminate() |
||
75 | { |
||
76 | ps.DeleteTerrain(); |
||
77 | ps.Dispose(); |
||
78 | |||
79 | } |
||
80 | |||
81 | [Test] |
||
82 | public void CreateAndDropPhysicalCube() |
||
83 | { |
||
84 | PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox(); |
||
85 | Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f); |
||
86 | Vector3 size = new Vector3(0.5f, 0.5f, 0.5f); |
||
87 | Quaternion rot = Quaternion.Identity; |
||
88 | PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true, 0); |
||
89 | OdePrim oprim = (OdePrim)prim; |
||
90 | OdeScene pscene = (OdeScene) ps; |
||
91 | |||
92 | Assert.That(oprim.m_taintadd); |
||
93 | |||
94 | prim.LocalID = 5; |
||
95 | |||
96 | for (int i = 0; i < 58; i++) |
||
97 | { |
||
98 | ps.Simulate(0.133f); |
||
99 | |||
100 | Assert.That(oprim.prim_geom != (IntPtr)0); |
||
101 | |||
102 | Assert.That(oprim.m_targetSpace != (IntPtr)0); |
||
103 | |||
104 | //Assert.That(oprim.m_targetSpace == pscene.space); |
||
105 | m_log.Info("TargetSpace: " + oprim.m_targetSpace + " - SceneMainSpace: " + pscene.space); |
||
106 | |||
107 | Assert.That(!oprim.m_taintadd); |
||
108 | m_log.Info("Prim Position (" + oprim.LocalID + "): " + prim.Position); |
||
109 | |||
110 | // Make sure we're above the ground |
||
111 | //Assert.That(prim.Position.Z > 20f); |
||
112 | //m_log.Info("PrimCollisionScore (" + oprim.m_localID + "): " + oprim.m_collisionscore); |
||
113 | |||
114 | // Make sure we've got a Body |
||
115 | Assert.That(oprim.Body != (IntPtr)0); |
||
116 | //m_log.Info( |
||
117 | } |
||
118 | |||
119 | // Make sure we're not somewhere above the ground |
||
120 | Assert.That(prim.Position.Z < 21.5f); |
||
121 | |||
122 | ps.RemovePrim(prim); |
||
123 | Assert.That(oprim.m_taintremove); |
||
124 | ps.Simulate(0.133f); |
||
125 | Assert.That(oprim.Body == (IntPtr)0); |
||
126 | } |
||
127 | } |
||
128 | } |