aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml1
-rw-r--r--OpenSim/Region/Framework/Scenes/Border.cs131
-rw-r--r--OpenSim/Region/Framework/Scenes/Cardinals.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs312
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs10
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs6
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs2
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs108
9 files changed, 532 insertions, 54 deletions
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index 8e85559..e38c755 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -10,6 +10,7 @@
10 <Extension path = "/OpenSim/RegionModules"> 10 <Extension path = "/OpenSim/RegionModules">
11 <RegionModule id="CapabilitiesModule" type="OpenSim.Region.CoreModules.Agent.Capabilities.CapabilitiesModule" /> 11 <RegionModule id="CapabilitiesModule" type="OpenSim.Region.CoreModules.Agent.Capabilities.CapabilitiesModule" />
12 <RegionModule id="TerrainModule" type="OpenSim.Region.CoreModules.World.Terrain.TerrainModule" /> 12 <RegionModule id="TerrainModule" type="OpenSim.Region.CoreModules.World.Terrain.TerrainModule" />
13 <RegionModule id="PhysicsCombiner" type="OpenSim.Region.CoreModules.World.Land.PhysicsCombiner" />
13 <RegionModule id="WorldMapModule" type="OpenSim.Region.CoreModules.World.WorldMap.WorldMapModule" /> 14 <RegionModule id="WorldMapModule" type="OpenSim.Region.CoreModules.World.WorldMap.WorldMapModule" />
14 <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" /> 15 <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" />
15 <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" /> 16 <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" />
diff --git a/OpenSim/Region/Framework/Scenes/Border.cs b/OpenSim/Region/Framework/Scenes/Border.cs
new file mode 100644
index 0000000..19ecb4f
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Border.cs
@@ -0,0 +1,131 @@
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
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenMetaverse;
32
33namespace OpenSim.Region.Framework.Scenes
34{
35 public class Border
36 {
37
38 /// <summary>
39 /// Line perpendicular to the Direction Cardinal. Z value is the
40 /// </summary>
41 public Vector3 BorderLine = Vector3.Zero;
42
43 /// <summary>
44 /// Direction cardinal of the border, think, 'which side of the region this is'. EX South border: Cardinal.S
45 /// </summary>
46 public Cardinals CrossDirection = Cardinals.N;
47 public uint TriggerRegionX = 0;
48 public uint TriggerRegionY = 0;
49
50 public Border()
51 {
52 }
53
54 /// <summary>
55 /// Creates a Border. The line is perpendicular to the direction cardinal.
56 /// IE: if the direction cardinal is South, the line is West->East
57 /// </summary>
58 /// <param name="lineStart">The starting point for the line of the border.
59 /// The position of an object must be greater then this for this border to trigger.
60 /// Perpendicular to the direction cardinal</param>
61 /// <param name="lineEnd">The ending point for the line of the border.
62 /// The position of an object must be less then this for this border to trigger.
63 /// Perpendicular to the direction cardinal</param>
64 /// <param name="triggerCoordinate">The position that triggers border the border
65 /// cross parallel to the direction cardinal. On the North cardinal, this
66 /// normally 256. On the South cardinal, it's normally 0. Any position past this
67 /// point on the cartesian coordinate will trigger the border cross as long as it
68 /// falls within the line start and the line end.</param>
69 /// <param name="triggerRegionX">When this border triggers, teleport to this regionX
70 /// in the grid</param>
71 /// <param name="triggerRegionY">When this border triggers, teleport to this regionY
72 /// in the grid</param>
73 /// <param name="direction">Cardinal for border direction. Think, 'which side of the
74 /// region is this'</param>
75 public Border(float lineStart, float lineEnd, float triggerCoordinate, uint triggerRegionX,
76 uint triggerRegionY, Cardinals direction)
77 {
78 BorderLine = new Vector3(lineStart,lineEnd,triggerCoordinate);
79 CrossDirection = direction;
80 TriggerRegionX = triggerRegionX;
81 TriggerRegionY = triggerRegionY;
82 }
83
84 public bool TestCross(Vector3 position)
85 {
86 bool result = false;
87 switch (CrossDirection)
88 {
89 case Cardinals.N: // x+0, y+1
90 if (position.X >= BorderLine.X && position.X <=BorderLine.Y && position.Y > BorderLine.Z )
91 {
92 return true;
93 }
94 break;
95 case Cardinals.NE: // x+1, y+1
96 break;
97 case Cardinals.E: // x+1, y+0
98 if (position.Y >= BorderLine.X && position.Y <= BorderLine.Y && position.X > BorderLine.Z)
99 {
100 return true;
101 }
102 break;
103 case Cardinals.SE: // x+1, y-1
104 break;
105 case Cardinals.S: // x+0, y-1
106 if (position.X >= BorderLine.X && position.X <= BorderLine.Y && position.Y < BorderLine.Z)
107 {
108 return true;
109 }
110 break;
111 case Cardinals.SW: // x-1, y-1
112 break;
113 case Cardinals.W: // x-1, y+0
114 if (position.Y >= BorderLine.X && position.Y <= BorderLine.Y && position.X < BorderLine.Z)
115 {
116 return true;
117 }
118 break;
119 case Cardinals.NW: // x-1, y+1
120 break;
121
122
123 }
124
125 return result;
126 }
127
128 }
129
130
131}
diff --git a/OpenSim/Region/Framework/Scenes/Cardinals.cs b/OpenSim/Region/Framework/Scenes/Cardinals.cs
new file mode 100644
index 0000000..692389a
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Cardinals.cs
@@ -0,0 +1,11 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Region.Framework.Scenes
6{
7 public enum Cardinals
8 {
9 N = 1, NE, E, SE, S, SW, W, NW
10 }
11}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index ff97183..5281c4f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -222,10 +222,7 @@ namespace OpenSim.Region.Framework.Scenes
222 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG 222 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
223 } 223 }
224 224
225 protected enum Cardinals 225
226 {
227 N=1,NE,E,SE,S,SW,W,NW
228 }
229 /// <summary> 226 /// <summary>
230 /// Position at which a significant movement was made 227 /// Position at which a significant movement was made
231 /// </summary> 228 /// </summary>
diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
new file mode 100644
index 0000000..6f77062
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
@@ -0,0 +1,312 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenMetaverse;
5using OpenSim.Region.Framework.Scenes;
6
7using NUnit.Framework;
8
9namespace OpenSim.Region.Framework.Tests
10{
11 [TestFixture]
12 public class BorderTests
13 {
14
15 [Test]
16 public void TestCross()
17 {
18 List<Border> testborders = new List<Border>();
19
20 Border NorthBorder = new Border();
21 NorthBorder.BorderLine = new Vector3(0, 256, 256); //<---
22 NorthBorder.CrossDirection = Cardinals.N;
23 testborders.Add(NorthBorder);
24
25 Border SouthBorder = new Border();
26 SouthBorder.BorderLine = new Vector3(0, 256, 0); //--->
27 SouthBorder.CrossDirection = Cardinals.S;
28 testborders.Add(SouthBorder);
29
30 Border EastBorder = new Border();
31 EastBorder.BorderLine = new Vector3(0, 256, 256); //<---
32 EastBorder.CrossDirection = Cardinals.E;
33 testborders.Add(EastBorder);
34
35 Border WestBorder = new Border();
36 WestBorder.BorderLine = new Vector3(0, 256, 0); //--->
37 WestBorder.CrossDirection = Cardinals.W;
38 testborders.Add(WestBorder);
39
40 Vector3 position = new Vector3(200,200,21);
41
42 foreach (Border b in testborders)
43 {
44 Assert.That(!b.TestCross(position));
45
46 }
47
48 position = new Vector3(200,280,21);
49 Assert.That(NorthBorder.TestCross(position));
50
51
52
53 // Test automatic border crossing
54 // by setting the border crossing aabb to be the whole region
55 position = new Vector3(25,25,21); // safely within one 256m region
56
57 // The Z value of the BorderLine is reversed, making all positions within the region
58 // trigger bordercross
59
60 SouthBorder.BorderLine = new Vector3(0,256,256); // automatic border cross in the region
61 Assert.That(SouthBorder.TestCross(position));
62
63 NorthBorder.BorderLine = new Vector3(0, 256, 0); // automatic border cross in the region
64 Assert.That(NorthBorder.TestCross(position));
65
66 EastBorder.BorderLine = new Vector3(0, 256, 0); // automatic border cross in the region
67 Assert.That(EastBorder.TestCross(position));
68
69 WestBorder.BorderLine = new Vector3(0, 256, 255); // automatic border cross in the region
70 Assert.That(WestBorder.TestCross(position));
71
72 }
73
74 [Test]
75 public void TestCrossSquare512()
76 {
77 List<Border> testborders = new List<Border>();
78
79 Border NorthBorder = new Border();
80 NorthBorder.BorderLine = new Vector3(0, 512, 512);
81 NorthBorder.CrossDirection = Cardinals.N;
82 testborders.Add(NorthBorder);
83
84 Border SouthBorder = new Border();
85 SouthBorder.BorderLine = new Vector3(0, 512, 0);
86 SouthBorder.CrossDirection = Cardinals.S;
87 testborders.Add(SouthBorder);
88
89 Border EastBorder = new Border();
90 EastBorder.BorderLine = new Vector3(0, 512, 512);
91 EastBorder.CrossDirection = Cardinals.E;
92 testborders.Add(EastBorder);
93
94 Border WestBorder = new Border();
95 WestBorder.BorderLine = new Vector3(0, 512, 0);
96 WestBorder.CrossDirection = Cardinals.W;
97 testborders.Add(WestBorder);
98
99 Vector3 position = new Vector3(450,220,21);
100
101 foreach (Border b in testborders)
102 {
103 Assert.That(!b.TestCross(position));
104
105 }
106
107 //Trigger east border
108 position = new Vector3(513,220,21);
109 foreach (Border b in testborders)
110 {
111 if (b.CrossDirection == Cardinals.E)
112 Assert.That(b.TestCross(position));
113 else
114 Assert.That(!b.TestCross(position));
115
116 }
117
118 //Trigger west border
119 position = new Vector3(-1, 220, 21);
120 foreach (Border b in testborders)
121 {
122 if (b.CrossDirection == Cardinals.W)
123 Assert.That(b.TestCross(position));
124 else
125 Assert.That(!b.TestCross(position));
126
127 }
128
129 //Trigger north border
130 position = new Vector3(220, 513, 21);
131 foreach (Border b in testborders)
132 {
133 if (b.CrossDirection == Cardinals.N)
134 Assert.That(b.TestCross(position));
135 else
136 Assert.That(!b.TestCross(position));
137
138 }
139
140 //Trigger south border
141 position = new Vector3(220, -1, 21);
142 foreach (Border b in testborders)
143 {
144 if (b.CrossDirection == Cardinals.S)
145 Assert.That(b.TestCross(position));
146 else
147 Assert.That(!b.TestCross(position));
148
149 }
150
151 }
152
153 [Test]
154 public void TestCrossRectangle512x256()
155 {
156 List<Border> testborders = new List<Border>();
157
158 Border NorthBorder = new Border();
159 NorthBorder.BorderLine = new Vector3(0, 512, 256);
160 NorthBorder.CrossDirection = Cardinals.N;
161 testborders.Add(NorthBorder);
162
163 Border SouthBorder = new Border();
164 SouthBorder.BorderLine = new Vector3(0, 512, 0);
165 SouthBorder.CrossDirection = Cardinals.S;
166 testborders.Add(SouthBorder);
167
168 Border EastBorder = new Border();
169 EastBorder.BorderLine = new Vector3(0, 256, 512);
170 EastBorder.CrossDirection = Cardinals.E;
171 testborders.Add(EastBorder);
172
173 Border WestBorder = new Border();
174 WestBorder.BorderLine = new Vector3(0, 256, 0);
175 WestBorder.CrossDirection = Cardinals.W;
176 testborders.Add(WestBorder);
177
178 Vector3 position = new Vector3(450, 220, 21);
179
180 foreach (Border b in testborders)
181 {
182 Assert.That(!b.TestCross(position));
183
184 }
185
186 //Trigger east border
187 position = new Vector3(513, 220, 21);
188 foreach (Border b in testborders)
189 {
190 if (b.CrossDirection == Cardinals.E)
191 Assert.That(b.TestCross(position));
192 else
193 Assert.That(!b.TestCross(position));
194
195 }
196
197 //Trigger west border
198 position = new Vector3(-1, 220, 21);
199 foreach (Border b in testborders)
200 {
201 if (b.CrossDirection == Cardinals.W)
202 Assert.That(b.TestCross(position));
203 else
204 Assert.That(!b.TestCross(position));
205
206 }
207
208 //Trigger north border
209 position = new Vector3(220, 257, 21);
210 foreach (Border b in testborders)
211 {
212 if (b.CrossDirection == Cardinals.N)
213 Assert.That(b.TestCross(position));
214 else
215 Assert.That(!b.TestCross(position));
216
217 }
218
219 //Trigger south border
220 position = new Vector3(220, -1, 21);
221 foreach (Border b in testborders)
222 {
223 if (b.CrossDirection == Cardinals.S)
224 Assert.That(b.TestCross(position));
225 else
226 Assert.That(!b.TestCross(position));
227
228 }
229 }
230
231 [Test]
232 public void TestCrossOdd512x512w256hole()
233 {
234 List<Border> testborders = new List<Border>();
235 // 512____
236 // | |
237 // 256__| |___
238 // | |
239 // |______|
240 // 0 | 512
241 // 256
242
243 // Compound North border since the hole is at the top
244 Border NorthBorder1 = new Border();
245 NorthBorder1.BorderLine = new Vector3(0, 256, 512);
246 NorthBorder1.CrossDirection = Cardinals.N;
247 testborders.Add(NorthBorder1);
248
249 Border NorthBorder2 = new Border();
250 NorthBorder2.BorderLine = new Vector3(256, 512, 256);
251 NorthBorder2.CrossDirection = Cardinals.N;
252 testborders.Add(NorthBorder2);
253
254 Border SouthBorder = new Border();
255 SouthBorder.BorderLine = new Vector3(0, 512, 0);
256 SouthBorder.CrossDirection = Cardinals.S;
257 testborders.Add(SouthBorder);
258
259 //Compound East border
260 Border EastBorder1 = new Border();
261 EastBorder1.BorderLine = new Vector3(0, 256, 512);
262 EastBorder1.CrossDirection = Cardinals.E;
263 testborders.Add(EastBorder1);
264
265 Border EastBorder2 = new Border();
266 EastBorder2.BorderLine = new Vector3(257, 512, 256);
267 EastBorder2.CrossDirection = Cardinals.E;
268 testborders.Add(EastBorder2);
269
270
271
272 Border WestBorder = new Border();
273 WestBorder.BorderLine = new Vector3(0, 512, 0);
274 WestBorder.CrossDirection = Cardinals.W;
275 testborders.Add(WestBorder);
276
277 Vector3 position = new Vector3(450, 220, 21);
278
279 foreach (Border b in testborders)
280 {
281 Assert.That(!b.TestCross(position));
282
283 }
284
285 position = new Vector3(220, 450, 21);
286
287 foreach (Border b in testborders)
288 {
289 Assert.That(!b.TestCross(position));
290
291 }
292
293 bool result = false;
294 int bordersTriggered = 0;
295
296 position = new Vector3(450, 450, 21);
297
298 foreach (Border b in testborders)
299 {
300 if (b.TestCross(position))
301 {
302 bordersTriggered++;
303 result = true;
304 }
305 }
306
307 Assert.That(result);
308 Assert.That(bordersTriggered == 2);
309
310 }
311 }
312}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index 6937a25..5c46344 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -162,6 +162,16 @@ namespace OpenSim.Region.Physics.Manager
162 return false; 162 return false;
163 } 163 }
164 164
165 public virtual bool SupportsCombining()
166 {
167 return false;
168 }
169
170 public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
171 {
172 return;
173 }
174
165 /// <summary> 175 /// <summary>
166 /// Queue a raycast against the physics scene. 176 /// Queue a raycast against the physics scene.
167 /// The provided callback method will be called when the raycast is complete 177 /// The provided callback method will be called when the raycast is complete
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 759692f..35433c6 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -161,7 +161,7 @@ namespace OpenSim.Region.Physics.OdePlugin
161 } 161 }
162 else 162 else
163 { 163 {
164 _position = new PhysicsVector(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), parent_scene.GetTerrainHeightAtXY(128, 128) + 10); 164 _position = new PhysicsVector(((int)_parent_scene.WorldExtents.X * 0.5f), ((int)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128, 128) + 10);
165 m_taintPosition.X = _position.X; 165 m_taintPosition.X = _position.X;
166 m_taintPosition.Y = _position.Y; 166 m_taintPosition.Y = _position.Y;
167 m_taintPosition.Z = _position.Z; 167 m_taintPosition.Z = _position.Z;
@@ -1096,8 +1096,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1096 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 1096 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
1097 if (vec.X < 0.0f) vec.X = 0.0f; 1097 if (vec.X < 0.0f) vec.X = 0.0f;
1098 if (vec.Y < 0.0f) vec.Y = 0.0f; 1098 if (vec.Y < 0.0f) vec.Y = 0.0f;
1099 if (vec.X > (int)Constants.RegionSize - 0.05f) vec.X = (int)Constants.RegionSize - 0.05f; 1099 if (vec.X > (int)_parent_scene.WorldExtents.X - 0.05f) vec.X = (int)_parent_scene.WorldExtents.X - 0.05f;
1100 if (vec.Y > (int)Constants.RegionSize - 0.05f) vec.Y = (int)Constants.RegionSize - 0.05f; 1100 if (vec.Y > (int)_parent_scene.WorldExtents.Y - 0.05f) vec.Y = (int)_parent_scene.WorldExtents.Y - 0.05f;
1101 1101
1102 _position.X = vec.X; 1102 _position.X = vec.X;
1103 _position.Y = vec.Y; 1103 _position.Y = vec.Y;
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 443788c..d0f77e6 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -2538,7 +2538,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2538 l_orientation.Z = ori.Z; 2538 l_orientation.Z = ori.Z;
2539 l_orientation.W = ori.W; 2539 l_orientation.W = ori.W;
2540 2540
2541 if (l_position.X > ((int)Constants.RegionSize - 0.05f) || l_position.X < 0f || l_position.Y > ((int)Constants.RegionSize - 0.05f) || l_position.Y < 0f) 2541 if (l_position.X > ((int)_parent_scene.WorldExtents.X - 0.05f) || l_position.X < 0f || l_position.Y > ((int)_parent_scene.WorldExtents.Y - 0.05f) || l_position.Y < 0f)
2542 { 2542 {
2543 //base.RaiseOutOfBounds(l_position); 2543 //base.RaiseOutOfBounds(l_position);
2544 2544
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index b7030f1..f97b49b 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -311,6 +311,9 @@ namespace OpenSim.Region.Physics.OdePlugin
311 311
312 private volatile int m_global_contactcount = 0; 312 private volatile int m_global_contactcount = 0;
313 313
314 private Vector3 m_worldOffset = Vector3.Zero;
315 public Vector2 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
316
314 private ODERayCastRequestManager m_rayCastManager; 317 private ODERayCastRequestManager m_rayCastManager;
315 318
316 /// <summary> 319 /// <summary>
@@ -348,10 +351,10 @@ namespace OpenSim.Region.Physics.OdePlugin
348 } 351 }
349 352
350 // zero out a heightmap array float array (single dimension [flattened])) 353 // zero out a heightmap array float array (single dimension [flattened]))
351 if ((int)Constants.RegionSize == 256) 354 if ((int)WorldExtents.X == 256 && (int)m_worldOffset.Y == 256)
352 _heightmap = new float[514*514]; 355 _heightmap = new float[514*514];
353 else 356 else
354 _heightmap = new float[(((int)Constants.RegionSize + 2) * ((int)Constants.RegionSize + 2))]; 357 _heightmap = new float[(((int)WorldExtents.Y + 2) * ((int)WorldExtents.X + 2))];
355 _watermap = new float[258 * 258]; 358 _watermap = new float[258 * 258];
356 359
357 // Zero out the prim spaces array (we split our space into smaller spaces so 360 // Zero out the prim spaces array (we split our space into smaller spaces so
@@ -1556,7 +1559,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1556 } 1559 }
1557 1560
1558 #endregion 1561 #endregion
1559 1562
1563 public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
1564 {
1565 m_worldOffset = offset;
1566 WorldExtents = new Vector2(extents.X, extents.Y);
1567 }
1560// Recovered for use by fly height. Kitto Flora 1568// Recovered for use by fly height. Kitto Flora
1561 public float GetTerrainHeightAtXY(float x, float y) 1569 public float GetTerrainHeightAtXY(float x, float y)
1562 { 1570 {
@@ -1568,14 +1576,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1568 // Is there any reason that we don't do this in ScenePresence? 1576 // Is there any reason that we don't do this in ScenePresence?
1569 // The only physics engine that benefits from it in the physics plugin is this one 1577 // The only physics engine that benefits from it in the physics plugin is this one
1570 1578
1571 if ((int)x > Constants.RegionSize || (int)y > Constants.RegionSize || 1579 if ((int)x > WorldExtents.X || (int)y > WorldExtents.Y ||
1572 (int)x < 0.001f || (int)y < 0.001f) 1580 (int)x < 0.001f || (int)y < 0.001f)
1573 return 0; 1581 return 0;
1574 1582
1575 index = (int) ((int)y * Constants.RegionSize + (int)x); 1583 index = (int)((int)y * WorldExtents.Y + (int)x);
1576 1584
1577 if (index < _origheightmap.Length) 1585 if (index < _origheightmap.Length)
1578 return (float)_origheightmap[(int)y * Constants.RegionSize + (int)x]; 1586 return (float)_origheightmap[(int)y * (int)WorldExtents.Y + (int)x];
1579 else 1587 else
1580 return 0; 1588 return 0;
1581 } 1589 }
@@ -1646,6 +1654,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1646 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, 1654 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation,
1647 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) 1655 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
1648 { 1656 {
1657
1649 PhysicsVector pos = new PhysicsVector(position.X, position.Y, position.Z); 1658 PhysicsVector pos = new PhysicsVector(position.X, position.Y, position.Z);
1650 //pos.X = position.X; 1659 //pos.X = position.X;
1651 //pos.Y = position.Y; 1660 //pos.Y = position.Y;
@@ -2548,6 +2557,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2548 if (framecount >= int.MaxValue) 2557 if (framecount >= int.MaxValue)
2549 framecount = 0; 2558 framecount = 0;
2550 2559
2560 if (m_worldOffset != Vector3.Zero)
2561 return 0;
2562
2551 framecount++; 2563 framecount++;
2552 2564
2553 float fps = 0; 2565 float fps = 0;
@@ -3006,14 +3018,14 @@ namespace OpenSim.Region.Physics.OdePlugin
3006 public float[] ResizeTerrain512NearestNeighbour(float[] heightMap) 3018 public float[] ResizeTerrain512NearestNeighbour(float[] heightMap)
3007 { 3019 {
3008 float[] returnarr = new float[262144]; 3020 float[] returnarr = new float[262144];
3009 float[,] resultarr = new float[m_regionWidth, m_regionHeight]; 3021 float[,] resultarr = new float[(int)WorldExtents.X, (int)WorldExtents.Y];
3010 3022
3011 // Filling out the array into its multi-dimensional components 3023 // Filling out the array into its multi-dimensional components
3012 for (int y = 0; y < m_regionHeight; y++) 3024 for (int y = 0; y < WorldExtents.Y; y++)
3013 { 3025 {
3014 for (int x = 0; x < m_regionWidth; x++) 3026 for (int x = 0; x < WorldExtents.X; x++)
3015 { 3027 {
3016 resultarr[y, x] = heightMap[y * m_regionWidth + x]; 3028 resultarr[y, x] = heightMap[y * (int)WorldExtents.Y + x];
3017 } 3029 }
3018 } 3030 }
3019 3031
@@ -3077,21 +3089,21 @@ namespace OpenSim.Region.Physics.OdePlugin
3077 // on single loop. 3089 // on single loop.
3078 3090
3079 float[,] resultarr2 = new float[512, 512]; 3091 float[,] resultarr2 = new float[512, 512];
3080 for (int y = 0; y < m_regionHeight; y++) 3092 for (int y = 0; y < WorldExtents.Y; y++)
3081 { 3093 {
3082 for (int x = 0; x < m_regionWidth; x++) 3094 for (int x = 0; x < WorldExtents.X; x++)
3083 { 3095 {
3084 resultarr2[y * 2, x * 2] = resultarr[y, x]; 3096 resultarr2[y * 2, x * 2] = resultarr[y, x];
3085 3097
3086 if (y < m_regionHeight) 3098 if (y < WorldExtents.Y)
3087 { 3099 {
3088 resultarr2[(y * 2) + 1, x * 2] = resultarr[y, x]; 3100 resultarr2[(y * 2) + 1, x * 2] = resultarr[y, x];
3089 } 3101 }
3090 if (x < m_regionWidth) 3102 if (x < WorldExtents.X)
3091 { 3103 {
3092 resultarr2[y * 2, (x * 2) + 1] = resultarr[y, x]; 3104 resultarr2[y * 2, (x * 2) + 1] = resultarr[y, x];
3093 } 3105 }
3094 if (x < m_regionWidth && y < m_regionHeight) 3106 if (x < WorldExtents.X && y < WorldExtents.Y)
3095 { 3107 {
3096 resultarr2[(y * 2) + 1, (x * 2) + 1] = resultarr[y, x]; 3108 resultarr2[(y * 2) + 1, (x * 2) + 1] = resultarr[y, x];
3097 } 3109 }
@@ -3119,14 +3131,14 @@ namespace OpenSim.Region.Physics.OdePlugin
3119 public float[] ResizeTerrain512Interpolation(float[] heightMap) 3131 public float[] ResizeTerrain512Interpolation(float[] heightMap)
3120 { 3132 {
3121 float[] returnarr = new float[262144]; 3133 float[] returnarr = new float[262144];
3122 float[,] resultarr = new float[m_regionWidth,m_regionHeight]; 3134 float[,] resultarr = new float[(int)WorldExtents.X,(int)WorldExtents.Y];
3123 3135
3124 // Filling out the array into its multi-dimensional components 3136 // Filling out the array into its multi-dimensional components
3125 for (int y = 0; y < m_regionHeight; y++) 3137 for (int y = 0; y < WorldExtents.Y; y++)
3126 { 3138 {
3127 for (int x = 0; x < m_regionWidth; x++) 3139 for (int x = 0; x < WorldExtents.X; x++)
3128 { 3140 {
3129 resultarr[y, x] = heightMap[y*m_regionWidth + x]; 3141 resultarr[y, x] = heightMap[y*(int)WorldExtents.Y + x];
3130 } 3142 }
3131 } 3143 }
3132 3144
@@ -3190,17 +3202,17 @@ namespace OpenSim.Region.Physics.OdePlugin
3190 // on single loop. 3202 // on single loop.
3191 3203
3192 float[,] resultarr2 = new float[512,512]; 3204 float[,] resultarr2 = new float[512,512];
3193 for (int y = 0; y < m_regionHeight; y++) 3205 for (int y = 0; y < WorldExtents.Y; y++)
3194 { 3206 {
3195 for (int x = 0; x < m_regionWidth; x++) 3207 for (int x = 0; x < WorldExtents.X; x++)
3196 { 3208 {
3197 resultarr2[y*2, x*2] = resultarr[y, x]; 3209 resultarr2[y*2, x*2] = resultarr[y, x];
3198 3210
3199 if (y < m_regionHeight) 3211 if (y < WorldExtents.Y)
3200 { 3212 {
3201 if (y + 1 < m_regionHeight) 3213 if (y + 1 < WorldExtents.Y)
3202 { 3214 {
3203 if (x + 1 < m_regionWidth) 3215 if (x + 1 < WorldExtents.X)
3204 { 3216 {
3205 resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x] + 3217 resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x] +
3206 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); 3218 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
@@ -3215,11 +3227,11 @@ namespace OpenSim.Region.Physics.OdePlugin
3215 resultarr2[(y*2) + 1, x*2] = resultarr[y, x]; 3227 resultarr2[(y*2) + 1, x*2] = resultarr[y, x];
3216 } 3228 }
3217 } 3229 }
3218 if (x < m_regionWidth) 3230 if (x < WorldExtents.X)
3219 { 3231 {
3220 if (x + 1 < m_regionWidth) 3232 if (x + 1 < WorldExtents.X)
3221 { 3233 {
3222 if (y + 1 < m_regionHeight) 3234 if (y + 1 < WorldExtents.Y)
3223 { 3235 {
3224 resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + 3236 resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] +
3225 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); 3237 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
@@ -3234,9 +3246,9 @@ namespace OpenSim.Region.Physics.OdePlugin
3234 resultarr2[y*2, (x*2) + 1] = resultarr[y, x]; 3246 resultarr2[y*2, (x*2) + 1] = resultarr[y, x];
3235 } 3247 }
3236 } 3248 }
3237 if (x < m_regionWidth && y < m_regionHeight) 3249 if (x < WorldExtents.X && y < WorldExtents.Y)
3238 { 3250 {
3239 if ((x + 1 < m_regionWidth) && (y + 1 < m_regionHeight)) 3251 if ((x + 1 < WorldExtents.X) && (y + 1 < WorldExtents.Y))
3240 { 3252 {
3241 resultarr2[(y*2) + 1, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + 3253 resultarr2[(y*2) + 1, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] +
3242 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); 3254 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
@@ -3274,24 +3286,26 @@ namespace OpenSim.Region.Physics.OdePlugin
3274 // this._heightmap[i] = (double)heightMap[i]; 3286 // this._heightmap[i] = (double)heightMap[i];
3275 // dbm (danx0r) -- creating a buffer zone of one extra sample all around 3287 // dbm (danx0r) -- creating a buffer zone of one extra sample all around
3276 _origheightmap = heightMap; // Used for Fly height. Kitto Flora 3288 _origheightmap = heightMap; // Used for Fly height. Kitto Flora
3277 uint heightmapWidth = m_regionWidth + 1; 3289 uint heightmapWidth = (uint)WorldExtents.X + 1;
3278 uint heightmapHeight = m_regionHeight + 1; 3290 uint heightmapHeight = (uint)WorldExtents.Y + 1;
3279 3291
3280 uint heightmapWidthSamples; 3292 uint heightmapWidthSamples;
3281 3293
3282 uint heightmapHeightSamples; 3294 uint heightmapHeightSamples;
3283 if (((int)Constants.RegionSize) == 256) 3295 /*
3296 if (((int)m_worldExtents.X) == 256 && (int)m_worldExtents.Y == 256)
3284 { 3297 {
3285 heightmapWidthSamples = 2*m_regionWidth + 2; 3298 heightmapWidthSamples = 2 * (uint)m_worldExtents.X + 2;
3286 heightmapHeightSamples = 2*m_regionHeight + 2; 3299 heightmapHeightSamples = 2*(uint)m_worldExtents.Y + 2;
3287 heightmapWidth++; 3300 heightmapWidth++;
3288 heightmapHeight++; 3301 heightmapHeight++;
3289 } 3302 }
3290 else 3303 else
3291 { 3304 {
3292 heightmapWidthSamples = m_regionWidth + 1; 3305 */
3293 heightmapHeightSamples = m_regionHeight + 1; 3306 heightmapWidthSamples = (uint)WorldExtents.X + 1;
3294 } 3307 heightmapHeightSamples = (uint)WorldExtents.Y + 1;
3308 //}
3295 3309
3296 const float scale = 1.0f; 3310 const float scale = 1.0f;
3297 const float offset = 0.0f; 3311 const float offset = 0.0f;
@@ -3300,12 +3314,12 @@ namespace OpenSim.Region.Physics.OdePlugin
3300 3314
3301 3315
3302 //Double resolution 3316 //Double resolution
3303 if (((int)Constants.RegionSize) == 256) 3317 //if (((int)m_worldExtents.X) == 256 && (int)m_worldExtents.Y == 256)
3304 heightMap = ResizeTerrain512Interpolation(heightMap); 3318 // heightMap = ResizeTerrain512Interpolation(heightMap);
3305 3319
3306 int regionsize = (int)Constants.RegionSize; 3320
3307 if (regionsize == 256) 3321 //if (((int)m_worldExtents.X) == 256 && (int)m_worldExtents.Y == 256)
3308 regionsize = 512; 3322 // regionsize = 512;
3309 3323
3310 float hfmin = 2000; 3324 float hfmin = 2000;
3311 float hfmax = -2000; 3325 float hfmax = -2000;
@@ -3313,10 +3327,10 @@ namespace OpenSim.Region.Physics.OdePlugin
3313 { 3327 {
3314 for (int y = 0; y < heightmapHeightSamples; y++) 3328 for (int y = 0; y < heightmapHeightSamples; y++)
3315 { 3329 {
3316 int xx = Util.Clip(x - 1, 0, regionsize - 1); 3330 int xx = Util.Clip(x - 1, 0, (int)WorldExtents.X - 1);
3317 int yy = Util.Clip(y - 1, 0, regionsize - 1); 3331 int yy = Util.Clip(y - 1, 0, (int)WorldExtents.Y - 1);
3318 3332
3319 float val = heightMap[yy*regionsize + xx]; 3333 float val = heightMap[yy*(int)WorldExtents.Y + xx];
3320 _heightmap[x*heightmapHeightSamples + y] = val; 3334 _heightmap[x*heightmapHeightSamples + y] = val;
3321 hfmin = (val < hfmin) ? val : hfmin; 3335 hfmin = (val < hfmin) ? val : hfmin;
3322 hfmax = (val > hfmax) ? val : hfmax; 3336 hfmax = (val > hfmax) ? val : hfmax;
@@ -3357,7 +3371,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3357 3371
3358 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); 3372 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
3359 d.GeomSetRotation(LandGeom, ref R); 3373 d.GeomSetRotation(LandGeom, ref R);
3360 d.GeomSetPosition(LandGeom, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, 0); 3374 d.GeomSetPosition(LandGeom, (int)WorldExtents.X * 0.5f, (int)WorldExtents.Y * 0.5f, 0);
3361 } 3375 }
3362 } 3376 }
3363 3377
@@ -3370,6 +3384,8 @@ namespace OpenSim.Region.Physics.OdePlugin
3370 return waterlevel; 3384 return waterlevel;
3371 } 3385 }
3372 3386
3387
3388
3373 public override void SetWaterLevel(float baseheight) 3389 public override void SetWaterLevel(float baseheight)
3374 { 3390 {
3375 waterlevel = baseheight; 3391 waterlevel = baseheight;