diff options
author | onefang | 2019-09-11 16:36:50 +1000 |
---|---|---|
committer | onefang | 2019-09-11 16:36:50 +1000 |
commit | 50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch) | |
tree | 52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Region/PhysicsModules/BulletS/Tests | |
parent | Renamed branch to SledjChisl. (diff) | |
parent | Bump to release flavour, build 0. (diff) | |
download | opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2 opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz |
Merge branch 'SledjChisl'
Diffstat (limited to '')
4 files changed, 184 insertions, 60 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTests.cs b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTests.cs index 0be1f4c..14d0bdc 100644 --- a/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTests.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTests.cs | |||
@@ -1,56 +1,56 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Linq; | 30 | using System.Linq; |
31 | using System.Text; | 31 | using System.Text; |
32 | 32 | ||
33 | using NUnit.Framework; | 33 | using NUnit.Framework; |
34 | using log4net; | 34 | using log4net; |
35 | 35 | ||
36 | using OpenSim.Tests.Common; | 36 | using OpenSim.Tests.Common; |
37 | 37 | ||
38 | namespace OpenSim.Region.PhysicsModule.BulletS.Tests | 38 | namespace OpenSim.Region.PhysicsModule.BulletS.Tests |
39 | { | 39 | { |
40 | [TestFixture] | 40 | [TestFixture] |
41 | public class BulletSimTests : OpenSimTestCase | 41 | public class BulletSimTests : OpenSimTestCase |
42 | { | 42 | { |
43 | // Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1 | 43 | // Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1 |
44 | // Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1 | 44 | // Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1 |
45 | 45 | ||
46 | [TestFixtureSetUp] | 46 | [TestFixtureSetUp] |
47 | public void Init() | 47 | public void Init() |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | [TestFixtureTearDown] | 51 | [TestFixtureTearDown] |
52 | public void TearDown() | 52 | public void TearDown() |
53 | { | 53 | { |
54 | } | 54 | } |
55 | } | 55 | } |
56 | } | 56 | } |
diff --git a/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs index 4eeea4d..3e8c1cd 100644 --- a/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs | |||
@@ -34,7 +34,7 @@ using Nini.Config; | |||
34 | 34 | ||
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.PhysicsModules.SharedBase; | 36 | using OpenSim.Region.PhysicsModules.SharedBase; |
37 | using OpenSim.Region.PhysicsModules.Meshing; | 37 | using OpenSim.Region.PhysicsModule.Meshing; |
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
39 | 39 | ||
40 | using OpenMetaverse; | 40 | using OpenMetaverse; |
@@ -80,13 +80,13 @@ public static class BulletSimTestsUtil | |||
80 | } | 80 | } |
81 | 81 | ||
82 | Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); | 82 | Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); |
83 | 83 | ||
84 | RegionInfo info = new RegionInfo(); | 84 | RegionInfo info = new RegionInfo(); |
85 | info.RegionName = "BSTestRegion"; | 85 | info.RegionName = "BSTestRegion"; |
86 | info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize; | 86 | info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize; |
87 | OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info); | 87 | OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info); |
88 | 88 | ||
89 | IMesher mesher = new OpenSim.Region.PhysicsModules.Meshing.Meshmerizer(); | 89 | IMesher mesher = new OpenSim.Region.PhysicsModule.Meshing.Meshmerizer(); |
90 | INonSharedRegionModule mod = mesher as INonSharedRegionModule; | 90 | INonSharedRegionModule mod = mesher as INonSharedRegionModule; |
91 | mod.Initialise(openSimINI); | 91 | mod.Initialise(openSimINI); |
92 | mod.AddRegion(scene); | 92 | mod.AddRegion(scene); |
diff --git a/OpenSim/Region/PhysicsModules/BulletS/Tests/HullCreation.cs b/OpenSim/Region/PhysicsModules/BulletS/Tests/HullCreation.cs index c0cf19a..c2be568 100644 --- a/OpenSim/Region/PhysicsModules/BulletS/Tests/HullCreation.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/Tests/HullCreation.cs | |||
@@ -146,7 +146,7 @@ public class HullCreation : OpenSimTestCase | |||
146 | uint torusLocalID = 125; | 146 | uint torusLocalID = 125; |
147 | PhysicsScene.AddPrimShape("testTorus", pbs, pos, size, rot, isPhys, torusLocalID); | 147 | PhysicsScene.AddPrimShape("testTorus", pbs, pos, size, rot, isPhys, torusLocalID); |
148 | BSPrim primTypeTorus = (BSPrim)PhysicsScene.PhysObjects[torusLocalID]; | 148 | BSPrim primTypeTorus = (BSPrim)PhysicsScene.PhysObjects[torusLocalID]; |
149 | 149 | ||
150 | // The actual prim shape creation happens at taint time | 150 | // The actual prim shape creation happens at taint time |
151 | PhysicsScene.ProcessTaints(); | 151 | PhysicsScene.ProcessTaints(); |
152 | 152 | ||
diff --git a/OpenSim/Region/PhysicsModules/BulletS/Tests/Raycast.cs b/OpenSim/Region/PhysicsModules/BulletS/Tests/Raycast.cs new file mode 100644 index 0000000..a6f587e --- /dev/null +++ b/OpenSim/Region/PhysicsModules/BulletS/Tests/Raycast.cs | |||
@@ -0,0 +1,124 @@ | |||
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 System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Text; | ||
32 | |||
33 | using NUnit.Framework; | ||
34 | using log4net; | ||
35 | |||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.PhysicsModule.BulletS; | ||
38 | using OpenSim.Region.PhysicsModules.SharedBase; | ||
39 | using OpenSim.Tests.Common; | ||
40 | |||
41 | using OpenMetaverse; | ||
42 | |||
43 | namespace OpenSim.Region.PhysicsModule.BulletS.Tests | ||
44 | { | ||
45 | [TestFixture] | ||
46 | public class BulletSimRaycast : OpenSimTestCase | ||
47 | { | ||
48 | // Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1 | ||
49 | // Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1 | ||
50 | |||
51 | BSScene _physicsScene { get; set; } | ||
52 | BSPrim _targetSphere { get; set; } | ||
53 | Vector3 _targetSpherePosition { get; set; } | ||
54 | // float _simulationTimeStep = 0.089f; | ||
55 | |||
56 | uint _targetLocalID = 123; | ||
57 | |||
58 | [TestFixtureSetUp] | ||
59 | public void Init() | ||
60 | { | ||
61 | Dictionary<string, string> engineParams = new Dictionary<string, string>(); | ||
62 | engineParams.Add("UseBulletRaycast", "true"); | ||
63 | _physicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams); | ||
64 | |||
65 | PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateSphere(); | ||
66 | Vector3 pos = new Vector3(100.0f, 100.0f, 50f); | ||
67 | _targetSpherePosition = pos; | ||
68 | Vector3 size = new Vector3(10f, 10f, 10f); | ||
69 | pbs.Scale = size; | ||
70 | Quaternion rot = Quaternion.Identity; | ||
71 | bool isPhys = false; | ||
72 | |||
73 | _physicsScene.AddPrimShape("TargetSphere", pbs, pos, size, rot, isPhys, _targetLocalID); | ||
74 | _targetSphere = (BSPrim)_physicsScene.PhysObjects[_targetLocalID]; | ||
75 | // The actual prim shape creation happens at taint time | ||
76 | _physicsScene.ProcessTaints(); | ||
77 | |||
78 | } | ||
79 | |||
80 | [TestFixtureTearDown] | ||
81 | public void TearDown() | ||
82 | { | ||
83 | if (_physicsScene != null) | ||
84 | { | ||
85 | // The Dispose() will also free any physical objects in the scene | ||
86 | _physicsScene.Dispose(); | ||
87 | _physicsScene = null; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | // There is a 10x10x10 sphere at <100,100,50> | ||
92 | // Shoot rays around the sphere and verify it hits and doesn't hit | ||
93 | // TestCase parameters are <x,y,z> of start and <x,y,z> of end and expected result | ||
94 | [TestCase(100f, 50f, 50f, 100f, 150f, 50f, true, "Pass through sphere from front")] | ||
95 | [TestCase(50f, 100f, 50f, 150f, 100f, 50f, true, "Pass through sphere from side")] | ||
96 | [TestCase(50f, 50f, 50f, 150f, 150f, 50f, true, "Pass through sphere diaginally")] | ||
97 | [TestCase(100f, 100f, 100f, 100f, 100f, 20f, true, "Pass through sphere from above")] | ||
98 | [TestCase(20f, 20f, 50f, 80f, 80f, 50f, false, "Not reach sphere")] | ||
99 | [TestCase(50f, 50f, 65f, 150f, 150f, 65f, false, "Passed over sphere")] | ||
100 | public void RaycastAroundObject(float fromX, float fromY, float fromZ, float toX, float toY, float toZ, bool expected, string msg) { | ||
101 | Vector3 fromPos = new Vector3(fromX, fromY, fromZ); | ||
102 | Vector3 toPos = new Vector3(toX, toY, toZ); | ||
103 | Vector3 direction = toPos - fromPos; | ||
104 | float len = Vector3.Distance(fromPos, toPos); | ||
105 | |||
106 | List<ContactResult> results = _physicsScene.RaycastWorld(fromPos, direction, len, 1); | ||
107 | |||
108 | if (expected) { | ||
109 | // The test coordinates should generate a hit | ||
110 | Assert.True(results.Count != 0, msg + ": Did not return a hit but expected to."); | ||
111 | Assert.True(results.Count == 1, msg + ": Raycast returned not just one hit result."); | ||
112 | Assert.True(results[0].ConsumerID == _targetLocalID, msg + ": Raycast returned a collision object other than the target"); | ||
113 | } | ||
114 | else | ||
115 | { | ||
116 | // The test coordinates should not generate a hit | ||
117 | if (results.Count > 0) | ||
118 | { | ||
119 | Assert.False(results.Count > 0, msg + ": Returned a hit at " + results[0].Pos.ToString()); | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | } \ No newline at end of file | ||