aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World
diff options
context:
space:
mode:
authorUbitUmarov2016-09-03 07:51:53 +0100
committerUbitUmarov2016-09-03 07:51:53 +0100
commit9aec227767cf726216514d0494f11b5d8bf5b807 (patch)
tree8f308f4c1eefa19954fc30a560ac780f8a8e916a /OpenSim/Region/CoreModules/World
parentmerge issue (diff)
parenttests making sure evering thing is coerently wrong.. (diff)
downloadopensim-SC-9aec227767cf726216514d0494f11b5d8bf5b807.zip
opensim-SC-9aec227767cf726216514d0494f11b5d8bf5b807.tar.gz
opensim-SC-9aec227767cf726216514d0494f11b5d8bf5b807.tar.bz2
opensim-SC-9aec227767cf726216514d0494f11b5d8bf5b807.tar.xz
Merge branch 'master' into httptests
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs21
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GIF.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs12
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/PNG.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs25
-rw-r--r--OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs162
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs8
12 files changed, 130 insertions, 158 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 839072e..2d590fc 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -1193,6 +1193,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
1193 } 1193 }
1194 1194
1195 ControlFileLoaded = true; 1195 ControlFileLoaded = true;
1196 if(xtr != null)
1197 xtr.Close();
1196 1198
1197 return dearchivedScenes; 1199 return dearchivedScenes;
1198 } 1200 }
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 56d41a8..425562f 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -1229,15 +1229,24 @@ namespace OpenSim.Region.CoreModules.World.Estate
1229 } 1229 }
1230 terr.SaveToFile(Util.dataDir() + "/terrain.raw"); 1230 terr.SaveToFile(Util.dataDir() + "/terrain.raw");
1231 1231
1232 FileStream input = new FileStream(Util.dataDir() + "/terrain.raw", FileMode.Open); 1232 byte[] bdata;
1233 byte[] bdata = new byte[input.Length]; 1233 using(FileStream input = new FileStream(Util.dataDir() + "/terrain.raw",FileMode.Open))
1234 input.Read(bdata, 0, (int)input.Length); 1234 {
1235 bdata = new byte[input.Length];
1236 input.Read(bdata, 0, (int)input.Length);
1237 }
1238 if(bdata == null || bdata.Length == 0)
1239 {
1240 remote_client.SendAlertMessage("Terrain error");
1241 return;
1242 }
1243
1235 remote_client.SendAlertMessage("Terrain file written, starting download..."); 1244 remote_client.SendAlertMessage("Terrain file written, starting download...");
1236 Scene.XferManager.AddNewFile("terrain.raw", bdata); 1245 string xfername = (UUID.Random()).ToString();
1246 Scene.XferManager.AddNewFile(xfername, bdata);
1237 1247
1238 m_log.DebugFormat("[CLIENT]: Sending terrain for region {0} to {1}", Scene.Name, remote_client.Name); 1248 m_log.DebugFormat("[CLIENT]: Sending terrain for region {0} to {1}", Scene.Name, remote_client.Name);
1239 1249 remote_client.SendInitiateDownload(xfername, clientFileName);
1240 remote_client.SendInitiateDownload("terrain.raw", clientFileName);
1241 } 1250 }
1242 } 1251 }
1243 1252
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
index 5155804..1f2b7c4 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
@@ -382,7 +382,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
382 382
383 Vector3 pos = part.GetWorldPosition(); 383 Vector3 pos = part.GetWorldPosition();
384 384
385 // skip prim outside of retion 385 // skip prim outside of region
386 if (!m_scene.PositionIsInCurrentRegion(pos)) 386 if (!m_scene.PositionIsInCurrentRegion(pos))
387 continue; 387 continue;
388 388
@@ -406,12 +406,13 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
406 { 406 {
407 // Translate scale by rotation so scale is represented properly when object is rotated 407 // Translate scale by rotation so scale is represented properly when object is rotated
408 Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z); 408 Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z);
409 lscale *= 0.5f;
410
409 Vector3 scale = new Vector3(); 411 Vector3 scale = new Vector3();
410 Vector3 tScale = new Vector3(); 412 Vector3 tScale = new Vector3();
411 Vector3 axPos = new Vector3(pos.X, pos.Y, pos.Z); 413 Vector3 axPos = new Vector3(pos.X, pos.Y, pos.Z);
412 414
413 Quaternion llrot = part.GetWorldRotation(); 415 Quaternion rot = part.GetWorldRotation();
414 Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z);
415 scale = lscale * rot; 416 scale = lscale * rot;
416 417
417 // negative scales don't work in this situation 418 // negative scales don't work in this situation
@@ -470,7 +471,6 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
470 471
471 tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z); 472 tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z);
472 scale = ((tScale * rot)); 473 scale = ((tScale * rot));
473
474 vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); 474 vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
475 475
476 //vertexes[2].x = pos.X + vertexes[2].x; 476 //vertexes[2].x = pos.X + vertexes[2].x;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs
index fb57c82..ec2d085 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs
@@ -47,9 +47,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
47 /// <param name="map">The terrain channel being saved</param> 47 /// <param name="map">The terrain channel being saved</param>
48 public override void SaveFile(string filename, ITerrainChannel map) 48 public override void SaveFile(string filename, ITerrainChannel map)
49 { 49 {
50 Bitmap colours = CreateGrayscaleBitmapFromMap(map); 50 using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
51 51 colours.Save(filename,ImageFormat.Bmp);
52 colours.Save(filename, ImageFormat.Bmp);
53 } 52 }
54 53
55 /// <summary> 54 /// <summary>
@@ -59,9 +58,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
59 /// <param name="map">The terrain channel being saved</param> 58 /// <param name="map">The terrain channel being saved</param>
60 public override void SaveStream(Stream stream, ITerrainChannel map) 59 public override void SaveStream(Stream stream, ITerrainChannel map)
61 { 60 {
62 Bitmap colours = CreateGrayscaleBitmapFromMap(map); 61 using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
63 62 colours.Save(stream,ImageFormat.Bmp);
64 colours.Save(stream, ImageFormat.Png);
65 } 63 }
66 64
67 /// <summary> 65 /// <summary>
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GIF.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GIF.cs
index 79cc50b..3843708 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GIF.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GIF.cs
@@ -36,9 +36,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
36 { 36 {
37 public override void SaveFile(string filename, ITerrainChannel map) 37 public override void SaveFile(string filename, ITerrainChannel map)
38 { 38 {
39 Bitmap colours = CreateGrayscaleBitmapFromMap(map); 39 using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
40 40 colours.Save(filename,ImageFormat.Gif);
41 colours.Save(filename, ImageFormat.Gif);
42 } 41 }
43 42
44 /// <summary> 43 /// <summary>
@@ -48,9 +47,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
48 /// <param name="map">The terrain channel being saved</param> 47 /// <param name="map">The terrain channel being saved</param>
49 public override void SaveStream(Stream stream, ITerrainChannel map) 48 public override void SaveStream(Stream stream, ITerrainChannel map)
50 { 49 {
51 Bitmap colours = CreateGrayscaleBitmapFromMap(map); 50 using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
52 51 colours.Save(stream,ImageFormat.Gif);
53 colours.Save(stream, ImageFormat.Gif);
54 } 52 }
55 53
56 public override string ToString() 54 public override string ToString()
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
index e8c719a..1e67f72 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
@@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
59 /// <returns>A terrain channel generated from the image.</returns> 59 /// <returns>A terrain channel generated from the image.</returns>
60 public virtual ITerrainChannel LoadFile(string filename) 60 public virtual ITerrainChannel LoadFile(string filename)
61 { 61 {
62 using (Bitmap b = new Bitmap(filename)) 62 using(Bitmap b = new Bitmap(filename))
63 return LoadBitmap(b); 63 return LoadBitmap(b);
64 } 64 }
65 65
@@ -111,9 +111,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
111 /// <param name="map">The terrain channel being saved</param> 111 /// <param name="map">The terrain channel being saved</param>
112 public virtual void SaveFile(string filename, ITerrainChannel map) 112 public virtual void SaveFile(string filename, ITerrainChannel map)
113 { 113 {
114 Bitmap colours = CreateGrayscaleBitmapFromMap(map); 114 using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
115 115 colours.Save(filename,ImageFormat.Png);
116 colours.Save(filename, ImageFormat.Png);
117 } 116 }
118 117
119 /// <summary> 118 /// <summary>
@@ -123,9 +122,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
123 /// <param name="map">The terrain channel being saved</param> 122 /// <param name="map">The terrain channel being saved</param>
124 public virtual void SaveStream(Stream stream, ITerrainChannel map) 123 public virtual void SaveStream(Stream stream, ITerrainChannel map)
125 { 124 {
126 Bitmap colours = CreateGrayscaleBitmapFromMap(map); 125 using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
127 126 colours.Save(stream,ImageFormat.Png);
128 colours.Save(stream, ImageFormat.Png);
129 } 127 }
130 128
131 public virtual void SaveFile(ITerrainChannel m_channel, string filename, 129 public virtual void SaveFile(ITerrainChannel m_channel, string filename,
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs
index 9cc767a..36c2bbf 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs
@@ -59,9 +59,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
59 59
60 public void SaveFile(string filename, ITerrainChannel map) 60 public void SaveFile(string filename, ITerrainChannel map)
61 { 61 {
62 Bitmap colours = CreateBitmapFromMap(map); 62 using(Bitmap colours = CreateBitmapFromMap(map))
63 63 colours.Save(filename,ImageFormat.Jpeg);
64 colours.Save(filename, ImageFormat.Jpeg);
65 } 64 }
66 65
67 /// <summary> 66 /// <summary>
@@ -71,9 +70,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
71 /// <param name="map">The terrain channel being saved</param> 70 /// <param name="map">The terrain channel being saved</param>
72 public void SaveStream(Stream stream, ITerrainChannel map) 71 public void SaveStream(Stream stream, ITerrainChannel map)
73 { 72 {
74 Bitmap colours = CreateBitmapFromMap(map); 73 using(Bitmap colours = CreateBitmapFromMap(map))
75 74 colours.Save(stream,ImageFormat.Jpeg);
76 colours.Save(stream, ImageFormat.Jpeg);
77 } 75 }
78 76
79 public virtual void SaveFile(ITerrainChannel m_channel, string filename, 77 public virtual void SaveFile(ITerrainChannel m_channel, string filename,
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/PNG.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/PNG.cs
index c5c12ae..8ea8e9d 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/PNG.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/PNG.cs
@@ -36,9 +36,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
36 { 36 {
37 public override void SaveFile(string filename, ITerrainChannel map) 37 public override void SaveFile(string filename, ITerrainChannel map)
38 { 38 {
39 Bitmap colours = CreateGrayscaleBitmapFromMap(map); 39 using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
40 40 colours.Save(filename,ImageFormat.Png);
41 colours.Save(filename, ImageFormat.Png);
42 } 41 }
43 42
44 /// <summary> 43 /// <summary>
@@ -48,9 +47,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
48 /// <param name="map">The terrain channel being saved</param> 47 /// <param name="map">The terrain channel being saved</param>
49 public override void SaveStream(Stream stream, ITerrainChannel map) 48 public override void SaveStream(Stream stream, ITerrainChannel map)
50 { 49 {
51 Bitmap colours = CreateGrayscaleBitmapFromMap(map); 50 using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
52 51 colours.Save(stream,ImageFormat.Png);
53 colours.Save(stream, ImageFormat.Png);
54 } 52 }
55 53
56 public override string ToString() 54 public override string ToString()
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs
index b416b82..d103a6f 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs
@@ -36,9 +36,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
36 { 36 {
37 public override void SaveFile(string filename, ITerrainChannel map) 37 public override void SaveFile(string filename, ITerrainChannel map)
38 { 38 {
39 Bitmap colours = CreateGrayscaleBitmapFromMap(map); 39 using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
40 40 colours.Save(filename,ImageFormat.Tiff);
41 colours.Save(filename, ImageFormat.Tiff);
42 } 41 }
43 42
44 /// <summary> 43 /// <summary>
@@ -48,9 +47,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
48 /// <param name="map">The terrain channel being saved</param> 47 /// <param name="map">The terrain channel being saved</param>
49 public override void SaveStream(Stream stream, ITerrainChannel map) 48 public override void SaveStream(Stream stream, ITerrainChannel map)
50 { 49 {
51 Bitmap colours = CreateGrayscaleBitmapFromMap(map); 50 using(Bitmap colours = CreateGrayscaleBitmapFromMap(map))
52 51 colours.Save(stream,ImageFormat.Tiff);
53 colours.Save(stream, ImageFormat.Tiff);
54 } 52 }
55 53
56 public override string ToString() 54 public override string ToString()
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 275aa2a..05d18da 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -963,6 +963,27 @@ namespace OpenSim.Region.CoreModules.World.Terrain
963 return wasLimited; 963 return wasLimited;
964 } 964 }
965 965
966 private bool EnforceEstateLimits(int startX, int startY, int endX, int endY)
967 {
968 TerrainData terrData = m_channel.GetTerrainData();
969
970 bool wasLimited = false;
971 for (int x = startX; x <= endX; x += Constants.TerrainPatchSize)
972 {
973 for (int y = startX; y <= endY; y += Constants.TerrainPatchSize)
974 {
975 if (terrData.IsTaintedAt(x, y, false /* clearOnTest */))
976 {
977 // If we should respect the estate settings then
978 // fixup and height deltas that don't respect them.
979 // Note that LimitChannelChanges() modifies the TerrainChannel with the limited height values.
980 wasLimited |= LimitChannelChanges(terrData, x, y);
981 }
982 }
983 }
984 return wasLimited;
985 }
986
966 /// <summary> 987 /// <summary>
967 /// Checks to see height deltas in the tainted terrain patch at xStart ,yStart 988 /// Checks to see height deltas in the tainted terrain patch at xStart ,yStart
968 /// are all within the current estate limits 989 /// are all within the current estate limits
@@ -1341,7 +1362,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1341 1362
1342 //block changes outside estate limits 1363 //block changes outside estate limits
1343 if (!god) 1364 if (!god)
1344 EnforceEstateLimits(); 1365 EnforceEstateLimits(startX, endX, startY, endY);
1345 } 1366 }
1346 } 1367 }
1347 else 1368 else
@@ -1404,7 +1425,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1404 1425
1405 //block changes outside estate limits 1426 //block changes outside estate limits
1406 if (!god) 1427 if (!god)
1407 EnforceEstateLimits(); 1428 EnforceEstateLimits(startX, endX, startY, endY);
1408 } 1429 }
1409 } 1430 }
1410 else 1431 else
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
index 443eee1..cb37067 100644
--- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
@@ -35,7 +35,7 @@ using System.Reflection;
35using CSJ2K; 35using CSJ2K;
36using Nini.Config; 36using Nini.Config;
37using log4net; 37using log4net;
38using Rednettle.Warp3D; 38using Warp3D;
39using Mono.Addins; 39using Mono.Addins;
40 40
41using OpenSim.Framework; 41using OpenSim.Framework;
@@ -76,11 +76,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
76 private bool m_texturePrims = true; // true if should texture the rendered prims 76 private bool m_texturePrims = true; // true if should texture the rendered prims
77 private float m_texturePrimSize = 48f; // size of prim before we consider texturing it 77 private float m_texturePrimSize = 48f; // size of prim before we consider texturing it
78 private bool m_renderMeshes = false; // true if to render meshes rather than just bounding boxes 78 private bool m_renderMeshes = false; // true if to render meshes rather than just bounding boxes
79 private bool m_useAntiAliasing = false; // true if to anti-alias the rendered image
80 79
81 private bool m_Enabled = false; 80 private bool m_Enabled = false;
82 81
83 private Bitmap lastImage = null; 82// private Bitmap lastImage = null;
84 private DateTime lastImageTime = DateTime.MinValue; 83 private DateTime lastImageTime = DateTime.MinValue;
85 84
86 #region Region Module interface 85 #region Region Module interface
@@ -107,10 +106,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
107 = Util.GetConfigVarFromSections<float>(m_config, "TexturePrimSize", configSections, m_texturePrimSize); 106 = Util.GetConfigVarFromSections<float>(m_config, "TexturePrimSize", configSections, m_texturePrimSize);
108 m_renderMeshes 107 m_renderMeshes
109 = Util.GetConfigVarFromSections<bool>(m_config, "RenderMeshes", configSections, m_renderMeshes); 108 = Util.GetConfigVarFromSections<bool>(m_config, "RenderMeshes", configSections, m_renderMeshes);
110 m_useAntiAliasing 109 }
111 = Util.GetConfigVarFromSections<bool>(m_config, "UseAntiAliasing", configSections, m_useAntiAliasing);
112
113 }
114 110
115 public void AddRegion(Scene scene) 111 public void AddRegion(Scene scene)
116 { 112 {
@@ -201,21 +197,14 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
201 int width = viewport.Width; 197 int width = viewport.Width;
202 int height = viewport.Height; 198 int height = viewport.Height;
203 199
204 if (m_useAntiAliasing)
205 {
206 width *= 2;
207 height *= 2;
208 }
209
210 WarpRenderer renderer = new WarpRenderer(); 200 WarpRenderer renderer = new WarpRenderer();
211 201
212 renderer.CreateScene(width, height); 202 if(!renderer.CreateScene(width, height))
213 renderer.Scene.autoCalcNormals = false; 203 return new Bitmap(width,height);
214 204
215 #region Camera 205 #region Camera
216 206
217 warp_Vector pos = ConvertVector(viewport.Position); 207 warp_Vector pos = ConvertVector(viewport.Position);
218 pos.z -= 0.001f; // Works around an issue with the Warp3D camera
219 warp_Vector lookat = warp_Vector.add(ConvertVector(viewport.Position), ConvertVector(viewport.LookDirection)); 208 warp_Vector lookat = warp_Vector.add(ConvertVector(viewport.Position), ConvertVector(viewport.LookDirection));
220 209
221 renderer.Scene.defaultCamera.setPos(pos); 210 renderer.Scene.defaultCamera.setPos(pos);
@@ -223,9 +212,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
223 212
224 if (viewport.Orthographic) 213 if (viewport.Orthographic)
225 { 214 {
226 renderer.Scene.defaultCamera.isOrthographic = true; 215 renderer.Scene.defaultCamera.setOrthographic(true,viewport.OrthoWindowWidth, viewport.OrthoWindowHeight);
227 renderer.Scene.defaultCamera.orthoViewWidth = viewport.OrthoWindowWidth;
228 renderer.Scene.defaultCamera.orthoViewHeight = viewport.OrthoWindowHeight;
229 } 216 }
230 else 217 else
231 { 218 {
@@ -247,24 +234,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
247 renderer.Render(); 234 renderer.Render();
248 Bitmap bitmap = renderer.Scene.getImage(); 235 Bitmap bitmap = renderer.Scene.getImage();
249 236
250 if (m_useAntiAliasing) 237 renderer.Scene.destroy();
251 { 238 renderer.Reset();
252 using (Bitmap origBitmap = bitmap)
253 bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height);
254 }
255
256 // XXX: It shouldn't really be necesary to force a GC here as one should occur anyway pretty shortly
257 // afterwards. It's generally regarded as a bad idea to manually GC. If Warp3D is using lots of memory
258 // then this may be some issue with the Warp3D code itself, though it's also quite possible that generating
259 // this map tile simply takes a lot of memory.
260 foreach (var o in renderer.Scene.objectData.Values)
261 {
262 warp_Object obj = (warp_Object)o;
263 obj.vertexData = null;
264 obj.triangleData = null;
265 }
266
267 renderer.Scene.removeAllObjects();
268 renderer = null; 239 renderer = null;
269 viewport = null; 240 viewport = null;
270 241
@@ -301,9 +272,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
301 float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; 272 float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight;
302 273
303 renderer.AddPlane("Water", m_scene.RegionInfo.RegionSizeX * 0.5f); 274 renderer.AddPlane("Water", m_scene.RegionInfo.RegionSizeX * 0.5f);
304 renderer.Scene.sceneobject("Water").setPos(m_scene.RegionInfo.RegionSizeX / 2 - 0.5f, 275 renderer.Scene.sceneobject("Water").setPos(m_scene.RegionInfo.RegionSizeX * 0.5f - 0.5f,
305 waterHeight, 276 waterHeight,
306 m_scene.RegionInfo.RegionSizeY / 2 - 0.5f); 277 m_scene.RegionInfo.RegionSizeY * 0.5f - 0.5f);
307 278
308 warp_Material waterColorMaterial = new warp_Material(ConvertColor(WATER_COLOR)); 279 warp_Material waterColorMaterial = new warp_Material(ConvertColor(WATER_COLOR));
309 waterColorMaterial.setReflectivity(0); // match water color with standard map module thanks lkalif 280 waterColorMaterial.setReflectivity(0); // match water color with standard map module thanks lkalif
@@ -319,53 +290,53 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
319 { 290 {
320 ITerrainChannel terrain = m_scene.Heightmap; 291 ITerrainChannel terrain = m_scene.Heightmap;
321 292
293 float regionsx = m_scene.RegionInfo.RegionSizeX;
294 float regionsy = m_scene.RegionInfo.RegionSizeY;
295
322 // 'diff' is the difference in scale between the real region size and the size of terrain we're buiding 296 // 'diff' is the difference in scale between the real region size and the size of terrain we're buiding
323 float diff = (float)m_scene.RegionInfo.RegionSizeX / 256f; 297 float diff = regionsx / 256f;
324 298
325 warp_Object obj = new warp_Object(256 * 256, 255 * 255 * 2); 299 int npointsx =(int)(regionsx / diff);
300 int npointsy =(int)(regionsy / diff);
301
302 float invsx = 1.0f / regionsx;
303 float invsy = 1.0f / (float)m_scene.RegionInfo.RegionSizeY;
326 304
327 // Create all the vertices for the terrain 305 // Create all the vertices for the terrain
328 for (float y = 0; y < m_scene.RegionInfo.RegionSizeY; y += diff) 306 warp_Object obj = new warp_Object();
307 for (float y = 0; y < regionsy; y += diff)
329 { 308 {
330 for (float x = 0; x < m_scene.RegionInfo.RegionSizeX; x += diff) 309 for (float x = 0; x < regionsx; x += diff)
331 { 310 {
332 warp_Vector pos = ConvertVector(x, y, (float)terrain[(int)x, (int)y]); 311 warp_Vector pos = ConvertVector(x , y , (float)terrain[(int)x, (int)y]);
333 obj.addVertex(new warp_Vertex(pos, 312 obj.addVertex(new warp_Vertex(pos, x * invsx, 1.0f - y * invsy));
334 x / (float)m_scene.RegionInfo.RegionSizeX,
335 (((float)m_scene.RegionInfo.RegionSizeY) - y) / m_scene.RegionInfo.RegionSizeY));
336 } 313 }
337 } 314 }
338 315
339 // Now that we have all the vertices, make another pass and create 316 // Now that we have all the vertices, make another pass and
340 // the normals for each of the surface triangles and 317 // create the list of triangle indices.
341 // create the list of triangle indices. 318 float invdiff = 1.0f / diff;
342 for (float y = 0; y < m_scene.RegionInfo.RegionSizeY; y += diff) 319 int limx = npointsx - 1;
320 int limy = npointsy - 1;
321 for (float y = 0; y < regionsy; y += diff)
343 { 322 {
344 for (float x = 0; x < m_scene.RegionInfo.RegionSizeX; x += diff) 323 for (float x = 0; x < regionsx; x += diff)
345 { 324 {
346 float newX = x / diff; 325 float newX = x * invdiff;
347 float newY = y / diff; 326 float newY = y * invdiff;
348 if (newX < 255 && newY < 255) 327 if (newX < limx && newY < limy)
349 { 328 {
350 int v = (int)newY * 256 + (int)newX; 329 int v = (int)newY * npointsx + (int)newX;
351
352 // Normal for a triangle made up of three adjacent vertices
353 Vector3 v1 = new Vector3(newX, newY, (float)terrain[(int)x, (int)y]);
354 Vector3 v2 = new Vector3(newX + 1, newY, (float)terrain[(int)(x + 1), (int)y]);
355 Vector3 v3 = new Vector3(newX, newY + 1, (float)terrain[(int)x, ((int)(y + 1))]);
356 warp_Vector norm = ConvertVector(SurfaceNormal(v1, v2, v3));
357 norm = norm.reverse();
358 obj.vertex(v).n = norm;
359 330
360 // Make two triangles for each of the squares in the grid of vertices 331 // Make two triangles for each of the squares in the grid of vertices
361 obj.addTriangle( 332 obj.addTriangle(
362 v, 333 v,
363 v + 1, 334 v + 1,
364 v + 256); 335 v + npointsx);
365 336
366 obj.addTriangle( 337 obj.addTriangle(
367 v + 256 + 1, 338 v + npointsx + 1,
368 v + 256, 339 v + npointsx,
369 v + 1); 340 v + 1);
370 } 341 }
371 } 342 }
@@ -398,14 +369,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
398 Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle, out globalX, out globalY); 369 Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle, out globalX, out globalY);
399 370
400 warp_Texture texture; 371 warp_Texture texture;
401 using ( 372 using (Bitmap image = TerrainSplat.Splat(
402 Bitmap image
403 = TerrainSplat.Splat(
404 terrain, textureIDs, startHeights, heightRanges, 373 terrain, textureIDs, startHeights, heightRanges,
405 new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain)) 374 new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain))
406 {
407 texture = new warp_Texture(image); 375 texture = new warp_Texture(image);
408 }
409 376
410 warp_Material material = new warp_Material(texture); 377 warp_Material material = new warp_Material(texture);
411 material.setReflectivity(50); 378 material.setReflectivity(50);
@@ -431,11 +398,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
431 private void CreatePrim(WarpRenderer renderer, SceneObjectPart prim, 398 private void CreatePrim(WarpRenderer renderer, SceneObjectPart prim,
432 bool useTextures) 399 bool useTextures)
433 { 400 {
434 const float MIN_SIZE = 2f; 401 const float MIN_SIZE_SQUARE = 4f;
435 402
436 if ((PCode)prim.Shape.PCode != PCode.Prim) 403 if ((PCode)prim.Shape.PCode != PCode.Prim)
437 return; 404 return;
438 if (prim.Scale.LengthSquared() < MIN_SIZE * MIN_SIZE) 405 float primScaleLenSquared = prim.Scale.LengthSquared();
406
407 if (primScaleLenSquared < MIN_SIZE_SQUARE)
439 return; 408 return;
440 409
441 FacetedMesh renderMesh = null; 410 FacetedMesh renderMesh = null;
@@ -459,13 +428,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
459 else // It's sculptie 428 else // It's sculptie
460 { 429 {
461 IJ2KDecoder imgDecoder = m_scene.RequestModuleInterface<IJ2KDecoder>(); 430 IJ2KDecoder imgDecoder = m_scene.RequestModuleInterface<IJ2KDecoder>();
462 if (imgDecoder != null) 431 if(imgDecoder != null)
463 { 432 {
464 Image sculpt = imgDecoder.DecodeToImage(sculptAsset); 433 Image sculpt = imgDecoder.DecodeToImage(sculptAsset);
465 if (sculpt != null) 434 if(sculpt != null)
466 { 435 {
467 renderMesh = m_primMesher.GenerateFacetedSculptMesh(omvPrim, (Bitmap)sculpt, 436 renderMesh = m_primMesher.GenerateFacetedSculptMesh(omvPrim,(Bitmap)sculpt,
468 DetailLevel.Medium); 437 DetailLevel.Medium);
469 sculpt.Dispose(); 438 sculpt.Dispose();
470 } 439 }
471 } 440 }
@@ -483,20 +452,6 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
483 if (renderMesh == null) 452 if (renderMesh == null)
484 return; 453 return;
485 454
486 warp_Vector primPos = ConvertVector(prim.GetWorldPosition());
487 warp_Quaternion primRot = ConvertQuaternion(prim.RotationOffset);
488
489 warp_Matrix m = warp_Matrix.quaternionMatrix(primRot);
490
491 if (prim.ParentID != 0)
492 {
493 SceneObjectGroup group = m_scene.SceneGraph.GetGroupByPrim(prim.LocalId);
494 if (group != null)
495 m.transform(warp_Matrix.quaternionMatrix(ConvertQuaternion(group.RootPart.RotationOffset)));
496 }
497
498 warp_Vector primScale = ConvertVector(prim.Scale);
499
500 string primID = prim.UUID.ToString(); 455 string primID = prim.UUID.ToString();
501 456
502 // Create the prim faces 457 // Create the prim faces
@@ -504,27 +459,18 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
504 for (int i = 0; i < renderMesh.Faces.Count; i++) 459 for (int i = 0; i < renderMesh.Faces.Count; i++)
505 { 460 {
506 Face face = renderMesh.Faces[i]; 461 Face face = renderMesh.Faces[i];
507 string meshName = primID + "-Face-" + i.ToString(); 462 string meshName = primID + i.ToString();
508 463
509 // Avoid adding duplicate meshes to the scene 464 // Avoid adding duplicate meshes to the scene
510 if (renderer.Scene.objectData.ContainsKey(meshName)) 465 if (renderer.Scene.objectData.ContainsKey(meshName))
511 {
512 continue; 466 continue;
513 }
514
515 warp_Object faceObj = new warp_Object(face.Vertices.Count, face.Indices.Count / 3);
516 467
468 warp_Object faceObj = new warp_Object();
517 for (int j = 0; j < face.Vertices.Count; j++) 469 for (int j = 0; j < face.Vertices.Count; j++)
518 { 470 {
519 Vertex v = face.Vertices[j]; 471 Vertex v = face.Vertices[j];
520
521 warp_Vector pos = ConvertVector(v.Position); 472 warp_Vector pos = ConvertVector(v.Position);
522 warp_Vector norm = ConvertVector(v.Normal); 473 warp_Vertex vert = new warp_Vertex(pos, v.TexCoord.X, v.TexCoord.Y);
523
524 if (prim.Shape.SculptTexture == UUID.Zero)
525 norm = norm.reverse();
526 warp_Vertex vert = new warp_Vertex(pos, norm, v.TexCoord.X, v.TexCoord.Y);
527
528 faceObj.addVertex(vert); 474 faceObj.addVertex(vert);
529 } 475 }
530 476
@@ -539,17 +485,19 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
539 Primitive.TextureEntryFace teFace = prim.Shape.Textures.GetFace((uint)i); 485 Primitive.TextureEntryFace teFace = prim.Shape.Textures.GetFace((uint)i);
540 Color4 faceColor = GetFaceColor(teFace); 486 Color4 faceColor = GetFaceColor(teFace);
541 string materialName = String.Empty; 487 string materialName = String.Empty;
542 if (m_texturePrims && prim.Scale.LengthSquared() > m_texturePrimSize*m_texturePrimSize) 488 if (m_texturePrims && primScaleLenSquared > m_texturePrimSize*m_texturePrimSize)
543 materialName = GetOrCreateMaterial(renderer, faceColor, teFace.TextureID); 489 materialName = GetOrCreateMaterial(renderer, faceColor, teFace.TextureID);
544 else 490 else
545 materialName = GetOrCreateMaterial(renderer, faceColor); 491 materialName = GetOrCreateMaterial(renderer, faceColor);
546 492
493 warp_Vector primPos = ConvertVector(prim.GetWorldPosition());
494 warp_Quaternion primRot = ConvertQuaternion(prim.GetWorldRotation());
495 warp_Matrix m = warp_Matrix.quaternionMatrix(primRot);
547 faceObj.transform(m); 496 faceObj.transform(m);
548 faceObj.setPos(primPos); 497 faceObj.setPos(primPos);
549 faceObj.scaleSelf(primScale.x, primScale.y, primScale.z); 498 faceObj.scaleSelf(prim.Scale.X, prim.Scale.Z, prim.Scale.Y);
550 499
551 renderer.Scene.addObject(meshName, faceObj); 500 renderer.Scene.addObject(meshName, faceObj);
552
553 renderer.SetObjectMaterial(meshName, materialName); 501 renderer.SetObjectMaterial(meshName, materialName);
554 } 502 }
555 } 503 }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 959829c..57ec800 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -1428,6 +1428,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1428 1428
1429 mapTexture.Save(exportPath, ImageFormat.Jpeg); 1429 mapTexture.Save(exportPath, ImageFormat.Jpeg);
1430 1430
1431 g.Dispose();
1432 mapTexture.Dispose();
1433 sea.Dispose();
1434
1431 m_log.InfoFormat( 1435 m_log.InfoFormat(
1432 "[WORLD MAP]: Successfully exported world map for {0} to {1}", 1436 "[WORLD MAP]: Successfully exported world map for {0} to {1}",
1433 m_scene.RegionInfo.RegionName, exportPath); 1437 m_scene.RegionInfo.RegionName, exportPath);
@@ -1613,9 +1617,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1613 int mb = bx; 1617 int mb = bx;
1614 if(mb < by) 1618 if(mb < by)
1615 mb = by; 1619 mb = by;
1616 if(mb > 2 * Constants.RegionSize && mb > 0) 1620 if(mb > Constants.RegionSize && mb > 0)
1617 { 1621 {
1618 float scale = 2.0f * (float)Constants.RegionSize/(float)mb; 1622 float scale = (float)Constants.RegionSize/(float)mb;
1619 Size newsize = new Size(); 1623 Size newsize = new Size();
1620 newsize.Width = (int)(bx * scale); 1624 newsize.Width = (int)(bx * scale);
1621 newsize.Height = (int)(by * scale); 1625 newsize.Height = (int)(by * scale);