diff options
author | Teravus Ovares (Dan Olivares) | 2009-08-21 13:22:49 -0400 |
---|---|---|
committer | Teravus Ovares (Dan Olivares) | 2009-08-21 13:22:49 -0400 |
commit | e1b38ff00196c61af4c78cc96bed12afee1dcaf3 (patch) | |
tree | 18d2677d387405c2cbebd6361677612cc0d55788 /OpenSim | |
parent | * Fixes Terrain issues with combined regions. (diff) | |
download | opensim-SC_OLD-e1b38ff00196c61af4c78cc96bed12afee1dcaf3.zip opensim-SC_OLD-e1b38ff00196c61af4c78cc96bed12afee1dcaf3.tar.gz opensim-SC_OLD-e1b38ff00196c61af4c78cc96bed12afee1dcaf3.tar.bz2 opensim-SC_OLD-e1b38ff00196c61af4c78cc96bed12afee1dcaf3.tar.xz |
* It turns out that Physics heightmap values were being stored in managed memory in _heightmap and using multiple heightmaps caused them all to overwrite each other and the last one was the heightmap for all of the regions. This fixes that. It also reduces the terrain resolution to half.
Diffstat (limited to 'OpenSim')
3 files changed, 96 insertions, 65 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index c917840..5c2e136 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -549,6 +549,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
549 | int x; | 549 | int x; |
550 | int y; | 550 | int y; |
551 | 551 | ||
552 | if (x_float > Constants.RegionSize || x_float <= 0 || y_float > Constants.RegionSize || y_float <= 0) | ||
553 | return null; | ||
552 | try | 554 | try |
553 | { | 555 | { |
554 | x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / 4.0)); | 556 | x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / 4.0)); |
diff --git a/OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs b/OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs index 450ec21..3a4a17b 100644 --- a/OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs +++ b/OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs | |||
@@ -23,6 +23,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
23 | public Type ReplacableInterface { get { return null; } } | 23 | public Type ReplacableInterface { get { return null; } } |
24 | 24 | ||
25 | private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>(); | 25 | private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>(); |
26 | private bool enabledYN = true; | ||
26 | public void Initialise(IConfigSource source) | 27 | public void Initialise(IConfigSource source) |
27 | { | 28 | { |
28 | 29 | ||
@@ -35,12 +36,9 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
35 | 36 | ||
36 | public void AddRegion(Scene scene) | 37 | public void AddRegion(Scene scene) |
37 | { | 38 | { |
38 | /* | 39 | if (!enabledYN) |
39 | RegionData regionData = new RegionData(); | 40 | return; |
40 | regionData.Offset = Vector3.Zero; | 41 | |
41 | regionData.RegionId = scene.RegionInfo.originRegionID; | ||
42 | regionData.RegionScene = scene; | ||
43 | */ | ||
44 | RegionConnections regionConnections = new RegionConnections(); | 42 | RegionConnections regionConnections = new RegionConnections(); |
45 | regionConnections.ConnectedRegions = new List<RegionData>(); | 43 | regionConnections.ConnectedRegions = new List<RegionData>(); |
46 | regionConnections.RegionScene = scene; | 44 | regionConnections.RegionScene = scene; |
@@ -55,12 +53,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
55 | 53 | ||
56 | foreach (RegionConnections conn in m_regions.Values) | 54 | foreach (RegionConnections conn in m_regions.Values) |
57 | { | 55 | { |
58 | 56 | #region commented | |
59 | /* | 57 | /* |
60 | // If we're one region over +x +y | 58 | // If we're one region over +x +y |
59 | //xxy | ||
61 | //xxx | 60 | //xxx |
62 | //xxx | 61 | //xxx |
63 | //xxy | ||
64 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd | 62 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd |
65 | == (regionConnections.X * (int)Constants.RegionSize)) | 63 | == (regionConnections.X * (int)Constants.RegionSize)) |
66 | && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd | 64 | && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd |
@@ -181,6 +179,38 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
181 | } | 179 | } |
182 | */ | 180 | */ |
183 | 181 | ||
182 | /* | ||
183 | // If we're one region over -x -y | ||
184 | //yxx | ||
185 | //xxx | ||
186 | //xxx | ||
187 | if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd | ||
188 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
189 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | ||
190 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
191 | { | ||
192 | Vector3 offset = Vector3.Zero; | ||
193 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
194 | ((conn.X * (int)Constants.RegionSize))); | ||
195 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
196 | ((conn.Y * (int)Constants.RegionSize))); | ||
197 | |||
198 | Vector3 extents = Vector3.Zero; | ||
199 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
200 | extents.X = conn.XEnd + conn.XEnd; | ||
201 | |||
202 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", | ||
203 | conn.RegionScene.RegionInfo.RegionName, | ||
204 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
205 | |||
206 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | ||
207 | |||
208 | connectedYN = true; | ||
209 | break; | ||
210 | } | ||
211 | */ | ||
212 | #endregion | ||
213 | |||
184 | // If we're one region over +x y | 214 | // If we're one region over +x y |
185 | //xxx | 215 | //xxx |
186 | //xxy | 216 | //xxy |
@@ -197,49 +227,37 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
197 | ((conn.Y * (int)Constants.RegionSize))); | 227 | ((conn.Y * (int)Constants.RegionSize))); |
198 | 228 | ||
199 | Vector3 extents = Vector3.Zero; | 229 | Vector3 extents = Vector3.Zero; |
200 | extents.Y = regionConnections.YEnd; | 230 | extents.Y = conn.YEnd; |
201 | extents.X = conn.XEnd + conn.XEnd; | 231 | extents.X = conn.XEnd + regionConnections.XEnd; |
232 | |||
233 | conn.UpdateExtents(extents); | ||
234 | |||
202 | 235 | ||
203 | m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", | 236 | m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", |
204 | conn.RegionScene.RegionInfo.RegionName, | 237 | conn.RegionScene.RegionInfo.RegionName, |
205 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | 238 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); |
206 | 239 | ||
207 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | 240 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); |
208 | 241 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | |
209 | connectedYN = true; | ||
210 | break; | ||
211 | } | ||
212 | |||
213 | // If we're one region over -x -y | ||
214 | //yxx | ||
215 | //xxx | ||
216 | //xxx | ||
217 | if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd | ||
218 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
219 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | ||
220 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
221 | { | ||
222 | Vector3 offset = Vector3.Zero; | ||
223 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
224 | ((conn.X * (int)Constants.RegionSize))); | ||
225 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
226 | ((conn.Y * (int)Constants.RegionSize))); | ||
227 | 242 | ||
228 | Vector3 extents = Vector3.Zero; | 243 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
229 | extents.Y = regionConnections.YEnd + conn.YEnd; | 244 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
230 | extents.X = conn.XEnd + conn.XEnd; | 245 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
231 | 246 | ||
232 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", | 247 | scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West |
233 | conn.RegionScene.RegionInfo.RegionName, | ||
234 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
235 | 248 | ||
236 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | 249 | // Reset Terrain.. since terrain normally loads first. |
250 | // | ||
251 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
252 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
237 | 253 | ||
238 | connectedYN = true; | 254 | connectedYN = true; |
239 | break; | 255 | break; |
240 | } | 256 | } |
241 | 257 | ||
242 | // If we're one region over x -y | 258 | |
259 | |||
260 | // If we're one region over x +y | ||
243 | //xyx | 261 | //xyx |
244 | //xxx | 262 | //xxx |
245 | //xxx | 263 | //xxx |
@@ -257,12 +275,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
257 | Vector3 extents = Vector3.Zero; | 275 | Vector3 extents = Vector3.Zero; |
258 | extents.Y = regionConnections.YEnd + conn.YEnd; | 276 | extents.Y = regionConnections.YEnd + conn.YEnd; |
259 | extents.X = conn.XEnd; | 277 | extents.X = conn.XEnd; |
260 | 278 | conn.UpdateExtents(extents); | |
261 | 279 | ||
262 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", | 280 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", |
263 | conn.RegionScene.RegionInfo.RegionName, | 281 | conn.RegionScene.RegionInfo.RegionName, |
264 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | 282 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); |
265 | conn.RegionScene.PhysicsScene.Combine(scene.PhysicsScene,Vector3.Zero,extents); | 283 | conn.RegionScene.PhysicsScene.Combine(null,Vector3.Zero,extents); |
266 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | 284 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); |
267 | 285 | ||
268 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | 286 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
@@ -272,14 +290,15 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
272 | scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south | 290 | scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south |
273 | 291 | ||
274 | // Reset Terrain.. since terrain normally loads first. | 292 | // Reset Terrain.. since terrain normally loads first. |
275 | conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | 293 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); |
276 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | 294 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); |
295 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
277 | 296 | ||
278 | connectedYN = true; | 297 | connectedYN = true; |
279 | break; | 298 | break; |
280 | } | 299 | } |
281 | 300 | ||
282 | // If we're one region over +x -y | 301 | // If we're one region over +x +y |
283 | //xxy | 302 | //xxy |
284 | //xxx | 303 | //xxx |
285 | //xxx | 304 | //xxx |
@@ -334,7 +353,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
334 | } | 353 | } |
335 | } | 354 | } |
336 | 355 | ||
337 | public struct RegionConnections | 356 | public class RegionConnections |
338 | { | 357 | { |
339 | public UUID RegionId; | 358 | public UUID RegionId; |
340 | public Scene RegionScene; | 359 | public Scene RegionScene; |
@@ -343,6 +362,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
343 | public int XEnd; | 362 | public int XEnd; |
344 | public int YEnd; | 363 | public int YEnd; |
345 | public List<RegionData> ConnectedRegions; | 364 | public List<RegionData> ConnectedRegions; |
365 | public void UpdateExtents(Vector3 extents) | ||
366 | { | ||
367 | XEnd = (int)extents.X; | ||
368 | YEnd = (int)extents.Y; | ||
369 | } | ||
346 | 370 | ||
347 | } | 371 | } |
348 | 372 | ||
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index de9b196..817cc22 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -227,7 +227,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
227 | 227 | ||
228 | public int bodyFramesAutoDisable = 20; | 228 | public int bodyFramesAutoDisable = 20; |
229 | 229 | ||
230 | private float[] _heightmap; | 230 | |
231 | 231 | ||
232 | private float[] _watermap; | 232 | private float[] _watermap; |
233 | private bool m_filterCollisions = true; | 233 | private bool m_filterCollisions = true; |
@@ -351,11 +351,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
351 | #endif | 351 | #endif |
352 | } | 352 | } |
353 | 353 | ||
354 | // zero out a heightmap array float array (single dimension [flattened])) | 354 | |
355 | if ((int)Constants.RegionSize == 256) | ||
356 | _heightmap = new float[514*514]; | ||
357 | else | ||
358 | _heightmap = new float[(((int)WorldExtents.Y + 2) * ((int)WorldExtents.X + 2))]; | ||
359 | _watermap = new float[258 * 258]; | 355 | _watermap = new float[258 * 258]; |
360 | 356 | ||
361 | // Zero out the prim spaces array (we split our space into smaller spaces so | 357 | // Zero out the prim spaces array (we split our space into smaller spaces so |
@@ -3334,6 +3330,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3334 | // this._heightmap[i] = (double)heightMap[i]; | 3330 | // this._heightmap[i] = (double)heightMap[i]; |
3335 | // dbm (danx0r) -- creating a buffer zone of one extra sample all around | 3331 | // dbm (danx0r) -- creating a buffer zone of one extra sample all around |
3336 | //_origheightmap = heightMap; | 3332 | //_origheightmap = heightMap; |
3333 | |||
3334 | float[] _heightmap; | ||
3335 | |||
3336 | // zero out a heightmap array float array (single dimension [flattened])) | ||
3337 | //if ((int)Constants.RegionSize == 256) | ||
3338 | // _heightmap = new float[514 * 514]; | ||
3339 | //else | ||
3340 | |||
3341 | _heightmap = new float[(((int)Constants.RegionSize + 2) * ((int)Constants.RegionSize + 2))]; | ||
3337 | 3342 | ||
3338 | uint heightmapWidth = Constants.RegionSize + 1; | 3343 | uint heightmapWidth = Constants.RegionSize + 1; |
3339 | uint heightmapHeight = Constants.RegionSize + 1; | 3344 | uint heightmapHeight = Constants.RegionSize + 1; |
@@ -3342,19 +3347,19 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3342 | 3347 | ||
3343 | uint heightmapHeightSamples; | 3348 | uint heightmapHeightSamples; |
3344 | 3349 | ||
3345 | if (((int)Constants.RegionSize) == 256) | 3350 | //if (((int)Constants.RegionSize) == 256) |
3346 | { | 3351 | //{ |
3347 | heightmapWidthSamples = 2 * (uint)Constants.RegionSize + 2; | 3352 | // heightmapWidthSamples = 2 * (uint)Constants.RegionSize + 2; |
3348 | heightmapHeightSamples = 2 * (uint)Constants.RegionSize + 2; | 3353 | // heightmapHeightSamples = 2 * (uint)Constants.RegionSize + 2; |
3349 | heightmapWidth++; | 3354 | // heightmapWidth++; |
3350 | heightmapHeight++; | 3355 | // heightmapHeight++; |
3351 | } | 3356 | //} |
3352 | else | 3357 | //else |
3353 | { | 3358 | //{ |
3354 | 3359 | ||
3355 | heightmapWidthSamples = (uint)Constants.RegionSize + 1; | 3360 | heightmapWidthSamples = (uint)Constants.RegionSize + 1; |
3356 | heightmapHeightSamples = (uint)Constants.RegionSize + 1; | 3361 | heightmapHeightSamples = (uint)Constants.RegionSize + 1; |
3357 | } | 3362 | //} |
3358 | 3363 | ||
3359 | const float scale = 1.0f; | 3364 | const float scale = 1.0f; |
3360 | const float offset = 0.0f; | 3365 | const float offset = 0.0f; |
@@ -3363,12 +3368,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3363 | 3368 | ||
3364 | int regionsize = (int) Constants.RegionSize; | 3369 | int regionsize = (int) Constants.RegionSize; |
3365 | //Double resolution | 3370 | //Double resolution |
3366 | if (((int)Constants.RegionSize) == 256) | 3371 | //if (((int)Constants.RegionSize) == 256) |
3367 | heightMap = ResizeTerrain512Interpolation(heightMap); | 3372 | // heightMap = ResizeTerrain512Interpolation(heightMap); |
3368 | 3373 | ||
3369 | 3374 | ||
3370 | if (((int)Constants.RegionSize) == 256 && (int)Constants.RegionSize == 256) | 3375 | // if (((int)Constants.RegionSize) == 256 && (int)Constants.RegionSize == 256) |
3371 | regionsize = 512; | 3376 | // regionsize = 512; |
3372 | 3377 | ||
3373 | float hfmin = 2000; | 3378 | float hfmin = 2000; |
3374 | float hfmax = -2000; | 3379 | float hfmax = -2000; |
@@ -3431,14 +3436,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3431 | 3436 | ||
3432 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | 3437 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); |
3433 | d.GeomSetRotation(GroundGeom, ref R); | 3438 | d.GeomSetRotation(GroundGeom, ref R); |
3434 | d.GeomSetPosition(GroundGeom, pOffset.X + ((int)Constants.RegionSize * 0.5f), (pOffset.Y + (int)Constants.RegionSize * 0.5f), 0); | 3439 | d.GeomSetPosition(GroundGeom, pOffset.X + ((int)Constants.RegionSize * 0.5f), pOffset.Y + ((int)Constants.RegionSize * 0.5f), 0); |
3435 | IntPtr testGround = IntPtr.Zero; | 3440 | IntPtr testGround = IntPtr.Zero; |
3436 | if (RegionTerrain.TryGetValue(pOffset, out testGround)) | 3441 | if (RegionTerrain.TryGetValue(pOffset, out testGround)) |
3437 | { | 3442 | { |
3438 | RegionTerrain.Remove(pOffset); | 3443 | RegionTerrain.Remove(pOffset); |
3439 | } | 3444 | } |
3440 | RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); | 3445 | RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); |
3441 | TerrainHeightFieldHeights.Add(GroundGeom,heightMap); | 3446 | TerrainHeightFieldHeights.Add(GroundGeom,_heightmap); |
3442 | 3447 | ||
3443 | } | 3448 | } |
3444 | } | 3449 | } |