aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs13
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs12
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs27
3 files changed, 33 insertions, 19 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 9c3f160..cfcccac 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -75,9 +75,10 @@ public sealed class BSCharacter : BSPhysObject
75 // Avatars are always complete (in the physics engine sense) 75 // Avatars are always complete (in the physics engine sense)
76 public override bool IsIncomplete { get { return false; } } 76 public override bool IsIncomplete { get { return false; } }
77 77
78 // 'activate' is called with this character after all initialization is complete
78 public BSCharacter( 79 public BSCharacter(
79 uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 vel, OMV.Vector3 size, bool isFlying) 80 uint localID, String avName, BSScene parent_scene,
80 81 OMV.Vector3 pos, OMV.Vector3 vel, OMV.Vector3 size, bool isFlying, Action<BSCharacter> activate)
81 : base(parent_scene, localID, avName, "BSCharacter") 82 : base(parent_scene, localID, avName, "BSCharacter")
82 { 83 {
83 _physicsActorType = (int)ActorTypes.Agent; 84 _physicsActorType = (int)ActorTypes.Agent;
@@ -124,6 +125,9 @@ public sealed class BSCharacter : BSPhysObject
124 SetPhysicalProperties(); 125 SetPhysicalProperties();
125 126
126 IsInitialized = true; 127 IsInitialized = true;
128
129 if (activate != null)
130 activate(this);
127 }); 131 });
128 return; 132 return;
129 } 133 }
@@ -472,12 +476,13 @@ public sealed class BSCharacter : BSPhysObject
472 } 476 }
473 } 477 }
474 478
479 // Force the setting of velocity. Called at taint time.
480 // Exists so that setting force by anyone can be overridden by a subcless.
475 public override OMV.Vector3 ForceVelocity { 481 public override OMV.Vector3 ForceVelocity {
476 get { return RawVelocity; } 482 get { return RawVelocity; }
477 set { 483 set {
478 PhysScene.AssertInTaintTime("BSCharacter.ForceVelocity"); 484 PhysScene.AssertInTaintTime("BSCharacter.ForceVelocity");
479// Util.PrintCallStack(); 485 DetailLog("{0},BSCharacter.setForceVelocity,call,vel={1}", LocalID, value);
480 DetailLog("{0}: set ForceVelocity = {1}", LocalID, value);
481 486
482 RawVelocity = value; 487 RawVelocity = value;
483 PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity); 488 PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index 90da7a6..4669d91 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -72,6 +72,11 @@ public abstract class BSPhysObject : PhysicsActor
72 } 72 }
73 protected BSPhysObject(BSScene parentScene, uint localID, string name, string typeName) 73 protected BSPhysObject(BSScene parentScene, uint localID, string name, string typeName)
74 { 74 {
75 InitializePhysObject(parentScene, localID, name, typeName);
76 }
77
78 protected void InitializePhysObject(BSScene parentScene, uint localID, string name, string typeName)
79 {
75 IsInitialized = false; 80 IsInitialized = false;
76 81
77 PhysScene = parentScene; 82 PhysScene = parentScene;
@@ -119,6 +124,8 @@ public abstract class BSPhysObject : PhysicsActor
119 // Tell the object to clean up. 124 // Tell the object to clean up.
120 public virtual void Destroy() 125 public virtual void Destroy()
121 { 126 {
127 SubscribedEventsMs = 0;
128
122 PhysicalActors.Enable(false); 129 PhysicalActors.Enable(false);
123 PhysScene.TaintedObject(LocalID, "BSPhysObject.Destroy", delegate() 130 PhysScene.TaintedObject(LocalID, "BSPhysObject.Destroy", delegate()
124 { 131 {
@@ -455,6 +462,7 @@ public abstract class BSPhysObject : PhysicsActor
455 // Return 'true' if a collision was processed and should be sent up. 462 // Return 'true' if a collision was processed and should be sent up.
456 // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision. 463 // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision.
457 // Called at taint time from within the Step() function 464 // Called at taint time from within the Step() function
465 // Both 'CollisionLock' and 'PhysObjects' are locked when this is called by 'SendCollisions'.
458 public delegate bool CollideCall(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth); 466 public delegate bool CollideCall(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth);
459 public virtual bool Collide(uint collidingWith, BSPhysObject collidee, 467 public virtual bool Collide(uint collidingWith, BSPhysObject collidee,
460 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) 468 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
@@ -512,7 +520,7 @@ public abstract class BSPhysObject : PhysicsActor
512 520
513 // If no collisions this call but there were collisions last call, force the collision 521 // If no collisions this call but there were collisions last call, force the collision
514 // event to be happen right now so quick collision_end. 522 // event to be happen right now so quick collision_end.
515 bool force = (CollisionCollection.Count == 0 && CollisionsLastReported.Count != 0); 523 bool force = (CollisionCollection.Count == 0 && CollisionsLastReported.Count != 0);
516 524
517 // throttle the collisions to the number of milliseconds specified in the subscription 525 // throttle the collisions to the number of milliseconds specified in the subscription
518 if (force || (PhysScene.SimulationNowTime >= NextCollisionOkTime)) 526 if (force || (PhysScene.SimulationNowTime >= NextCollisionOkTime))
@@ -545,7 +553,7 @@ public abstract class BSPhysObject : PhysicsActor
545 // Subscribe for collision events. 553 // Subscribe for collision events.
546 // Parameter is the millisecond rate the caller wishes collision events to occur. 554 // Parameter is the millisecond rate the caller wishes collision events to occur.
547 public override void SubscribeEvents(int ms) { 555 public override void SubscribeEvents(int ms) {
548 // DetailLog("{0},{1}.SubscribeEvents,subscribing,ms={2}", LocalID, TypeName, ms); 556 DetailLog("{0},{1}.SubscribeEvents,subscribing,ms={2}", LocalID, TypeName, ms);
549 SubscribedEventsMs = ms; 557 SubscribedEventsMs = ms;
550 if (ms > 0) 558 if (ms > 0)
551 { 559 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 8a19944..2a8a6a5 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -477,16 +477,19 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
477 477
478 if (!m_initialized) return null; 478 if (!m_initialized) return null;
479 479
480 BSCharacter actor = new BSCharacter(localID, avName, this, position, velocity, size, isFlying); 480 BSCharacter actor = new BSCharacter(localID, avName, this, position, velocity, size, isFlying,
481 lock (PhysObjects) 481 (aa) =>
482 PhysObjects.Add(localID, actor); 482 {
483 483 // While the actor exists, don't add it to the active avatar lists until completely initialized
484 // TODO: Remove kludge someday. 484 lock (PhysObjects)
485 // We must generate a collision for avatars whether they collide or not. 485 PhysObjects.Add(localID, aa);
486 // This is required by OpenSim to update avatar animations, etc.
487 lock (AvatarsInSceneLock)
488 AvatarsInScene.Add(actor);
489 486
487 // TODO: Remove kludge someday.
488 // We must generate a collision for avatars whether they collide or not.
489 // This is required by OpenSim to update avatar animations, etc.
490 lock (AvatarsInSceneLock)
491 AvatarsInScene.Add(aa);
492 });
490 return actor; 493 return actor;
491 } 494 }
492 495
@@ -830,10 +833,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
830 if (collider.Collide(collidingWith, collidee, collidePoint, collideNormal, penetration)) 833 if (collider.Collide(collidingWith, collidee, collidePoint, collideNormal, penetration))
831 { 834 {
832 // If a collision was 'good', remember to send it to the simulator 835 // If a collision was 'good', remember to send it to the simulator
833 lock (CollisionLock) 836 // Note that 'CollisionLock' was locked before the call to 'SendCollsions'
834 { 837 ObjectsWithCollisions.Add(collider);
835 ObjectsWithCollisions.Add(collider);
836 }
837 } 838 }
838 } 839 }
839 840