- Timestamp:
- Jul 3, 2015, 4:16:11 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/MapRendering/MapRendering.cs
r235 r238 24 24 private static object lockObject = new object (); 25 25 private MapRenderBlockBuffer[] zoomLevelBuffers; 26 private Dictionary<Vector2i, Color []> dirtyChunks = new Dictionary<Vector2i, Color[]> ();26 private Dictionary<Vector2i, Color32[]> dirtyChunks = new Dictionary<Vector2i, Color32[]> (); 27 27 private System.Timers.Timer chunkSaveTimer = new System.Timers.Timer (500); 28 28 private bool renderingFullMap = false; … … 37 37 private MapRendering () 38 38 { 39 Constants.MAP_DIRECTORY = StaticDirectories.GetSaveGameDir () + "/map";39 Constants.MAP_DIRECTORY = GameUtils.GetSaveGameDir () + "/map"; 40 40 41 41 lock (lockObject) { … … 69 69 ushort[] mapColors = c.GetMapColors (); 70 70 if (mapColors != null) { 71 Color [] realColors = new Color[Constants.MAP_CHUNK_SIZE * Constants.MAP_CHUNK_SIZE];71 Color32[] realColors = new Color32[Constants.MAP_CHUNK_SIZE * Constants.MAP_CHUNK_SIZE]; 72 72 for (int i_colors = 0; i_colors < mapColors.Length; i_colors++) { 73 realColors [i_colors] = shortColorToColor (mapColors [i_colors]);73 realColors [i_colors] = shortColorToColor32 (mapColors [i_colors]); 74 74 } 75 75 Instance.dirtyChunks [cPos2] = realColors; … … 91 91 MicroStopwatch microStopwatch = new MicroStopwatch (); 92 92 93 string regionSaveDir = StaticDirectories.GetSaveGameRegionDir ();93 string regionSaveDir = GameUtils.GetSaveGameRegionDir (); 94 94 RegionFileManager rfm = new RegionFileManager (regionSaveDir, regionSaveDir, 0, false); 95 95 Texture2D fullMapTexture = null; … … 119 119 renderingFullMap = true; 120 120 121 if (widthPix <= 8 000 && heightPix <= 8000)121 if (widthPix <= 8192 && heightPix <= 8192) 122 122 fullMapTexture = new Texture2D (widthPix, heightPix); 123 123 … … 135 135 ushort[] mapColors = c.GetMapColors (); 136 136 if (mapColors != null) { 137 Color [] realColors = new Color[Constants.MAP_CHUNK_SIZE * Constants.MAP_CHUNK_SIZE];137 Color32[] realColors = new Color32[Constants.MAP_CHUNK_SIZE * Constants.MAP_CHUNK_SIZE]; 138 138 for (int i_colors = 0; i_colors < mapColors.Length; i_colors++) { 139 realColors [i_colors] = shortColorToColor (mapColors [i_colors]);139 realColors [i_colors] = shortColorToColor32 (mapColors [i_colors]); 140 140 } 141 141 dirtyChunks [curChunkPos] = realColors; 142 142 if (fullMapTexture != null) 143 fullMapTexture.SetPixels (curFullMapPos.x, curFullMapPos.y, Constants.MAP_CHUNK_SIZE, Constants.MAP_CHUNK_SIZE, realColors);143 fullMapTexture.SetPixels32 (curFullMapPos.x, curFullMapPos.y, Constants.MAP_CHUNK_SIZE, Constants.MAP_CHUNK_SIZE, realColors); 144 144 } 145 145 } … … 160 160 byte[] array = fullMapTexture.EncodeToPNG (); 161 161 File.WriteAllBytes (Constants.MAP_DIRECTORY + "/map.png", array); 162 Texture2D.Destroy (fullMapTexture);162 UnityEngine.Object.Destroy (fullMapTexture); 163 163 fullMapTexture = null; 164 164 } … … 337 337 } 338 338 339 private static Color32 shortColorToColor32 (ushort col) 340 { 341 byte r = (byte)(256 * (col >> 10 & 31) / 32); 342 byte g = (byte)(256 * (col >> 5 & 31) / 32); 343 byte b = (byte)(256 * (col & 31) / 32); 344 byte a = 255; 345 return new Color32 (r, g, b, a); 346 } 339 347 } 340 348 }
Note:
See TracChangeset
for help on using the changeset viewer.