aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
authorMelanie2011-10-30 10:16:25 +0000
committerMelanie2011-10-30 10:16:25 +0000
commit083b28de8c45589a43ce6ceed4dbfb70c698f2d0 (patch)
treefc494b5d401bf2190e8c2d9ee027021f330d6285 /OpenSim/Region/Physics/OdePlugin
parentFix the offline message module to revert core changes and restore avn (diff)
parentAdd missing max_listens_per_region to [LL_Functions] config section in OpenSi... (diff)
downloadopensim-SC_OLD-083b28de8c45589a43ce6ceed4dbfb70c698f2d0.zip
opensim-SC_OLD-083b28de8c45589a43ce6ceed4dbfb70c698f2d0.tar.gz
opensim-SC_OLD-083b28de8c45589a43ce6ceed4dbfb70c698f2d0.tar.bz2
opensim-SC_OLD-083b28de8c45589a43ce6ceed4dbfb70c698f2d0.tar.xz
Merge branch 'master' into bigmerge
Conflicts: OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs126
1 files changed, 58 insertions, 68 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index c22d27f..f93d7ba 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -74,6 +74,7 @@ namespace OpenSim.Region.Physics.OdePlugin
74 private bool _zeroFlag = false; 74 private bool _zeroFlag = false;
75 private bool m_lastUpdateSent = false; 75 private bool m_lastUpdateSent = false;
76 private Vector3 _velocity; 76 private Vector3 _velocity;
77 private Vector3 m_taintTargetVelocity;
77 private Vector3 _target_velocity; 78 private Vector3 _target_velocity;
78 private Vector3 _acceleration; 79 private Vector3 _acceleration;
79 private Vector3 m_rotationalVelocity; 80 private Vector3 m_rotationalVelocity;
@@ -161,17 +162,19 @@ namespace OpenSim.Region.Physics.OdePlugin
161 { 162 {
162 pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 163 pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
163 } 164 }
165
164 _position = pos; 166 _position = pos;
165 m_taintPosition.X = pos.X; 167 m_taintPosition = pos;
166 m_taintPosition.Y = pos.Y;
167 m_taintPosition.Z = pos.Z;
168 } 168 }
169 else 169 else
170 { 170 {
171 _position = new Vector3(((float)_parent_scene.WorldExtents.X * 0.5f), ((float)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f); 171 _position
172 m_taintPosition.X = _position.X; 172 = new Vector3(
173 m_taintPosition.Y = _position.Y; 173 (float)_parent_scene.WorldExtents.X * 0.5f,
174 m_taintPosition.Z = _position.Z; 174 (float)_parent_scene.WorldExtents.Y * 0.5f,
175 parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f);
176 m_taintPosition = _position;
177
175 m_log.Warn("[PHYSICS]: Got NaN Position on Character Create"); 178 m_log.Warn("[PHYSICS]: Got NaN Position on Character Create");
176 } 179 }
177 180
@@ -431,13 +434,7 @@ namespace OpenSim.Region.Physics.OdePlugin
431 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 434 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
432 } 435 }
433 436
434 _position.X = value.X; 437 m_taintPosition = value;
435 _position.Y = value.Y;
436 _position.Z = value.Z;
437
438 m_taintPosition.X = value.X;
439 m_taintPosition.Y = value.Y;
440 m_taintPosition.Z = value.Z;
441 _parent_scene.AddPhysicsActorTaint(this); 438 _parent_scene.AddPhysicsActorTaint(this);
442 } 439 }
443 else 440 else
@@ -585,15 +582,12 @@ namespace OpenSim.Region.Physics.OdePlugin
585 d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH); 582 d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH);
586 Body = d.BodyCreate(_parent_scene.world); 583 Body = d.BodyCreate(_parent_scene.world);
587 d.BodySetPosition(Body, npositionX, npositionY, npositionZ); 584 d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
588 585
589 _position.X = npositionX; 586 _position.X = npositionX;
590 _position.Y = npositionY; 587 _position.Y = npositionY;
591 _position.Z = npositionZ; 588 _position.Z = npositionZ;
592 589
593 590 m_taintPosition = _position;
594 m_taintPosition.X = npositionX;
595 m_taintPosition.Y = npositionY;
596 m_taintPosition.Z = npositionZ;
597 591
598 d.BodySetMass(Body, ref ShellMass); 592 d.BodySetMass(Body, ref ShellMass);
599 d.Matrix3 m_caprot; 593 d.Matrix3 m_caprot;
@@ -708,7 +702,7 @@ namespace OpenSim.Region.Physics.OdePlugin
708// d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f); 702// d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f);
709// d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); 703// d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f);
710// //d.Matrix3 bodyrotation = d.BodyGetRotation(Body); 704// //d.Matrix3 bodyrotation = d.BodyGetRotation(Body);
711// //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); 705// //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyFArotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
712// } 706// }
713 707
714 public override Vector3 Force 708 public override Vector3 Force
@@ -774,14 +768,15 @@ namespace OpenSim.Region.Physics.OdePlugin
774 if (value.IsFinite()) 768 if (value.IsFinite())
775 { 769 {
776 m_pidControllerActive = true; 770 m_pidControllerActive = true;
777 _target_velocity = value; 771 m_taintTargetVelocity = value;
772 _parent_scene.AddPhysicsActorTaint(this);
778 } 773 }
779 else 774 else
780 { 775 {
781 m_log.Warn("[PHYSICS]: Got a NaN velocity from Scene in a Character"); 776 m_log.Warn("[PHYSICS]: Got a NaN velocity from Scene in a Character");
782 } 777 }
783 778
784// m_log.DebugFormat("[PHYSICS]: Set target velocity of {0}", _target_velocity); 779// m_log.DebugFormat("[PHYSICS]: Set target velocity of {0}", m_taintTargetVelocity);
785 } 780 }
786 } 781 }
787 782
@@ -841,16 +836,14 @@ namespace OpenSim.Region.Physics.OdePlugin
841 // If uncommented, things get pushed off world 836 // If uncommented, things get pushed off world
842 // 837 //
843 // m_log.Debug("Push!"); 838 // m_log.Debug("Push!");
844 // _target_velocity.X += force.X; 839 // m_taintTargetVelocity.X += force.X;
845 // _target_velocity.Y += force.Y; 840 // m_taintTargetVelocity.Y += force.Y;
846 // _target_velocity.Z += force.Z; 841 // m_taintTargetVelocity.Z += force.Z;
847 } 842 }
848 else 843 else
849 { 844 {
850 m_pidControllerActive = true; 845 m_pidControllerActive = true;
851 _target_velocity.X += force.X; 846 m_taintTargetVelocity += force;
852 _target_velocity.Y += force.Y;
853 _target_velocity.Z += force.Z;
854 } 847 }
855 } 848 }
856 else 849 else
@@ -871,8 +864,6 @@ namespace OpenSim.Region.Physics.OdePlugin
871 public void doForce(Vector3 force) 864 public void doForce(Vector3 force)
872 { 865 {
873 d.BodyAddForce(Body, force.X, force.Y, force.Z); 866 d.BodyAddForce(Body, force.X, force.Y, force.Z);
874 //d.BodySetRotation(Body, ref m_StandUpRotation);
875 //standupStraight();
876 } 867 }
877 868
878 public override void SetMomentum(Vector3 momentum) 869 public override void SetMomentum(Vector3 momentum)
@@ -1062,69 +1053,66 @@ namespace OpenSim.Region.Physics.OdePlugin
1062 internal void UpdatePositionAndVelocity() 1053 internal void UpdatePositionAndVelocity()
1063 { 1054 {
1064 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 1055 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
1065 d.Vector3 vec; 1056 d.Vector3 newPos;
1066 try 1057 try
1067 { 1058 {
1068 vec = d.BodyGetPosition(Body); 1059 newPos = d.BodyGetPosition(Body);
1069 } 1060 }
1070 catch (NullReferenceException) 1061 catch (NullReferenceException)
1071 { 1062 {
1072 bad = true; 1063 bad = true;
1073 _parent_scene.BadCharacter(this); 1064 _parent_scene.BadCharacter(this);
1074 vec = new d.Vector3(_position.X, _position.Y, _position.Z); 1065 newPos = new d.Vector3(_position.X, _position.Y, _position.Z);
1075 base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem! 1066 base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem!
1076 m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar {0}, physical actor {1}", m_name, m_uuid); 1067 m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar {0}, physical actor {1}", m_name, m_uuid);
1077 } 1068 }
1078 1069
1079 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 1070 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
1080 if (vec.X < 0.0f) vec.X = 0.0f; 1071 if (newPos.X < 0.0f) newPos.X = 0.0f;
1081 if (vec.Y < 0.0f) vec.Y = 0.0f; 1072 if (newPos.Y < 0.0f) newPos.Y = 0.0f;
1082 if (vec.X > (int)_parent_scene.WorldExtents.X - 0.05f) vec.X = (int)_parent_scene.WorldExtents.X - 0.05f; 1073 if (newPos.X > (int)_parent_scene.WorldExtents.X - 0.05f) newPos.X = (int)_parent_scene.WorldExtents.X - 0.05f;
1083 if (vec.Y > (int)_parent_scene.WorldExtents.Y - 0.05f) vec.Y = (int)_parent_scene.WorldExtents.Y - 0.05f; 1074 if (newPos.Y > (int)_parent_scene.WorldExtents.Y - 0.05f) newPos.Y = (int)_parent_scene.WorldExtents.Y - 0.05f;
1084 1075
1085 _position.X = vec.X; 1076 _position.X = newPos.X;
1086 _position.Y = vec.Y; 1077 _position.Y = newPos.Y;
1087 _position.Z = vec.Z; 1078 _position.Z = newPos.Z;
1088 1079
1089 // I think we need to update the taintPosition too -- Diva 12/24/10 1080 // I think we need to update the taintPosition too -- Diva 12/24/10
1090 m_taintPosition.X = vec.X; 1081 m_taintPosition = _position;
1091 m_taintPosition.Y = vec.Y;
1092 m_taintPosition.Z = vec.Z;
1093 1082
1094 // Did we move last? = zeroflag 1083 // Did we move last? = zeroflag
1095 // This helps keep us from sliding all over 1084 // This helps keep us from sliding all over
1096 1085
1097 if (_zeroFlag) 1086 if (_zeroFlag)
1098 { 1087 {
1099 _velocity.X = 0.0f; 1088 _velocity = Vector3.Zero;
1100 _velocity.Y = 0.0f;
1101 _velocity.Z = 0.0f;
1102 1089
1103 // Did we send out the 'stopped' message? 1090 // Did we send out the 'stopped' message?
1104 if (!m_lastUpdateSent) 1091 if (!m_lastUpdateSent)
1105 { 1092 {
1106 m_lastUpdateSent = true; 1093 m_lastUpdateSent = true;
1107 //base.RequestPhysicsterseUpdate(); 1094 //base.RequestPhysicsterseUpdate();
1108
1109 } 1095 }
1110 } 1096 }
1111 else 1097 else
1112 { 1098 {
1113 m_lastUpdateSent = false; 1099 m_lastUpdateSent = false;
1100 d.Vector3 newVelocity;
1101
1114 try 1102 try
1115 { 1103 {
1116 vec = d.BodyGetLinearVel(Body); 1104 newVelocity = d.BodyGetLinearVel(Body);
1117 } 1105 }
1118 catch (NullReferenceException) 1106 catch (NullReferenceException)
1119 { 1107 {
1120 vec.X = _velocity.X; 1108 newVelocity.X = _velocity.X;
1121 vec.Y = _velocity.Y; 1109 newVelocity.Y = _velocity.Y;
1122 vec.Z = _velocity.Z; 1110 newVelocity.Z = _velocity.Z;
1123 } 1111 }
1124 _velocity.X = (vec.X);
1125 _velocity.Y = (vec.Y);
1126 1112
1127 _velocity.Z = (vec.Z); 1113 _velocity.X = newVelocity.X;
1114 _velocity.Y = newVelocity.Y;
1115 _velocity.Z = newVelocity.Z;
1128 1116
1129 if (_velocity.Z < -6 && !m_hackSentFall) 1117 if (_velocity.Z < -6 && !m_hackSentFall)
1130 { 1118 {
@@ -1253,6 +1241,18 @@ namespace OpenSim.Region.Physics.OdePlugin
1253 1241
1254 internal void ProcessTaints() 1242 internal void ProcessTaints()
1255 { 1243 {
1244 if (m_taintPosition != _position)
1245 {
1246 if (Body != IntPtr.Zero)
1247 {
1248 d.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z);
1249 _position = m_taintPosition;
1250 }
1251 }
1252
1253 if (m_taintTargetVelocity != _target_velocity)
1254 _target_velocity = m_taintTargetVelocity;
1255
1256 if (m_tainted_isPhysical != m_isPhysical) 1256 if (m_tainted_isPhysical != m_isPhysical)
1257 { 1257 {
1258 if (m_tainted_isPhysical) 1258 if (m_tainted_isPhysical)
@@ -1294,8 +1294,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1294 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); 1294 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
1295 d.BodyDestroy(Body); 1295 d.BodyDestroy(Body);
1296 d.GeomDestroy(Shell); 1296 d.GeomDestroy(Shell);
1297 AvatarGeomAndBodyCreation(_position.X, _position.Y, 1297 AvatarGeomAndBodyCreation(
1298 _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); 1298 _position.X,
1299 _position.Y,
1300 _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor);
1299 1301
1300 // As with Size, we reset velocity. However, this isn't strictly necessary since it doesn't 1302 // As with Size, we reset velocity. However, this isn't strictly necessary since it doesn't
1301 // appear to stall initial region crossings when done here. Being done for consistency. 1303 // appear to stall initial region crossings when done here. Being done for consistency.
@@ -1312,18 +1314,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1312 + (Amotor==IntPtr.Zero ? "Amotor ":"")); 1314 + (Amotor==IntPtr.Zero ? "Amotor ":""));
1313 } 1315 }
1314 } 1316 }
1315
1316 if (!m_taintPosition.ApproxEquals(_position, 0.05f))
1317 {
1318 if (Body != IntPtr.Zero)
1319 {
1320 d.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z);
1321
1322 _position.X = m_taintPosition.X;
1323 _position.Y = m_taintPosition.Y;
1324 _position.Z = m_taintPosition.Z;
1325 }
1326 }
1327 } 1317 }
1328 1318
1329 internal void AddCollisionFrameTime(int p) 1319 internal void AddCollisionFrameTime(int p)