diff options
author | UbitUmarov | 2015-08-19 14:26:14 +0100 |
---|---|---|
committer | UbitUmarov | 2015-08-19 14:26:14 +0100 |
commit | abeb2ec4b30357366314c844ae9609431652e05d (patch) | |
tree | 600c10db6b11b8a405c9a1791315233eb8ffda14 /OpenSim/Region | |
parent | fixes on warp3D (diff) | |
download | opensim-SC_OLD-abeb2ec4b30357366314c844ae9609431652e05d.zip opensim-SC_OLD-abeb2ec4b30357366314c844ae9609431652e05d.tar.gz opensim-SC_OLD-abeb2ec4b30357366314c844ae9609431652e05d.tar.bz2 opensim-SC_OLD-abeb2ec4b30357366314c844ae9609431652e05d.tar.xz |
ubitode varsize ( Mega disabled till better checks )
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 155 |
1 files changed, 101 insertions, 54 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 2adbe01..f2b21a3 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -170,6 +170,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
170 | // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); | 170 | // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); |
171 | 171 | ||
172 | public bool OdeUbitLib = false; | 172 | public bool OdeUbitLib = false; |
173 | public bool m_suportCombine = false; // mega suport not tested | ||
174 | |||
173 | // private int threadid = 0; | 175 | // private int threadid = 0; |
174 | // private Random fluidRandomizer = new Random(Environment.TickCount); | 176 | // private Random fluidRandomizer = new Random(Environment.TickCount); |
175 | 177 | ||
@@ -187,8 +189,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
187 | 189 | ||
188 | public float AvatarFriction = 0;// 0.9f * 0.5f; | 190 | public float AvatarFriction = 0;// 0.9f * 0.5f; |
189 | 191 | ||
190 | private const uint m_regionWidth = Constants.RegionSize; | 192 | private uint m_regionWidth = Constants.RegionSize; |
191 | private const uint m_regionHeight = Constants.RegionSize; | 193 | private uint m_regionHeight = Constants.RegionSize; |
192 | 194 | ||
193 | public float ODE_STEPSIZE = 0.020f; | 195 | public float ODE_STEPSIZE = 0.020f; |
194 | public float HalfOdeStep = 0.01f; | 196 | public float HalfOdeStep = 0.01f; |
@@ -418,8 +420,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
418 | } | 420 | } |
419 | } | 421 | } |
420 | 422 | ||
421 | // Initialize the mesh plugin | 423 | public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) |
422 | // public override void Initialise(IMesher meshmerizer, IConfigSource config, RegionInfo region ) | 424 | { |
425 | WorldExtents.X = regionExtent.X; | ||
426 | WorldExtents.Y = regionExtent.Y; | ||
427 | m_suportCombine = false; | ||
428 | Initialise(meshmerizer, config); | ||
429 | } | ||
430 | |||
431 | |||
423 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | 432 | public override void Initialise(IMesher meshmerizer, IConfigSource config) |
424 | { | 433 | { |
425 | // checkThread(); | 434 | // checkThread(); |
@@ -557,6 +566,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
557 | spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeter); | 566 | spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeter); |
558 | spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeter); | 567 | spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeter); |
559 | 568 | ||
569 | if (spaceGridMaxX > 40) | ||
570 | spaceGridMaxX = 40; | ||
571 | if (spaceGridMaxY > 40) | ||
572 | spaceGridMaxY = 40; | ||
573 | |||
560 | staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY]; | 574 | staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY]; |
561 | 575 | ||
562 | // create all spaces now | 576 | // create all spaces now |
@@ -1882,17 +1896,25 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1882 | 1896 | ||
1883 | public float GetTerrainHeightAtXY(float x, float y) | 1897 | public float GetTerrainHeightAtXY(float x, float y) |
1884 | { | 1898 | { |
1899 | IntPtr heightFieldGeom = IntPtr.Zero; | ||
1885 | 1900 | ||
1901 | int offsetX = 0; | ||
1902 | int offsetY = 0; | ||
1886 | 1903 | ||
1887 | int offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | 1904 | if (m_suportCombine) |
1888 | int offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | 1905 | { |
1889 | 1906 | offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | |
1890 | 1907 | offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | |
1891 | IntPtr heightFieldGeom = IntPtr.Zero; | 1908 | // get region map |
1909 | if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom)) | ||
1910 | return 0f; | ||
1911 | } | ||
1912 | else | ||
1913 | { | ||
1914 | if (!RegionTerrain.TryGetValue(Vector3.Zero , out heightFieldGeom)) | ||
1915 | return 0f; | ||
1916 | } | ||
1892 | 1917 | ||
1893 | // get region map | ||
1894 | if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom)) | ||
1895 | return 0f; | ||
1896 | 1918 | ||
1897 | if (heightFieldGeom == IntPtr.Zero) | 1919 | if (heightFieldGeom == IntPtr.Zero) |
1898 | return 0f; | 1920 | return 0f; |
@@ -1917,28 +1939,30 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1917 | float dx; | 1939 | float dx; |
1918 | float dy; | 1940 | float dy; |
1919 | 1941 | ||
1920 | int regsize = (int)Constants.RegionSize + 3; // map size see setterrain number of samples | 1942 | int regsizeX = (int)WorldExtents.X + 3; // map size see setterrain number of samples |
1943 | int regsizeY = (int)WorldExtents.Y + 3; // map size see setterrain number of samples | ||
1944 | int regsize = regsizeX; | ||
1921 | 1945 | ||
1922 | if (OdeUbitLib) | 1946 | if (OdeUbitLib) |
1923 | { | 1947 | { |
1924 | if (x < regsize - 1) | 1948 | if (x < regsizeX - 1) |
1925 | { | 1949 | { |
1926 | ix = (int)x; | 1950 | ix = (int)x; |
1927 | dx = x - (float)ix; | 1951 | dx = x - (float)ix; |
1928 | } | 1952 | } |
1929 | else // out world use external height | 1953 | else // out world use external height |
1930 | { | 1954 | { |
1931 | ix = regsize - 2; | 1955 | ix = regsizeX - 2; |
1932 | dx = 0; | 1956 | dx = 0; |
1933 | } | 1957 | } |
1934 | if (y < regsize - 1) | 1958 | if (y < regsizeY - 1) |
1935 | { | 1959 | { |
1936 | iy = (int)y; | 1960 | iy = (int)y; |
1937 | dy = y - (float)iy; | 1961 | dy = y - (float)iy; |
1938 | } | 1962 | } |
1939 | else | 1963 | else |
1940 | { | 1964 | { |
1941 | iy = regsize - 2; | 1965 | iy = regsizeY - 2; |
1942 | dy = 0; | 1966 | dy = 0; |
1943 | } | 1967 | } |
1944 | } | 1968 | } |
@@ -1948,24 +1972,26 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1948 | // also flip x and y because of how map is done for ODE fliped axis | 1972 | // also flip x and y because of how map is done for ODE fliped axis |
1949 | // so ix,iy,dx and dy are inter exchanged | 1973 | // so ix,iy,dx and dy are inter exchanged |
1950 | 1974 | ||
1951 | if (x < regsize - 1) | 1975 | regsize = regsizeY; |
1976 | |||
1977 | if (x < regsizeX - 1) | ||
1952 | { | 1978 | { |
1953 | iy = (int)x; | 1979 | iy = (int)x; |
1954 | dy = x - (float)iy; | 1980 | dy = x - (float)iy; |
1955 | } | 1981 | } |
1956 | else // out world use external height | 1982 | else // out world use external height |
1957 | { | 1983 | { |
1958 | iy = regsize - 2; | 1984 | iy = regsizeX - 2; |
1959 | dy = 0; | 1985 | dy = 0; |
1960 | } | 1986 | } |
1961 | if (y < regsize - 1) | 1987 | if (y < regsizeY - 1) |
1962 | { | 1988 | { |
1963 | ix = (int)y; | 1989 | ix = (int)y; |
1964 | dx = y - (float)ix; | 1990 | dx = y - (float)ix; |
1965 | } | 1991 | } |
1966 | else | 1992 | else |
1967 | { | 1993 | { |
1968 | ix = regsize - 2; | 1994 | ix = regsizeY - 2; |
1969 | dx = 0; | 1995 | dx = 0; |
1970 | } | 1996 | } |
1971 | } | 1997 | } |
@@ -2014,15 +2040,25 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2014 | 2040 | ||
2015 | public Vector3 GetTerrainNormalAtXY(float x, float y) | 2041 | public Vector3 GetTerrainNormalAtXY(float x, float y) |
2016 | { | 2042 | { |
2017 | int offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
2018 | int offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
2019 | |||
2020 | IntPtr heightFieldGeom = IntPtr.Zero; | 2043 | IntPtr heightFieldGeom = IntPtr.Zero; |
2021 | Vector3 norm = new Vector3(0, 0, 1); | 2044 | Vector3 norm = new Vector3(0, 0, 1); |
2022 | 2045 | ||
2023 | // get region map | 2046 | int offsetX = 0; |
2024 | if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom)) | 2047 | int offsetY = 0; |
2025 | return norm; | 2048 | |
2049 | if (m_suportCombine) | ||
2050 | { | ||
2051 | offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
2052 | offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
2053 | // get region map | ||
2054 | if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom)) | ||
2055 | return norm; ; | ||
2056 | } | ||
2057 | else | ||
2058 | { | ||
2059 | if (!RegionTerrain.TryGetValue(Vector3.Zero, out heightFieldGeom)) | ||
2060 | return norm; ; | ||
2061 | } | ||
2026 | 2062 | ||
2027 | if (heightFieldGeom == IntPtr.Zero) | 2063 | if (heightFieldGeom == IntPtr.Zero) |
2028 | return norm; | 2064 | return norm; |
@@ -2047,32 +2083,34 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2047 | float dx; | 2083 | float dx; |
2048 | float dy; | 2084 | float dy; |
2049 | 2085 | ||
2086 | int regsizeX = (int)WorldExtents.X + 3; // map size see setterrain number of samples | ||
2087 | int regsizeY = (int)WorldExtents.Y + 3; // map size see setterrain number of samples | ||
2088 | int regsize = regsizeX; | ||
2050 | 2089 | ||
2051 | int regsize = (int)Constants.RegionSize + 3; // map size see setterrain number of samples | ||
2052 | int xstep = 1; | 2090 | int xstep = 1; |
2053 | int ystep = regsize; | 2091 | int ystep = regsizeX; |
2054 | bool firstTri = false; | 2092 | bool firstTri = false; |
2055 | 2093 | ||
2056 | if (OdeUbitLib) | 2094 | if (OdeUbitLib) |
2057 | { | 2095 | { |
2058 | if (x < regsize - 1) | 2096 | if (x < regsizeX - 1) |
2059 | { | 2097 | { |
2060 | ix = (int)x; | 2098 | ix = (int)x; |
2061 | dx = x - (float)ix; | 2099 | dx = x - (float)ix; |
2062 | } | 2100 | } |
2063 | else // out world use external height | 2101 | else // out world use external height |
2064 | { | 2102 | { |
2065 | ix = regsize - 2; | 2103 | ix = regsizeX - 2; |
2066 | dx = 0; | 2104 | dx = 0; |
2067 | } | 2105 | } |
2068 | if (y < regsize - 1) | 2106 | if (y < regsizeY - 1) |
2069 | { | 2107 | { |
2070 | iy = (int)y; | 2108 | iy = (int)y; |
2071 | dy = y - (float)iy; | 2109 | dy = y - (float)iy; |
2072 | } | 2110 | } |
2073 | else | 2111 | else |
2074 | { | 2112 | { |
2075 | iy = regsize - 2; | 2113 | iy = regsizeY - 2; |
2076 | dy = 0; | 2114 | dy = 0; |
2077 | } | 2115 | } |
2078 | firstTri = dy > dx; | 2116 | firstTri = dy > dx; |
@@ -2080,29 +2118,31 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2080 | 2118 | ||
2081 | else | 2119 | else |
2082 | { | 2120 | { |
2083 | xstep = regsize; | 2121 | xstep = regsizeY; |
2084 | ystep = 1; | 2122 | ystep = 1; |
2123 | regsize = regsizeY; | ||
2124 | |||
2085 | // we still have square fixed size regions | 2125 | // we still have square fixed size regions |
2086 | // also flip x and y because of how map is done for ODE fliped axis | 2126 | // also flip x and y because of how map is done for ODE fliped axis |
2087 | // so ix,iy,dx and dy are inter exchanged | 2127 | // so ix,iy,dx and dy are inter exchanged |
2088 | if (x < regsize - 1) | 2128 | if (x < regsizeX - 1) |
2089 | { | 2129 | { |
2090 | iy = (int)x; | 2130 | iy = (int)x; |
2091 | dy = x - (float)iy; | 2131 | dy = x - (float)iy; |
2092 | } | 2132 | } |
2093 | else // out world use external height | 2133 | else // out world use external height |
2094 | { | 2134 | { |
2095 | iy = regsize - 2; | 2135 | iy = regsizeX - 2; |
2096 | dy = 0; | 2136 | dy = 0; |
2097 | } | 2137 | } |
2098 | if (y < regsize - 1) | 2138 | if (y < regsizeY - 1) |
2099 | { | 2139 | { |
2100 | ix = (int)y; | 2140 | ix = (int)y; |
2101 | dx = y - (float)ix; | 2141 | dx = y - (float)ix; |
2102 | } | 2142 | } |
2103 | else | 2143 | else |
2104 | { | 2144 | { |
2105 | ix = regsize - 2; | 2145 | ix = regsizeY - 2; |
2106 | dx = 0; | 2146 | dx = 0; |
2107 | } | 2147 | } |
2108 | firstTri = dx > dy; | 2148 | firstTri = dx > dy; |
@@ -2175,8 +2215,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2175 | 2215 | ||
2176 | float[] _heightmap; | 2216 | float[] _heightmap; |
2177 | 2217 | ||
2178 | uint heightmapWidth = Constants.RegionSize + 2; | 2218 | uint regionsizeX = (uint)WorldExtents.X; |
2179 | uint heightmapHeight = Constants.RegionSize + 2; | 2219 | uint regionsizeY = (uint)WorldExtents.Y; |
2220 | |||
2221 | // map is rotated | ||
2222 | uint heightmapWidth = regionsizeY + 2; | ||
2223 | uint heightmapHeight = regionsizeX + 2; | ||
2180 | 2224 | ||
2181 | uint heightmapWidthSamples = heightmapWidth + 1; | 2225 | uint heightmapWidthSamples = heightmapWidth + 1; |
2182 | uint heightmapHeightSamples = heightmapHeight + 1; | 2226 | uint heightmapHeightSamples = heightmapHeight + 1; |
@@ -2188,7 +2232,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2188 | const float thickness = 10f; | 2232 | const float thickness = 10f; |
2189 | const int wrap = 0; | 2233 | const int wrap = 0; |
2190 | 2234 | ||
2191 | uint regionsize = Constants.RegionSize; | ||
2192 | 2235 | ||
2193 | float hfmin = float.MaxValue; | 2236 | float hfmin = float.MaxValue; |
2194 | float hfmax = float.MinValue; | 2237 | float hfmax = float.MinValue; |
@@ -2196,7 +2239,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2196 | uint xx; | 2239 | uint xx; |
2197 | uint yy; | 2240 | uint yy; |
2198 | 2241 | ||
2199 | uint maxXXYY = regionsize - 1; | 2242 | uint maxXX = regionsizeX - 1; |
2243 | uint maxYY = regionsizeY - 1; | ||
2200 | // flipping map adding one margin all around so things don't fall in edges | 2244 | // flipping map adding one margin all around so things don't fall in edges |
2201 | 2245 | ||
2202 | uint xt = 0; | 2246 | uint xt = 0; |
@@ -2204,13 +2248,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2204 | 2248 | ||
2205 | for (uint x = 0; x < heightmapWidthSamples; x++) | 2249 | for (uint x = 0; x < heightmapWidthSamples; x++) |
2206 | { | 2250 | { |
2207 | if (x > 1 && xx < maxXXYY) | 2251 | if (x > 1 && xx < maxXX) |
2208 | xx++; | 2252 | xx++; |
2209 | yy = 0; | 2253 | yy = 0; |
2210 | for (uint y = 0; y < heightmapHeightSamples; y++) | 2254 | for (uint y = 0; y < heightmapHeightSamples; y++) |
2211 | { | 2255 | { |
2212 | if (y > 1 && y < maxXXYY) | 2256 | if (y > 1 && y < maxYY) |
2213 | yy += regionsize; | 2257 | yy += regionsizeX; |
2214 | 2258 | ||
2215 | val = heightMap[yy + xx]; | 2259 | val = heightMap[yy + xx]; |
2216 | if (val < 0.0f) | 2260 | if (val < 0.0f) |
@@ -2224,6 +2268,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2224 | } | 2268 | } |
2225 | xt += heightmapHeightSamples; | 2269 | xt += heightmapHeightSamples; |
2226 | } | 2270 | } |
2271 | |||
2227 | lock (OdeLock) | 2272 | lock (OdeLock) |
2228 | { | 2273 | { |
2229 | IntPtr GroundGeom = IntPtr.Zero; | 2274 | IntPtr GroundGeom = IntPtr.Zero; |
@@ -2296,8 +2341,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2296 | 2341 | ||
2297 | float[] _heightmap; | 2342 | float[] _heightmap; |
2298 | 2343 | ||
2299 | uint heightmapWidth = Constants.RegionSize + 2; | 2344 | uint regionsizeX = (uint)WorldExtents.X; |
2300 | uint heightmapHeight = Constants.RegionSize + 2; | 2345 | uint regionsizeY = (uint)WorldExtents.Y; |
2346 | |||
2347 | uint heightmapWidth = regionsizeX + 2; | ||
2348 | uint heightmapHeight = regionsizeY + 2; | ||
2301 | 2349 | ||
2302 | uint heightmapWidthSamples = heightmapWidth + 1; | 2350 | uint heightmapWidthSamples = heightmapWidth + 1; |
2303 | uint heightmapHeightSamples = heightmapHeight + 1; | 2351 | uint heightmapHeightSamples = heightmapHeight + 1; |
@@ -2305,14 +2353,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2305 | _heightmap = new float[heightmapWidthSamples * heightmapHeightSamples]; | 2353 | _heightmap = new float[heightmapWidthSamples * heightmapHeightSamples]; |
2306 | 2354 | ||
2307 | 2355 | ||
2308 | uint regionsize = Constants.RegionSize; | ||
2309 | |||
2310 | float hfmin = float.MaxValue; | 2356 | float hfmin = float.MaxValue; |
2311 | // float hfmax = float.MinValue; | 2357 | // float hfmax = float.MinValue; |
2312 | float val; | 2358 | float val; |
2313 | 2359 | ||
2314 | 2360 | ||
2315 | uint maxXXYY = regionsize - 1; | 2361 | uint maxXX = regionsizeX - 1; |
2362 | uint maxYY = regionsizeY - 1; | ||
2316 | // adding one margin all around so things don't fall in edges | 2363 | // adding one margin all around so things don't fall in edges |
2317 | 2364 | ||
2318 | uint xx; | 2365 | uint xx; |
@@ -2321,12 +2368,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2321 | 2368 | ||
2322 | for (uint y = 0; y < heightmapHeightSamples; y++) | 2369 | for (uint y = 0; y < heightmapHeightSamples; y++) |
2323 | { | 2370 | { |
2324 | if (y > 1 && y < maxXXYY) | 2371 | if (y > 1 && y < maxYY) |
2325 | yy += regionsize; | 2372 | yy += regionsizeX; |
2326 | xx = 0; | 2373 | xx = 0; |
2327 | for (uint x = 0; x < heightmapWidthSamples; x++) | 2374 | for (uint x = 0; x < heightmapWidthSamples; x++) |
2328 | { | 2375 | { |
2329 | if (x > 1 && x < maxXXYY) | 2376 | if (x > 1 && x < maxXX) |
2330 | xx++; | 2377 | xx++; |
2331 | 2378 | ||
2332 | val = heightMap[yy + xx]; | 2379 | val = heightMap[yy + xx]; |
@@ -2409,7 +2456,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2409 | 2456 | ||
2410 | public override bool SupportsCombining() | 2457 | public override bool SupportsCombining() |
2411 | { | 2458 | { |
2412 | return true; | 2459 | return m_suportCombine; |
2413 | } | 2460 | } |
2414 | /* | 2461 | /* |
2415 | public override void UnCombine(PhysicsScene pScene) | 2462 | public override void UnCombine(PhysicsScene pScene) |