diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSScene.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index c4b4332..9d41ce8 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -30,9 +30,9 @@ using System.Runtime.InteropServices; | |||
30 | using System.Text; | 30 | using System.Text; |
31 | using System.Threading; | 31 | using System.Threading; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Region.CoreModules.Framework.Statistics.Logging; | ||
34 | using OpenSim.Region.Framework; | 33 | using OpenSim.Region.Framework; |
35 | using OpenSim.Region.Physics.Manager; | 34 | using OpenSim.Region.Physics.Manager; |
35 | using Logging = OpenSim.Region.CoreModules.Framework.Statistics.Logging; | ||
36 | using Nini.Config; | 36 | using Nini.Config; |
37 | using log4net; | 37 | using log4net; |
38 | using OpenMetaverse; | 38 | using OpenMetaverse; |
@@ -45,15 +45,17 @@ using OpenMetaverse; | |||
45 | // Compute physics FPS reasonably | 45 | // Compute physics FPS reasonably |
46 | // Based on material, set density and friction | 46 | // Based on material, set density and friction |
47 | // More efficient memory usage when passing hull information from BSPrim to BulletSim | 47 | // More efficient memory usage when passing hull information from BSPrim to BulletSim |
48 | // Move all logic out of the C++ code and into the C# code for easier future modifications. | ||
48 | // Four states of prim: Physical, regular, phantom and selected. Are we modeling these correctly? | 49 | // Four states of prim: Physical, regular, phantom and selected. Are we modeling these correctly? |
49 | // In SL one can set both physical and phantom (gravity, does not effect others, makes collisions with ground) | 50 | // In SL one can set both physical and phantom (gravity, does not effect others, makes collisions with ground) |
50 | // At the moment, physical and phantom causes object to drop through the terrain | 51 | // At the moment, physical and phantom causes object to drop through the terrain |
51 | // Physical phantom objects and related typing (collision options ) | 52 | // Physical phantom objects and related typing (collision options ) |
53 | // Use collision masks for collision with terrain and phantom objects | ||
52 | // Check out llVolumeDetect. Must do something for that. | 54 | // Check out llVolumeDetect. Must do something for that. |
53 | // Should prim.link() and prim.delink() membership checking happen at taint time? | 55 | // Should prim.link() and prim.delink() membership checking happen at taint time? |
56 | // changing the position and orientation of a linked prim must rebuild the constraint with the root. | ||
54 | // Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once | 57 | // Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once |
55 | // Do attachments need to be handled separately? Need collision events. Do not collide with VolumeDetect | 58 | // Do attachments need to be handled separately? Need collision events. Do not collide with VolumeDetect |
56 | // Use collision masks for collision with terrain and phantom objects | ||
57 | // Implement the genCollisions feature in BulletSim::SetObjectProperties (don't pass up unneeded collisions) | 59 | // Implement the genCollisions feature in BulletSim::SetObjectProperties (don't pass up unneeded collisions) |
58 | // Implement LockAngularMotion | 60 | // Implement LockAngularMotion |
59 | // Decide if clearing forces is the right thing to do when setting position (BulletSim::SetObjectTranslation) | 61 | // Decide if clearing forces is the right thing to do when setting position (BulletSim::SetObjectTranslation) |
@@ -61,9 +63,6 @@ using OpenMetaverse; | |||
61 | // Remove mesh and Hull stuff. Use mesh passed to bullet and use convexdecom from bullet. | 63 | // Remove mesh and Hull stuff. Use mesh passed to bullet and use convexdecom from bullet. |
62 | // Add PID movement operations. What does ScenePresence.MoveToTarget do? | 64 | // Add PID movement operations. What does ScenePresence.MoveToTarget do? |
63 | // Check terrain size. 128 or 127? | 65 | // Check terrain size. 128 or 127? |
64 | // Multiple contact points on collision? | ||
65 | // See code in ode::near... calls to collision_accounting_events() | ||
66 | // (This might not be a problem. ODE collects all the collisions with one object in one tick.) | ||
67 | // Raycast | 66 | // Raycast |
68 | // | 67 | // |
69 | namespace OpenSim.Region.Physics.BulletSPlugin | 68 | namespace OpenSim.Region.Physics.BulletSPlugin |
@@ -160,17 +159,14 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
160 | private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle; | 159 | private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle; |
161 | 160 | ||
162 | // Sometimes you just have to log everything. | 161 | // Sometimes you just have to log everything. |
163 | public LogWriter PhysicsLogging; | 162 | public Logging.LogWriter PhysicsLogging; |
164 | private bool m_physicsLoggingEnabled; | 163 | private bool m_physicsLoggingEnabled; |
165 | private string m_physicsLoggingDir; | 164 | private string m_physicsLoggingDir; |
166 | private string m_physicsLoggingPrefix; | 165 | private string m_physicsLoggingPrefix; |
167 | private int m_physicsLoggingFileMinutes; | 166 | private int m_physicsLoggingFileMinutes; |
168 | 167 | ||
169 | public LogWriter VehicleLogging; | ||
170 | private bool m_vehicleLoggingEnabled; | 168 | private bool m_vehicleLoggingEnabled; |
171 | private string m_vehicleLoggingDir; | 169 | public bool VehicleLoggingEnabled { get { return m_vehicleLoggingEnabled; } } |
172 | private string m_vehicleLoggingPrefix; | ||
173 | private int m_vehicleLoggingFileMinutes; | ||
174 | 170 | ||
175 | public BSScene(string identifier) | 171 | public BSScene(string identifier) |
176 | { | 172 | { |
@@ -197,19 +193,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
197 | // can be left in and every call doesn't have to check for null. | 193 | // can be left in and every call doesn't have to check for null. |
198 | if (m_physicsLoggingEnabled) | 194 | if (m_physicsLoggingEnabled) |
199 | { | 195 | { |
200 | PhysicsLogging = new LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes); | 196 | PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes); |
201 | } | 197 | } |
202 | else | 198 | else |
203 | { | 199 | { |
204 | PhysicsLogging = new LogWriter(); | 200 | PhysicsLogging = new Logging.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 | } | 201 | } |
214 | 202 | ||
215 | // Get the version of the DLL | 203 | // Get the version of the DLL |
@@ -218,11 +206,14 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
218 | // m_log.WarnFormat("{0}: BulletSim.dll version='{1}'", LogHeader, BulletSimVersion); | 206 | // m_log.WarnFormat("{0}: BulletSim.dll version='{1}'", LogHeader, BulletSimVersion); |
219 | 207 | ||
220 | // if Debug, enable logging from the unmanaged code | 208 | // if Debug, enable logging from the unmanaged code |
221 | if (m_log.IsDebugEnabled) | 209 | if (m_log.IsDebugEnabled || PhysicsLogging.Enabled) |
222 | { | 210 | { |
223 | m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader); | 211 | m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader); |
224 | // the handle is saved to it doesn't get freed after this call | 212 | if (PhysicsLogging.Enabled) |
225 | m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger); | 213 | m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLoggerPhysLog); |
214 | else | ||
215 | m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger); | ||
216 | // the handle is saved in a variable to make sure it doesn't get freed after this call | ||
226 | BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle); | 217 | BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle); |
227 | } | 218 | } |
228 | 219 | ||
@@ -363,9 +354,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
363 | m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5); | 354 | m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5); |
364 | // Very detailed logging for vehicle debugging | 355 | // Very detailed logging for vehicle debugging |
365 | m_vehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false); | 356 | 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); | ||
369 | } | 357 | } |
370 | } | 358 | } |
371 | m_params[0] = parms; | 359 | m_params[0] = parms; |
@@ -386,12 +374,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
386 | return ret; | 374 | return ret; |
387 | } | 375 | } |
388 | 376 | ||
389 | |||
390 | // Called directly from unmanaged code so don't do much | 377 | // Called directly from unmanaged code so don't do much |
391 | private void BulletLogger(string msg) | 378 | private void BulletLogger(string msg) |
392 | { | 379 | { |
393 | m_log.Debug("[BULLETS UNMANAGED]:" + msg); | 380 | m_log.Debug("[BULLETS UNMANAGED]:" + msg); |
394 | } | 381 | } |
382 | |||
383 | // Called directly from unmanaged code so don't do much | ||
384 | private void BulletLoggerPhysLog(string msg) | ||
385 | { | ||
386 | PhysicsLogging.Write("[BULLETS UNMANAGED]:" + msg); | ||
387 | } | ||
395 | 388 | ||
396 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) | 389 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) |
397 | { | 390 | { |
@@ -532,7 +525,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
532 | for (int ii = 0; ii < updatedEntityCount; ii++) | 525 | for (int ii = 0; ii < updatedEntityCount; ii++) |
533 | { | 526 | { |
534 | EntityProperties entprop = m_updateArray[ii]; | 527 | EntityProperties entprop = m_updateArray[ii]; |
535 | // m_log.DebugFormat("{0}: entprop[{1}]: id={2}, pos={3}", LogHeader, ii, entprop.ID, entprop.Position); | ||
536 | BSPrim prim; | 528 | BSPrim prim; |
537 | if (m_prims.TryGetValue(entprop.ID, out prim)) | 529 | if (m_prims.TryGetValue(entprop.ID, out prim)) |
538 | { | 530 | { |