aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRobert Adams2012-11-28 08:05:01 -0800
committerRobert Adams2012-11-28 09:48:33 -0800
commit0a66317fa6414dff9a7a4ab5bae10802e1e6693f (patch)
treea0705a43191649f43c80d43ee8537f5ab6581e94 /OpenSim
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-0a66317fa6414dff9a7a4ab5bae10802e1e6693f.zip
opensim-SC_OLD-0a66317fa6414dff9a7a4ab5bae10802e1e6693f.tar.gz
opensim-SC_OLD-0a66317fa6414dff9a7a4ab5bae10802e1e6693f.tar.bz2
opensim-SC_OLD-0a66317fa6414dff9a7a4ab5bae10802e1e6693f.tar.xz
BulletSim: move GetWaterLevelAtXYZ from BSScene to BSPhysTerrain.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs10
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs7
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs17
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs8
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs33
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs8
7 files changed, 63 insertions, 22 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 4c195e1..1dfc420 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -307,7 +307,7 @@ public sealed class BSCharacter : BSPhysObject
307 } 307 }
308 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) 308 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0)
309 { 309 {
310 float waterHeight = PhysicsScene.GetWaterLevelAtXYZ(_position); 310 float waterHeight = PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(_position);
311 if (Position.Z < waterHeight) 311 if (Position.Z < waterHeight)
312 { 312 {
313 _position.Z = waterHeight; 313 _position.Z = waterHeight;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 74eb9ab..b6e3594 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -713,7 +713,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
713 // We should hover, get the target height 713 // We should hover, get the target height
714 if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0) 714 if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0)
715 { 715 {
716 m_VhoverTargetHeight = Prim.PhysicsScene.GetWaterLevelAtXYZ(pos) + m_VhoverHeight; 716 m_VhoverTargetHeight = Prim.PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(pos) + m_VhoverHeight;
717 } 717 }
718 if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) 718 if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0)
719 { 719 {
@@ -730,6 +730,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
730 if (pos.Z > m_VhoverTargetHeight) 730 if (pos.Z > m_VhoverTargetHeight)
731 m_VhoverTargetHeight = pos.Z; 731 m_VhoverTargetHeight = pos.Z;
732 } 732 }
733
733 if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0) 734 if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0)
734 { 735 {
735 if (Math.Abs(pos.Z - m_VhoverTargetHeight) > 0.2f) 736 if (Math.Abs(pos.Z - m_VhoverTargetHeight) > 0.2f)
@@ -883,8 +884,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
883 // Sum velocities 884 // Sum velocities
884 m_lastAngularVelocity = angularMotorContribution 885 m_lastAngularVelocity = angularMotorContribution
885 + verticalAttractionContribution 886 + verticalAttractionContribution
886 + bankingContribution 887 + deflectionContribution
887 + deflectionContribution; 888 + bankingContribution;
888 889
889 // ================================================================== 890 // ==================================================================
890 //Offset section 891 //Offset section
@@ -921,8 +922,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
921 if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) 922 if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
922 { 923 {
923 m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero. 924 m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero.
924 Prim.ZeroAngularMotion(true); 925 // TODO: zeroing is good but it also sets values in unmanaged code. Remove the stores when idle.
925 VDetailLog("{0},MoveAngular,zeroAngularMotion,lastAngular={1}", Prim.LocalID, m_lastAngularVelocity); 926 VDetailLog("{0},MoveAngular,zeroAngularMotion,lastAngular={1}", Prim.LocalID, m_lastAngularVelocity);
927 Prim.ZeroAngularMotion(true);
926 } 928 }
927 else 929 else
928 { 930 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index c62c79a..3fb0300 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -253,8 +253,9 @@ public sealed class BSPrim : BSPhysObject
253 // Zero some other properties in the physics engine 253 // Zero some other properties in the physics engine
254 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() 254 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
255 { 255 {
256 BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); 256 // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity);
257 BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); 257 BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
258 BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
258 }); 259 });
259 } 260 }
260 261
@@ -329,7 +330,7 @@ public sealed class BSPrim : BSPhysObject
329 330
330 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) 331 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0)
331 { 332 {
332 float waterHeight = PhysicsScene.GetWaterLevelAtXYZ(_position); 333 float waterHeight = PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(_position);
333 // TODO: a floating motor so object will bob in the water 334 // TODO: a floating motor so object will bob in the water
334 if (Math.Abs(Position.Z - waterHeight) > 0.1f) 335 if (Math.Abs(Position.Z - waterHeight) > 0.1f)
335 { 336 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 09b1423..0c80611 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -127,7 +127,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
127 public const uint GROUNDPLANE_ID = 1; 127 public const uint GROUNDPLANE_ID = 1;
128 public const uint CHILDTERRAIN_ID = 2; // Terrain allocated based on our mega-prim childre start here 128 public const uint CHILDTERRAIN_ID = 2; // Terrain allocated based on our mega-prim childre start here
129 129
130 private float m_waterLevel; 130 public float SimpleWaterLevel { get; set; }
131 public BSTerrainManager TerrainManager { get; private set; } 131 public BSTerrainManager TerrainManager { get; private set; }
132 132
133 public ConfigurationParameters Params 133 public ConfigurationParameters Params
@@ -182,6 +182,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
182 private string m_physicsLoggingDir; 182 private string m_physicsLoggingDir;
183 private string m_physicsLoggingPrefix; 183 private string m_physicsLoggingPrefix;
184 private int m_physicsLoggingFileMinutes; 184 private int m_physicsLoggingFileMinutes;
185 private bool m_physicsLoggingDoFlush;
185 // 'true' of the vehicle code is to log lots of details 186 // 'true' of the vehicle code is to log lots of details
186 public bool VehicleLoggingEnabled { get; private set; } 187 public bool VehicleLoggingEnabled { get; private set; }
187 188
@@ -290,6 +291,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
290 m_physicsLoggingDir = pConfig.GetString("PhysicsLoggingDir", "."); 291 m_physicsLoggingDir = pConfig.GetString("PhysicsLoggingDir", ".");
291 m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-%REGIONNAME%-"); 292 m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-%REGIONNAME%-");
292 m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5); 293 m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5);
294 m_physicsLoggingDoFlush = pConfig.GetBoolean("PhysicsLoggingDoFlush", false);
293 // Very detailed logging for vehicle debugging 295 // Very detailed logging for vehicle debugging
294 VehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false); 296 VehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false);
295 297
@@ -494,7 +496,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
494 496
495 try 497 try
496 { 498 {
497 if (VehicleLoggingEnabled) DumpVehicles(); // DEBUG 499 // if (VehicleLoggingEnabled) DumpVehicles(); // DEBUG
498 if (PhysicsLogging.Enabled) beforeTime = Util.EnvironmentTickCount(); 500 if (PhysicsLogging.Enabled) beforeTime = Util.EnvironmentTickCount();
499 501
500 numSubSteps = BulletSimAPI.PhysicsStep2(World.ptr, timeStep, m_maxSubSteps, m_fixedTimeStep, 502 numSubSteps = BulletSimAPI.PhysicsStep2(World.ptr, timeStep, m_maxSubSteps, m_fixedTimeStep,
@@ -503,7 +505,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
503 if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime); 505 if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime);
504 DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}", 506 DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}",
505 DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, updatedEntityCount, collidersCount); 507 DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, updatedEntityCount, collidersCount);
506 if (VehicleLoggingEnabled) DumpVehicles(); // DEBUG 508 // if (VehicleLoggingEnabled) DumpVehicles(); // DEBUG
507 } 509 }
508 catch (Exception e) 510 catch (Exception e)
509 { 511 {
@@ -634,12 +636,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
634 636
635 public override void SetWaterLevel(float baseheight) 637 public override void SetWaterLevel(float baseheight)
636 { 638 {
637 m_waterLevel = baseheight; 639 SimpleWaterLevel = baseheight;
638 }
639 // Someday....
640 public float GetWaterLevelAtXYZ(Vector3 loc)
641 {
642 return m_waterLevel;
643 } 640 }
644 641
645 public override void DeleteTerrain() 642 public override void DeleteTerrain()
@@ -1493,7 +1490,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
1493 { 1490 {
1494 PhysicsLogging.Write(msg, args); 1491 PhysicsLogging.Write(msg, args);
1495 // Add the Flush() if debugging crashes. Gets all the messages written out. 1492 // Add the Flush() if debugging crashes. Gets all the messages written out.
1496 // PhysicsLogging.Flush(); 1493 if (m_physicsLoggingDoFlush) PhysicsLogging.Flush();
1497 } 1494 }
1498 // Used to fill in the LocalID when there isn't one. It's the correct number of characters. 1495 // Used to fill in the LocalID when there isn't one. It's the correct number of characters.
1499 public const string DetailLogZero = "0000000000"; 1496 public const string DetailLogZero = "0000000000";
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
index 1450f66..0cb151e 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
@@ -148,7 +148,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
148 } 148 }
149 149
150 // The passed position is relative to the base of the region. 150 // The passed position is relative to the base of the region.
151 public override float GetHeightAtXYZ(Vector3 pos) 151 public override float GetTerrainHeightAtXYZ(Vector3 pos)
152 { 152 {
153 float ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET; 153 float ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET;
154 154
@@ -166,5 +166,11 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
166 } 166 }
167 return ret; 167 return ret;
168 } 168 }
169
170 // The passed position is relative to the base of the region.
171 public override float GetWaterLevelAtXYZ(Vector3 pos)
172 {
173 return PhysicsScene.SimpleWaterLevel;
174 }
169} 175}
170} 176}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
index cd623f1..17d9536 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.
@@ -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 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
index 5f6675d..7e93ab4 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
@@ -148,7 +148,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
148 } 148 }
149 } 149 }
150 150
151 public override float GetHeightAtXYZ(Vector3 pos) 151 public override float GetTerrainHeightAtXYZ(Vector3 pos)
152 { 152 {
153 // For the moment use the saved heightmap to get the terrain height. 153 // For the moment use the saved heightmap to get the terrain height.
154 // TODO: raycast downward to find the true terrain below the position. 154 // TODO: raycast downward to find the true terrain below the position.
@@ -169,6 +169,12 @@ public sealed class BSTerrainMesh : BSTerrainPhys
169 return ret; 169 return ret;
170 } 170 }
171 171
172 // The passed position is relative to the base of the region.
173 public override float GetWaterLevelAtXYZ(Vector3 pos)
174 {
175 return PhysicsScene.SimpleWaterLevel;
176 }
177
172 // Convert the passed heightmap to mesh information suitable for CreateMeshShape2(). 178 // Convert the passed heightmap to mesh information suitable for CreateMeshShape2().
173 // Return 'true' if successfully created. 179 // Return 'true' if successfully created.
174 public static bool ConvertHeightmapToMesh( 180 public static bool ConvertHeightmapToMesh(