diff options
author | Robert Adams | 2012-08-09 15:17:19 -0700 |
---|---|---|
committer | Robert Adams | 2012-08-09 15:17:19 -0700 |
commit | 320982cae388814b8e7e9e9fe62724caa9621d90 (patch) | |
tree | ef2d7bd50cfb5276b7573022867d812446a2e54e /OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |
parent | BulletSim: separate out the constraints by type. The linksets use (diff) | |
download | opensim-SC_OLD-320982cae388814b8e7e9e9fe62724caa9621d90.zip opensim-SC_OLD-320982cae388814b8e7e9e9fe62724caa9621d90.tar.gz opensim-SC_OLD-320982cae388814b8e7e9e9fe62724caa9621d90.tar.bz2 opensim-SC_OLD-320982cae388814b8e7e9e9fe62724caa9621d90.tar.xz |
BulletSim: add an identifier to the TaintObject call so exceptions that happen when the taint is invoked can be debugged
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSScene.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 117086a..65a8014 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -162,7 +162,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
162 | } | 162 | } |
163 | 163 | ||
164 | public delegate void TaintCallback(); | 164 | public delegate void TaintCallback(); |
165 | private List<TaintCallback> _taintedObjects; | 165 | private struct TaintCallbackEntry |
166 | { | ||
167 | public String ident; | ||
168 | public TaintCallback callback; | ||
169 | public TaintCallbackEntry(string i, TaintCallback c) | ||
170 | { | ||
171 | ident = i; | ||
172 | callback = c; | ||
173 | } | ||
174 | } | ||
175 | private List<TaintCallbackEntry> _taintedObjects; | ||
166 | private Object _taintLock = new Object(); | 176 | private Object _taintLock = new Object(); |
167 | 177 | ||
168 | // A pointer to an instance if this structure is passed to the C++ code | 178 | // A pointer to an instance if this structure is passed to the C++ code |
@@ -232,7 +242,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
232 | BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle); | 242 | BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle); |
233 | } | 243 | } |
234 | 244 | ||
235 | _taintedObjects = new List<TaintCallback>(); | 245 | _taintedObjects = new List<TaintCallbackEntry>(); |
236 | 246 | ||
237 | mesher = meshmerizer; | 247 | mesher = meshmerizer; |
238 | // The bounding box for the simulated world | 248 | // The bounding box for the simulated world |
@@ -535,7 +545,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
535 | 545 | ||
536 | public override void SetTerrain(float[] heightMap) { | 546 | public override void SetTerrain(float[] heightMap) { |
537 | m_heightMap = heightMap; | 547 | m_heightMap = heightMap; |
538 | this.TaintedObject(delegate() | 548 | this.TaintedObject("BSScene.SetTerrain", delegate() |
539 | { | 549 | { |
540 | BulletSimAPI.SetHeightmap(m_worldID, m_heightMap); | 550 | BulletSimAPI.SetHeightmap(m_worldID, m_heightMap); |
541 | }); | 551 | }); |
@@ -727,12 +737,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
727 | // Calls to the PhysicsActors can't directly call into the physics engine | 737 | // Calls to the PhysicsActors can't directly call into the physics engine |
728 | // because it might be busy. We delay changes to a known time. | 738 | // because it might be busy. We delay changes to a known time. |
729 | // We rely on C#'s closure to save and restore the context for the delegate. | 739 | // We rely on C#'s closure to save and restore the context for the delegate. |
730 | public void TaintedObject(TaintCallback callback) | 740 | public void TaintedObject(String ident, TaintCallback callback) |
731 | { | 741 | { |
732 | if (!m_initialized) return; | 742 | if (!m_initialized) return; |
733 | 743 | ||
734 | lock (_taintLock) | 744 | lock (_taintLock) |
735 | _taintedObjects.Add(callback); | 745 | _taintedObjects.Add(new TaintCallbackEntry(ident, callback)); |
736 | return; | 746 | return; |
737 | } | 747 | } |
738 | 748 | ||
@@ -744,22 +754,22 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
744 | if (_taintedObjects.Count > 0) // save allocating new list if there is nothing to process | 754 | if (_taintedObjects.Count > 0) // save allocating new list if there is nothing to process |
745 | { | 755 | { |
746 | // swizzle a new list into the list location so we can process what's there | 756 | // swizzle a new list into the list location so we can process what's there |
747 | List<TaintCallback> oldList; | 757 | List<TaintCallbackEntry> oldList; |
748 | lock (_taintLock) | 758 | lock (_taintLock) |
749 | { | 759 | { |
750 | oldList = _taintedObjects; | 760 | oldList = _taintedObjects; |
751 | _taintedObjects = new List<TaintCallback>(); | 761 | _taintedObjects = new List<TaintCallbackEntry>(); |
752 | } | 762 | } |
753 | 763 | ||
754 | foreach (TaintCallback callback in oldList) | 764 | foreach (TaintCallbackEntry tcbe in oldList) |
755 | { | 765 | { |
756 | try | 766 | try |
757 | { | 767 | { |
758 | callback(); | 768 | tcbe.callback(); |
759 | } | 769 | } |
760 | catch (Exception e) | 770 | catch (Exception e) |
761 | { | 771 | { |
762 | m_log.ErrorFormat("{0}: ProcessTaints: Exception: {1}", LogHeader, e); | 772 | m_log.ErrorFormat("{0}: ProcessTaints: {1}: Exception: {2}", LogHeader, tcbe.ident, e); |
763 | } | 773 | } |
764 | } | 774 | } |
765 | oldList.Clear(); | 775 | oldList.Clear(); |
@@ -1248,7 +1258,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1248 | List<uint> objectIDs = lIDs; | 1258 | List<uint> objectIDs = lIDs; |
1249 | string xparm = parm.ToLower(); | 1259 | string xparm = parm.ToLower(); |
1250 | float xval = val; | 1260 | float xval = val; |
1251 | TaintedObject(delegate() { | 1261 | TaintedObject("BSScene.UpdateParameterSet", delegate() { |
1252 | foreach (uint lID in objectIDs) | 1262 | foreach (uint lID in objectIDs) |
1253 | { | 1263 | { |
1254 | BulletSimAPI.UpdateParameter(m_worldID, lID, xparm, xval); | 1264 | BulletSimAPI.UpdateParameter(m_worldID, lID, xparm, xval); |
@@ -1268,7 +1278,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1268 | uint xlocalID = localID; | 1278 | uint xlocalID = localID; |
1269 | string xparm = parm.ToLower(); | 1279 | string xparm = parm.ToLower(); |
1270 | float xval = val; | 1280 | float xval = val; |
1271 | TaintedObject(delegate() { | 1281 | TaintedObject("BSScene.TaintedUpdateParameter", delegate() { |
1272 | BulletSimAPI.UpdateParameter(m_worldID, xlocalID, xparm, xval); | 1282 | BulletSimAPI.UpdateParameter(m_worldID, xlocalID, xparm, xval); |
1273 | }); | 1283 | }); |
1274 | } | 1284 | } |