aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs514
1 files changed, 123 insertions, 391 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 56f3786..6e4c373 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -137,6 +137,7 @@ namespace OpenSim.Region.Physics.OdePlugin
137 VehicleVectorParam, 137 VehicleVectorParam,
138 VehicleRotationParam, 138 VehicleRotationParam,
139 VehicleFlags, 139 VehicleFlags,
140 SetVehicle,
140 141
141 Null //keep this last used do dim the methods array. does nothing but pulsing the prim 142 Null //keep this last used do dim the methods array. does nothing but pulsing the prim
142 } 143 }
@@ -166,8 +167,8 @@ namespace OpenSim.Region.Physics.OdePlugin
166 167
167 float frictionMovementMult = 0.3f; 168 float frictionMovementMult = 0.3f;
168 169
169 float TerrainBounce = 0.3f; 170 float TerrainBounce = 0.1f;
170 float TerrainFriction = 0.3f; 171 float TerrainFriction = 0.1f;
171 172
172 public float AvatarBounce = 0.3f; 173 public float AvatarBounce = 0.3f;
173 public float AvatarFriction = 0;// 0.9f * 0.5f; 174 public float AvatarFriction = 0;// 0.9f * 0.5f;
@@ -989,145 +990,62 @@ namespace OpenSim.Region.Physics.OdePlugin
989 /// <param name="timeStep"></param> 990 /// <param name="timeStep"></param>
990 private void collision_optimized() 991 private void collision_optimized()
991 { 992 {
992// _perloopContact.Clear();
993// clear characts IsColliding until we do it some other way
994
995 lock (_characters) 993 lock (_characters)
996 { 994 {
997 foreach (OdeCharacter chr in _characters) 995 try
996 {
997 foreach (OdeCharacter chr in _characters)
998 { 998 {
999 // this are odd checks if they are needed something is wrong elsewhere 999 if (chr == null || chr.Shell == IntPtr.Zero || chr.Body == IntPtr.Zero)
1000 // keep for now 1000 continue;
1001 if (chr == null) 1001
1002 continue; 1002 chr.IsColliding = false;
1003 1003 // chr.CollidingGround = false; not done here
1004 if (chr.Shell == IntPtr.Zero || chr.Body == IntPtr.Zero) 1004 chr.CollidingObj = false;
1005 continue; 1005 // do colisions with static space
1006 1006 d.SpaceCollide2(StaticSpace, chr.Shell, IntPtr.Zero, nearCallback);
1007 chr.IsColliding = false;
1008 // chr.CollidingGround = false; not done here
1009 chr.CollidingObj = false;
1010 } 1007 }
1011 } 1008 }
1012 1009 catch (AccessViolationException)
1013 // now let ode do its job
1014 // colide active things amoung them
1015
1016 int st = Util.EnvironmentTickCount();
1017 int ta;
1018 int ts;
1019 try
1020 {
1021 d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback);
1022 }
1023 catch (AccessViolationException)
1024 { 1010 {
1025 m_log.Warn("[PHYSICS]: Unable to Active space collide"); 1011 m_log.Warn("[PHYSICS]: Unable to collide Character to static space");
1026 } 1012 }
1027 ta = Util.EnvironmentTickCountSubtract(st); 1013
1028 // then active things with static enviroment 1014 }
1029 try 1015
1016 // collide active prims with static enviroment
1017 lock (_activeprims)
1018 {
1019 try
1030 { 1020 {
1031 d.SpaceCollide2(ActiveSpace,StaticSpace, IntPtr.Zero, nearCallback); 1021 foreach (OdePrim prm in _activeprims)
1022 {
1023 if (d.BodyIsEnabled(prm.Body))
1024 d.SpaceCollide2(StaticSpace, prm.prim_geom, IntPtr.Zero, nearCallback);
1025 }
1032 } 1026 }
1033 catch (AccessViolationException) 1027 catch (AccessViolationException)
1034 { 1028 {
1035 m_log.Warn("[PHYSICS]: Unable to Active to static space collide"); 1029 m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space");
1036 } 1030 }
1037 ts = Util.EnvironmentTickCountSubtract(st);
1038// _perloopContact.Clear();
1039 }
1040
1041 #endregion
1042
1043
1044 public float GetTerrainHeightAtXY(float x, float y)
1045 {
1046 // assumes 1m size grid and constante size square regions
1047 // region offset in mega position
1048
1049 int offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
1050 int offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
1051
1052 IntPtr heightFieldGeom = IntPtr.Zero;
1053
1054 // get region map
1055 if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom))
1056 return 0f;
1057
1058 if (heightFieldGeom == IntPtr.Zero)
1059 return 0f;
1060
1061 if (!TerrainHeightFieldHeights.ContainsKey(heightFieldGeom))
1062 return 0f;
1063
1064 // TerrainHeightField for ODE as offset 1m
1065 x += 1f - offsetX;
1066 y += 1f - offsetY;
1067
1068 // make position fit into array
1069 if (x < 0)
1070 x = 0;
1071 if (y < 0)
1072 y = 0;
1073
1074 // integer indexs
1075 int ix;
1076 int iy;
1077 // interpolators offset
1078 float dx;
1079 float dy;
1080
1081 int regsize = (int)Constants.RegionSize + 2; // map size see setterrain
1082
1083 // we still have square fixed size regions
1084 // also flip x and y because of how map is done for ODE fliped axis
1085 // so ix,iy,dx and dy are inter exchanged
1086 if (x < regsize - 1)
1087 {
1088 iy = (int)x;
1089 dy = x - (float)iy;
1090 }
1091 else // out world use external height
1092 {
1093 iy = regsize - 1;
1094 dy = 0;
1095 } 1031 }
1096 if (y < regsize - 1) 1032
1033 // finally colide active things amoung them
1034 try
1097 { 1035 {
1098 ix = (int)y; 1036 d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback);
1099 dx = y - (float)ix;
1100 } 1037 }
1101 else 1038 catch (AccessViolationException)
1102 { 1039 {
1103 ix = regsize - 1; 1040 m_log.Warn("[PHYSICS]: Unable to collide in Active space");
1104 dx = 0;
1105 } 1041 }
1106 1042
1107 float h0; 1043// _perloopContact.Clear();
1108 float h1; 1044 }
1109 float h2;
1110
1111 iy *= regsize;
1112 iy += ix; // all indexes have iy + ix
1113 1045
1114 float[] heights = TerrainHeightFieldHeights[heightFieldGeom]; 1046 #endregion
1115 1047
1116 if ((dx + dy) <= 1.0f)
1117 {
1118 h0 = ((float)heights[iy]); // 0,0 vertice
1119 h1 = (((float)heights[iy + 1]) - h0) * dx; // 1,0 vertice minus 0,0
1120 h2 = (((float)heights[iy + regsize]) - h0) * dy; // 0,1 vertice minus 0,0
1121 }
1122 else
1123 {
1124 h0 = ((float)heights[iy + regsize + 1]); // 1,1 vertice
1125 h1 = (((float)heights[iy + 1]) - h0) * (1 - dy); // 1,1 vertice minus 1,0
1126 h2 = (((float)heights[iy + regsize]) - h0) * (1 - dx); // 1,1 vertice minus 0,1
1127 }
1128 1048
1129 return h0 + h1 + h2;
1130 }
1131 1049
1132 /// <summary> 1050 /// <summary>
1133 /// Add actor to the list that should receive collision events in the simulate loop. 1051 /// Add actor to the list that should receive collision events in the simulate loop.
@@ -1835,273 +1753,94 @@ namespace OpenSim.Region.Physics.OdePlugin
1835 get { return (false); } 1753 get { return (false); }
1836 } 1754 }
1837 1755
1838 #region ODE Specific Terrain Fixes 1756 public float GetTerrainHeightAtXY(float x, float y)
1839 public float[] ResizeTerrain512NearestNeighbour(float[] heightMap)
1840 { 1757 {
1841 float[] returnarr = new float[262144]; 1758 // assumes 1m size grid and constante size square regions
1842 float[,] resultarr = new float[(int)WorldExtents.X, (int)WorldExtents.Y]; 1759 // needs to know about sims around in future
1760 // region offset in mega position
1843 1761
1844 // Filling out the array into its multi-dimensional components 1762 int offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
1845 for (int y = 0; y < WorldExtents.Y; y++) 1763 int offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
1846 {
1847 for (int x = 0; x < WorldExtents.X; x++)
1848 {
1849 resultarr[y, x] = heightMap[y * (int)WorldExtents.Y + x];
1850 }
1851 }
1852 1764
1853 // Resize using Nearest Neighbour 1765 IntPtr heightFieldGeom = IntPtr.Zero;
1854
1855 // This particular way is quick but it only works on a multiple of the original
1856
1857 // The idea behind this method can be described with the following diagrams
1858 // second pass and third pass happen in the same loop really.. just separated
1859 // them to show what this does.
1860
1861 // First Pass
1862 // ResultArr:
1863 // 1,1,1,1,1,1
1864 // 1,1,1,1,1,1
1865 // 1,1,1,1,1,1
1866 // 1,1,1,1,1,1
1867 // 1,1,1,1,1,1
1868 // 1,1,1,1,1,1
1869
1870 // Second Pass
1871 // ResultArr2:
1872 // 1,,1,,1,,1,,1,,1,
1873 // ,,,,,,,,,,
1874 // 1,,1,,1,,1,,1,,1,
1875 // ,,,,,,,,,,
1876 // 1,,1,,1,,1,,1,,1,
1877 // ,,,,,,,,,,
1878 // 1,,1,,1,,1,,1,,1,
1879 // ,,,,,,,,,,
1880 // 1,,1,,1,,1,,1,,1,
1881 // ,,,,,,,,,,
1882 // 1,,1,,1,,1,,1,,1,
1883
1884 // Third pass fills in the blanks
1885 // ResultArr2:
1886 // 1,1,1,1,1,1,1,1,1,1,1,1
1887 // 1,1,1,1,1,1,1,1,1,1,1,1
1888 // 1,1,1,1,1,1,1,1,1,1,1,1
1889 // 1,1,1,1,1,1,1,1,1,1,1,1
1890 // 1,1,1,1,1,1,1,1,1,1,1,1
1891 // 1,1,1,1,1,1,1,1,1,1,1,1
1892 // 1,1,1,1,1,1,1,1,1,1,1,1
1893 // 1,1,1,1,1,1,1,1,1,1,1,1
1894 // 1,1,1,1,1,1,1,1,1,1,1,1
1895 // 1,1,1,1,1,1,1,1,1,1,1,1
1896 // 1,1,1,1,1,1,1,1,1,1,1,1
1897
1898 // X,Y = .
1899 // X+1,y = ^
1900 // X,Y+1 = *
1901 // X+1,Y+1 = #
1902
1903 // Filling in like this;
1904 // .*
1905 // ^#
1906 // 1st .
1907 // 2nd *
1908 // 3rd ^
1909 // 4th #
1910 // on single loop.
1911
1912 float[,] resultarr2 = new float[512, 512];
1913 for (int y = 0; y < WorldExtents.Y; y++)
1914 {
1915 for (int x = 0; x < WorldExtents.X; x++)
1916 {
1917 resultarr2[y * 2, x * 2] = resultarr[y, x];
1918 1766
1919 if (y < WorldExtents.Y) 1767 // get region map
1920 { 1768 if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom))
1921 resultarr2[(y * 2) + 1, x * 2] = resultarr[y, x]; 1769 return 0f;
1922 }
1923 if (x < WorldExtents.X)
1924 {
1925 resultarr2[y * 2, (x * 2) + 1] = resultarr[y, x];
1926 }
1927 if (x < WorldExtents.X && y < WorldExtents.Y)
1928 {
1929 resultarr2[(y * 2) + 1, (x * 2) + 1] = resultarr[y, x];
1930 }
1931 }
1932 }
1933 1770
1934 //Flatten out the array 1771 if (heightFieldGeom == IntPtr.Zero)
1935 int i = 0; 1772 return 0f;
1936 for (int y = 0; y < 512; y++)
1937 {
1938 for (int x = 0; x < 512; x++)
1939 {
1940 if (resultarr2[y, x] <= 0)
1941 returnarr[i] = 0.0000001f;
1942 else
1943 returnarr[i] = resultarr2[y, x];
1944 1773
1945 i++; 1774 if (!TerrainHeightFieldHeights.ContainsKey(heightFieldGeom))
1946 } 1775 return 0f;
1947 }
1948 1776
1949 return returnarr; 1777 // TerrainHeightField for ODE as offset 1m
1950 } 1778 x += 1f - offsetX;
1779 y += 1f - offsetY;
1951 1780
1952 public float[] ResizeTerrain512Interpolation(float[] heightMap) 1781 // make position fit into array
1953 { 1782 if (x < 0)
1954 float[] returnarr = new float[262144]; 1783 x = 0;
1955 float[,] resultarr = new float[512,512]; 1784 if (y < 0)
1785 y = 0;
1786
1787 // integer indexs
1788 int ix;
1789 int iy;
1790 // interpolators offset
1791 float dx;
1792 float dy;
1793
1794 int regsize = (int)Constants.RegionSize + 3; // map size see setterrain number of samples
1956 1795
1957 // Filling out the array into its multi-dimensional components 1796 // we still have square fixed size regions
1958 for (int y = 0; y < 256; y++) 1797 // also flip x and y because of how map is done for ODE fliped axis
1798 // so ix,iy,dx and dy are inter exchanged
1799 if (x < regsize - 1)
1959 { 1800 {
1960 for (int x = 0; x < 256; x++) 1801 iy = (int)x;
1961 { 1802 dy = x - (float)iy;
1962 resultarr[y, x] = heightMap[y * 256 + x];
1963 }
1964 } 1803 }
1965 1804 else // out world use external height
1966 // Resize using interpolation
1967
1968 // This particular way is quick but it only works on a multiple of the original
1969
1970 // The idea behind this method can be described with the following diagrams
1971 // second pass and third pass happen in the same loop really.. just separated
1972 // them to show what this does.
1973
1974 // First Pass
1975 // ResultArr:
1976 // 1,1,1,1,1,1
1977 // 1,1,1,1,1,1
1978 // 1,1,1,1,1,1
1979 // 1,1,1,1,1,1
1980 // 1,1,1,1,1,1
1981 // 1,1,1,1,1,1
1982
1983 // Second Pass
1984 // ResultArr2:
1985 // 1,,1,,1,,1,,1,,1,
1986 // ,,,,,,,,,,
1987 // 1,,1,,1,,1,,1,,1,
1988 // ,,,,,,,,,,
1989 // 1,,1,,1,,1,,1,,1,
1990 // ,,,,,,,,,,
1991 // 1,,1,,1,,1,,1,,1,
1992 // ,,,,,,,,,,
1993 // 1,,1,,1,,1,,1,,1,
1994 // ,,,,,,,,,,
1995 // 1,,1,,1,,1,,1,,1,
1996
1997 // Third pass fills in the blanks
1998 // ResultArr2:
1999 // 1,1,1,1,1,1,1,1,1,1,1,1
2000 // 1,1,1,1,1,1,1,1,1,1,1,1
2001 // 1,1,1,1,1,1,1,1,1,1,1,1
2002 // 1,1,1,1,1,1,1,1,1,1,1,1
2003 // 1,1,1,1,1,1,1,1,1,1,1,1
2004 // 1,1,1,1,1,1,1,1,1,1,1,1
2005 // 1,1,1,1,1,1,1,1,1,1,1,1
2006 // 1,1,1,1,1,1,1,1,1,1,1,1
2007 // 1,1,1,1,1,1,1,1,1,1,1,1
2008 // 1,1,1,1,1,1,1,1,1,1,1,1
2009 // 1,1,1,1,1,1,1,1,1,1,1,1
2010
2011 // X,Y = .
2012 // X+1,y = ^
2013 // X,Y+1 = *
2014 // X+1,Y+1 = #
2015
2016 // Filling in like this;
2017 // .*
2018 // ^#
2019 // 1st .
2020 // 2nd *
2021 // 3rd ^
2022 // 4th #
2023 // on single loop.
2024
2025 float[,] resultarr2 = new float[512,512];
2026 for (int y = 0; y < (int)Constants.RegionSize; y++)
2027 { 1805 {
2028 for (int x = 0; x < (int)Constants.RegionSize; x++) 1806 iy = regsize - 1;
2029 { 1807 dy = 0;
2030 resultarr2[y*2, x*2] = resultarr[y, x];
2031
2032 if (y < (int)Constants.RegionSize)
2033 {
2034 if (y + 1 < (int)Constants.RegionSize)
2035 {
2036 if (x + 1 < (int)Constants.RegionSize)
2037 {
2038 resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x] +
2039 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
2040 }
2041 else
2042 {
2043 resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x])/2);
2044 }
2045 }
2046 else
2047 {
2048 resultarr2[(y*2) + 1, x*2] = resultarr[y, x];
2049 }
2050 }
2051 if (x < (int)Constants.RegionSize)
2052 {
2053 if (x + 1 < (int)Constants.RegionSize)
2054 {
2055 if (y + 1 < (int)Constants.RegionSize)
2056 {
2057 resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] +
2058 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
2059 }
2060 else
2061 {
2062 resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y, x + 1])/2);
2063 }
2064 }
2065 else
2066 {
2067 resultarr2[y*2, (x*2) + 1] = resultarr[y, x];
2068 }
2069 }
2070 if (x < (int)Constants.RegionSize && y < (int)Constants.RegionSize)
2071 {
2072 if ((x + 1 < (int)Constants.RegionSize) && (y + 1 < (int)Constants.RegionSize))
2073 {
2074 resultarr2[(y*2) + 1, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] +
2075 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
2076 }
2077 else
2078 {
2079 resultarr2[(y*2) + 1, (x*2) + 1] = resultarr[y, x];
2080 }
2081 }
2082 }
2083 } 1808 }
2084 //Flatten out the array 1809 if (y < regsize - 1)
2085 int i = 0;
2086 for (int y = 0; y < 512; y++)
2087 { 1810 {
2088 for (int x = 0; x < 512; x++) 1811 ix = (int)y;
2089 { 1812 dx = y - (float)ix;
2090 if (Single.IsNaN(resultarr2[y, x]) || Single.IsInfinity(resultarr2[y, x])) 1813 }
2091 { 1814 else
2092 m_log.Warn("[PHYSICS]: Non finite heightfield element detected. Setting it to 0"); 1815 {
2093 resultarr2[y, x] = 0; 1816 ix = regsize - 1;
2094 } 1817 dx = 0;
2095 returnarr[i] = resultarr2[y, x];
2096 i++;
2097 }
2098 } 1818 }
2099 1819
2100 return returnarr; 1820 float h0;
2101 } 1821 float h1;
1822 float h2;
2102 1823
2103 #endregion 1824 iy *= regsize;
1825 iy += ix; // all indexes have iy + ix
2104 1826
1827 float[] heights = TerrainHeightFieldHeights[heightFieldGeom];
1828
1829 if ((dx + dy) <= 1.0f)
1830 {
1831 h0 = ((float)heights[iy]); // 0,0 vertice
1832 h1 = (((float)heights[iy + 1]) - h0) * dx; // 1,0 vertice minus 0,0
1833 h2 = (((float)heights[iy + regsize]) - h0) * dy; // 0,1 vertice minus 0,0
1834 }
1835 else
1836 {
1837 h0 = ((float)heights[iy + regsize + 1]); // 1,1 vertice
1838 h1 = (((float)heights[iy + 1]) - h0) * (1 - dy); // 1,1 vertice minus 1,0
1839 h2 = (((float)heights[iy + regsize]) - h0) * (1 - dx); // 1,1 vertice minus 0,1
1840 }
1841
1842 return h0 + h1 + h2;
1843 }
2105 public override void SetTerrain(float[] heightMap) 1844 public override void SetTerrain(float[] heightMap)
2106 { 1845 {
2107 if (m_worldOffset != Vector3.Zero && m_parentScene != null) 1846 if (m_worldOffset != Vector3.Zero && m_parentScene != null)
@@ -2124,48 +1863,47 @@ namespace OpenSim.Region.Physics.OdePlugin
2124 1863
2125 public void SetTerrain(float[] heightMap, Vector3 pOffset) 1864 public void SetTerrain(float[] heightMap, Vector3 pOffset)
2126 { 1865 {
1866 // assumes 1m size grid and constante size square regions
1867 // needs to know about sims around in future
2127 1868
2128 float[] _heightmap; 1869 float[] _heightmap;
2129 _heightmap = new float[(((int)Constants.RegionSize + 2) * ((int)Constants.RegionSize + 2))];
2130 1870
2131 uint heightmapWidth = Constants.RegionSize + 2; 1871 uint heightmapWidth = Constants.RegionSize + 2;
2132 uint heightmapHeight = Constants.RegionSize + 2; 1872 uint heightmapHeight = Constants.RegionSize + 2;
2133 1873
2134 uint heightmapWidthSamples; 1874 uint heightmapWidthSamples = heightmapWidth + 1;
1875 uint heightmapHeightSamples = heightmapHeight + 1;
2135 1876
2136 uint heightmapHeightSamples; 1877 _heightmap = new float[heightmapWidthSamples * heightmapHeightSamples];
2137
2138 heightmapWidthSamples = (uint)Constants.RegionSize + 2;
2139 heightmapHeightSamples = (uint)Constants.RegionSize + 2;
2140 1878
2141 const float scale = 1.0f; 1879 const float scale = 1.0f;
2142 const float offset = 0.0f; 1880 const float offset = 0.0f;
2143 const float thickness = 10f; 1881 const float thickness = 10f;
2144 const int wrap = 0; 1882 const int wrap = 0;
2145 1883
2146 int regionsize = (int) Constants.RegionSize + 2; 1884 uint regionsize = Constants.RegionSize;
2147 1885
2148 float hfmin = float.MaxValue; 1886 float hfmin = float.MaxValue;
2149 float hfmax = float.MinValue; 1887 float hfmax = float.MinValue;
2150 float val; 1888 float val;
2151 int xx; 1889 uint xx;
2152 int yy; 1890 uint yy;
2153 1891
2154 int maxXXYY = regionsize - 3; 1892 uint maxXXYY = regionsize - 1;
2155 // flipping map adding one margin all around so things don't fall in edges 1893 // flipping map adding one margin all around so things don't fall in edges
2156 1894
2157 int xt = 0; 1895 uint xt = 0;
2158 xx = 0; 1896 xx = 0;
2159 1897
2160 for (int x = 0; x < heightmapWidthSamples; x++) 1898 for (uint x = 0; x < heightmapWidthSamples; x++)
2161 { 1899 {
2162 if (x > 1 && xx < maxXXYY) 1900 if (x > 1 && xx < maxXXYY)
2163 xx++; 1901 xx++;
2164 yy = 0; 1902 yy = 0;
2165 for (int y = 0; y < heightmapHeightSamples; y++) 1903 for (uint y = 0; y < heightmapHeightSamples; y++)
2166 { 1904 {
2167 if (y > 1 && y < maxXXYY) 1905 if (y > 1 && y < maxXXYY)
2168 yy += (int)Constants.RegionSize; 1906 yy += regionsize;
2169 1907
2170 val = heightMap[yy + xx]; 1908 val = heightMap[yy + xx];
2171 _heightmap[xt + y] = val; 1909 _heightmap[xt + y] = val;
@@ -2176,8 +1914,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2176 hfmax = val; 1914 hfmax = val;
2177 1915
2178 } 1916 }
2179 1917 xt += heightmapHeightSamples;
2180 xt += regionsize;
2181 } 1918 }
2182 lock (OdeLock) 1919 lock (OdeLock)
2183 { 1920 {
@@ -2230,11 +1967,6 @@ namespace OpenSim.Region.Physics.OdePlugin
2230 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); 1967 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
2231 d.GeomSetRotation(GroundGeom, ref R); 1968 d.GeomSetRotation(GroundGeom, ref R);
2232 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f - 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f - 0.5f, 0); 1969 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f - 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f - 0.5f, 0);
2233 IntPtr testGround = IntPtr.Zero;
2234 if (RegionTerrain.TryGetValue(pOffset, out testGround))
2235 {
2236 RegionTerrain.Remove(pOffset);
2237 }
2238 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); 1970 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom);
2239// TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap); 1971// TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
2240 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 1972 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);