diff options
author | UbitUmarov | 2015-12-14 11:57:24 +0000 |
---|---|---|
committer | UbitUmarov | 2015-12-14 11:57:24 +0000 |
commit | 2a354f6c286b4b70e2768d9b267f53c3d391a10b (patch) | |
tree | 7a162221d865ed9e10c0d9049cd82d705bb4c6d6 /OpenSim/Region/CoreModules/World/Land | |
parent | taint prim count when join or subdivide parcels (diff) | |
download | opensim-SC-2a354f6c286b4b70e2768d9b267f53c3d391a10b.zip opensim-SC-2a354f6c286b4b70e2768d9b267f53c3d391a10b.tar.gz opensim-SC-2a354f6c286b4b70e2768d9b267f53c3d391a10b.tar.bz2 opensim-SC-2a354f6c286b4b70e2768d9b267f53c3d391a10b.tar.xz |
calculate land startpoint, endpoint and center estimate when it is updated, it not every time they are needed
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Land')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandObject.cs | 82 |
1 files changed, 53 insertions, 29 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 28652d7..e1cd283 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -90,43 +90,32 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
90 | get { return m_scene.RegionInfo.RegionID; } | 90 | get { return m_scene.RegionInfo.RegionID; } |
91 | } | 91 | } |
92 | 92 | ||
93 | public Vector3 StartPoint | 93 | private Vector2 m_startPoint = Vector2.Zero; |
94 | private Vector2 m_endPoint = Vector2.Zero; | ||
95 | private Vector2 m_centerPoint = Vector2.Zero; | ||
96 | |||
97 | public Vector2 StartPoint | ||
94 | { | 98 | { |
95 | get | 99 | get |
96 | { | 100 | { |
97 | for (int y = 0; y < LandBitmap.GetLength(1); y++) | 101 | return m_startPoint; |
98 | { | ||
99 | for (int x = 0; x < LandBitmap.GetLength(0); x++) | ||
100 | { | ||
101 | if (LandBitmap[x, y]) | ||
102 | return new Vector3(x * landUnit, y * landUnit, 0); | ||
103 | } | ||
104 | } | ||
105 | |||
106 | m_log.ErrorFormat("{0} StartPoint. No start point found. bitmapSize=<{1},{2}>", | ||
107 | LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1)); | ||
108 | return new Vector3(-1, -1, -1); | ||
109 | } | 102 | } |
110 | } | 103 | } |
111 | 104 | ||
112 | public Vector3 EndPoint | 105 | public Vector2 EndPoint |
113 | { | 106 | { |
114 | get | 107 | get |
115 | { | 108 | { |
116 | for (int y = LandBitmap.GetLength(1) - 1; y >= 0; y--) | 109 | return m_endPoint; |
117 | { | 110 | } |
118 | for (int x = LandBitmap.GetLength(0) - 1; x >= 0; x--) | 111 | } |
119 | { | ||
120 | if (LandBitmap[x, y]) | ||
121 | { | ||
122 | return new Vector3(x * landUnit + landUnit, y * landUnit + landUnit, 0); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | 112 | ||
127 | m_log.ErrorFormat("{0} EndPoint. No end point found. bitmapSize=<{1},{2}>", | 113 | //estimate a center point of a parcel |
128 | LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1)); | 114 | public Vector2 CenterPoint |
129 | return new Vector3(-1, -1, -1); | 115 | { |
116 | get | ||
117 | { | ||
118 | return m_centerPoint; | ||
130 | } | 119 | } |
131 | } | 120 | } |
132 | 121 | ||
@@ -789,6 +778,14 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
789 | int max_y = Int32.MinValue; | 778 | int max_y = Int32.MinValue; |
790 | int tempArea = 0; | 779 | int tempArea = 0; |
791 | int x, y; | 780 | int x, y; |
781 | |||
782 | int lastX = 0; | ||
783 | int lastY = 0; | ||
784 | float avgx = 0f; | ||
785 | float avgy = 0f; | ||
786 | |||
787 | bool needStart = true; | ||
788 | |||
792 | for (x = 0; x < LandBitmap.GetLength(0); x++) | 789 | for (x = 0; x < LandBitmap.GetLength(0); x++) |
793 | { | 790 | { |
794 | for (y = 0; y < LandBitmap.GetLength(1); y++) | 791 | for (y = 0; y < LandBitmap.GetLength(1); y++) |
@@ -803,10 +800,37 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
803 | max_x = x; | 800 | max_x = x; |
804 | if (max_y < y) | 801 | if (max_y < y) |
805 | max_y = y; | 802 | max_y = y; |
806 | tempArea += landUnit * landUnit; //16sqm peice of land | 803 | |
804 | if(needStart) | ||
805 | { | ||
806 | avgx = x; | ||
807 | avgy = y; | ||
808 | m_startPoint.X = x * landUnit; | ||
809 | m_startPoint.Y = y * landUnit; | ||
810 | needStart = false; | ||
811 | } | ||
812 | else | ||
813 | { | ||
814 | avgx = (avgx * tempArea + x) / (tempArea + 1); | ||
815 | avgy = (avgy * tempArea + y) / (tempArea + 1); | ||
816 | } | ||
817 | |||
818 | tempArea++; | ||
819 | |||
820 | lastX = x; | ||
821 | lastY = y; | ||
807 | } | 822 | } |
808 | } | 823 | } |
809 | } | 824 | } |
825 | |||
826 | int halfunit = landUnit/2; | ||
827 | |||
828 | m_centerPoint.X = avgx * landUnit + halfunit; | ||
829 | m_centerPoint.Y = avgy * landUnit + halfunit; | ||
830 | |||
831 | m_endPoint.X = lastX * landUnit + landUnit; | ||
832 | m_endPoint.Y = lastY * landUnit + landUnit; | ||
833 | |||
810 | int tx = min_x * landUnit; | 834 | int tx = min_x * landUnit; |
811 | if (tx > ((int)m_scene.RegionInfo.RegionSizeX - 1)) | 835 | if (tx > ((int)m_scene.RegionInfo.RegionSizeX - 1)) |
812 | tx = ((int)m_scene.RegionInfo.RegionSizeX - 1); | 836 | tx = ((int)m_scene.RegionInfo.RegionSizeX - 1); |
@@ -847,7 +871,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
847 | = new Vector3( | 871 | = new Vector3( |
848 | (float)(tx), (float)(ty), m_scene != null ? (float)m_scene.Heightmap[htx, hty] : 0); | 872 | (float)(tx), (float)(ty), m_scene != null ? (float)m_scene.Heightmap[htx, hty] : 0); |
849 | 873 | ||
850 | LandData.Area = tempArea; | 874 | LandData.Area = tempArea * landUnit * landUnit; |
851 | } | 875 | } |
852 | 876 | ||
853 | #endregion | 877 | #endregion |