varregion: update MapImageModule and ShadedMapTimeRenderer for variable sized regions.
							parent
							
								
									df14b40e88
								
							
						
					
					
						commit
						6081ae3554
					
				|  | @ -102,7 +102,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
| 
 | 
 | ||||||
|                 terrainRenderer.Initialise(m_scene, m_config); |                 terrainRenderer.Initialise(m_scene, m_config); | ||||||
| 
 | 
 | ||||||
|                 mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize, System.Drawing.Imaging.PixelFormat.Format24bppRgb); |                 mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height, | ||||||
|  |                                         System.Drawing.Imaging.PixelFormat.Format24bppRgb); | ||||||
|                 //long t = System.Environment.TickCount; |                 //long t = System.Environment.TickCount; | ||||||
|                 //for (int i = 0; i < 10; ++i) { |                 //for (int i = 0; i < 10; ++i) { | ||||||
|                 terrainRenderer.TerrainToBitmap(mapbmp); |                 terrainRenderer.TerrainToBitmap(mapbmp); | ||||||
|  | @ -277,7 +278,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
|         private Bitmap DrawObjectVolume(Scene whichScene, Bitmap mapbmp) |         private Bitmap DrawObjectVolume(Scene whichScene, Bitmap mapbmp) | ||||||
|         { |         { | ||||||
|             int tc = 0; |             int tc = 0; | ||||||
|             double[,] hm = whichScene.Heightmap.GetDoubles(); |             ITerrainChannel hm = whichScene.Heightmap; | ||||||
|             tc = Environment.TickCount; |             tc = Environment.TickCount; | ||||||
|             m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); |             m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); | ||||||
|             EntityBase[] objs = whichScene.GetEntities(); |             EntityBase[] objs = whichScene.GetEntities(); | ||||||
|  | @ -363,7 +364,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
|                                     Vector3 pos = part.GetWorldPosition(); |                                     Vector3 pos = part.GetWorldPosition(); | ||||||
| 
 | 
 | ||||||
|                                     // skip prim outside of retion |                                     // skip prim outside of retion | ||||||
|                                     if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f) |                                     if (!m_scene.PositionIsInCurrentRegion(pos)) | ||||||
|                                         continue; |                                         continue; | ||||||
| 
 | 
 | ||||||
|                                     // skip prim in non-finite position |                                     // skip prim in non-finite position | ||||||
|  | @ -388,7 +389,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
|                                         Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z); |                                         Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z); | ||||||
|                                         Vector3 scale = new Vector3(); |                                         Vector3 scale = new Vector3(); | ||||||
|                                         Vector3 tScale = new Vector3(); |                                         Vector3 tScale = new Vector3(); | ||||||
|                                         Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z); |                                         Vector3 axPos = new Vector3(pos.X, pos.Y, pos.Z); | ||||||
| 
 | 
 | ||||||
|                                         Quaternion llrot = part.GetWorldRotation(); |                                         Quaternion llrot = part.GetWorldRotation(); | ||||||
|                                         Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z); |                                         Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z); | ||||||
|  | @ -406,9 +407,14 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
|                                         int mapdrawendY = (int)(pos.Y + scale.Y); |                                         int mapdrawendY = (int)(pos.Y + scale.Y); | ||||||
| 
 | 
 | ||||||
|                                         // If object is beyond the edge of the map, don't draw it to avoid errors |                                         // If object is beyond the edge of the map, don't draw it to avoid errors | ||||||
|                                         if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1) |                                         if (mapdrawstartX < 0 | ||||||
|                                                               || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0 |                                                     || mapdrawstartX > (hm.Width - 1) | ||||||
|                                                               || mapdrawendY > ((int)Constants.RegionSize - 1)) |                                                     || mapdrawendX < 0 | ||||||
|  |                                                     || mapdrawendX > (hm.Width - 1) | ||||||
|  |                                                     || mapdrawstartY < 0 | ||||||
|  |                                                     || mapdrawstartY > (hm.Height - 1) | ||||||
|  |                                                     || mapdrawendY < 0 | ||||||
|  |                                                     || mapdrawendY > (hm.Height - 1)) | ||||||
|                                             continue; |                                             continue; | ||||||
| 
 | 
 | ||||||
|     #region obb face reconstruction part duex |     #region obb face reconstruction part duex | ||||||
|  | @ -530,11 +536,11 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
|                                         for (int i = 0; i < FaceA.Length; i++) |                                         for (int i = 0; i < FaceA.Length; i++) | ||||||
|                                         { |                                         { | ||||||
|                                             Point[] working = new Point[5]; |                                             Point[] working = new Point[5]; | ||||||
|                                             working[0] = project(FaceA[i], axPos); |                                             working[0] = project(hm, FaceA[i], axPos); | ||||||
|                                             working[1] = project(FaceB[i], axPos); |                                             working[1] = project(hm, FaceB[i], axPos); | ||||||
|                                             working[2] = project(FaceD[i], axPos); |                                             working[2] = project(hm, FaceD[i], axPos); | ||||||
|                                             working[3] = project(FaceC[i], axPos); |                                             working[3] = project(hm, FaceC[i], axPos); | ||||||
|                                             working[4] = project(FaceA[i], axPos); |                                             working[4] = project(hm, FaceA[i], axPos); | ||||||
| 
 | 
 | ||||||
|                                             face workingface = new face(); |                                             face workingface = new face(); | ||||||
|                                             workingface.pts = working; |                                             workingface.pts = working; | ||||||
|  | @ -609,17 +615,17 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
|             return mapbmp; |             return mapbmp; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         private Point project(Vector3 point3d, Vector3 originpos) |         private Point project(ITerrainChannel hm, Vector3 point3d, Vector3 originpos) | ||||||
|         { |         { | ||||||
|             Point returnpt = new Point(); |             Point returnpt = new Point(); | ||||||
|             //originpos = point3d; |             //originpos = point3d; | ||||||
|             //int d = (int)(256f / 1.5f); |             //int d = (int)(256f / 1.5f); | ||||||
| 
 | 
 | ||||||
|             //Vector3 topos = new Vector3(0, 0, 0); |             //Vector3 topos = new Vector3(0, 0, 0); | ||||||
|            // float z = -point3d.z - topos.z; |             // float z = -point3d.z - topos.z; | ||||||
| 
 | 
 | ||||||
|             returnpt.X = (int)point3d.X;//(int)((topos.x - point3d.x) / z * d); |             returnpt.X = (int)point3d.X;//(int)((topos.x - point3d.x) / z * d); | ||||||
|             returnpt.Y = (int)(((int)Constants.RegionSize - 1) - point3d.Y);//(int)(255 - (((topos.y - point3d.y) / z * d))); |             returnpt.Y = (int)((hm.Width - 1) - point3d.Y);//(int)(255 - (((topos.y - point3d.y) / z * d))); | ||||||
| 
 | 
 | ||||||
|             return returnpt; |             return returnpt; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -31,6 +31,7 @@ using System.Reflection; | ||||||
| using log4net; | using log4net; | ||||||
| using Nini.Config; | using Nini.Config; | ||||||
| using OpenSim.Framework; | using OpenSim.Framework; | ||||||
|  | using OpenSim.Region.Framework.Interfaces; | ||||||
| using OpenSim.Region.Framework.Scenes; | using OpenSim.Region.Framework.Scenes; | ||||||
| 
 | 
 | ||||||
| namespace OpenSim.Region.CoreModules.World.LegacyMap | namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
|  | @ -39,8 +40,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
|     { |     { | ||||||
|         private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95); |         private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95); | ||||||
| 
 | 
 | ||||||
|         private static readonly ILog m_log = |         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||||||
|             LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |         private static readonly string LogHeader = "[SHADED MAPTILE RENDERER]"; | ||||||
| 
 | 
 | ||||||
|         private Scene m_scene; |         private Scene m_scene; | ||||||
|         //private IConfigSource m_config; // not used currently |         //private IConfigSource m_config; // not used currently | ||||||
|  | @ -53,19 +54,26 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
| 
 | 
 | ||||||
|         public void TerrainToBitmap(Bitmap mapbmp) |         public void TerrainToBitmap(Bitmap mapbmp) | ||||||
|         { |         { | ||||||
|  |             m_log.DebugFormat("{0} Generating Maptile Step 1: Terrain", LogHeader); | ||||||
|             int tc = Environment.TickCount; |             int tc = Environment.TickCount; | ||||||
|             m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Terrain"); |  | ||||||
| 
 | 
 | ||||||
|             double[,] hm = m_scene.Heightmap.GetDoubles(); |             ITerrainChannel hm = m_scene.Heightmap; | ||||||
|  | 
 | ||||||
|  |             if (mapbmp.Width != hm.Width || mapbmp.Height != hm.Height) | ||||||
|  |             { | ||||||
|  |                 m_log.ErrorFormat("{0} TerrainToBitmap. Passed bitmap wrong dimensions. passed=<{1},{2}>, size=<{3},{4}>", | ||||||
|  |                     LogHeader, mapbmp.Width, mapbmp.Height, hm.Width, hm.Height); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|             bool ShadowDebugContinue = true; |             bool ShadowDebugContinue = true; | ||||||
| 
 | 
 | ||||||
|             bool terraincorruptedwarningsaid = false; |             bool terraincorruptedwarningsaid = false; | ||||||
| 
 | 
 | ||||||
|             float low = 255; |             float low = 255; | ||||||
|             float high = 0; |             float high = 0; | ||||||
|             for (int x = 0; x < (int)Constants.RegionSize; x++) |             for (int x = 0; x < hm.Width; x++) | ||||||
|             { |             { | ||||||
|                 for (int y = 0; y < (int)Constants.RegionSize; y++) |                 for (int y = 0; y < hm.Height; y++) | ||||||
|                 { |                 { | ||||||
|                     float hmval = (float)hm[x, y]; |                     float hmval = (float)hm[x, y]; | ||||||
|                     if (hmval < low) |                     if (hmval < low) | ||||||
|  | @ -77,12 +85,12 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
| 
 | 
 | ||||||
|             float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; |             float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; | ||||||
| 
 | 
 | ||||||
|             for (int x = 0; x < (int)Constants.RegionSize; x++) |             for (int x = 0; x < hm.Width; x++) | ||||||
|             { |             { | ||||||
|                 for (int y = 0; y < (int)Constants.RegionSize; y++) |                 for (int y = 0; y < hm.Height; y++) | ||||||
|                 { |                 { | ||||||
|                     // Y flip the cordinates for the bitmap: hf origin is lower left, bm origin is upper left |                     // Y flip the cordinates for the bitmap: hf origin is lower left, bm origin is upper left | ||||||
|                     int yr = ((int)Constants.RegionSize - 1) - y; |                     int yr = ((int)hm.Height - 1) - y; | ||||||
| 
 | 
 | ||||||
|                     float heightvalue = (float)hm[x, y]; |                     float heightvalue = (float)hm[x, y]; | ||||||
| 
 | 
 | ||||||
|  | @ -109,12 +117,12 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
|                             // . |                             // . | ||||||
|                             // |                             // | ||||||
|                             // Shade the terrain for shadows |                             // Shade the terrain for shadows | ||||||
|                             if (x < ((int)Constants.RegionSize - 1) && yr < ((int)Constants.RegionSize - 1)) |                             if (x < (hm.Width - 1) && yr < (hm.Height - 1)) | ||||||
|                             { |                             { | ||||||
|                                 float hfvalue = (float)hm[x, y]; |                                 float hfvalue = (float)hm[x, y]; | ||||||
|                                 float hfvaluecompare = 0f; |                                 float hfvaluecompare = 0f; | ||||||
| 
 | 
 | ||||||
|                                 if ((x + 1 < (int)Constants.RegionSize) && (y + 1 < (int)Constants.RegionSize)) |                                 if ((x + 1 < hm.Width) && (y + 1 < hm.Height)) | ||||||
|                                 { |                                 { | ||||||
|                                     hfvaluecompare = (float)hm[x + 1, y + 1]; // light from north-east => look at land height there |                                     hfvaluecompare = (float)hm[x + 1, y + 1]; // light from north-east => look at land height there | ||||||
|                                 } |                                 } | ||||||
|  | @ -179,7 +187,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
| 
 | 
 | ||||||
|                                     if (ShadowDebugContinue) |                                     if (ShadowDebugContinue) | ||||||
|                                     { |                                     { | ||||||
|                                         if ((x - 1 > 0) && (yr + 1 < (int)Constants.RegionSize)) |                                         if ((x - 1 > 0) && (yr + 1 < hm.Height)) | ||||||
|                                         { |                                         { | ||||||
|                                             color = mapbmp.GetPixel(x - 1, yr + 1); |                                             color = mapbmp.GetPixel(x - 1, yr + 1); | ||||||
|                                             int r = color.R; |                                             int r = color.R; | ||||||
|  | @ -233,7 +241,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
|                                 terraincorruptedwarningsaid = true; |                                 terraincorruptedwarningsaid = true; | ||||||
|                             } |                             } | ||||||
|                             Color black = Color.Black; |                             Color black = Color.Black; | ||||||
|                             mapbmp.SetPixel(x, ((int)Constants.RegionSize - y) - 1, black); |                             mapbmp.SetPixel(x, (hm.Width - y) - 1, black); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  | @ -242,4 +250,4 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | ||||||
|             m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); |             m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Robert Adams
						Robert Adams