aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-10-29 02:07:28 +0100
committerJustin Clark-Casey (justincc)2011-10-29 02:07:28 +0100
commitef8370fb8e527ca20c13d18aad1cbf7f8a44c70a (patch)
treee779e4632ddfe6bebd24f40021d2ebe58c603ba3 /OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
parentMove position set from taint to logically better position at top of ODECharac... (diff)
downloadopensim-SC-ef8370fb8e527ca20c13d18aad1cbf7f8a44c70a.zip
opensim-SC-ef8370fb8e527ca20c13d18aad1cbf7f8a44c70a.tar.gz
opensim-SC-ef8370fb8e527ca20c13d18aad1cbf7f8a44c70a.tar.bz2
opensim-SC-ef8370fb8e527ca20c13d18aad1cbf7f8a44c70a.tar.xz
tidy up OdeCharacter so that we just use OpenMetaverse.Vector3 assignment directly where possible, instead of transferring X, Y and Z components separately
some of this is probably a hold over from using ODE.Vector3, which is still necessary in some places.
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/ODECharacter.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs90
1 files changed, 39 insertions, 51 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index ca8fef9..09581c3 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -161,17 +161,19 @@ namespace OpenSim.Region.Physics.OdePlugin
161 { 161 {
162 pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 162 pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
163 } 163 }
164
164 _position = pos; 165 _position = pos;
165 m_taintPosition.X = pos.X; 166 m_taintPosition = pos;
166 m_taintPosition.Y = pos.Y;
167 m_taintPosition.Z = pos.Z;
168 } 167 }
169 else 168 else
170 { 169 {
171 _position = new Vector3(((float)_parent_scene.WorldExtents.X * 0.5f), ((float)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f); 170 _position
172 m_taintPosition.X = _position.X; 171 = new Vector3(
173 m_taintPosition.Y = _position.Y; 172 (float)_parent_scene.WorldExtents.X * 0.5f,
174 m_taintPosition.Z = _position.Z; 173 (float)_parent_scene.WorldExtents.Y * 0.5f,
174 parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f);
175 m_taintPosition = _position;
176
175 m_log.Warn("[PHYSICS]: Got NaN Position on Character Create"); 177 m_log.Warn("[PHYSICS]: Got NaN Position on Character Create");
176 } 178 }
177 179
@@ -431,10 +433,7 @@ namespace OpenSim.Region.Physics.OdePlugin
431 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 433 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
432 } 434 }
433 435
434 m_taintPosition.X = value.X; 436 m_taintPosition = value;
435 m_taintPosition.Y = value.Y;
436 m_taintPosition.Z = value.Z;
437
438 _parent_scene.AddPhysicsActorTaint(this); 437 _parent_scene.AddPhysicsActorTaint(this);
439 } 438 }
440 else 439 else
@@ -582,15 +581,12 @@ namespace OpenSim.Region.Physics.OdePlugin
582 d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH); 581 d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH);
583 Body = d.BodyCreate(_parent_scene.world); 582 Body = d.BodyCreate(_parent_scene.world);
584 d.BodySetPosition(Body, npositionX, npositionY, npositionZ); 583 d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
585 584
586 _position.X = npositionX; 585 _position.X = npositionX;
587 _position.Y = npositionY; 586 _position.Y = npositionY;
588 _position.Z = npositionZ; 587 _position.Z = npositionZ;
589 588
590 589 m_taintPosition = _position;
591 m_taintPosition.X = npositionX;
592 m_taintPosition.Y = npositionY;
593 m_taintPosition.Z = npositionZ;
594 590
595 d.BodySetMass(Body, ref ShellMass); 591 d.BodySetMass(Body, ref ShellMass);
596 d.Matrix3 m_caprot; 592 d.Matrix3 m_caprot;
@@ -845,9 +841,7 @@ namespace OpenSim.Region.Physics.OdePlugin
845 else 841 else
846 { 842 {
847 m_pidControllerActive = true; 843 m_pidControllerActive = true;
848 _target_velocity.X += force.X; 844 _target_velocity += force;
849 _target_velocity.Y += force.Y;
850 _target_velocity.Z += force.Z;
851 } 845 }
852 } 846 }
853 else 847 else
@@ -868,8 +862,6 @@ namespace OpenSim.Region.Physics.OdePlugin
868 public void doForce(Vector3 force) 862 public void doForce(Vector3 force)
869 { 863 {
870 d.BodyAddForce(Body, force.X, force.Y, force.Z); 864 d.BodyAddForce(Body, force.X, force.Y, force.Z);
871 //d.BodySetRotation(Body, ref m_StandUpRotation);
872 //standupStraight();
873 } 865 }
874 866
875 public override void SetMomentum(Vector3 momentum) 867 public override void SetMomentum(Vector3 momentum)
@@ -1059,69 +1051,66 @@ namespace OpenSim.Region.Physics.OdePlugin
1059 internal void UpdatePositionAndVelocity() 1051 internal void UpdatePositionAndVelocity()
1060 { 1052 {
1061 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 1053 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
1062 d.Vector3 vec; 1054 d.Vector3 newPos;
1063 try 1055 try
1064 { 1056 {
1065 vec = d.BodyGetPosition(Body); 1057 newPos = d.BodyGetPosition(Body);
1066 } 1058 }
1067 catch (NullReferenceException) 1059 catch (NullReferenceException)
1068 { 1060 {
1069 bad = true; 1061 bad = true;
1070 _parent_scene.BadCharacter(this); 1062 _parent_scene.BadCharacter(this);
1071 vec = new d.Vector3(_position.X, _position.Y, _position.Z); 1063 newPos = new d.Vector3(_position.X, _position.Y, _position.Z);
1072 base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem! 1064 base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem!
1073 m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar {0}, physical actor {1}", m_name, m_uuid); 1065 m_log.WarnFormat("[ODEPLUGIN]: Avatar Null reference for Avatar {0}, physical actor {1}", m_name, m_uuid);
1074 } 1066 }
1075 1067
1076 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 1068 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
1077 if (vec.X < 0.0f) vec.X = 0.0f; 1069 if (newPos.X < 0.0f) newPos.X = 0.0f;
1078 if (vec.Y < 0.0f) vec.Y = 0.0f; 1070 if (newPos.Y < 0.0f) newPos.Y = 0.0f;
1079 if (vec.X > (int)_parent_scene.WorldExtents.X - 0.05f) vec.X = (int)_parent_scene.WorldExtents.X - 0.05f; 1071 if (newPos.X > (int)_parent_scene.WorldExtents.X - 0.05f) newPos.X = (int)_parent_scene.WorldExtents.X - 0.05f;
1080 if (vec.Y > (int)_parent_scene.WorldExtents.Y - 0.05f) vec.Y = (int)_parent_scene.WorldExtents.Y - 0.05f; 1072 if (newPos.Y > (int)_parent_scene.WorldExtents.Y - 0.05f) newPos.Y = (int)_parent_scene.WorldExtents.Y - 0.05f;
1081 1073
1082 _position.X = vec.X; 1074 _position.X = newPos.X;
1083 _position.Y = vec.Y; 1075 _position.Y = newPos.Y;
1084 _position.Z = vec.Z; 1076 _position.Z = newPos.Z;
1085 1077
1086 // I think we need to update the taintPosition too -- Diva 12/24/10 1078 // I think we need to update the taintPosition too -- Diva 12/24/10
1087 m_taintPosition.X = vec.X; 1079 m_taintPosition = _position;
1088 m_taintPosition.Y = vec.Y;
1089 m_taintPosition.Z = vec.Z;
1090 1080
1091 // Did we move last? = zeroflag 1081 // Did we move last? = zeroflag
1092 // This helps keep us from sliding all over 1082 // This helps keep us from sliding all over
1093 1083
1094 if (_zeroFlag) 1084 if (_zeroFlag)
1095 { 1085 {
1096 _velocity.X = 0.0f; 1086 _velocity = Vector3.Zero;
1097 _velocity.Y = 0.0f;
1098 _velocity.Z = 0.0f;
1099 1087
1100 // Did we send out the 'stopped' message? 1088 // Did we send out the 'stopped' message?
1101 if (!m_lastUpdateSent) 1089 if (!m_lastUpdateSent)
1102 { 1090 {
1103 m_lastUpdateSent = true; 1091 m_lastUpdateSent = true;
1104 //base.RequestPhysicsterseUpdate(); 1092 //base.RequestPhysicsterseUpdate();
1105
1106 } 1093 }
1107 } 1094 }
1108 else 1095 else
1109 { 1096 {
1110 m_lastUpdateSent = false; 1097 m_lastUpdateSent = false;
1098 d.Vector3 newVelocity;
1099
1111 try 1100 try
1112 { 1101 {
1113 vec = d.BodyGetLinearVel(Body); 1102 newVelocity = d.BodyGetLinearVel(Body);
1114 } 1103 }
1115 catch (NullReferenceException) 1104 catch (NullReferenceException)
1116 { 1105 {
1117 vec.X = _velocity.X; 1106 newVelocity.X = _velocity.X;
1118 vec.Y = _velocity.Y; 1107 newVelocity.Y = _velocity.Y;
1119 vec.Z = _velocity.Z; 1108 newVelocity.Z = _velocity.Z;
1120 } 1109 }
1121 _velocity.X = (vec.X);
1122 _velocity.Y = (vec.Y);
1123 1110
1124 _velocity.Z = (vec.Z); 1111 _velocity.X = newVelocity.X;
1112 _velocity.Y = newVelocity.Y;
1113 _velocity.Z = newVelocity.Z;
1125 1114
1126 if (_velocity.Z < -6 && !m_hackSentFall) 1115 if (_velocity.Z < -6 && !m_hackSentFall)
1127 { 1116 {
@@ -1255,10 +1244,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1255 if (Body != IntPtr.Zero) 1244 if (Body != IntPtr.Zero)
1256 { 1245 {
1257 d.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z); 1246 d.BodySetPosition(Body, m_taintPosition.X, m_taintPosition.Y, m_taintPosition.Z);
1258 1247 _position = m_taintPosition;
1259 _position.X = m_taintPosition.X;
1260 _position.Y = m_taintPosition.Y;
1261 _position.Z = m_taintPosition.Z;
1262 } 1248 }
1263 } 1249 }
1264 1250
@@ -1303,8 +1289,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1303 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); 1289 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
1304 d.BodyDestroy(Body); 1290 d.BodyDestroy(Body);
1305 d.GeomDestroy(Shell); 1291 d.GeomDestroy(Shell);
1306 AvatarGeomAndBodyCreation(_position.X, _position.Y, 1292 AvatarGeomAndBodyCreation(
1307 _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); 1293 _position.X,
1294 _position.Y,
1295 _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor);
1308 1296
1309 // As with Size, we reset velocity. However, this isn't strictly necessary since it doesn't 1297 // As with Size, we reset velocity. However, this isn't strictly necessary since it doesn't
1310 // appear to stall initial region crossings when done here. Being done for consistency. 1298 // appear to stall initial region crossings when done here. Being done for consistency.