diff options
author | UbitUmarov | 2015-12-15 11:46:50 +0000 |
---|---|---|
committer | UbitUmarov | 2015-12-15 11:46:50 +0000 |
commit | 9db987b6f9d88b3a2cb77f50b43e9800e91bd610 (patch) | |
tree | 9cd2d9600336bee0ddd44ea0d5cb9799264fc93d | |
parent | dont round to nearest int when checking position in parcel since next high in... (diff) | |
download | opensim-SC-9db987b6f9d88b3a2cb77f50b43e9800e91bd610.zip opensim-SC-9db987b6f9d88b3a2cb77f50b43e9800e91bd610.tar.gz opensim-SC-9db987b6f9d88b3a2cb77f50b43e9800e91bd610.tar.bz2 opensim-SC-9db987b6f9d88b3a2cb77f50b43e9800e91bd610.tar.xz |
some changes parcels AABB math etc
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandObject.cs | 99 |
1 files changed, 45 insertions, 54 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index e1cd283..ed509fe 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -93,6 +93,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
93 | private Vector2 m_startPoint = Vector2.Zero; | 93 | private Vector2 m_startPoint = Vector2.Zero; |
94 | private Vector2 m_endPoint = Vector2.Zero; | 94 | private Vector2 m_endPoint = Vector2.Zero; |
95 | private Vector2 m_centerPoint = Vector2.Zero; | 95 | private Vector2 m_centerPoint = Vector2.Zero; |
96 | private Vector2 m_AABBmin = Vector2.Zero; | ||
97 | private Vector2 m_AABBmax = Vector2.Zero; | ||
96 | 98 | ||
97 | public Vector2 StartPoint | 99 | public Vector2 StartPoint |
98 | { | 100 | { |
@@ -757,7 +759,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
757 | /// </summary> | 759 | /// </summary> |
758 | public void ForceUpdateLandInfo() | 760 | public void ForceUpdateLandInfo() |
759 | { | 761 | { |
760 | UpdateAABBAndAreaValues(); | 762 | UpdateGeometryValues(); |
761 | UpdateLandBitmapByteArray(); | 763 | UpdateLandBitmapByteArray(); |
762 | } | 764 | } |
763 | 765 | ||
@@ -767,11 +769,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
767 | } | 769 | } |
768 | 770 | ||
769 | /// <summary> | 771 | /// <summary> |
770 | /// Updates the AABBMin and AABBMax values after area/shape modification of the land object | 772 | /// Updates geomtric values after area/shape modification of the land object |
771 | /// </summary> | 773 | /// </summary> |
772 | private void UpdateAABBAndAreaValues() | 774 | private void UpdateGeometryValues() |
773 | { | 775 | { |
774 | |||
775 | int min_x = Int32.MaxValue; | 776 | int min_x = Int32.MaxValue; |
776 | int min_y = Int32.MaxValue; | 777 | int min_y = Int32.MaxValue; |
777 | int max_x = Int32.MinValue; | 778 | int max_x = Int32.MinValue; |
@@ -784,7 +785,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
784 | float avgx = 0f; | 785 | float avgx = 0f; |
785 | float avgy = 0f; | 786 | float avgy = 0f; |
786 | 787 | ||
787 | bool needStart = true; | 788 | bool needFirst = true; |
788 | 789 | ||
789 | for (x = 0; x < LandBitmap.GetLength(0); x++) | 790 | for (x = 0; x < LandBitmap.GetLength(0); x++) |
790 | { | 791 | { |
@@ -801,16 +802,17 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
801 | if (max_y < y) | 802 | if (max_y < y) |
802 | max_y = y; | 803 | max_y = y; |
803 | 804 | ||
804 | if(needStart) | 805 | if(needFirst) |
805 | { | 806 | { |
806 | avgx = x; | 807 | avgx = x; |
807 | avgy = y; | 808 | avgy = y; |
808 | m_startPoint.X = x * landUnit; | 809 | m_startPoint.X = x * landUnit; |
809 | m_startPoint.Y = y * landUnit; | 810 | m_startPoint.Y = y * landUnit; |
810 | needStart = false; | 811 | needFirst = false; |
811 | } | 812 | } |
812 | else | 813 | else |
813 | { | 814 | { |
815 | // keeping previus odd average | ||
814 | avgx = (avgx * tempArea + x) / (tempArea + 1); | 816 | avgx = (avgx * tempArea + x) / (tempArea + 1); |
815 | avgy = (avgy * tempArea + y) / (tempArea + 1); | 817 | avgy = (avgy * tempArea + y) / (tempArea + 1); |
816 | } | 818 | } |
@@ -831,46 +833,52 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
831 | m_endPoint.X = lastX * landUnit + landUnit; | 833 | m_endPoint.X = lastX * landUnit + landUnit; |
832 | m_endPoint.Y = lastY * landUnit + landUnit; | 834 | m_endPoint.Y = lastY * landUnit + landUnit; |
833 | 835 | ||
836 | // next tests should not be needed | ||
837 | // if they fail, something is wrong | ||
838 | |||
839 | int regionSizeX = (int)Constants.RegionSize; | ||
840 | int regionSizeY = (int)Constants.RegionSize; | ||
841 | |||
842 | if(m_scene != null) | ||
843 | { | ||
844 | regionSizeX = (int)m_scene.RegionInfo.RegionSizeX; | ||
845 | regionSizeY = (int)m_scene.RegionInfo.RegionSizeX; | ||
846 | } | ||
847 | |||
834 | int tx = min_x * landUnit; | 848 | int tx = min_x * landUnit; |
835 | if (tx > ((int)m_scene.RegionInfo.RegionSizeX - 1)) | 849 | if (tx >= regionSizeX) |
836 | tx = ((int)m_scene.RegionInfo.RegionSizeX - 1); | 850 | tx = regionSizeX - 1; |
837 | int htx; | ||
838 | if (tx >= ((int)m_scene.RegionInfo.RegionSizeX)) | ||
839 | htx = (int)m_scene.RegionInfo.RegionSizeX - 1; | ||
840 | else | ||
841 | htx = tx; | ||
842 | |||
843 | int ty = min_y * landUnit; | ||
844 | int hty; | ||
845 | 851 | ||
846 | if (ty >= ((int)m_scene.RegionInfo.RegionSizeY)) | 852 | int ty = min_y * landUnit; |
847 | hty = (int)m_scene.RegionInfo.RegionSizeY - 1; | 853 | if (ty >= regionSizeY) |
848 | else | 854 | ty = regionSizeY - 1; |
849 | hty = ty; | ||
850 | 855 | ||
851 | LandData.AABBMin = | 856 | m_AABBmin.X = tx; |
852 | new Vector3( | 857 | m_AABBmin.Y = ty; |
853 | (float)(tx), (float)(ty), m_scene != null ? (float)m_scene.Heightmap[htx, hty] : 0); | ||
854 | 858 | ||
859 | if(m_scene == null) | ||
860 | LandData.AABBMin = new Vector3(tx, ty, 0f); | ||
861 | else | ||
862 | LandData.AABBMin = new Vector3(tx, ty, (float)m_scene.Heightmap[tx, ty]); | ||
863 | |||
855 | max_x++; | 864 | max_x++; |
856 | tx = max_x * landUnit; | 865 | tx = max_x * landUnit; |
857 | if (tx >= ((int)m_scene.RegionInfo.RegionSizeX)) | 866 | if (tx > regionSizeX) |
858 | htx = (int)m_scene.RegionInfo.RegionSizeX - 1; | 867 | tx = regionSizeX; |
859 | else | ||
860 | htx = tx; | ||
861 | 868 | ||
862 | max_y++; | 869 | max_y++; |
863 | ty = max_y * 4; | 870 | ty = max_y * landUnit; |
864 | 871 | if (ty > regionSizeY) | |
865 | if (ty >= ((int)m_scene.RegionInfo.RegionSizeY)) | 872 | ty = regionSizeY; |
866 | hty = (int)m_scene.RegionInfo.RegionSizeY - 1; | ||
867 | else | ||
868 | hty = ty; | ||
869 | 873 | ||
870 | LandData.AABBMax | 874 | m_AABBmax.X = tx; |
871 | = new Vector3( | 875 | m_AABBmax.Y = ty; |
872 | (float)(tx), (float)(ty), m_scene != null ? (float)m_scene.Heightmap[htx, hty] : 0); | ||
873 | 876 | ||
877 | if(m_scene == null) | ||
878 | LandData.AABBMax = new Vector3(tx, ty, 0f); | ||
879 | else | ||
880 | LandData.AABBMax = new Vector3(tx, ty, (float)m_scene.Heightmap[tx - 1, ty - 1]); | ||
881 | |||
874 | LandData.Area = tempArea * landUnit * landUnit; | 882 | LandData.Area = tempArea * landUnit * landUnit; |
875 | } | 883 | } |
876 | 884 | ||
@@ -1223,23 +1231,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1223 | if(tempByte != 0 && byteNum < 512) | 1231 | if(tempByte != 0 && byteNum < 512) |
1224 | tempConvertArr[byteNum] = (byte)tempByte; | 1232 | tempConvertArr[byteNum] = (byte)tempByte; |
1225 | 1233 | ||
1226 | |||
1227 | /* | ||
1228 | tempByte = Convert.ToByte(tempByte | Convert.ToByte(LandBitmap[x, y]) << (i++ % 8)); | ||
1229 | if (i % 8 == 0) | ||
1230 | { | ||
1231 | tempConvertArr[byteNum] = tempByte; | ||
1232 | tempByte = (byte) 0; | ||
1233 | i = 0; | ||
1234 | byteNum++; | ||
1235 | } | ||
1236 | <<<<<<< HEAD | ||
1237 | } | ||
1238 | } | ||
1239 | // m_log.DebugFormat("{0} ConvertLandBitmapToBytes. BitmapSize=<{1},{2}>", | ||
1240 | // LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1)); | ||
1241 | ======= | ||
1242 | */ | ||
1243 | return tempConvertArr; | 1234 | return tempConvertArr; |
1244 | } | 1235 | } |
1245 | 1236 | ||