From 73719b2efce8c1d22d154d4530e98b2ed5bc2bae Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 21 Aug 2016 00:25:32 +0100 Subject: fix terrain BMP image format on SaveStream mantis: 8001 --- OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs index fb57c82..8b95a33 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs @@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders { Bitmap colours = CreateGrayscaleBitmapFromMap(map); - colours.Save(stream, ImageFormat.Png); + colours.Save(stream, ImageFormat.Bmp); } /// -- cgit v1.1 From 5d42d244286472077123cf1ca0e781d2c0c57e48 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 21 Aug 2016 02:10:45 +0100 Subject: limit the scan of terrain EnforceEstateLimits to the area changed. --- .../CoreModules/World/Terrain/TerrainModule.cs | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') 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 return wasLimited; } + private bool EnforceEstateLimits(int startX, int startY, int endX, int endY) + { + TerrainData terrData = m_channel.GetTerrainData(); + + bool wasLimited = false; + for (int x = startX; x <= endX; x += Constants.TerrainPatchSize) + { + for (int y = startX; y <= endY; y += Constants.TerrainPatchSize) + { + if (terrData.IsTaintedAt(x, y, false /* clearOnTest */)) + { + // If we should respect the estate settings then + // fixup and height deltas that don't respect them. + // Note that LimitChannelChanges() modifies the TerrainChannel with the limited height values. + wasLimited |= LimitChannelChanges(terrData, x, y); + } + } + } + return wasLimited; + } + /// /// Checks to see height deltas in the tainted terrain patch at xStart ,yStart /// are all within the current estate limits @@ -1341,7 +1362,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain //block changes outside estate limits if (!god) - EnforceEstateLimits(); + EnforceEstateLimits(startX, endX, startY, endY); } } else @@ -1404,7 +1425,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain //block changes outside estate limits if (!god) - EnforceEstateLimits(); + EnforceEstateLimits(startX, endX, startY, endY); } } else -- cgit v1.1 From c8a1d7e5a74161d51841d5abbe9b76a7da51c872 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Aug 2016 03:55:01 +0100 Subject: workaround potencial memory leaks --- OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs | 10 ++++------ OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GIF.cs | 10 ++++------ .../World/Terrain/FileLoaders/GenericSystemDrawing.cs | 12 +++++------- OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs | 10 ++++------ OpenSim/Region/CoreModules/World/Terrain/FileLoaders/PNG.cs | 10 ++++------ OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs | 10 ++++------ 6 files changed, 25 insertions(+), 37 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs index 8b95a33..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 /// The terrain channel being saved public override void SaveFile(string filename, ITerrainChannel map) { - Bitmap colours = CreateGrayscaleBitmapFromMap(map); - - colours.Save(filename, ImageFormat.Bmp); + using(Bitmap colours = CreateGrayscaleBitmapFromMap(map)) + colours.Save(filename,ImageFormat.Bmp); } /// @@ -59,9 +58,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders /// The terrain channel being saved public override void SaveStream(Stream stream, ITerrainChannel map) { - Bitmap colours = CreateGrayscaleBitmapFromMap(map); - - colours.Save(stream, ImageFormat.Bmp); + using(Bitmap colours = CreateGrayscaleBitmapFromMap(map)) + colours.Save(stream,ImageFormat.Bmp); } /// 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 { public override void SaveFile(string filename, ITerrainChannel map) { - Bitmap colours = CreateGrayscaleBitmapFromMap(map); - - colours.Save(filename, ImageFormat.Gif); + using(Bitmap colours = CreateGrayscaleBitmapFromMap(map)) + colours.Save(filename,ImageFormat.Gif); } /// @@ -48,9 +47,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders /// The terrain channel being saved public override void SaveStream(Stream stream, ITerrainChannel map) { - Bitmap colours = CreateGrayscaleBitmapFromMap(map); - - colours.Save(stream, ImageFormat.Gif); + using(Bitmap colours = CreateGrayscaleBitmapFromMap(map)) + colours.Save(stream,ImageFormat.Gif); } 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 /// A terrain channel generated from the image. public virtual ITerrainChannel LoadFile(string filename) { - using (Bitmap b = new Bitmap(filename)) + using(Bitmap b = new Bitmap(filename)) return LoadBitmap(b); } @@ -111,9 +111,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders /// The terrain channel being saved public virtual void SaveFile(string filename, ITerrainChannel map) { - Bitmap colours = CreateGrayscaleBitmapFromMap(map); - - colours.Save(filename, ImageFormat.Png); + using(Bitmap colours = CreateGrayscaleBitmapFromMap(map)) + colours.Save(filename,ImageFormat.Png); } /// @@ -123,9 +122,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders /// The terrain channel being saved public virtual void SaveStream(Stream stream, ITerrainChannel map) { - Bitmap colours = CreateGrayscaleBitmapFromMap(map); - - colours.Save(stream, ImageFormat.Png); + using(Bitmap colours = CreateGrayscaleBitmapFromMap(map)) + colours.Save(stream,ImageFormat.Png); } 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 public void SaveFile(string filename, ITerrainChannel map) { - Bitmap colours = CreateBitmapFromMap(map); - - colours.Save(filename, ImageFormat.Jpeg); + using(Bitmap colours = CreateBitmapFromMap(map)) + colours.Save(filename,ImageFormat.Jpeg); } /// @@ -71,9 +70,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders /// The terrain channel being saved public void SaveStream(Stream stream, ITerrainChannel map) { - Bitmap colours = CreateBitmapFromMap(map); - - colours.Save(stream, ImageFormat.Jpeg); + using(Bitmap colours = CreateBitmapFromMap(map)) + colours.Save(stream,ImageFormat.Jpeg); } 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 { public override void SaveFile(string filename, ITerrainChannel map) { - Bitmap colours = CreateGrayscaleBitmapFromMap(map); - - colours.Save(filename, ImageFormat.Png); + using(Bitmap colours = CreateGrayscaleBitmapFromMap(map)) + colours.Save(filename,ImageFormat.Png); } /// @@ -48,9 +47,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders /// The terrain channel being saved public override void SaveStream(Stream stream, ITerrainChannel map) { - Bitmap colours = CreateGrayscaleBitmapFromMap(map); - - colours.Save(stream, ImageFormat.Png); + using(Bitmap colours = CreateGrayscaleBitmapFromMap(map)) + colours.Save(stream,ImageFormat.Png); } 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 { public override void SaveFile(string filename, ITerrainChannel map) { - Bitmap colours = CreateGrayscaleBitmapFromMap(map); - - colours.Save(filename, ImageFormat.Tiff); + using(Bitmap colours = CreateGrayscaleBitmapFromMap(map)) + colours.Save(filename,ImageFormat.Tiff); } /// @@ -48,9 +47,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders /// The terrain channel being saved public override void SaveStream(Stream stream, ITerrainChannel map) { - Bitmap colours = CreateGrayscaleBitmapFromMap(map); - - colours.Save(stream, ImageFormat.Tiff); + using(Bitmap colours = CreateGrayscaleBitmapFromMap(map)) + colours.Save(stream,ImageFormat.Tiff); } public override string ToString() -- cgit v1.1 From 4f4227d5bbb9a3d86a0d024fcdc4f14f23889735 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Aug 2016 06:23:55 +0100 Subject: workaround potencial memory leak --- OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/CoreModules/World') 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 } ControlFileLoaded = true; + if(xtr != null) + xtr.Close(); return dearchivedScenes; } -- cgit v1.1 From 39e92adaf2b34899ee2b9e606ae81f2288243bc6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Aug 2016 08:12:32 +0100 Subject: workaround potencial memory leak --- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 959829c..88ce305 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 mapTexture.Save(exportPath, ImageFormat.Jpeg); + g.Dispose(); + mapTexture.Dispose(); + sea.Dispose(); + m_log.InfoFormat( "[WORLD MAP]: Successfully exported world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath); -- cgit v1.1 From 08c1dff86ce454eb0f53eba9dedceb1bca0e143c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Aug 2016 20:43:11 +0100 Subject: change strange rotation in legacy MapImageModule (untested) --- OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') 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 Vector3 pos = part.GetWorldPosition(); - // skip prim outside of retion + // skip prim outside of region if (!m_scene.PositionIsInCurrentRegion(pos)) continue; @@ -406,12 +406,13 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap { // Translate scale by rotation so scale is represented properly when object is rotated Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z); + lscale *= 0.5f; + Vector3 scale = new Vector3(); Vector3 tScale = new Vector3(); Vector3 axPos = new Vector3(pos.X, pos.Y, pos.Z); - Quaternion llrot = part.GetWorldRotation(); - Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z); + Quaternion rot = part.GetWorldRotation(); scale = lscale * rot; // negative scales don't work in this situation @@ -470,7 +471,6 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z); scale = ((tScale * rot)); - vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); //vertexes[2].x = pos.X + vertexes[2].x; -- cgit v1.1 From 8eacc6b2077b302132eae82ce4bf22bf35b62ac5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 23 Aug 2016 10:58:34 +0100 Subject: replace warp3D.dll by a newer modified version. (only minor testing done :( --- .../World/Warp3DMap/Warp3DImageModule.cs | 158 +++++++-------------- .../CoreModules/World/WorldMap/WorldMapModule.cs | 4 +- 2 files changed, 56 insertions(+), 106 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index 443eee1..e2c1c01 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs @@ -35,7 +35,7 @@ using System.Reflection; using CSJ2K; using Nini.Config; using log4net; -using Rednettle.Warp3D; +using Warp3D; using Mono.Addins; using OpenSim.Framework; @@ -76,11 +76,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap private bool m_texturePrims = true; // true if should texture the rendered prims private float m_texturePrimSize = 48f; // size of prim before we consider texturing it private bool m_renderMeshes = false; // true if to render meshes rather than just bounding boxes - private bool m_useAntiAliasing = false; // true if to anti-alias the rendered image private bool m_Enabled = false; - private Bitmap lastImage = null; +// private Bitmap lastImage = null; private DateTime lastImageTime = DateTime.MinValue; #region Region Module interface @@ -107,10 +106,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap = Util.GetConfigVarFromSections(m_config, "TexturePrimSize", configSections, m_texturePrimSize); m_renderMeshes = Util.GetConfigVarFromSections(m_config, "RenderMeshes", configSections, m_renderMeshes); - m_useAntiAliasing - = Util.GetConfigVarFromSections(m_config, "UseAntiAliasing", configSections, m_useAntiAliasing); - - } + } public void AddRegion(Scene scene) { @@ -201,21 +197,14 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap int width = viewport.Width; int height = viewport.Height; - if (m_useAntiAliasing) - { - width *= 2; - height *= 2; - } - WarpRenderer renderer = new WarpRenderer(); - renderer.CreateScene(width, height); - renderer.Scene.autoCalcNormals = false; + if(!renderer.CreateScene(width, height)) + return new Bitmap(width,height); #region Camera warp_Vector pos = ConvertVector(viewport.Position); - pos.z -= 0.001f; // Works around an issue with the Warp3D camera warp_Vector lookat = warp_Vector.add(ConvertVector(viewport.Position), ConvertVector(viewport.LookDirection)); renderer.Scene.defaultCamera.setPos(pos); @@ -247,24 +236,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap renderer.Render(); Bitmap bitmap = renderer.Scene.getImage(); - if (m_useAntiAliasing) - { - using (Bitmap origBitmap = bitmap) - bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height); - } - - // XXX: It shouldn't really be necesary to force a GC here as one should occur anyway pretty shortly - // afterwards. It's generally regarded as a bad idea to manually GC. If Warp3D is using lots of memory - // then this may be some issue with the Warp3D code itself, though it's also quite possible that generating - // this map tile simply takes a lot of memory. - foreach (var o in renderer.Scene.objectData.Values) - { - warp_Object obj = (warp_Object)o; - obj.vertexData = null; - obj.triangleData = null; - } - - renderer.Scene.removeAllObjects(); + renderer.Scene.destroy(); + renderer.Reset(); renderer = null; viewport = null; @@ -301,9 +274,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; renderer.AddPlane("Water", m_scene.RegionInfo.RegionSizeX * 0.5f); - renderer.Scene.sceneobject("Water").setPos(m_scene.RegionInfo.RegionSizeX / 2 - 0.5f, + renderer.Scene.sceneobject("Water").setPos(m_scene.RegionInfo.RegionSizeX * 0.5f - 0.5f, waterHeight, - m_scene.RegionInfo.RegionSizeY / 2 - 0.5f); + m_scene.RegionInfo.RegionSizeY * 0.5f - 0.5f); warp_Material waterColorMaterial = new warp_Material(ConvertColor(WATER_COLOR)); waterColorMaterial.setReflectivity(0); // match water color with standard map module thanks lkalif @@ -319,53 +292,53 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap { ITerrainChannel terrain = m_scene.Heightmap; + float regionsx = m_scene.RegionInfo.RegionSizeX; + float regionsy = m_scene.RegionInfo.RegionSizeY; + // 'diff' is the difference in scale between the real region size and the size of terrain we're buiding - float diff = (float)m_scene.RegionInfo.RegionSizeX / 256f; + float diff = regionsx / 256f; - warp_Object obj = new warp_Object(256 * 256, 255 * 255 * 2); + int npointsx =(int)(regionsx / diff); + int npointsy =(int)(regionsy / diff); + + float invsx = 1.0f / regionsx; + float invsy = 1.0f / (float)m_scene.RegionInfo.RegionSizeY; // Create all the vertices for the terrain - for (float y = 0; y < m_scene.RegionInfo.RegionSizeY; y += diff) + warp_Object obj = new warp_Object(); + for (float y = 0; y < regionsy; y += diff) { - for (float x = 0; x < m_scene.RegionInfo.RegionSizeX; x += diff) + for (float x = 0; x < regionsx; x += diff) { - warp_Vector pos = ConvertVector(x, y, (float)terrain[(int)x, (int)y]); - obj.addVertex(new warp_Vertex(pos, - x / (float)m_scene.RegionInfo.RegionSizeX, - (((float)m_scene.RegionInfo.RegionSizeY) - y) / m_scene.RegionInfo.RegionSizeY)); + warp_Vector pos = ConvertVector(x , y , (float)terrain[(int)x, (int)y]); + obj.addVertex(new warp_Vertex(pos, x * invsx, 1.0f - y * invsy)); } } - // Now that we have all the vertices, make another pass and create - // the normals for each of the surface triangles and - // create the list of triangle indices. - for (float y = 0; y < m_scene.RegionInfo.RegionSizeY; y += diff) + // Now that we have all the vertices, make another pass and + // create the list of triangle indices. + float invdiff = 1.0f / diff; + int limx = npointsx - 1; + int limy = npointsy - 1; + for (float y = 0; y < regionsy; y += diff) { - for (float x = 0; x < m_scene.RegionInfo.RegionSizeX; x += diff) + for (float x = 0; x < regionsx; x += diff) { - float newX = x / diff; - float newY = y / diff; - if (newX < 255 && newY < 255) + float newX = x * invdiff; + float newY = y * invdiff; + if (newX < limx && newY < limy) { - int v = (int)newY * 256 + (int)newX; - - // Normal for a triangle made up of three adjacent vertices - Vector3 v1 = new Vector3(newX, newY, (float)terrain[(int)x, (int)y]); - Vector3 v2 = new Vector3(newX + 1, newY, (float)terrain[(int)(x + 1), (int)y]); - Vector3 v3 = new Vector3(newX, newY + 1, (float)terrain[(int)x, ((int)(y + 1))]); - warp_Vector norm = ConvertVector(SurfaceNormal(v1, v2, v3)); - norm = norm.reverse(); - obj.vertex(v).n = norm; + int v = (int)newY * npointsx + (int)newX; // Make two triangles for each of the squares in the grid of vertices obj.addTriangle( v, v + 1, - v + 256); + v + npointsx); obj.addTriangle( - v + 256 + 1, - v + 256, + v + npointsx + 1, + v + npointsx, v + 1); } } @@ -398,14 +371,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle, out globalX, out globalY); warp_Texture texture; - using ( - Bitmap image - = TerrainSplat.Splat( + using (Bitmap image = TerrainSplat.Splat( terrain, textureIDs, startHeights, heightRanges, new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain)) - { texture = new warp_Texture(image); - } warp_Material material = new warp_Material(texture); material.setReflectivity(50); @@ -431,11 +400,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap private void CreatePrim(WarpRenderer renderer, SceneObjectPart prim, bool useTextures) { - const float MIN_SIZE = 2f; + const float MIN_SIZE_SQUARE = 4f; if ((PCode)prim.Shape.PCode != PCode.Prim) return; - if (prim.Scale.LengthSquared() < MIN_SIZE * MIN_SIZE) + float primScaleLenSquared = prim.Scale.LengthSquared(); + + if (primScaleLenSquared < MIN_SIZE_SQUARE) return; FacetedMesh renderMesh = null; @@ -459,13 +430,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap else // It's sculptie { IJ2KDecoder imgDecoder = m_scene.RequestModuleInterface(); - if (imgDecoder != null) + if(imgDecoder != null) { Image sculpt = imgDecoder.DecodeToImage(sculptAsset); - if (sculpt != null) + if(sculpt != null) { - renderMesh = m_primMesher.GenerateFacetedSculptMesh(omvPrim, (Bitmap)sculpt, - DetailLevel.Medium); + renderMesh = m_primMesher.GenerateFacetedSculptMesh(omvPrim,(Bitmap)sculpt, + DetailLevel.Medium); sculpt.Dispose(); } } @@ -483,20 +454,6 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap if (renderMesh == null) return; - warp_Vector primPos = ConvertVector(prim.GetWorldPosition()); - warp_Quaternion primRot = ConvertQuaternion(prim.RotationOffset); - - warp_Matrix m = warp_Matrix.quaternionMatrix(primRot); - - if (prim.ParentID != 0) - { - SceneObjectGroup group = m_scene.SceneGraph.GetGroupByPrim(prim.LocalId); - if (group != null) - m.transform(warp_Matrix.quaternionMatrix(ConvertQuaternion(group.RootPart.RotationOffset))); - } - - warp_Vector primScale = ConvertVector(prim.Scale); - string primID = prim.UUID.ToString(); // Create the prim faces @@ -504,27 +461,18 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap for (int i = 0; i < renderMesh.Faces.Count; i++) { Face face = renderMesh.Faces[i]; - string meshName = primID + "-Face-" + i.ToString(); + string meshName = primID + i.ToString(); // Avoid adding duplicate meshes to the scene if (renderer.Scene.objectData.ContainsKey(meshName)) - { continue; - } - - warp_Object faceObj = new warp_Object(face.Vertices.Count, face.Indices.Count / 3); + warp_Object faceObj = new warp_Object(); for (int j = 0; j < face.Vertices.Count; j++) { Vertex v = face.Vertices[j]; - warp_Vector pos = ConvertVector(v.Position); - warp_Vector norm = ConvertVector(v.Normal); - - if (prim.Shape.SculptTexture == UUID.Zero) - norm = norm.reverse(); - warp_Vertex vert = new warp_Vertex(pos, norm, v.TexCoord.X, v.TexCoord.Y); - + warp_Vertex vert = new warp_Vertex(pos, v.TexCoord.X, v.TexCoord.Y); faceObj.addVertex(vert); } @@ -539,17 +487,19 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap Primitive.TextureEntryFace teFace = prim.Shape.Textures.GetFace((uint)i); Color4 faceColor = GetFaceColor(teFace); string materialName = String.Empty; - if (m_texturePrims && prim.Scale.LengthSquared() > m_texturePrimSize*m_texturePrimSize) + if (m_texturePrims && primScaleLenSquared > m_texturePrimSize*m_texturePrimSize) materialName = GetOrCreateMaterial(renderer, faceColor, teFace.TextureID); else materialName = GetOrCreateMaterial(renderer, faceColor); + warp_Vector primPos = ConvertVector(prim.GetWorldPosition()); + warp_Quaternion primRot = ConvertQuaternion(prim.GetWorldRotation()); + warp_Matrix m = warp_Matrix.quaternionMatrix(primRot); faceObj.transform(m); faceObj.setPos(primPos); - faceObj.scaleSelf(primScale.x, primScale.y, primScale.z); + faceObj.scaleSelf(prim.Scale.X, prim.Scale.Z, prim.Scale.Y); renderer.Scene.addObject(meshName, faceObj); - renderer.SetObjectMaterial(meshName, materialName); } } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 88ce305..57ec800 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1617,9 +1617,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap int mb = bx; if(mb < by) mb = by; - if(mb > 2 * Constants.RegionSize && mb > 0) + if(mb > Constants.RegionSize && mb > 0) { - float scale = 2.0f * (float)Constants.RegionSize/(float)mb; + float scale = (float)Constants.RegionSize/(float)mb; Size newsize = new Size(); newsize.Width = (int)(bx * scale); newsize.Height = (int)(by * scale); -- cgit v1.1 From 517064121dc301327cda5c9c4ab1b039d0a31e35 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 24 Aug 2016 01:22:50 +0100 Subject: estate handleTerrainRequest memory leaks --- .../World/Estate/EstateManagementModule.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') 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 } terr.SaveToFile(Util.dataDir() + "/terrain.raw"); - FileStream input = new FileStream(Util.dataDir() + "/terrain.raw", FileMode.Open); - byte[] bdata = new byte[input.Length]; - input.Read(bdata, 0, (int)input.Length); + byte[] bdata; + using(FileStream input = new FileStream(Util.dataDir() + "/terrain.raw",FileMode.Open)) + { + bdata = new byte[input.Length]; + input.Read(bdata, 0, (int)input.Length); + } + if(bdata == null || bdata.Length == 0) + { + remote_client.SendAlertMessage("Terrain error"); + return; + } + remote_client.SendAlertMessage("Terrain file written, starting download..."); - Scene.XferManager.AddNewFile("terrain.raw", bdata); + string xfername = (UUID.Random()).ToString(); + Scene.XferManager.AddNewFile(xfername, bdata); m_log.DebugFormat("[CLIENT]: Sending terrain for region {0} to {1}", Scene.Name, remote_client.Name); - - remote_client.SendInitiateDownload("terrain.raw", clientFileName); + remote_client.SendInitiateDownload(xfername, clientFileName); } } -- cgit v1.1 From c05ee23d3dd533f19295f6b038898c09196e475b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 24 Aug 2016 04:10:35 +0100 Subject: minor change on warp3d lib --- OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index e2c1c01..cb37067 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs @@ -212,9 +212,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap if (viewport.Orthographic) { - renderer.Scene.defaultCamera.isOrthographic = true; - renderer.Scene.defaultCamera.orthoViewWidth = viewport.OrthoWindowWidth; - renderer.Scene.defaultCamera.orthoViewHeight = viewport.OrthoWindowHeight; + renderer.Scene.defaultCamera.setOrthographic(true,viewport.OrthoWindowWidth, viewport.OrthoWindowHeight); } else { -- cgit v1.1