aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2013-01-14 15:46:46 -0800
committerRobert Adams2013-01-14 15:46:46 -0800
commit4e1ca890c2d41bf244ed7d4847c0d0a4fc7f6c51 (patch)
treebef4e616c6fb6a3de0e6859b6ef3e664095c2ae6 /OpenSim/Region
parentBulletSim: disable center-of-mass computation for linksets until debugged. Mo... (diff)
downloadopensim-SC_OLD-4e1ca890c2d41bf244ed7d4847c0d0a4fc7f6c51.zip
opensim-SC_OLD-4e1ca890c2d41bf244ed7d4847c0d0a4fc7f6c51.tar.gz
opensim-SC_OLD-4e1ca890c2d41bf244ed7d4847c0d0a4fc7f6c51.tar.bz2
opensim-SC_OLD-4e1ca890c2d41bf244ed7d4847c0d0a4fc7f6c51.tar.xz
BulletSim: fix not moving physical objects below terrain to over terrain.
Add locking on register prestep action list preventing potential race conditions. Little comment and formatting changes.
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs4
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs29
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs17
5 files changed, 36 insertions, 18 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
index 0fef67c..9ff7084 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
@@ -202,7 +202,7 @@ private void BulletLoggerPhysLog(string msg)
202} 202}
203 203
204public override int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, 204public override int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep,
205 out int updatedEntityCount, out int collidersCount) 205 out int updatedEntityCount, out int collidersCount)
206{ 206{
207 BulletWorldUnman worldu = world as BulletWorldUnman; 207 BulletWorldUnman worldu = world as BulletWorldUnman;
208 return BSAPICPP.PhysicsStep2(worldu.ptr, timeStep, maxSubSteps, fixedTimeStep, out updatedEntityCount, out collidersCount); 208 return BSAPICPP.PhysicsStep2(worldu.ptr, timeStep, maxSubSteps, fixedTimeStep, out updatedEntityCount, out collidersCount);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index aadb583..a5fec87 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -126,9 +126,9 @@ public sealed class BSCharacter : BSPhysObject
126 DetailLog("{0},BSCharacter.Destroy", LocalID); 126 DetailLog("{0},BSCharacter.Destroy", LocalID);
127 PhysicsScene.TaintedObject("BSCharacter.destroy", delegate() 127 PhysicsScene.TaintedObject("BSCharacter.destroy", delegate()
128 { 128 {
129 PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null); 129 PhysicsScene.Shapes.DereferenceBody(PhysBody, true /* inTaintTime */, null /* bodyCallback */);
130 PhysBody.Clear(); 130 PhysBody.Clear();
131 PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null); 131 PhysicsScene.Shapes.DereferenceShape(PhysShape, true /* inTaintTime */, null /* bodyCallback */);
132 PhysShape.Clear(); 132 PhysShape.Clear();
133 }); 133 });
134 } 134 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index 185f111..821f470 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -382,10 +382,13 @@ public abstract class BSPhysObject : PhysicsActor
382 { 382 {
383 string identifier = op + "-" + id.ToString(); 383 string identifier = op + "-" + id.ToString();
384 384
385 // Clean out any existing action 385 lock (RegisteredActions)
386 UnRegisterPreStepAction(op, id); 386 {
387 // Clean out any existing action
388 UnRegisterPreStepAction(op, id);
387 389
388 RegisteredActions[identifier] = actn; 390 RegisteredActions[identifier] = actn;
391 }
389 PhysicsScene.BeforeStep += actn; 392 PhysicsScene.BeforeStep += actn;
390 DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier); 393 DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier);
391 } 394 }
@@ -395,22 +398,28 @@ public abstract class BSPhysObject : PhysicsActor
395 { 398 {
396 string identifier = op + "-" + id.ToString(); 399 string identifier = op + "-" + id.ToString();
397 bool removed = false; 400 bool removed = false;
398 if (RegisteredActions.ContainsKey(identifier)) 401 lock (RegisteredActions)
399 { 402 {
400 PhysicsScene.BeforeStep -= RegisteredActions[identifier]; 403 if (RegisteredActions.ContainsKey(identifier))
401 RegisteredActions.Remove(identifier); 404 {
402 removed = true; 405 PhysicsScene.BeforeStep -= RegisteredActions[identifier];
406 RegisteredActions.Remove(identifier);
407 removed = true;
408 }
403 } 409 }
404 DetailLog("{0},BSPhysObject.UnRegisterPreStepAction,id={1},removed={2}", LocalID, identifier, removed); 410 DetailLog("{0},BSPhysObject.UnRegisterPreStepAction,id={1},removed={2}", LocalID, identifier, removed);
405 } 411 }
406 412
407 protected void UnRegisterAllPreStepActions() 413 protected void UnRegisterAllPreStepActions()
408 { 414 {
409 foreach (KeyValuePair<string, BSScene.PreStepAction> kvp in RegisteredActions) 415 lock (RegisteredActions)
410 { 416 {
411 PhysicsScene.BeforeStep -= kvp.Value; 417 foreach (KeyValuePair<string, BSScene.PreStepAction> kvp in RegisteredActions)
418 {
419 PhysicsScene.BeforeStep -= kvp.Value;
420 }
421 RegisteredActions.Clear();
412 } 422 }
413 RegisteredActions.Clear();
414 DetailLog("{0},BSPhysObject.UnRegisterAllPreStepActions,", LocalID); 423 DetailLog("{0},BSPhysObject.UnRegisterAllPreStepActions,", LocalID);
415 } 424 }
416 425
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index e5f7ab7..79fe632 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -379,7 +379,7 @@ public sealed class BSPrim : BSPhysObject
379 // If the object is below ground it just has to be moved up because pushing will 379 // If the object is below ground it just has to be moved up because pushing will
380 // not get it through the terrain 380 // not get it through the terrain
381 _position.Z = targetHeight; 381 _position.Z = targetHeight;
382 if (!inTaintTime) 382 if (inTaintTime)
383 ForcePosition = _position; 383 ForcePosition = _position;
384 ret = true; 384 ret = true;
385 } 385 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index a5bdc07..e0b4992 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -387,12 +387,14 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
387 if (!m_initialized) return null; 387 if (!m_initialized) return null;
388 388
389 BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying); 389 BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying);
390 lock (PhysObjects) PhysObjects.Add(localID, actor); 390 lock (PhysObjects)
391 PhysObjects.Add(localID, actor);
391 392
392 // TODO: Remove kludge someday. 393 // TODO: Remove kludge someday.
393 // We must generate a collision for avatars whether they collide or not. 394 // We must generate a collision for avatars whether they collide or not.
394 // This is required by OpenSim to update avatar animations, etc. 395 // This is required by OpenSim to update avatar animations, etc.
395 lock (m_avatars) m_avatars.Add(actor); 396 lock (m_avatars)
397 m_avatars.Add(actor);
396 398
397 return actor; 399 return actor;
398 } 400 }
@@ -408,9 +410,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
408 { 410 {
409 try 411 try
410 { 412 {
411 lock (PhysObjects) PhysObjects.Remove(actor.LocalID); 413 lock (PhysObjects)
414 PhysObjects.Remove(bsactor.LocalID);
412 // Remove kludge someday 415 // Remove kludge someday
413 lock (m_avatars) m_avatars.Remove(bsactor); 416 lock (m_avatars)
417 m_avatars.Remove(bsactor);
414 } 418 }
415 catch (Exception e) 419 catch (Exception e)
416 { 420 {
@@ -419,6 +423,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
419 bsactor.Destroy(); 423 bsactor.Destroy();
420 // bsactor.dispose(); 424 // bsactor.dispose();
421 } 425 }
426 else
427 {
428 m_log.ErrorFormat("{0}: Requested to remove avatar that is not a BSCharacter. ID={1}, type={2}",
429 LogHeader, actor.LocalID, actor.GetType().Name);
430 }
422 } 431 }
423 432
424 public override void RemovePrim(PhysicsActor prim) 433 public override void RemovePrim(PhysicsActor prim)