diff options
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 24 |
2 files changed, 31 insertions, 2 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 646a483..96fa467 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3410,11 +3410,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3410 | scene.AddPhysicsActorTaint(m_physicsActor); | 3410 | scene.AddPhysicsActorTaint(m_physicsActor); |
3411 | //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3411 | //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3412 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3412 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3413 | m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | ||
3413 | m_physicsActor.SubscribeEvents(500); | 3414 | m_physicsActor.SubscribeEvents(500); |
3414 | m_physicsActor.LocalID = LocalId; | 3415 | m_physicsActor.LocalID = LocalId; |
3415 | 3416 | ||
3416 | } | 3417 | } |
3417 | 3418 | ||
3419 | private void OutOfBoundsCall(PhysicsVector pos) | ||
3420 | { | ||
3421 | bool flying = m_physicsActor.Flying; | ||
3422 | RemoveFromPhysicalScene(); | ||
3423 | |||
3424 | AddToPhysicalScene(flying); | ||
3425 | } | ||
3426 | |||
3418 | // Event called by the physics plugin to tell the avatar about a collision. | 3427 | // Event called by the physics plugin to tell the avatar about a collision. |
3419 | private void PhysicsCollisionUpdate(EventArgs e) | 3428 | private void PhysicsCollisionUpdate(EventArgs e) |
3420 | { | 3429 | { |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index bd81d50..bd05c92 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | |||
@@ -1105,7 +1105,18 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1105 | public void UpdatePositionAndVelocity() | 1105 | public void UpdatePositionAndVelocity() |
1106 | { | 1106 | { |
1107 | // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! | 1107 | // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! |
1108 | d.Vector3 vec = d.BodyGetPosition(Body); | 1108 | d.Vector3 vec; |
1109 | try | ||
1110 | { | ||
1111 | vec = d.BodyGetPosition(Body); | ||
1112 | //throw new NullReferenceException("foo!"); | ||
1113 | } | ||
1114 | catch (NullReferenceException) | ||
1115 | { | ||
1116 | vec = new d.Vector3(Position.X, Position.Y, Position.Z); | ||
1117 | base.RaiseOutOfBounds(_position); | ||
1118 | } | ||
1119 | |||
1109 | 1120 | ||
1110 | // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) | 1121 | // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) |
1111 | if (vec.X < 0.0f) vec.X = 0.0f; | 1122 | if (vec.X < 0.0f) vec.X = 0.0f; |
@@ -1137,7 +1148,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1137 | else | 1148 | else |
1138 | { | 1149 | { |
1139 | m_lastUpdateSent = false; | 1150 | m_lastUpdateSent = false; |
1140 | vec = d.BodyGetLinearVel(Body); | 1151 | try |
1152 | { | ||
1153 | vec = d.BodyGetLinearVel(Body); | ||
1154 | } | ||
1155 | catch (NullReferenceException) | ||
1156 | { | ||
1157 | vec.X = _velocity.X; | ||
1158 | vec.Y = _velocity.Y; | ||
1159 | vec.Z = _velocity.Z; | ||
1160 | } | ||
1141 | _velocity.X = (vec.X); | 1161 | _velocity.X = (vec.X); |
1142 | _velocity.Y = (vec.Y); | 1162 | _velocity.Y = (vec.Y); |
1143 | 1163 | ||