aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorRobert Adams2012-08-09 15:17:19 -0700
committerRobert Adams2012-08-09 15:17:19 -0700
commit320982cae388814b8e7e9e9fe62724caa9621d90 (patch)
treeef2d7bd50cfb5276b7573022867d812446a2e54e /OpenSim/Region/Physics
parentBulletSim: separate out the constraints by type. The linksets use (diff)
downloadopensim-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')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs22
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs4
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs49
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs34
4 files changed, 57 insertions, 52 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 8149a53..d49a578 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -122,7 +122,7 @@ public class BSCharacter : PhysicsActor
122 shapeData.Restitution = _scene.Params.avatarRestitution; 122 shapeData.Restitution = _scene.Params.avatarRestitution;
123 123
124 // do actual create at taint time 124 // do actual create at taint time
125 _scene.TaintedObject(delegate() 125 _scene.TaintedObject("BSCharacter.create", delegate()
126 { 126 {
127 BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData); 127 BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
128 128
@@ -138,7 +138,7 @@ public class BSCharacter : PhysicsActor
138 public void Destroy() 138 public void Destroy()
139 { 139 {
140 // DetailLog("{0},Destroy", LocalID); 140 // DetailLog("{0},Destroy", LocalID);
141 _scene.TaintedObject(delegate() 141 _scene.TaintedObject("BSCharacter.destroy", delegate()
142 { 142 {
143 BulletSimAPI.DestroyObject(_scene.WorldID, _localID); 143 BulletSimAPI.DestroyObject(_scene.WorldID, _localID);
144 }); 144 });
@@ -169,7 +169,7 @@ public class BSCharacter : PhysicsActor
169 169
170 ComputeAvatarVolumeAndMass(); 170 ComputeAvatarVolumeAndMass();
171 171
172 _scene.TaintedObject(delegate() 172 _scene.TaintedObject("BSCharacter.setSize", delegate()
173 { 173 {
174 BulletSimAPI.SetObjectScaleMass(_scene.WorldID, LocalID, _scale, _mass, true); 174 BulletSimAPI.SetObjectScaleMass(_scene.WorldID, LocalID, _scale, _mass, true);
175 }); 175 });
@@ -207,7 +207,7 @@ public class BSCharacter : PhysicsActor
207 _position = value; 207 _position = value;
208 PositionSanityCheck(); 208 PositionSanityCheck();
209 209
210 _scene.TaintedObject(delegate() 210 _scene.TaintedObject("BSCharacter.setPosition", delegate()
211 { 211 {
212 DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 212 DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
213 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); 213 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
@@ -246,7 +246,7 @@ public class BSCharacter : PhysicsActor
246 set { 246 set {
247 _force = value; 247 _force = value;
248 // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force); 248 // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force);
249 Scene.TaintedObject(delegate() 249 Scene.TaintedObject("BSCharacter.SetForce", delegate()
250 { 250 {
251 DetailLog("{0},setForce,taint,force={1}", LocalID, _force); 251 DetailLog("{0},setForce,taint,force={1}", LocalID, _force);
252 BulletSimAPI.SetObjectForce(Scene.WorldID, LocalID, _force); 252 BulletSimAPI.SetObjectForce(Scene.WorldID, LocalID, _force);
@@ -273,7 +273,7 @@ public class BSCharacter : PhysicsActor
273 set { 273 set {
274 _velocity = value; 274 _velocity = value;
275 // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity); 275 // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity);
276 _scene.TaintedObject(delegate() 276 _scene.TaintedObject("BSCharacter.setVelocity", delegate()
277 { 277 {
278 DetailLog("{0},setVelocity,taint,vel={1}", LocalID, _velocity); 278 DetailLog("{0},setVelocity,taint,vel={1}", LocalID, _velocity);
279 BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity); 279 BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity);
@@ -299,7 +299,7 @@ public class BSCharacter : PhysicsActor
299 set { 299 set {
300 _orientation = value; 300 _orientation = value;
301 // m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation); 301 // m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
302 _scene.TaintedObject(delegate() 302 _scene.TaintedObject("BSCharacter.setOrientation", delegate()
303 { 303 {
304 // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); 304 // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
305 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); 305 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
@@ -366,7 +366,7 @@ public class BSCharacter : PhysicsActor
366 public override float Buoyancy { 366 public override float Buoyancy {
367 get { return _buoyancy; } 367 get { return _buoyancy; }
368 set { _buoyancy = value; 368 set { _buoyancy = value;
369 _scene.TaintedObject(delegate() 369 _scene.TaintedObject("BSCharacter.setBuoyancy", delegate()
370 { 370 {
371 DetailLog("{0},setBuoyancy,taint,buoy={1}", LocalID, _buoyancy); 371 DetailLog("{0},setBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
372 BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy); 372 BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy);
@@ -413,7 +413,7 @@ public class BSCharacter : PhysicsActor
413 _force.Y += force.Y; 413 _force.Y += force.Y;
414 _force.Z += force.Z; 414 _force.Z += force.Z;
415 // m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force); 415 // m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force);
416 _scene.TaintedObject(delegate() 416 _scene.TaintedObject("BSCharacter.AddForce", delegate()
417 { 417 {
418 DetailLog("{0},setAddForce,taint,addedForce={1}", LocalID, _force); 418 DetailLog("{0},setAddForce,taint,addedForce={1}", LocalID, _force);
419 BulletSimAPI.AddObjectForce2(Body.Ptr, _force); 419 BulletSimAPI.AddObjectForce2(Body.Ptr, _force);
@@ -439,7 +439,7 @@ public class BSCharacter : PhysicsActor
439 // make sure first collision happens 439 // make sure first collision happens
440 _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; 440 _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs;
441 441
442 Scene.TaintedObject(delegate() 442 Scene.TaintedObject("BSCharacter.SubscribeEvents", delegate()
443 { 443 {
444 BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); 444 BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
445 }); 445 });
@@ -449,7 +449,7 @@ public class BSCharacter : PhysicsActor
449 public override void UnSubscribeEvents() { 449 public override void UnSubscribeEvents() {
450 _subscribedEventsMs = 0; 450 _subscribedEventsMs = 0;
451 // Avatars get all their collision events 451 // Avatars get all their collision events
452 // Scene.TaintedObject(delegate() 452 // Scene.TaintedObject("BSCharacter.UnSubscribeEvents", delegate()
453 // { 453 // {
454 // BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); 454 // BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
455 // }); 455 // });
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index e265d6d..bf262c5 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -236,7 +236,7 @@ public class BSLinkset
236 { 236 {
237 m_children.Add(child); 237 m_children.Add(child);
238 238
239 m_scene.TaintedObject(delegate() 239 m_scene.TaintedObject("AddChildToLinkset", delegate()
240 { 240 {
241 DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID); 241 DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID);
242 DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID); 242 DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID);
@@ -265,7 +265,7 @@ public class BSLinkset
265 265
266 if (m_children.Remove(child)) 266 if (m_children.Remove(child))
267 { 267 {
268 m_scene.TaintedObject(delegate() 268 m_scene.TaintedObject("RemoveChildFromLinkset", delegate()
269 { 269 {
270 DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); 270 DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID);
271 DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID); 271 DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index e0f6ed2..988e03b 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -145,7 +145,7 @@ public sealed class BSPrim : PhysicsActor
145 _vehicle = new BSDynamics(this); // add vehicleness 145 _vehicle = new BSDynamics(this); // add vehicleness
146 _mass = CalculateMass(); 146 _mass = CalculateMass();
147 // do the actual object creation at taint time 147 // do the actual object creation at taint time
148 _scene.TaintedObject(delegate() 148 _scene.TaintedObject("BSPrim.create", delegate()
149 { 149 {
150 RecreateGeomAndObject(); 150 RecreateGeomAndObject();
151 151
@@ -166,7 +166,7 @@ public sealed class BSPrim : PhysicsActor
166 _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); 166 _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE);
167 _scene.RemoveVehiclePrim(this); // just to make sure 167 _scene.RemoveVehiclePrim(this); // just to make sure
168 168
169 _scene.TaintedObject(delegate() 169 _scene.TaintedObject("BSPrim.destroy", delegate()
170 { 170 {
171 // Undo any links between me and any other object 171 // Undo any links between me and any other object
172 _linkset = _linkset.RemoveMeFromLinkset(this); 172 _linkset = _linkset.RemoveMeFromLinkset(this);
@@ -183,7 +183,7 @@ public sealed class BSPrim : PhysicsActor
183 get { return _size; } 183 get { return _size; }
184 set { 184 set {
185 _size = value; 185 _size = value;
186 _scene.TaintedObject(delegate() 186 _scene.TaintedObject("BSPrim.setSize", delegate()
187 { 187 {
188 _mass = CalculateMass(); // changing size changes the mass 188 _mass = CalculateMass(); // changing size changes the mass
189 BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical); 189 BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical);
@@ -195,7 +195,7 @@ public sealed class BSPrim : PhysicsActor
195 public override PrimitiveBaseShape Shape { 195 public override PrimitiveBaseShape Shape {
196 set { 196 set {
197 _pbs = value; 197 _pbs = value;
198 _scene.TaintedObject(delegate() 198 _scene.TaintedObject("BSPrim.setShape", delegate()
199 { 199 {
200 _mass = CalculateMass(); // changing the shape changes the mass 200 _mass = CalculateMass(); // changing the shape changes the mass
201 RecreateGeomAndObject(); 201 RecreateGeomAndObject();
@@ -213,7 +213,7 @@ public sealed class BSPrim : PhysicsActor
213 public override bool Selected { 213 public override bool Selected {
214 set { 214 set {
215 _isSelected = value; 215 _isSelected = value;
216 _scene.TaintedObject(delegate() 216 _scene.TaintedObject("BSPrim.setSelected", delegate()
217 { 217 {
218 SetObjectDynamic(); 218 SetObjectDynamic();
219 }); 219 });
@@ -281,7 +281,7 @@ public sealed class BSPrim : PhysicsActor
281 set { 281 set {
282 _position = value; 282 _position = value;
283 // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? 283 // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint?
284 _scene.TaintedObject(delegate() 284 _scene.TaintedObject("BSPrim.setPosition", delegate()
285 { 285 {
286 DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 286 DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
287 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); 287 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
@@ -318,7 +318,7 @@ public sealed class BSPrim : PhysicsActor
318 get { return _force; } 318 get { return _force; }
319 set { 319 set {
320 _force = value; 320 _force = value;
321 _scene.TaintedObject(delegate() 321 _scene.TaintedObject("BSPrim.setForce", delegate()
322 { 322 {
323 DetailLog("{0},setForce,taint,force={1}", LocalID, _force); 323 DetailLog("{0},setForce,taint,force={1}", LocalID, _force);
324 // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); 324 // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force);
@@ -333,7 +333,7 @@ public sealed class BSPrim : PhysicsActor
333 } 333 }
334 set { 334 set {
335 Vehicle type = (Vehicle)value; 335 Vehicle type = (Vehicle)value;
336 _scene.TaintedObject(delegate() 336 _scene.TaintedObject("BSPrim.setVehicleType", delegate()
337 { 337 {
338 DetailLog("{0},SetVehicleType,taint,type={1}", LocalID, type); 338 DetailLog("{0},SetVehicleType,taint,type={1}", LocalID, type);
339 _vehicle.ProcessTypeChange(type); 339 _vehicle.ProcessTypeChange(type);
@@ -343,12 +343,7 @@ public sealed class BSPrim : PhysicsActor
343 } 343 }
344 else 344 else
345 { 345 {
346 _scene.TaintedObject(delegate() 346 BulletSimAPI.ClearForces2(this.Body.Ptr);
347 {
348 // Tell the physics engine to clear state
349 BulletSimAPI.ClearForces2(this.Body.Ptr);
350 });
351
352 // make it so the scene will call us each tick to do vehicle things 347 // make it so the scene will call us each tick to do vehicle things
353 _scene.AddVehiclePrim(this); 348 _scene.AddVehiclePrim(this);
354 } 349 }
@@ -358,28 +353,28 @@ public sealed class BSPrim : PhysicsActor
358 } 353 }
359 public override void VehicleFloatParam(int param, float value) 354 public override void VehicleFloatParam(int param, float value)
360 { 355 {
361 _scene.TaintedObject(delegate() 356 _scene.TaintedObject("BSPrim.VehicleFloatParam", delegate()
362 { 357 {
363 _vehicle.ProcessFloatVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep); 358 _vehicle.ProcessFloatVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep);
364 }); 359 });
365 } 360 }
366 public override void VehicleVectorParam(int param, OMV.Vector3 value) 361 public override void VehicleVectorParam(int param, OMV.Vector3 value)
367 { 362 {
368 _scene.TaintedObject(delegate() 363 _scene.TaintedObject("BSPrim.VehicleVectorParam", delegate()
369 { 364 {
370 _vehicle.ProcessVectorVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep); 365 _vehicle.ProcessVectorVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep);
371 }); 366 });
372 } 367 }
373 public override void VehicleRotationParam(int param, OMV.Quaternion rotation) 368 public override void VehicleRotationParam(int param, OMV.Quaternion rotation)
374 { 369 {
375 _scene.TaintedObject(delegate() 370 _scene.TaintedObject("BSPrim.VehicleRotationParam", delegate()
376 { 371 {
377 _vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); 372 _vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation);
378 }); 373 });
379 } 374 }
380 public override void VehicleFlags(int param, bool remove) 375 public override void VehicleFlags(int param, bool remove)
381 { 376 {
382 _scene.TaintedObject(delegate() 377 _scene.TaintedObject("BSPrim.VehicleFlags", delegate()
383 { 378 {
384 _vehicle.ProcessVehicleFlags(param, remove); 379 _vehicle.ProcessVehicleFlags(param, remove);
385 }); 380 });
@@ -397,7 +392,7 @@ public sealed class BSPrim : PhysicsActor
397 public override void SetVolumeDetect(int param) { 392 public override void SetVolumeDetect(int param) {
398 bool newValue = (param != 0); 393 bool newValue = (param != 0);
399 _isVolumeDetect = newValue; 394 _isVolumeDetect = newValue;
400 _scene.TaintedObject(delegate() 395 _scene.TaintedObject("BSPrim.SetVolumeDetect", delegate()
401 { 396 {
402 SetObjectDynamic(); 397 SetObjectDynamic();
403 }); 398 });
@@ -408,7 +403,7 @@ public sealed class BSPrim : PhysicsActor
408 get { return _velocity; } 403 get { return _velocity; }
409 set { 404 set {
410 _velocity = value; 405 _velocity = value;
411 _scene.TaintedObject(delegate() 406 _scene.TaintedObject("BSPrim.setVelocity", delegate()
412 { 407 {
413 DetailLog("{0},SetVelocity,taint,vel={1}", LocalID, _velocity); 408 DetailLog("{0},SetVelocity,taint,vel={1}", LocalID, _velocity);
414 BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity); 409 BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity);
@@ -442,7 +437,7 @@ public sealed class BSPrim : PhysicsActor
442 set { 437 set {
443 _orientation = value; 438 _orientation = value;
444 // TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint? 439 // TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint?
445 _scene.TaintedObject(delegate() 440 _scene.TaintedObject("BSPrim.setOrientation", delegate()
446 { 441 {
447 // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); 442 // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
448 DetailLog("{0},setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); 443 DetailLog("{0},setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
@@ -459,7 +454,7 @@ public sealed class BSPrim : PhysicsActor
459 get { return _isPhysical; } 454 get { return _isPhysical; }
460 set { 455 set {
461 _isPhysical = value; 456 _isPhysical = value;
462 _scene.TaintedObject(delegate() 457 _scene.TaintedObject("BSPrim.setIsPhysical", delegate()
463 { 458 {
464 SetObjectDynamic(); 459 SetObjectDynamic();
465 }); 460 });
@@ -547,7 +542,7 @@ public sealed class BSPrim : PhysicsActor
547 set { 542 set {
548 _rotationalVelocity = value; 543 _rotationalVelocity = value;
549 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); 544 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
550 _scene.TaintedObject(delegate() 545 _scene.TaintedObject("BSPrim.setRotationalVelocity", delegate()
551 { 546 {
552 DetailLog("{0},SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); 547 DetailLog("{0},SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
553 BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity); 548 BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity);
@@ -564,7 +559,7 @@ public sealed class BSPrim : PhysicsActor
564 get { return _buoyancy; } 559 get { return _buoyancy; }
565 set { 560 set {
566 _buoyancy = value; 561 _buoyancy = value;
567 _scene.TaintedObject(delegate() 562 _scene.TaintedObject("BSPrim.setBuoyancy", delegate()
568 { 563 {
569 DetailLog("{0},SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); 564 DetailLog("{0},SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
570 BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy); 565 BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy);
@@ -618,7 +613,7 @@ public sealed class BSPrim : PhysicsActor
618 m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader); 613 m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader);
619 return; 614 return;
620 } 615 }
621 _scene.TaintedObject(delegate() 616 _scene.TaintedObject("BSPrim.AddForce", delegate()
622 { 617 {
623 OMV.Vector3 fSum = OMV.Vector3.Zero; 618 OMV.Vector3 fSum = OMV.Vector3.Zero;
624 lock (m_accumulatedForces) 619 lock (m_accumulatedForces)
@@ -648,7 +643,7 @@ public sealed class BSPrim : PhysicsActor
648 // make sure first collision happens 643 // make sure first collision happens
649 _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; 644 _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs;
650 645
651 Scene.TaintedObject(delegate() 646 Scene.TaintedObject("BSPrim.SubscribeEvents", delegate()
652 { 647 {
653 BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); 648 BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
654 }); 649 });
@@ -656,7 +651,7 @@ public sealed class BSPrim : PhysicsActor
656 } 651 }
657 public override void UnSubscribeEvents() { 652 public override void UnSubscribeEvents() {
658 _subscribedEventsMs = 0; 653 _subscribedEventsMs = 0;
659 Scene.TaintedObject(delegate() 654 Scene.TaintedObject("BSPrim.UnSubscribeEvents", delegate()
660 { 655 {
661 BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); 656 BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
662 }); 657 });
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 }