diff options
author | Adam Frisby | 2007-07-23 05:29:52 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-23 05:29:52 +0000 |
commit | b8da9c3a64b84ab14642bad8c79d3b2ed62e62fb (patch) | |
tree | de4466ffdf017e140ec3aca9bb52cbe14e5e5b12 /OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | |
parent | Couple of small changes (diff) | |
download | opensim-SC_OLD-b8da9c3a64b84ab14642bad8c79d3b2ed62e62fb.zip opensim-SC_OLD-b8da9c3a64b84ab14642bad8c79d3b2ed62e62fb.tar.gz opensim-SC_OLD-b8da9c3a64b84ab14642bad8c79d3b2ed62e62fb.tar.bz2 opensim-SC_OLD-b8da9c3a64b84ab14642bad8c79d3b2ed62e62fb.tar.xz |
* Major style changes in libTerrain.Channel - now uses .NET-style naming syntax.
* Issue#218 - Updated mySQL region table.
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs index 2e40531..e5cc5ea 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | |||
@@ -109,13 +109,13 @@ namespace OpenSim.Region.Terrain | |||
109 | { | 109 | { |
110 | for (y = 0; y < h; y++) | 110 | for (y = 0; y < h; y++) |
111 | { | 111 | { |
112 | if ((heightmap.get(x, y) > revertmap.get(x, y) + maxRaise)) | 112 | if ((heightmap.Get(x, y) > revertmap.Get(x, y) + maxRaise)) |
113 | { | 113 | { |
114 | heightmap.map[x, y] = revertmap.get(x, y) + maxRaise; | 114 | heightmap.map[x, y] = revertmap.Get(x, y) + maxRaise; |
115 | } | 115 | } |
116 | if ((heightmap.get(x, y) > revertmap.get(x, y) - minLower)) | 116 | if ((heightmap.Get(x, y) > revertmap.Get(x, y) - minLower)) |
117 | { | 117 | { |
118 | heightmap.map[x, y] = revertmap.get(x, y) - minLower; | 118 | heightmap.map[x, y] = revertmap.Get(x, y) - minLower; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
@@ -192,7 +192,7 @@ namespace OpenSim.Region.Terrain | |||
192 | { | 192 | { |
193 | for (y = 0; y < h; y++) | 193 | for (y = 0; y < h; y++) |
194 | { | 194 | { |
195 | heightmap.set(x, y, (double)heights[x, y]); | 195 | heightmap.Set(x, y, (double)heights[x, y]); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | SaveRevertMap(); | 198 | SaveRevertMap(); |
@@ -210,7 +210,7 @@ namespace OpenSim.Region.Terrain | |||
210 | { | 210 | { |
211 | for (y = 0; y < h; y++) | 211 | for (y = 0; y < h; y++) |
212 | { | 212 | { |
213 | heightmap.set(x, y, heights[x, y]); | 213 | heightmap.Set(x, y, heights[x, y]); |
214 | } | 214 | } |
215 | } | 215 | } |
216 | SaveRevertMap(); | 216 | SaveRevertMap(); |
@@ -222,7 +222,7 @@ namespace OpenSim.Region.Terrain | |||
222 | /// </summary> | 222 | /// </summary> |
223 | public void SwapRevertMaps() | 223 | public void SwapRevertMaps() |
224 | { | 224 | { |
225 | Channel backup = heightmap.copy(); | 225 | Channel backup = heightmap.Copy(); |
226 | heightmap = revertmap; | 226 | heightmap = revertmap; |
227 | revertmap = backup; | 227 | revertmap = backup; |
228 | } | 228 | } |
@@ -232,7 +232,7 @@ namespace OpenSim.Region.Terrain | |||
232 | /// </summary> | 232 | /// </summary> |
233 | public void SaveRevertMap() | 233 | public void SaveRevertMap() |
234 | { | 234 | { |
235 | revertmap = heightmap.copy(); | 235 | revertmap = heightmap.Copy(); |
236 | } | 236 | } |
237 | 237 | ||
238 | /// <summary> | 238 | /// <summary> |
@@ -295,7 +295,7 @@ namespace OpenSim.Region.Terrain | |||
295 | double[] c = new double[2]; | 295 | double[] c = new double[2]; |
296 | c[0] = -1; | 296 | c[0] = -1; |
297 | c[1] = 1; | 297 | c[1] = 1; |
298 | heightmap.voronoiDiagram(Convert.ToInt32(args[1]), Convert.ToInt32(args[2]), c); | 298 | heightmap.VoronoiDiagram(Convert.ToInt32(args[1]), Convert.ToInt32(args[2]), c); |
299 | break; | 299 | break; |
300 | 300 | ||
301 | case "hills": | 301 | case "hills": |
@@ -331,7 +331,7 @@ namespace OpenSim.Region.Terrain | |||
331 | break; | 331 | break; |
332 | 332 | ||
333 | case "img": | 333 | case "img": |
334 | heightmap.loadImage(args[2]); | 334 | heightmap.LoadImage(args[2]); |
335 | return false; | 335 | return false; |
336 | 336 | ||
337 | default: | 337 | default: |
@@ -357,7 +357,7 @@ namespace OpenSim.Region.Terrain | |||
357 | break; | 357 | break; |
358 | 358 | ||
359 | case "png": | 359 | case "png": |
360 | heightmap.saveImage(args[2]); | 360 | heightmap.SaveImage(args[2]); |
361 | break; | 361 | break; |
362 | 362 | ||
363 | case "raw": | 363 | case "raw": |
@@ -412,12 +412,12 @@ namespace OpenSim.Region.Terrain | |||
412 | heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToDouble(args[5]), Convert.ToInt32(args[6]), Convert.ToBoolean(args[7]), true); | 412 | heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToDouble(args[5]), Convert.ToInt32(args[6]), Convert.ToBoolean(args[7]), true); |
413 | break; | 413 | break; |
414 | case "thermal": | 414 | case "thermal": |
415 | heightmap.thermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4])); | 415 | heightmap.ThermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4])); |
416 | break; | 416 | break; |
417 | case "hydraulic": | 417 | case "hydraulic": |
418 | Channel rainMap = new Channel(w, h); | 418 | Channel rainMap = new Channel(w, h); |
419 | rainMap.fill(Convert.ToDouble(args[2])); | 419 | rainMap.Fill(Convert.ToDouble(args[2])); |
420 | heightmap.hydraulicErosion(rainMap, Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); | 420 | heightmap.HydraulicErosion(rainMap, Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); |
421 | break; | 421 | break; |
422 | default: | 422 | default: |
423 | resultText = "Unknown erosion type"; | 423 | resultText = "Unknown erosion type"; |
@@ -459,16 +459,16 @@ namespace OpenSim.Region.Terrain | |||
459 | switch (args[1].ToLower()) | 459 | switch (args[1].ToLower()) |
460 | { | 460 | { |
461 | case "blocks": | 461 | case "blocks": |
462 | heightmap.hillsBlocks(count, sizeMin, sizeRange, island, additive, noisy); | 462 | heightmap.HillsBlocks(count, sizeMin, sizeRange, island, additive, noisy); |
463 | break; | 463 | break; |
464 | case "cones": | 464 | case "cones": |
465 | heightmap.hillsCones(count, sizeMin, sizeRange, island, additive, noisy); | 465 | heightmap.HillsCones(count, sizeMin, sizeRange, island, additive, noisy); |
466 | break; | 466 | break; |
467 | case "spheres": | 467 | case "spheres": |
468 | heightmap.hillsSpheres(count, sizeMin, sizeRange, island, additive, noisy); | 468 | heightmap.HillsSpheres(count, sizeMin, sizeRange, island, additive, noisy); |
469 | break; | 469 | break; |
470 | case "squared": | 470 | case "squared": |
471 | heightmap.hillsSquared(count, sizeMin, sizeRange, island, additive, noisy); | 471 | heightmap.HillsSquared(count, sizeMin, sizeRange, island, additive, noisy); |
472 | break; | 472 | break; |
473 | default: | 473 | default: |
474 | resultText = "Unknown hills type"; | 474 | resultText = "Unknown hills type"; |
@@ -485,7 +485,7 @@ namespace OpenSim.Region.Terrain | |||
485 | /// <param name="max">Maximum value of the new array</param> | 485 | /// <param name="max">Maximum value of the new array</param> |
486 | public void SetRange(float min, float max) | 486 | public void SetRange(float min, float max) |
487 | { | 487 | { |
488 | heightmap.normalise((double)min, (double)max); | 488 | heightmap.Normalise((double)min, (double)max); |
489 | tainted++; | 489 | tainted++; |
490 | } | 490 | } |
491 | 491 | ||
@@ -580,7 +580,7 @@ namespace OpenSim.Region.Terrain | |||
580 | { | 580 | { |
581 | for (y = 0; y < h; y++) | 581 | for (y = 0; y < h; y++) |
582 | { | 582 | { |
583 | bs.Write(heightmap.get(x, y)); | 583 | bs.Write(heightmap.Get(x, y)); |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
@@ -603,7 +603,7 @@ namespace OpenSim.Region.Terrain | |||
603 | { | 603 | { |
604 | for (y = 0; y < h; y++) | 604 | for (y = 0; y < h; y++) |
605 | { | 605 | { |
606 | bs.Write((float)heightmap.get(x, y)); | 606 | bs.Write((float)heightmap.Get(x, y)); |
607 | } | 607 | } |
608 | } | 608 | } |
609 | 609 | ||
@@ -625,8 +625,8 @@ namespace OpenSim.Region.Terrain | |||
625 | int x, y; | 625 | int x, y; |
626 | 626 | ||
627 | // Used for the 'green' channel. | 627 | // Used for the 'green' channel. |
628 | byte avgMultiplier = (byte)heightmap.avg(); | 628 | byte avgMultiplier = (byte)heightmap.Avg(); |
629 | byte backupMultiplier = (byte)revertmap.avg(); | 629 | byte backupMultiplier = (byte)revertmap.Avg(); |
630 | 630 | ||
631 | // Limit the multiplier so it can represent points >64m. | 631 | // Limit the multiplier so it can represent points >64m. |
632 | if (avgMultiplier > 196) | 632 | if (avgMultiplier > 196) |
@@ -643,9 +643,9 @@ namespace OpenSim.Region.Terrain | |||
643 | { | 643 | { |
644 | for (y = 0; y < h; y++) | 644 | for (y = 0; y < h; y++) |
645 | { | 645 | { |
646 | byte red = (byte)(heightmap.get(x, y) / ((double)avgMultiplier / 128.0)); | 646 | byte red = (byte)(heightmap.Get(x, y) / ((double)avgMultiplier / 128.0)); |
647 | byte green = avgMultiplier; | 647 | byte green = avgMultiplier; |
648 | byte blue = (byte)watermap.get(x, y); | 648 | byte blue = (byte)watermap.Get(x, y); |
649 | byte alpha1 = 0; // Land Parcels | 649 | byte alpha1 = 0; // Land Parcels |
650 | byte alpha2 = 0; // For Sale Land | 650 | byte alpha2 = 0; // For Sale Land |
651 | byte alpha3 = 0; // Public Edit Object | 651 | byte alpha3 = 0; // Public Edit Object |
@@ -654,7 +654,7 @@ namespace OpenSim.Region.Terrain | |||
654 | byte alpha6 = 255; // Flying Allowed | 654 | byte alpha6 = 255; // Flying Allowed |
655 | byte alpha7 = 255; // Create Landmark | 655 | byte alpha7 = 255; // Create Landmark |
656 | byte alpha8 = 255; // Outside Scripts | 656 | byte alpha8 = 255; // Outside Scripts |
657 | byte alpha9 = (byte)(revertmap.get(x, y) / ((double)backupMultiplier / 128.0)); | 657 | byte alpha9 = (byte)(revertmap.Get(x, y) / ((double)backupMultiplier / 128.0)); |
658 | byte alpha10 = backupMultiplier; | 658 | byte alpha10 = backupMultiplier; |
659 | 659 | ||
660 | binStream.Write(red); | 660 | binStream.Write(red); |
@@ -703,7 +703,7 @@ namespace OpenSim.Region.Terrain | |||
703 | { | 703 | { |
704 | for (y = 0; y < h; y++) | 704 | for (y = 0; y < h; y++) |
705 | { | 705 | { |
706 | double t = heightmap.get(x, y); | 706 | double t = heightmap.Get(x, y); |
707 | double min = double.MaxValue; | 707 | double min = double.MaxValue; |
708 | int index = 0; | 708 | int index = 0; |
709 | 709 | ||
@@ -718,7 +718,7 @@ namespace OpenSim.Region.Terrain | |||
718 | 718 | ||
719 | byte red = (byte)(index & 0xFF); | 719 | byte red = (byte)(index & 0xFF); |
720 | byte green = (byte)((index >> 8) & 0xFF); | 720 | byte green = (byte)((index >> 8) & 0xFF); |
721 | byte blue = (byte)watermap.get(x, y); | 721 | byte blue = (byte)watermap.Get(x, y); |
722 | byte alpha1 = 0; // Land Parcels | 722 | byte alpha1 = 0; // Land Parcels |
723 | byte alpha2 = 0; // For Sale Land | 723 | byte alpha2 = 0; // For Sale Land |
724 | byte alpha3 = 0; // Public Edit Object | 724 | byte alpha3 = 0; // Public Edit Object |
@@ -770,7 +770,7 @@ namespace OpenSim.Region.Terrain | |||
770 | { | 770 | { |
771 | lock (heightmap) | 771 | lock (heightmap) |
772 | { | 772 | { |
773 | heightmap.raise(rx, ry, size, amount); | 773 | heightmap.Raise(rx, ry, size, amount); |
774 | } | 774 | } |
775 | 775 | ||
776 | tainted++; | 776 | tainted++; |
@@ -787,7 +787,7 @@ namespace OpenSim.Region.Terrain | |||
787 | { | 787 | { |
788 | lock (heightmap) | 788 | lock (heightmap) |
789 | { | 789 | { |
790 | heightmap.lower(rx, ry, size, amount); | 790 | heightmap.Lower(rx, ry, size, amount); |
791 | } | 791 | } |
792 | 792 | ||
793 | tainted++; | 793 | tainted++; |
@@ -804,7 +804,7 @@ namespace OpenSim.Region.Terrain | |||
804 | { | 804 | { |
805 | lock (heightmap) | 805 | lock (heightmap) |
806 | { | 806 | { |
807 | heightmap.flatten(rx, ry, size, amount); | 807 | heightmap.Flatten(rx, ry, size, amount); |
808 | } | 808 | } |
809 | 809 | ||
810 | tainted++; | 810 | tainted++; |
@@ -822,12 +822,12 @@ namespace OpenSim.Region.Terrain | |||
822 | lock (heightmap) | 822 | lock (heightmap) |
823 | { | 823 | { |
824 | Channel smoothed = new Channel(); | 824 | Channel smoothed = new Channel(); |
825 | smoothed.noise(); | 825 | smoothed.Noise(); |
826 | 826 | ||
827 | Channel mask = new Channel(); | 827 | Channel mask = new Channel(); |
828 | mask.raise(rx, ry, size, amount); | 828 | mask.Raise(rx, ry, size, amount); |
829 | 829 | ||
830 | heightmap.blend(smoothed, mask); | 830 | heightmap.Blend(smoothed, mask); |
831 | } | 831 | } |
832 | 832 | ||
833 | tainted++; | 833 | tainted++; |
@@ -845,9 +845,9 @@ namespace OpenSim.Region.Terrain | |||
845 | lock (heightmap) | 845 | lock (heightmap) |
846 | { | 846 | { |
847 | Channel mask = new Channel(); | 847 | Channel mask = new Channel(); |
848 | mask.raise(rx, ry, size, amount); | 848 | mask.Raise(rx, ry, size, amount); |
849 | 849 | ||
850 | heightmap.blend(revertmap, mask); | 850 | heightmap.Blend(revertmap, mask); |
851 | } | 851 | } |
852 | 852 | ||
853 | tainted++; | 853 | tainted++; |
@@ -864,13 +864,13 @@ namespace OpenSim.Region.Terrain | |||
864 | { | 864 | { |
865 | lock (heightmap) | 865 | lock (heightmap) |
866 | { | 866 | { |
867 | Channel smoothed = heightmap.copy(); | 867 | Channel smoothed = heightmap.Copy(); |
868 | smoothed.smooth(amount); | 868 | smoothed.Smooth(amount); |
869 | 869 | ||
870 | Channel mask = new Channel(); | 870 | Channel mask = new Channel(); |
871 | mask.raise(rx,ry,size,amount); | 871 | mask.Raise(rx,ry,size,amount); |
872 | 872 | ||
873 | heightmap.blend(smoothed, mask); | 873 | heightmap.Blend(smoothed, mask); |
874 | } | 874 | } |
875 | 875 | ||
876 | tainted++; | 876 | tainted++; |
@@ -883,8 +883,8 @@ namespace OpenSim.Region.Terrain | |||
883 | { | 883 | { |
884 | lock (heightmap) | 884 | lock (heightmap) |
885 | { | 885 | { |
886 | heightmap.hillsSpheres(200, 20, 40, true, true, false); | 886 | heightmap.HillsSpheres(200, 20, 40, true, true, false); |
887 | heightmap.normalise(); | 887 | heightmap.Normalise(); |
888 | heightmap *= 60.0; // Raise to 60m | 888 | heightmap *= 60.0; // Raise to 60m |
889 | } | 889 | } |
890 | 890 | ||
@@ -899,7 +899,7 @@ namespace OpenSim.Region.Terrain | |||
899 | /// <returns>Height at specified coordinates</returns> | 899 | /// <returns>Height at specified coordinates</returns> |
900 | public double GetHeight(int x, int y) | 900 | public double GetHeight(int x, int y) |
901 | { | 901 | { |
902 | return heightmap.get(x, y); | 902 | return heightmap.Get(x, y); |
903 | } | 903 | } |
904 | 904 | ||
905 | /// <summary> | 905 | /// <summary> |
@@ -936,13 +936,13 @@ namespace OpenSim.Region.Terrain | |||
936 | colours[i] = gradientmapLd.GetPixel(0, i); | 936 | colours[i] = gradientmapLd.GetPixel(0, i); |
937 | } | 937 | } |
938 | 938 | ||
939 | Channel copy = heightmap.copy(); | 939 | Channel copy = heightmap.Copy(); |
940 | for (int x = 0; x < copy.w; x++) | 940 | for (int x = 0; x < copy.w; x++) |
941 | { | 941 | { |
942 | for (int y = 0; y < copy.h; y++) | 942 | for (int y = 0; y < copy.h; y++) |
943 | { | 943 | { |
944 | // 512 is the largest possible height before colours clamp | 944 | // 512 is the largest possible height before colours clamp |
945 | int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(x, y) / 512.0), 0.0) * (pallete - 1)); | 945 | int colorindex = (int)(Math.Max(Math.Min(1.0, copy.Get(x, y) / 512.0), 0.0) * (pallete - 1)); |
946 | bmp.SetPixel(x, y, colours[colorindex]); | 946 | bmp.SetPixel(x, y, colours[colorindex]); |
947 | } | 947 | } |
948 | } | 948 | } |
@@ -976,13 +976,13 @@ namespace OpenSim.Region.Terrain | |||
976 | colours[i] = gradientmapLd.GetPixel(0, i); | 976 | colours[i] = gradientmapLd.GetPixel(0, i); |
977 | } | 977 | } |
978 | 978 | ||
979 | Channel copy = heightmap.copy(); | 979 | Channel copy = heightmap.Copy(); |
980 | for (int x = 0; x < copy.w; x++) | 980 | for (int x = 0; x < copy.w; x++) |
981 | { | 981 | { |
982 | for (int y = 0; y < copy.h; y++) | 982 | for (int y = 0; y < copy.h; y++) |
983 | { | 983 | { |
984 | // 512 is the largest possible height before colours clamp | 984 | // 512 is the largest possible height before colours clamp |
985 | int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(copy.h - y, x) / 512.0), 0.0) * pallete); | 985 | int colorindex = (int)(Math.Max(Math.Min(1.0, copy.Get(copy.h - y, x) / 512.0), 0.0) * pallete); |
986 | bmp.SetPixel(x, y, colours[colorindex]); | 986 | bmp.SetPixel(x, y, colours[colorindex]); |
987 | } | 987 | } |
988 | } | 988 | } |