diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index cd623f1..83df360 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -62,7 +62,8 @@ public abstract class BSTerrainPhys : IDisposable | |||
62 | ID = id; | 62 | ID = id; |
63 | } | 63 | } |
64 | public abstract void Dispose(); | 64 | public abstract void Dispose(); |
65 | public abstract float GetHeightAtXYZ(Vector3 pos); | 65 | public abstract float GetTerrainHeightAtXYZ(Vector3 pos); |
66 | public abstract float GetWaterLevelAtXYZ(Vector3 pos); | ||
66 | } | 67 | } |
67 | 68 | ||
68 | // ========================================================================================== | 69 | // ========================================================================================== |
@@ -75,6 +76,7 @@ public sealed class BSTerrainManager | |||
75 | public const float HEIGHT_INITIALIZATION = 24.987f; | 76 | public const float HEIGHT_INITIALIZATION = 24.987f; |
76 | public const float HEIGHT_INITIAL_LASTHEIGHT = 24.876f; | 77 | public const float HEIGHT_INITIAL_LASTHEIGHT = 24.876f; |
77 | public const float HEIGHT_GETHEIGHT_RET = 24.765f; | 78 | public const float HEIGHT_GETHEIGHT_RET = 24.765f; |
79 | public const float WATER_HEIGHT_GETHEIGHT_RET = 19.998f; | ||
78 | 80 | ||
79 | // If the min and max height are equal, we reduce the min by this | 81 | // If the min and max height are equal, we reduce the min by this |
80 | // amount to make sure that a bounding box is built for the terrain. | 82 | // amount to make sure that a bounding box is built for the terrain. |
@@ -138,8 +140,8 @@ public sealed class BSTerrainManager | |||
138 | // Ground plane does not move | 140 | // Ground plane does not move |
139 | BulletSimAPI.ForceActivationState2(m_groundPlane.ptr, ActivationState.DISABLE_SIMULATION); | 141 | BulletSimAPI.ForceActivationState2(m_groundPlane.ptr, ActivationState.DISABLE_SIMULATION); |
140 | // Everything collides with the ground plane. | 142 | // Everything collides with the ground plane. |
141 | BulletSimAPI.SetCollisionFilterMask2(m_groundPlane.ptr, | 143 | BulletSimAPI.SetCollisionGroupMask2(m_groundPlane.ptr, |
142 | (uint)CollisionFilterGroups.GroundPlaneFilter, (uint)CollisionFilterGroups.GroundPlaneMask); | 144 | (uint)CollisionFilterGroups.GroundPlaneGroup, (uint)CollisionFilterGroups.GroundPlaneMask); |
143 | 145 | ||
144 | // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain. | 146 | // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain. |
145 | BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize); | 147 | BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize); |
@@ -358,7 +360,7 @@ public sealed class BSTerrainManager | |||
358 | BSTerrainPhys physTerrain; | 360 | BSTerrainPhys physTerrain; |
359 | if (m_terrains.TryGetValue(terrainBaseXYZ, out physTerrain)) | 361 | if (m_terrains.TryGetValue(terrainBaseXYZ, out physTerrain)) |
360 | { | 362 | { |
361 | ret = physTerrain.GetHeightAtXYZ(loc - terrainBaseXYZ); | 363 | ret = physTerrain.GetTerrainHeightAtXYZ(loc - terrainBaseXYZ); |
362 | } | 364 | } |
363 | else | 365 | else |
364 | { | 366 | { |
@@ -370,6 +372,33 @@ public sealed class BSTerrainManager | |||
370 | return ret; | 372 | return ret; |
371 | } | 373 | } |
372 | 374 | ||
375 | public float GetWaterLevelAtXYZ(Vector3 pos) | ||
376 | { | ||
377 | float ret = WATER_HEIGHT_GETHEIGHT_RET; | ||
378 | |||
379 | float tX = pos.X; | ||
380 | float tY = pos.Y; | ||
381 | |||
382 | Vector3 terrainBaseXYZ = Vector3.Zero; | ||
383 | terrainBaseXYZ.X = ((int)(tX / (int)DefaultRegionSize.X)) * (int)DefaultRegionSize.X; | ||
384 | terrainBaseXYZ.Y = ((int)(tY / (int)DefaultRegionSize.Y)) * (int)DefaultRegionSize.Y; | ||
385 | |||
386 | lock (m_terrains) | ||
387 | { | ||
388 | BSTerrainPhys physTerrain; | ||
389 | if (m_terrains.TryGetValue(terrainBaseXYZ, out physTerrain)) | ||
390 | { | ||
391 | ret = physTerrain.GetWaterLevelAtXYZ(pos); | ||
392 | } | ||
393 | else | ||
394 | { | ||
395 | PhysicsScene.Logger.ErrorFormat("{0} GetWaterHeightAtXY: terrain not found: region={1}, x={2}, y={3}", | ||
396 | LogHeader, PhysicsScene.RegionName, tX, tY); | ||
397 | } | ||
398 | } | ||
399 | return ret; | ||
400 | } | ||
401 | |||
373 | // Although no one seems to check this, I do support combining. | 402 | // Although no one seems to check this, I do support combining. |
374 | public bool SupportsCombining() | 403 | public bool SupportsCombining() |
375 | { | 404 | { |