diff options
author | Robert Adams | 2012-07-18 08:36:41 -0700 |
---|---|---|
committer | Robert Adams | 2012-07-20 14:02:27 -0700 |
commit | cda67a68de11790ff7f3f19937b4d08309bc1e89 (patch) | |
tree | 7c4df7a4ffd035a043856b2698518e9dc8c868d6 /OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |
parent | Correct namespace of BinaryLoggingModule (a cut-and-paste error). Add a simpl... (diff) | |
download | opensim-SC-cda67a68de11790ff7f3f19937b4d08309bc1e89.zip opensim-SC-cda67a68de11790ff7f3f19937b4d08309bc1e89.tar.gz opensim-SC-cda67a68de11790ff7f3f19937b4d08309bc1e89.tar.bz2 opensim-SC-cda67a68de11790ff7f3f19937b4d08309bc1e89.tar.xz |
BulletSim: Add very detailed logging to BSDynamics for vehicle debugging
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSScene.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 150326e..c4b4332 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -29,12 +29,13 @@ using System.Collections.Generic; | |||
29 | using System.Runtime.InteropServices; | 29 | using System.Runtime.InteropServices; |
30 | using System.Text; | 30 | using System.Text; |
31 | using System.Threading; | 31 | using System.Threading; |
32 | using Nini.Config; | ||
33 | using log4net; | ||
34 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Region.CoreModules.Framework.Statistics.Logging; | ||
34 | using OpenSim.Region.Framework; | ||
35 | using OpenSim.Region.Physics.Manager; | 35 | using OpenSim.Region.Physics.Manager; |
36 | using Nini.Config; | ||
37 | using log4net; | ||
36 | using OpenMetaverse; | 38 | using OpenMetaverse; |
37 | using OpenSim.Region.Framework; | ||
38 | 39 | ||
39 | // TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim) | 40 | // TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim) |
40 | // Debug linkset | 41 | // Debug linkset |
@@ -158,6 +159,19 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
158 | 159 | ||
159 | private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle; | 160 | private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle; |
160 | 161 | ||
162 | // Sometimes you just have to log everything. | ||
163 | public LogWriter PhysicsLogging; | ||
164 | private bool m_physicsLoggingEnabled; | ||
165 | private string m_physicsLoggingDir; | ||
166 | private string m_physicsLoggingPrefix; | ||
167 | private int m_physicsLoggingFileMinutes; | ||
168 | |||
169 | public LogWriter VehicleLogging; | ||
170 | private bool m_vehicleLoggingEnabled; | ||
171 | private string m_vehicleLoggingDir; | ||
172 | private string m_vehicleLoggingPrefix; | ||
173 | private int m_vehicleLoggingFileMinutes; | ||
174 | |||
161 | public BSScene(string identifier) | 175 | public BSScene(string identifier) |
162 | { | 176 | { |
163 | m_initialized = false; | 177 | m_initialized = false; |
@@ -178,6 +192,26 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
178 | m_updateArray = new EntityProperties[m_maxUpdatesPerFrame]; | 192 | m_updateArray = new EntityProperties[m_maxUpdatesPerFrame]; |
179 | m_updateArrayPinnedHandle = GCHandle.Alloc(m_updateArray, GCHandleType.Pinned); | 193 | m_updateArrayPinnedHandle = GCHandle.Alloc(m_updateArray, GCHandleType.Pinned); |
180 | 194 | ||
195 | // Enable very detailed logging. | ||
196 | // By creating an empty logger when not logging, the log message invocation code | ||
197 | // can be left in and every call doesn't have to check for null. | ||
198 | if (m_physicsLoggingEnabled) | ||
199 | { | ||
200 | PhysicsLogging = new LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes); | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | PhysicsLogging = new LogWriter(); | ||
205 | } | ||
206 | if (m_vehicleLoggingEnabled) | ||
207 | { | ||
208 | VehicleLogging = new LogWriter(m_vehicleLoggingDir, m_vehicleLoggingPrefix, m_vehicleLoggingFileMinutes); | ||
209 | } | ||
210 | else | ||
211 | { | ||
212 | VehicleLogging = new LogWriter(); | ||
213 | } | ||
214 | |||
181 | // Get the version of the DLL | 215 | // Get the version of the DLL |
182 | // TODO: this doesn't work yet. Something wrong with marshaling the returned string. | 216 | // TODO: this doesn't work yet. Something wrong with marshaling the returned string. |
183 | // BulletSimVersion = BulletSimAPI.GetVersion(); | 217 | // BulletSimVersion = BulletSimAPI.GetVersion(); |
@@ -321,6 +355,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
321 | parms.shouldSplitSimulationIslands = ParamBoolean(pConfig, "ShouldSplitSimulationIslands", parms.shouldSplitSimulationIslands); | 355 | parms.shouldSplitSimulationIslands = ParamBoolean(pConfig, "ShouldSplitSimulationIslands", parms.shouldSplitSimulationIslands); |
322 | parms.shouldEnableFrictionCaching = ParamBoolean(pConfig, "ShouldEnableFrictionCaching", parms.shouldEnableFrictionCaching); | 356 | parms.shouldEnableFrictionCaching = ParamBoolean(pConfig, "ShouldEnableFrictionCaching", parms.shouldEnableFrictionCaching); |
323 | parms.numberOfSolverIterations = pConfig.GetFloat("NumberOfSolverIterations", parms.numberOfSolverIterations); | 357 | parms.numberOfSolverIterations = pConfig.GetFloat("NumberOfSolverIterations", parms.numberOfSolverIterations); |
358 | |||
359 | // Very detailed logging for physics debugging | ||
360 | m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false); | ||
361 | m_physicsLoggingDir = pConfig.GetString("PhysicsLoggingDir", "."); | ||
362 | m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-"); | ||
363 | m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5); | ||
364 | // Very detailed logging for vehicle debugging | ||
365 | m_vehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false); | ||
366 | m_vehicleLoggingDir = pConfig.GetString("VehicleLoggingDir", "."); | ||
367 | m_vehicleLoggingPrefix = pConfig.GetString("VehicleLoggingPrefix", "vehicle-"); | ||
368 | m_vehicleLoggingFileMinutes = pConfig.GetInt("VehicleLoggingFileMinutes", 5); | ||
324 | } | 369 | } |
325 | } | 370 | } |
326 | m_params[0] = parms; | 371 | m_params[0] = parms; |
@@ -560,8 +605,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
560 | }); | 605 | }); |
561 | } | 606 | } |
562 | 607 | ||
608 | // Someday we will have complex terrain with caves and tunnels | ||
609 | // For the moment, it's flat and convex | ||
610 | public float GetTerrainHeightAtXYZ(Vector3 loc) | ||
611 | { | ||
612 | return GetTerrainHeightAtXY(loc.X, loc.Y); | ||
613 | } | ||
614 | |||
563 | public float GetTerrainHeightAtXY(float tX, float tY) | 615 | public float GetTerrainHeightAtXY(float tX, float tY) |
564 | { | 616 | { |
617 | if (tX < 0 || tX >= Constants.RegionSize || tY < 0 || tY >= Constants.RegionSize) | ||
618 | return 30; | ||
565 | return m_heightMap[((int)tX) * Constants.RegionSize + ((int)tY)]; | 619 | return m_heightMap[((int)tX) * Constants.RegionSize + ((int)tY)]; |
566 | } | 620 | } |
567 | 621 | ||