diff options
author | UbitUmarov | 2015-08-20 18:15:58 +0100 |
---|---|---|
committer | UbitUmarov | 2015-08-20 18:15:58 +0100 |
commit | 63f13b901a1a34ff7ab049ebf6c5e758d28bdb0e (patch) | |
tree | f19e36929e19fc7e788ced1a329c06be5f650263 /OpenSim/Region | |
parent | make basic ode work with var regions for contribution back to CORE. ( avn (diff) | |
download | opensim-SC_OLD-63f13b901a1a34ff7ab049ebf6c5e758d28bdb0e.zip opensim-SC_OLD-63f13b901a1a34ff7ab049ebf6c5e758d28bdb0e.tar.gz opensim-SC_OLD-63f13b901a1a34ff7ab049ebf6c5e758d28bdb0e.tar.bz2 opensim-SC_OLD-63f13b901a1a34ff7ab049ebf6c5e758d28bdb0e.tar.xz |
ubitode a bit more friendly for megas (still disabled)
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 220 |
1 files changed, 49 insertions, 171 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 6612e97..dafd3a3 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -189,6 +189,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
189 | 189 | ||
190 | public float AvatarFriction = 0;// 0.9f * 0.5f; | 190 | public float AvatarFriction = 0;// 0.9f * 0.5f; |
191 | 191 | ||
192 | // this netx dimensions are only relevant for terrain partition (mega regions) | ||
193 | // WorldExtents below has the simulation dimensions | ||
194 | // they should be identical except on mega regions | ||
192 | private uint m_regionWidth = Constants.RegionSize; | 195 | private uint m_regionWidth = Constants.RegionSize; |
193 | private uint m_regionHeight = Constants.RegionSize; | 196 | private uint m_regionHeight = Constants.RegionSize; |
194 | 197 | ||
@@ -208,11 +211,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
208 | private float waterlevel = 0f; | 211 | private float waterlevel = 0f; |
209 | private int framecount = 0; | 212 | private int framecount = 0; |
210 | 213 | ||
211 | private int m_meshExpireCntr; | 214 | // private int m_meshExpireCntr; |
212 | |||
213 | // private IntPtr WaterGeom = IntPtr.Zero; | ||
214 | // private IntPtr WaterHeightmapData = IntPtr.Zero; | ||
215 | // private GCHandle WaterMapHandler = new GCHandle(); | ||
216 | 215 | ||
217 | private float avDensity = 3f; | 216 | private float avDensity = 3f; |
218 | private float avMovementDivisorWalk = 1.3f; | 217 | private float avMovementDivisorWalk = 1.3f; |
@@ -223,14 +222,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
223 | 222 | ||
224 | public float geomDefaultDensity = 10.000006836f; | 223 | public float geomDefaultDensity = 10.000006836f; |
225 | 224 | ||
226 | // public int geomContactPointsStartthrottle = 3; | ||
227 | // public int geomUpdatesPerThrottledUpdate = 15; | ||
228 | |||
229 | public float bodyPIDD = 35f; | 225 | public float bodyPIDD = 35f; |
230 | public float bodyPIDG = 25; | 226 | public float bodyPIDG = 25; |
231 | 227 | ||
232 | // public int geomCrossingFailuresBeforeOutofbounds = 6; | ||
233 | |||
234 | public int bodyFramesAutoDisable = 5; | 228 | public int bodyFramesAutoDisable = 5; |
235 | 229 | ||
236 | private d.NearCallback nearCallback; | 230 | private d.NearCallback nearCallback; |
@@ -293,7 +287,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
293 | // some speedup variables | 287 | // some speedup variables |
294 | private int spaceGridMaxX; | 288 | private int spaceGridMaxX; |
295 | private int spaceGridMaxY; | 289 | private int spaceGridMaxY; |
296 | private float spacesPerMeter; | 290 | private float spacesPerMeterX; |
291 | private float spacesPerMeterY; | ||
297 | 292 | ||
298 | // split static geometry collision into a grid as before | 293 | // split static geometry collision into a grid as before |
299 | private IntPtr[,] staticPrimspace; | 294 | private IntPtr[,] staticPrimspace; |
@@ -423,7 +418,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
423 | public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) | 418 | public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) |
424 | { | 419 | { |
425 | WorldExtents.X = regionExtent.X; | 420 | WorldExtents.X = regionExtent.X; |
421 | m_regionWidth = (uint)regionExtent.X; | ||
426 | WorldExtents.Y = regionExtent.Y; | 422 | WorldExtents.Y = regionExtent.Y; |
423 | m_regionHeight = (uint)regionExtent.Y; | ||
424 | |||
427 | m_suportCombine = false; | 425 | m_suportCombine = false; |
428 | Initialise(meshmerizer, config); | 426 | Initialise(meshmerizer, config); |
429 | } | 427 | } |
@@ -446,14 +444,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
446 | } | 444 | } |
447 | } | 445 | } |
448 | 446 | ||
449 | /* | ||
450 | if (region != null) | ||
451 | { | ||
452 | WorldExtents.X = region.RegionSizeX; | ||
453 | WorldExtents.Y = region.RegionSizeY; | ||
454 | } | ||
455 | */ | ||
456 | |||
457 | // Defaults | 447 | // Defaults |
458 | 448 | ||
459 | int contactsPerCollision = 80; | 449 | int contactsPerCollision = 80; |
@@ -474,7 +464,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
474 | // contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", contactsurfacelayer); | 464 | // contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", contactsurfacelayer); |
475 | 465 | ||
476 | ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", ODE_STEPSIZE); | 466 | ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", ODE_STEPSIZE); |
477 | // m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", m_physicsiterations); | ||
478 | 467 | ||
479 | avDensity = physicsconfig.GetFloat("av_density", avDensity); | 468 | avDensity = physicsconfig.GetFloat("av_density", avDensity); |
480 | avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk); | 469 | avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk); |
@@ -482,10 +471,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
482 | 471 | ||
483 | contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision); | 472 | contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision); |
484 | 473 | ||
485 | // geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); | ||
486 | // geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); | ||
487 | // geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5); | ||
488 | |||
489 | geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", geomDefaultDensity); | 474 | geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", geomDefaultDensity); |
490 | bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", bodyFramesAutoDisable); | 475 | bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", bodyFramesAutoDisable); |
491 | 476 | ||
@@ -562,14 +547,22 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
562 | m_materialContactsData[(int)Material.light].bounce = 0.0f; | 547 | m_materialContactsData[(int)Material.light].bounce = 0.0f; |
563 | 548 | ||
564 | 549 | ||
565 | spacesPerMeter = 1 / metersInSpace; | 550 | spacesPerMeterX = 1.0f / metersInSpace; |
566 | spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeter); | 551 | spacesPerMeterY = spacesPerMeterX; |
567 | spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeter); | 552 | spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeterX); |
553 | spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeterY); | ||
568 | 554 | ||
569 | if (spaceGridMaxX > 40) | 555 | if (spaceGridMaxX > 40) |
556 | { | ||
570 | spaceGridMaxX = 40; | 557 | spaceGridMaxX = 40; |
558 | spacesPerMeterX = WorldExtents.X / spaceGridMaxX; | ||
559 | } | ||
560 | |||
571 | if (spaceGridMaxY > 40) | 561 | if (spaceGridMaxY > 40) |
562 | { | ||
572 | spaceGridMaxY = 40; | 563 | spaceGridMaxY = 40; |
564 | spacesPerMeterY = WorldExtents.Y / spaceGridMaxY; | ||
565 | } | ||
573 | 566 | ||
574 | staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY]; | 567 | staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY]; |
575 | 568 | ||
@@ -596,7 +589,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
596 | 589 | ||
597 | staticPrimspace[i, j] = newspace; | 590 | staticPrimspace[i, j] = newspace; |
598 | } | 591 | } |
599 | // let this now be real maximum values | 592 | |
593 | // let this now be index limit | ||
600 | spaceGridMaxX--; | 594 | spaceGridMaxX--; |
601 | spaceGridMaxY--; | 595 | spaceGridMaxY--; |
602 | 596 | ||
@@ -1362,18 +1356,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1362 | } | 1356 | } |
1363 | } | 1357 | } |
1364 | } | 1358 | } |
1365 | /// <summary> | 1359 | |
1366 | /// This is called from within simulate but outside the locked portion | ||
1367 | /// We need to do our own locking here | ||
1368 | /// (Note: As of 20110801 this no longer appears to be true - this is being called within lock (odeLock) in | ||
1369 | /// Simulate() -- justincc). | ||
1370 | /// | ||
1371 | /// Essentially, we need to remove the prim from our space segment, whatever segment it's in. | ||
1372 | /// | ||
1373 | /// If there are no more prim in the segment, we need to empty (spacedestroy)the segment and reclaim memory | ||
1374 | /// that the space was using. | ||
1375 | /// </summary> | ||
1376 | /// <param name="prim"></param> | ||
1377 | public void RemovePrimThreadLocked(OdePrim prim) | 1360 | public void RemovePrimThreadLocked(OdePrim prim) |
1378 | { | 1361 | { |
1379 | //Console.WriteLine("RemovePrimThreadLocked " + prim.m_primName); | 1362 | //Console.WriteLine("RemovePrimThreadLocked " + prim.m_primName); |
@@ -1496,11 +1479,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1496 | if (pos.Y < 0) | 1479 | if (pos.Y < 0) |
1497 | return staticPrimspaceOffRegion[2]; | 1480 | return staticPrimspaceOffRegion[2]; |
1498 | 1481 | ||
1499 | x = (int)(pos.X * spacesPerMeter); | 1482 | x = (int)(pos.X * spacesPerMeterX); |
1500 | if (x > spaceGridMaxX) | 1483 | if (x > spaceGridMaxX) |
1501 | return staticPrimspaceOffRegion[1]; | 1484 | return staticPrimspaceOffRegion[1]; |
1502 | 1485 | ||
1503 | y = (int)(pos.Y * spacesPerMeter); | 1486 | y = (int)(pos.Y * spacesPerMeterY); |
1504 | if (y > spaceGridMaxY) | 1487 | if (y > spaceGridMaxY) |
1505 | return staticPrimspaceOffRegion[3]; | 1488 | return staticPrimspaceOffRegion[3]; |
1506 | 1489 | ||
@@ -1694,10 +1677,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1694 | aprim.Move(); | 1677 | aprim.Move(); |
1695 | } | 1678 | } |
1696 | } | 1679 | } |
1697 | 1680 | ||
1698 | //if ((framecount % m_randomizeWater) == 0) | ||
1699 | // randomizeWater(waterlevel); | ||
1700 | |||
1701 | m_rayCastManager.ProcessQueuedRequests(); | 1681 | m_rayCastManager.ProcessQueuedRequests(); |
1702 | 1682 | ||
1703 | collision_optimized(); | 1683 | collision_optimized(); |
@@ -1896,7 +1876,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1896 | 1876 | ||
1897 | public float GetTerrainHeightAtXY(float x, float y) | 1877 | public float GetTerrainHeightAtXY(float x, float y) |
1898 | { | 1878 | { |
1899 | IntPtr heightFieldGeom = IntPtr.Zero; | ||
1900 | 1879 | ||
1901 | int offsetX = 0; | 1880 | int offsetX = 0; |
1902 | int offsetY = 0; | 1881 | int offsetY = 0; |
@@ -1905,16 +1884,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1905 | { | 1884 | { |
1906 | offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | 1885 | offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; |
1907 | offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | 1886 | offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; |
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 | } | 1887 | } |
1917 | 1888 | ||
1889 | // get region map | ||
1890 | IntPtr heightFieldGeom = IntPtr.Zero; | ||
1891 | if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom)) | ||
1892 | return 0f; | ||
1918 | 1893 | ||
1919 | if (heightFieldGeom == IntPtr.Zero) | 1894 | if (heightFieldGeom == IntPtr.Zero) |
1920 | return 0f; | 1895 | return 0f; |
@@ -1939,8 +1914,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1939 | float dx; | 1914 | float dx; |
1940 | float dy; | 1915 | float dy; |
1941 | 1916 | ||
1942 | int regsizeX = (int)WorldExtents.X + 3; // map size see setterrain number of samples | 1917 | int regsizeX = (int)m_regionWidth + 3; // map size see setterrain number of samples |
1943 | int regsizeY = (int)WorldExtents.Y + 3; // map size see setterrain number of samples | 1918 | int regsizeY = (int)m_regionHeight + 3; // map size see setterrain number of samples |
1944 | int regsize = regsizeX; | 1919 | int regsize = regsizeX; |
1945 | 1920 | ||
1946 | if (OdeUbitLib) | 1921 | if (OdeUbitLib) |
@@ -2040,9 +2015,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2040 | 2015 | ||
2041 | public Vector3 GetTerrainNormalAtXY(float x, float y) | 2016 | public Vector3 GetTerrainNormalAtXY(float x, float y) |
2042 | { | 2017 | { |
2043 | IntPtr heightFieldGeom = IntPtr.Zero; | ||
2044 | Vector3 norm = new Vector3(0, 0, 1); | ||
2045 | |||
2046 | int offsetX = 0; | 2018 | int offsetX = 0; |
2047 | int offsetY = 0; | 2019 | int offsetY = 0; |
2048 | 2020 | ||
@@ -2050,16 +2022,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2050 | { | 2022 | { |
2051 | offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | 2023 | offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; |
2052 | offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | 2024 | 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 | } | 2025 | } |
2062 | 2026 | ||
2027 | // get region map | ||
2028 | IntPtr heightFieldGeom = IntPtr.Zero; | ||
2029 | Vector3 norm = new Vector3(0, 0, 1); | ||
2030 | |||
2031 | if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom)) | ||
2032 | return norm; ; | ||
2033 | |||
2063 | if (heightFieldGeom == IntPtr.Zero) | 2034 | if (heightFieldGeom == IntPtr.Zero) |
2064 | return norm; | 2035 | return norm; |
2065 | 2036 | ||
@@ -2083,8 +2054,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2083 | float dx; | 2054 | float dx; |
2084 | float dy; | 2055 | float dy; |
2085 | 2056 | ||
2086 | int regsizeX = (int)WorldExtents.X + 3; // map size see setterrain number of samples | 2057 | int regsizeX = (int)m_regionWidth + 3; // map size see setterrain number of samples |
2087 | int regsizeY = (int)WorldExtents.Y + 3; // map size see setterrain number of samples | 2058 | int regsizeY = (int)m_regionHeight + 3; // map size see setterrain number of samples |
2088 | int regsize = regsizeX; | 2059 | int regsize = regsizeX; |
2089 | 2060 | ||
2090 | int xstep = 1; | 2061 | int xstep = 1; |
@@ -2197,7 +2168,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2197 | 2168 | ||
2198 | public override void CombineTerrain(float[] heightMap, Vector3 pOffset) | 2169 | public override void CombineTerrain(float[] heightMap, Vector3 pOffset) |
2199 | { | 2170 | { |
2200 | SetTerrain(heightMap, pOffset); | 2171 | if(m_suportCombine) |
2172 | SetTerrain(heightMap, pOffset); | ||
2201 | } | 2173 | } |
2202 | 2174 | ||
2203 | public void SetTerrain(float[] heightMap, Vector3 pOffset) | 2175 | public void SetTerrain(float[] heightMap, Vector3 pOffset) |
@@ -2215,8 +2187,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2215 | 2187 | ||
2216 | float[] _heightmap; | 2188 | float[] _heightmap; |
2217 | 2189 | ||
2218 | uint regionsizeX = (uint)WorldExtents.X; | 2190 | uint regionsizeX = m_regionWidth; |
2219 | uint regionsizeY = (uint)WorldExtents.Y; | 2191 | uint regionsizeY = m_regionHeight; |
2220 | 2192 | ||
2221 | // map is rotated | 2193 | // map is rotated |
2222 | uint heightmapWidth = regionsizeY + 2; | 2194 | uint heightmapWidth = regionsizeY + 2; |
@@ -2326,7 +2298,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2326 | 2298 | ||
2327 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | 2299 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); |
2328 | d.GeomSetRotation(GroundGeom, ref R); | 2300 | d.GeomSetRotation(GroundGeom, ref R); |
2329 | d.GeomSetPosition(GroundGeom, pOffset.X + WorldExtents.X * 0.5f, pOffset.Y + WorldExtents.Y * 0.5f, 0); | 2301 | d.GeomSetPosition(GroundGeom, pOffset.X + m_regionWidth * 0.5f, pOffset.Y + m_regionHeight * 0.5f, 0); |
2330 | RegionTerrain.Add(pOffset, GroundGeom); | 2302 | RegionTerrain.Add(pOffset, GroundGeom); |
2331 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); | 2303 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); |
2332 | TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); | 2304 | TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); |
@@ -2341,8 +2313,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2341 | 2313 | ||
2342 | float[] _heightmap; | 2314 | float[] _heightmap; |
2343 | 2315 | ||
2344 | uint regionsizeX = (uint)WorldExtents.X; | 2316 | uint regionsizeX = m_regionWidth; |
2345 | uint regionsizeY = (uint)WorldExtents.Y; | 2317 | uint regionsizeY = m_regionHeight; |
2346 | 2318 | ||
2347 | uint heightmapWidth = regionsizeX + 2; | 2319 | uint heightmapWidth = regionsizeX + 2; |
2348 | uint heightmapHeight = regionsizeY + 2; | 2320 | uint heightmapHeight = regionsizeY + 2; |
@@ -2436,7 +2408,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2436 | 2408 | ||
2437 | // geom_name_map[GroundGeom] = "Terrain"; | 2409 | // geom_name_map[GroundGeom] = "Terrain"; |
2438 | 2410 | ||
2439 | d.GeomSetPosition(GroundGeom, pOffset.X + WorldExtents.X * 0.5f, pOffset.Y + WorldExtents.Y * 0.5f, 0); | 2411 | d.GeomSetPosition(GroundGeom, pOffset.X + m_regionWidth * 0.5f, pOffset.Y + m_regionHeight * 0.5f, 0); |
2440 | RegionTerrain.Add(pOffset, GroundGeom); | 2412 | RegionTerrain.Add(pOffset, GroundGeom); |
2441 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); | 2413 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); |
2442 | TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); | 2414 | TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); |
@@ -2521,90 +2493,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2521 | public override void SetWaterLevel(float baseheight) | 2493 | public override void SetWaterLevel(float baseheight) |
2522 | { | 2494 | { |
2523 | waterlevel = baseheight; | 2495 | waterlevel = baseheight; |
2524 | // randomizeWater(waterlevel); | ||
2525 | } | 2496 | } |
2526 | /* | ||
2527 | public void randomizeWater(float baseheight) | ||
2528 | { | ||
2529 | const uint heightmapWidth = Constants.RegionSize + 2; | ||
2530 | const uint heightmapHeight = Constants.RegionSize + 2; | ||
2531 | const uint heightmapWidthSamples = heightmapWidth + 1; | ||
2532 | const uint heightmapHeightSamples = heightmapHeight + 1; | ||
2533 | 2497 | ||
2534 | const float scale = 1.0f; | ||
2535 | const float offset = 0.0f; | ||
2536 | const int wrap = 0; | ||
2537 | |||
2538 | float[] _watermap = new float[heightmapWidthSamples * heightmapWidthSamples]; | ||
2539 | |||
2540 | float maxheigh = float.MinValue; | ||
2541 | float minheigh = float.MaxValue; | ||
2542 | float val; | ||
2543 | for (int i = 0; i < (heightmapWidthSamples * heightmapHeightSamples); i++) | ||
2544 | { | ||
2545 | |||
2546 | val = (baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f); | ||
2547 | _watermap[i] = val; | ||
2548 | if (maxheigh < val) | ||
2549 | maxheigh = val; | ||
2550 | if (minheigh > val) | ||
2551 | minheigh = val; | ||
2552 | } | ||
2553 | |||
2554 | float thickness = minheigh; | ||
2555 | |||
2556 | lock (OdeLock) | ||
2557 | { | ||
2558 | if (WaterGeom != IntPtr.Zero) | ||
2559 | { | ||
2560 | actor_name_map.Remove(WaterGeom); | ||
2561 | d.GeomDestroy(WaterGeom); | ||
2562 | d.GeomHeightfieldDataDestroy(WaterHeightmapData); | ||
2563 | WaterGeom = IntPtr.Zero; | ||
2564 | WaterHeightmapData = IntPtr.Zero; | ||
2565 | if(WaterMapHandler.IsAllocated) | ||
2566 | WaterMapHandler.Free(); | ||
2567 | } | ||
2568 | |||
2569 | WaterHeightmapData = d.GeomHeightfieldDataCreate(); | ||
2570 | |||
2571 | WaterMapHandler = GCHandle.Alloc(_watermap, GCHandleType.Pinned); | ||
2572 | |||
2573 | d.GeomHeightfieldDataBuildSingle(WaterHeightmapData, WaterMapHandler.AddrOfPinnedObject(), 0, heightmapWidth, heightmapHeight, | ||
2574 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, | ||
2575 | offset, thickness, wrap); | ||
2576 | d.GeomHeightfieldDataSetBounds(WaterHeightmapData, minheigh, maxheigh); | ||
2577 | WaterGeom = d.CreateHeightfield(StaticSpace, WaterHeightmapData, 1); | ||
2578 | if (WaterGeom != IntPtr.Zero) | ||
2579 | { | ||
2580 | d.GeomSetCategoryBits(WaterGeom, (uint)(CollisionCategories.Water)); | ||
2581 | d.GeomSetCollideBits(WaterGeom, 0); | ||
2582 | |||
2583 | |||
2584 | PhysicsActor pa = new NullPhysicsActor(); | ||
2585 | pa.Name = "Water"; | ||
2586 | pa.PhysicsActorType = (int)ActorTypes.Water; | ||
2587 | |||
2588 | actor_name_map[WaterGeom] = pa; | ||
2589 | // geom_name_map[WaterGeom] = "Water"; | ||
2590 | |||
2591 | d.Matrix3 R = new d.Matrix3(); | ||
2592 | |||
2593 | Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); | ||
2594 | Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); | ||
2595 | |||
2596 | q1 = q1 * q2; | ||
2597 | Vector3 v3; | ||
2598 | float angle; | ||
2599 | q1.GetAxisAngle(out v3, out angle); | ||
2600 | |||
2601 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | ||
2602 | d.GeomSetRotation(WaterGeom, ref R); | ||
2603 | d.GeomSetPosition(WaterGeom, (float)Constants.RegionSize * 0.5f, (float)Constants.RegionSize * 0.5f, 0); | ||
2604 | } | ||
2605 | } | ||
2606 | } | ||
2607 | */ | ||
2608 | public override void Dispose() | 2498 | public override void Dispose() |
2609 | { | 2499 | { |
2610 | if (m_meshWorker != null) | 2500 | if (m_meshWorker != null) |
@@ -2658,19 +2548,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2658 | 2548 | ||
2659 | TerrainHeightFieldHeightsHandlers.Clear(); | 2549 | TerrainHeightFieldHeightsHandlers.Clear(); |
2660 | TerrainHeightFieldHeights.Clear(); | 2550 | TerrainHeightFieldHeights.Clear(); |
2661 | /* | ||
2662 | if (WaterGeom != IntPtr.Zero) | ||
2663 | { | ||
2664 | d.GeomDestroy(WaterGeom); | ||
2665 | WaterGeom = IntPtr.Zero; | ||
2666 | if (WaterHeightmapData != IntPtr.Zero) | ||
2667 | d.GeomHeightfieldDataDestroy(WaterHeightmapData); | ||
2668 | WaterHeightmapData = IntPtr.Zero; | ||
2669 | 2551 | ||
2670 | if (WaterMapHandler.IsAllocated) | ||
2671 | WaterMapHandler.Free(); | ||
2672 | } | ||
2673 | */ | ||
2674 | if (ContactgeomsArray != IntPtr.Zero) | 2552 | if (ContactgeomsArray != IntPtr.Zero) |
2675 | Marshal.FreeHGlobal(ContactgeomsArray); | 2553 | Marshal.FreeHGlobal(ContactgeomsArray); |
2676 | if (GlobalContactsArray != IntPtr.Zero) | 2554 | if (GlobalContactsArray != IntPtr.Zero) |