aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs119
1 files changed, 78 insertions, 41 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 1ba40b8..d44c8e6 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -109,7 +109,7 @@ namespace OpenSim.Region.Physics.OdePlugin
109 private string m_name = String.Empty; 109 private string m_name = String.Empty;
110 // other filter control 110 // other filter control
111 int m_colliderfilter = 0; 111 int m_colliderfilter = 0;
112 // int m_colliderGroundfilter = 0; 112 int m_colliderGroundfilter = 0;
113 int m_colliderObjectfilter = 0; 113 int m_colliderObjectfilter = 0;
114 114
115 // Default we're a Character 115 // Default we're a Character
@@ -281,7 +281,6 @@ namespace OpenSim.Region.Physics.OdePlugin
281 m_iscolliding = false; 281 m_iscolliding = false;
282 else 282 else
283 { 283 {
284// SetPidStatus(false);
285 m_pidControllerActive = true; 284 m_pidControllerActive = true;
286 m_iscolliding = true; 285 m_iscolliding = true;
287 } 286 }
@@ -617,7 +616,7 @@ namespace OpenSim.Region.Physics.OdePlugin
617 { 616 {
618 if (pushforce) 617 if (pushforce)
619 { 618 {
620 AddChange(changes.Force, force * m_density / _parent_scene.ODE_STEPSIZE / 28f); 619 AddChange(changes.Force, force * m_density / (_parent_scene.ODE_STEPSIZE * 28f));
621 } 620 }
622 else 621 else
623 { 622 {
@@ -791,7 +790,7 @@ namespace OpenSim.Region.Physics.OdePlugin
791 qtmp.Z = 0; 790 qtmp.Z = 0;
792 d.BodySetQuaternion(Body, ref qtmp); 791 d.BodySetQuaternion(Body, ref qtmp);
793 792
794 if (m_pidControllerActive == false && !m_freemove) 793 if (m_pidControllerActive == false)
795 { 794 {
796 _zeroPosition = localpos; 795 _zeroPosition = localpos;
797 } 796 }
@@ -830,11 +829,17 @@ namespace OpenSim.Region.Physics.OdePlugin
830 localpos.Y = _parent_scene.WorldExtents.Y - 0.1f; 829 localpos.Y = _parent_scene.WorldExtents.Y - 0.1f;
831 } 830 }
832 if (fixbody) 831 if (fixbody)
832 {
833 m_freemove = false;
833 d.BodySetPosition(Body, localpos.X, localpos.Y, localpos.Z); 834 d.BodySetPosition(Body, localpos.X, localpos.Y, localpos.Z);
835 }
836
837 float breakfactor;
834 838
835 Vector3 vec = Vector3.Zero; 839 Vector3 vec = Vector3.Zero;
836 dtmp = d.BodyGetLinearVel(Body); 840 dtmp = d.BodyGetLinearVel(Body);
837 Vector3 vel = new Vector3(dtmp.X, dtmp.Y, dtmp.Z); 841 Vector3 vel = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
842 float velLengthSquared = vel.LengthSquared();
838 843
839 float movementdivisor = 1f; 844 float movementdivisor = 1f;
840 //Ubit change divisions into multiplications below 845 //Ubit change divisions into multiplications below
@@ -863,7 +868,6 @@ namespace OpenSim.Region.Physics.OdePlugin
863 float terrainheight = _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y); 868 float terrainheight = _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y);
864 if (chrminZ < terrainheight) 869 if (chrminZ < terrainheight)
865 { 870 {
866 m_freemove = false;
867 float depth = terrainheight - chrminZ; 871 float depth = terrainheight - chrminZ;
868 if (!flying) 872 if (!flying)
869 { 873 {
@@ -874,34 +878,46 @@ namespace OpenSim.Region.Physics.OdePlugin
874 878
875 if (depth < 0.1f) 879 if (depth < 0.1f)
876 { 880 {
877 m_iscolliding = true; 881 m_colliderGroundfilter++;
878 m_colliderfilter = 2; 882 if (m_colliderGroundfilter > 2)
879 m_iscollidingGround = true; 883 {
880 884 m_iscolliding = true;
881 ContactPoint contact = new ContactPoint(); 885 m_colliderfilter = 2;
882 contact.PenetrationDepth = depth; 886 m_colliderGroundfilter = 2;
883 contact.Position.X = localpos.X; 887 m_iscollidingGround = true;
884 contact.Position.Y = localpos.Y; 888
885 contact.Position.Z = chrminZ; 889 ContactPoint contact = new ContactPoint();
886 contact.SurfaceNormal.X = 0f; 890 contact.PenetrationDepth = depth;
887 contact.SurfaceNormal.Y = 0f; 891 contact.Position.X = localpos.X;
888 contact.SurfaceNormal.Z = -1f; 892 contact.Position.Y = localpos.Y;
889 AddCollisionEvent(0, contact); 893 contact.Position.Z = chrminZ;
890 894 contact.SurfaceNormal.X = 0f;
891 vec.Z *= 0.5f; 895 contact.SurfaceNormal.Y = 0f;
896 contact.SurfaceNormal.Z = -1f;
897 AddCollisionEvent(0, contact);
898
899 vec.Z *= 0.5f;
900 }
892 } 901 }
893 902
894 else 903 else
904 {
905 m_colliderGroundfilter = 0;
895 m_iscollidingGround = false; 906 m_iscollidingGround = false;
907 }
896 } 908 }
897 else 909 else
910 {
911 m_colliderGroundfilter = 0;
898 m_iscollidingGround = false; 912 m_iscollidingGround = false;
913 }
899 914
900 //****************************************** 915 //******************************************
901 916
902 bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f); 917 bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f);
903 918
904 if(!tviszero || m_iscolliding) 919 // if (!tviszero || m_iscolliding || velLengthSquared <0.01)
920 if (!tviszero)
905 m_freemove = false; 921 m_freemove = false;
906 922
907 if (!m_freemove) 923 if (!m_freemove)
@@ -934,7 +950,6 @@ namespace OpenSim.Region.Physics.OdePlugin
934 } 950 }
935 else 951 else
936 { 952 {
937 m_freemove = false;
938 m_pidControllerActive = true; 953 m_pidControllerActive = true;
939 _zeroFlag = false; 954 _zeroFlag = false;
940 955
@@ -981,6 +996,24 @@ namespace OpenSim.Region.Physics.OdePlugin
981 } 996 }
982 } 997 }
983 } 998 }
999
1000 if (velLengthSquared > 2500.0f) // 50m/s apply breaks
1001 {
1002 breakfactor = 0.16f * m_mass;
1003 vec.X -= breakfactor * vel.X;
1004 vec.Y -= breakfactor * vel.Y;
1005 vec.Z -= breakfactor * vel.Z;
1006 }
1007 }
1008 else
1009 {
1010 breakfactor = 5f * m_mass;
1011 vec.X -= breakfactor * vel.X;
1012 vec.Y -= breakfactor * vel.Y;
1013 if (flying)
1014 vec.Z -= breakfactor * vel.Z;
1015 else
1016 vec.Z -= 2f* m_mass * vel.Z;
984 } 1017 }
985 1018
986 if (flying) 1019 if (flying)
@@ -997,14 +1030,6 @@ namespace OpenSim.Region.Physics.OdePlugin
997 // end add Kitto Flora 1030 // end add Kitto Flora
998 } 1031 }
999 1032
1000 if (vel.X * vel.X + vel.Y * vel.Y + vel.Z * vel.Z > 2500.0f) // 50m/s apply breaks
1001 {
1002 float breakfactor = 0.16f * m_mass; // will give aprox 60m/s terminal velocity at free fall
1003 vec.X -= breakfactor * vel.X;
1004 vec.Y -= breakfactor * vel.Y;
1005 vec.Z -= breakfactor * vel.Z;
1006 }
1007
1008 if (vec.IsFinite()) 1033 if (vec.IsFinite())
1009 { 1034 {
1010 if (vec.X != 0 || vec.Y !=0 || vec.Z !=0) 1035 if (vec.X != 0 || vec.Y !=0 || vec.Z !=0)
@@ -1222,7 +1247,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1222 if (Body != IntPtr.Zero) 1247 if (Body != IntPtr.Zero)
1223 d.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z); 1248 d.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z);
1224 _position = newPos; 1249 _position = newPos;
1225 m_pidControllerActive = true; 1250 m_pidControllerActive = false;
1226 } 1251 }
1227 1252
1228 private void changeOrientation(Quaternion newOri) 1253 private void changeOrientation(Quaternion newOri)
@@ -1269,11 +1294,30 @@ namespace OpenSim.Region.Physics.OdePlugin
1269 1294
1270 private void changeBuilding(bool arg) 1295 private void changeBuilding(bool arg)
1271 { 1296 {
1272 } 1297 }
1298
1299 private void setFreeMove()
1300 {
1301 m_pidControllerActive = true;
1302 _zeroFlag = false;
1303 _target_velocity = Vector3.Zero;
1304 m_freemove = true;
1305 m_colliderfilter = -2;
1306 m_colliderObjectfilter = -2;
1307 m_colliderGroundfilter = -2;
1308
1309 m_iscolliding = false;
1310 m_iscollidingGround = false;
1311 m_iscollidingObj = false;
1312
1313 CollisionEventsThisFrame = new CollisionEventUpdate();
1314 m_eventsubscription = 0;
1315 }
1273 1316
1274 private void changeForce(Vector3 newForce) 1317 private void changeForce(Vector3 newForce)
1275 { 1318 {
1276 m_pidControllerActive = false; 1319 setFreeMove();
1320
1277 if (Body != IntPtr.Zero) 1321 if (Body != IntPtr.Zero)
1278 { 1322 {
1279 if (newForce.X != 0f || newForce.Y != 0f || newForce.Z != 0) 1323 if (newForce.X != 0f || newForce.Y != 0f || newForce.Z != 0)
@@ -1285,14 +1329,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1285 private void changeMomentum(Vector3 newmomentum) 1329 private void changeMomentum(Vector3 newmomentum)
1286 { 1330 {
1287 _velocity = newmomentum; 1331 _velocity = newmomentum;
1288 _target_velocity = Vector3.Zero; 1332 setFreeMove();
1289 m_freemove = true;
1290 m_pidControllerActive = true;
1291 m_colliderfilter = 0;
1292 m_colliderObjectfilter = 0;
1293 m_iscolliding = false;
1294 m_iscollidingGround = false;
1295 m_iscollidingObj = false;
1296 1333
1297 if (Body != IntPtr.Zero) 1334 if (Body != IntPtr.Zero)
1298 d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z); 1335 d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z);