aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs166
1 files changed, 94 insertions, 72 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 2f42646..981cf43 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -159,6 +159,7 @@ namespace OpenSim.Region.Physics.OdePlugin
159 159
160 private float ODE_STEPSIZE = 0.020f; 160 private float ODE_STEPSIZE = 0.020f;
161 private float metersInSpace = 29.9f; 161 private float metersInSpace = 29.9f;
162 private float m_timeDilation = 1.0f;
162 163
163 public float gravityx = 0f; 164 public float gravityx = 0f;
164 public float gravityy = 0f; 165 public float gravityy = 0f;
@@ -177,8 +178,8 @@ namespace OpenSim.Region.Physics.OdePlugin
177 //private int m_returncollisions = 10; 178 //private int m_returncollisions = 10;
178 179
179 private readonly IntPtr contactgroup; 180 private readonly IntPtr contactgroup;
180 internal IntPtr LandGeom;
181 181
182 internal IntPtr LandGeom;
182 internal IntPtr WaterGeom; 183 internal IntPtr WaterGeom;
183 184
184 private float nmTerrainContactFriction = 255.0f; 185 private float nmTerrainContactFriction = 255.0f;
@@ -250,7 +251,7 @@ namespace OpenSim.Region.Physics.OdePlugin
250 private bool m_NINJA_physics_joints_enabled = false; 251 private bool m_NINJA_physics_joints_enabled = false;
251 //private Dictionary<String, IntPtr> jointpart_name_map = new Dictionary<String,IntPtr>(); 252 //private Dictionary<String, IntPtr> jointpart_name_map = new Dictionary<String,IntPtr>();
252 private readonly Dictionary<String, List<PhysicsJoint>> joints_connecting_actor = new Dictionary<String, List<PhysicsJoint>>(); 253 private readonly Dictionary<String, List<PhysicsJoint>> joints_connecting_actor = new Dictionary<String, List<PhysicsJoint>>();
253 private d.ContactGeom[] contacts = new d.ContactGeom[80]; 254 private d.ContactGeom[] contacts;
254 private readonly List<PhysicsJoint> requestedJointsToBeCreated = new List<PhysicsJoint>(); // lock only briefly. accessed by external code (to request new joints) and by OdeScene.Simulate() to move those joints into pending/active 255 private readonly List<PhysicsJoint> requestedJointsToBeCreated = new List<PhysicsJoint>(); // lock only briefly. accessed by external code (to request new joints) and by OdeScene.Simulate() to move those joints into pending/active
255 private readonly List<PhysicsJoint> pendingJoints = new List<PhysicsJoint>(); // can lock for longer. accessed only by OdeScene. 256 private readonly List<PhysicsJoint> pendingJoints = new List<PhysicsJoint>(); // can lock for longer. accessed only by OdeScene.
256 private readonly List<PhysicsJoint> activeJoints = new List<PhysicsJoint>(); // can lock for longer. accessed only by OdeScene. 257 private readonly List<PhysicsJoint> activeJoints = new List<PhysicsJoint>(); // can lock for longer. accessed only by OdeScene.
@@ -396,6 +397,8 @@ namespace OpenSim.Region.Physics.OdePlugin
396 avStandupTensor = 550000f; 397 avStandupTensor = 550000f;
397 } 398 }
398 399
400 int contactsPerCollision = 80;
401
399 if (m_config != null) 402 if (m_config != null)
400 { 403 {
401 IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; 404 IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"];
@@ -436,7 +439,9 @@ namespace OpenSim.Region.Physics.OdePlugin
436 avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f); 439 avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f);
437 avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f); 440 avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f);
438 avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); 441 avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f);
439 avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", true); 442 avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", false);
443
444 contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80);
440 445
441 geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); 446 geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3);
442 geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); 447 geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15);
@@ -475,10 +480,11 @@ namespace OpenSim.Region.Physics.OdePlugin
475 480
476 m_NINJA_physics_joints_enabled = physicsconfig.GetBoolean("use_NINJA_physics_joints", false); 481 m_NINJA_physics_joints_enabled = physicsconfig.GetBoolean("use_NINJA_physics_joints", false);
477 minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f); 482 minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f);
478
479 } 483 }
480 } 484 }
481 485
486 contacts = new d.ContactGeom[contactsPerCollision];
487
482 staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; 488 staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)];
483 489
484 // Centeral contact friction and bounce 490 // Centeral contact friction and bounce
@@ -771,7 +777,9 @@ namespace OpenSim.Region.Physics.OdePlugin
771 777
772 lock (contacts) 778 lock (contacts)
773 { 779 {
774 count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); 780 count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf);
781 if (count > contacts.Length)
782 m_log.Error("[PHYSICS]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length);
775 } 783 }
776 } 784 }
777 catch (SEHException) 785 catch (SEHException)
@@ -799,7 +807,7 @@ namespace OpenSim.Region.Physics.OdePlugin
799 p2 = PANull; 807 p2 = PANull;
800 } 808 }
801 809
802 float max_collision_depth = 0f; 810 ContactPoint maxDepthContact = new ContactPoint();
803 if (p1.CollisionScore + count >= float.MaxValue) 811 if (p1.CollisionScore + count >= float.MaxValue)
804 p1.CollisionScore = 0; 812 p1.CollisionScore = 0;
805 p1.CollisionScore += count; 813 p1.CollisionScore += count;
@@ -810,9 +818,17 @@ namespace OpenSim.Region.Physics.OdePlugin
810 818
811 for (int i = 0; i < count; i++) 819 for (int i = 0; i < count; i++)
812 { 820 {
821 d.ContactGeom curContact = contacts[i];
813 822
823 if (curContact.depth > maxDepthContact.PenetrationDepth)
824 {
825 maxDepthContact = new ContactPoint(
826 new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z),
827 new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z),
828 curContact.depth
829 );
830 }
814 831
815 max_collision_depth = (contacts[i].depth > max_collision_depth) ? contacts[i].depth : max_collision_depth;
816 //m_log.Warn("[CCOUNT]: " + count); 832 //m_log.Warn("[CCOUNT]: " + count);
817 IntPtr joint; 833 IntPtr joint;
818 // If we're colliding with terrain, use 'TerrainContact' instead of contact. 834 // If we're colliding with terrain, use 'TerrainContact' instead of contact.
@@ -829,7 +845,7 @@ namespace OpenSim.Region.Physics.OdePlugin
829 p2.CollidingObj = true; 845 p2.CollidingObj = true;
830 break; 846 break;
831 case (int)ActorTypes.Prim: 847 case (int)ActorTypes.Prim:
832 if (p2.Velocity.X > 0 || p2.Velocity.Y > 0 || p2.Velocity.Z > 0) 848 if (p2.Velocity.LengthSquared() > 0.0f)
833 p2.CollidingObj = true; 849 p2.CollidingObj = true;
834 break; 850 break;
835 case (int)ActorTypes.Unknown: 851 case (int)ActorTypes.Unknown:
@@ -845,14 +861,14 @@ namespace OpenSim.Region.Physics.OdePlugin
845 #region InterPenetration Handling - Unintended physics explosions 861 #region InterPenetration Handling - Unintended physics explosions
846# region disabled code1 862# region disabled code1
847 863
848 if (contacts[i].depth >= 0.08f) 864 if (curContact.depth >= 0.08f)
849 { 865 {
850 //This is disabled at the moment only because it needs more tweaking 866 //This is disabled at the moment only because it needs more tweaking
851 //It will eventually be uncommented 867 //It will eventually be uncommented
852 /* 868 /*
853 if (contacts[i].depth >= 1.00f) 869 if (contact.depth >= 1.00f)
854 { 870 {
855 //m_log.Debug("[PHYSICS]: " + contacts[i].depth.ToString()); 871 //m_log.Debug("[PHYSICS]: " + contact.depth.ToString());
856 } 872 }
857 873
858 //If you interpenetrate a prim with an agent 874 //If you interpenetrate a prim with an agent
@@ -862,37 +878,37 @@ namespace OpenSim.Region.Physics.OdePlugin
862 p2.PhysicsActorType == (int) ActorTypes.Prim)) 878 p2.PhysicsActorType == (int) ActorTypes.Prim))
863 { 879 {
864 880
865 //contacts[i].depth = contacts[i].depth * 4.15f; 881 //contact.depth = contact.depth * 4.15f;
866 /* 882 /*
867 if (p2.PhysicsActorType == (int) ActorTypes.Agent) 883 if (p2.PhysicsActorType == (int) ActorTypes.Agent)
868 { 884 {
869 p2.CollidingObj = true; 885 p2.CollidingObj = true;
870 contacts[i].depth = 0.003f; 886 contact.depth = 0.003f;
871 p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); 887 p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f);
872 OdeCharacter character = (OdeCharacter) p2; 888 OdeCharacter character = (OdeCharacter) p2;
873 character.SetPidStatus(true); 889 character.SetPidStatus(true);
874 contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); 890 contact.pos = new d.Vector3(contact.pos.X + (p1.Size.X / 2), contact.pos.Y + (p1.Size.Y / 2), contact.pos.Z + (p1.Size.Z / 2));
875 891
876 } 892 }
877 else 893 else
878 { 894 {
879 895
880 //contacts[i].depth = 0.0000000f; 896 //contact.depth = 0.0000000f;
881 } 897 }
882 if (p1.PhysicsActorType == (int) ActorTypes.Agent) 898 if (p1.PhysicsActorType == (int) ActorTypes.Agent)
883 { 899 {
884 900
885 p1.CollidingObj = true; 901 p1.CollidingObj = true;
886 contacts[i].depth = 0.003f; 902 contact.depth = 0.003f;
887 p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f); 903 p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f);
888 contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p2.Size.X / 2), contacts[i].pos.Y + (p2.Size.Y / 2), contacts[i].pos.Z + (p2.Size.Z / 2)); 904 contact.pos = new d.Vector3(contact.pos.X + (p2.Size.X / 2), contact.pos.Y + (p2.Size.Y / 2), contact.pos.Z + (p2.Size.Z / 2));
889 OdeCharacter character = (OdeCharacter)p1; 905 OdeCharacter character = (OdeCharacter)p1;
890 character.SetPidStatus(true); 906 character.SetPidStatus(true);
891 } 907 }
892 else 908 else
893 { 909 {
894 910
895 //contacts[i].depth = 0.0000000f; 911 //contact.depth = 0.0000000f;
896 } 912 }
897 913
898 914
@@ -917,7 +933,7 @@ namespace OpenSim.Region.Physics.OdePlugin
917 //AddPhysicsActorTaint(p2); 933 //AddPhysicsActorTaint(p2);
918 //} 934 //}
919 935
920 //if (contacts[i].depth >= 0.25f) 936 //if (contact.depth >= 0.25f)
921 //{ 937 //{
922 // Don't collide, one or both prim will expld. 938 // Don't collide, one or both prim will expld.
923 939
@@ -935,21 +951,21 @@ namespace OpenSim.Region.Physics.OdePlugin
935 //AddPhysicsActorTaint(p2); 951 //AddPhysicsActorTaint(p2);
936 //} 952 //}
937 953
938 //contacts[i].depth = contacts[i].depth / 8f; 954 //contact.depth = contact.depth / 8f;
939 //contacts[i].normal = new d.Vector3(0, 0, 1); 955 //contact.normal = new d.Vector3(0, 0, 1);
940 //} 956 //}
941 //if (op1.m_disabled || op2.m_disabled) 957 //if (op1.m_disabled || op2.m_disabled)
942 //{ 958 //{
943 //Manually disabled objects stay disabled 959 //Manually disabled objects stay disabled
944 //contacts[i].depth = 0f; 960 //contact.depth = 0f;
945 //} 961 //}
946 #endregion 962 #endregion
947 } 963 }
948 */ 964 */
949#endregion 965#endregion
950 if (contacts[i].depth >= 1.00f) 966 if (curContact.depth >= 1.00f)
951 { 967 {
952 //m_log.Info("[P]: " + contacts[i].depth.ToString()); 968 //m_log.Info("[P]: " + contact.depth.ToString());
953 if ((p2.PhysicsActorType == (int) ActorTypes.Agent && 969 if ((p2.PhysicsActorType == (int) ActorTypes.Agent &&
954 p1.PhysicsActorType == (int) ActorTypes.Unknown) || 970 p1.PhysicsActorType == (int) ActorTypes.Unknown) ||
955 (p1.PhysicsActorType == (int) ActorTypes.Agent && 971 (p1.PhysicsActorType == (int) ActorTypes.Agent &&
@@ -962,12 +978,12 @@ namespace OpenSim.Region.Physics.OdePlugin
962 OdeCharacter character = (OdeCharacter) p2; 978 OdeCharacter character = (OdeCharacter) p2;
963 979
964 //p2.CollidingObj = true; 980 //p2.CollidingObj = true;
965 contacts[i].depth = 0.00000003f; 981 curContact.depth = 0.00000003f;
966 p2.Velocity = p2.Velocity + new Vector3(0f, 0f, 0.5f); 982 p2.Velocity = p2.Velocity + new Vector3(0f, 0f, 0.5f);
967 contacts[i].pos = 983 curContact.pos =
968 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), 984 new d.Vector3(curContact.pos.X + (p1.Size.X/2),
969 contacts[i].pos.Y + (p1.Size.Y/2), 985 curContact.pos.Y + (p1.Size.Y/2),
970 contacts[i].pos.Z + (p1.Size.Z/2)); 986 curContact.pos.Z + (p1.Size.Z/2));
971 character.SetPidStatus(true); 987 character.SetPidStatus(true);
972 } 988 }
973 } 989 }
@@ -980,12 +996,12 @@ namespace OpenSim.Region.Physics.OdePlugin
980 OdeCharacter character = (OdeCharacter) p1; 996 OdeCharacter character = (OdeCharacter) p1;
981 997
982 //p2.CollidingObj = true; 998 //p2.CollidingObj = true;
983 contacts[i].depth = 0.00000003f; 999 curContact.depth = 0.00000003f;
984 p1.Velocity = p1.Velocity + new Vector3(0f, 0f, 0.5f); 1000 p1.Velocity = p1.Velocity + new Vector3(0f, 0f, 0.5f);
985 contacts[i].pos = 1001 curContact.pos =
986 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), 1002 new d.Vector3(curContact.pos.X + (p1.Size.X/2),
987 contacts[i].pos.Y + (p1.Size.Y/2), 1003 curContact.pos.Y + (p1.Size.Y/2),
988 contacts[i].pos.Z + (p1.Size.Z/2)); 1004 curContact.pos.Z + (p1.Size.Z/2));
989 character.SetPidStatus(true); 1005 character.SetPidStatus(true);
990 } 1006 }
991 } 1007 }
@@ -1007,16 +1023,15 @@ namespace OpenSim.Region.Physics.OdePlugin
1007 if (!skipThisContact && (p2 is OdePrim) && (((OdePrim)p2).m_isVolumeDetect)) 1023 if (!skipThisContact && (p2 is OdePrim) && (((OdePrim)p2).m_isVolumeDetect))
1008 skipThisContact = true; // No collision on volume detect prims 1024 skipThisContact = true; // No collision on volume detect prims
1009 1025
1010 if (!skipThisContact && contacts[i].depth < 0f) 1026 if (!skipThisContact && curContact.depth < 0f)
1011 skipThisContact = true; 1027 skipThisContact = true;
1012 1028
1013 if (!skipThisContact && checkDupe(contacts[i], p2.PhysicsActorType)) 1029 if (!skipThisContact && checkDupe(curContact, p2.PhysicsActorType))
1014 skipThisContact = true; 1030 skipThisContact = true;
1015 1031
1016 int maxContactsbeforedeath = 4000; 1032 const int maxContactsbeforedeath = 4000;
1017 joint = IntPtr.Zero; 1033 joint = IntPtr.Zero;
1018 1034
1019
1020 if (!skipThisContact) 1035 if (!skipThisContact)
1021 { 1036 {
1022 // If we're colliding against terrain 1037 // If we're colliding against terrain
@@ -1027,8 +1042,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1027 (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) 1042 (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f))
1028 { 1043 {
1029 // Use the movement terrain contact 1044 // Use the movement terrain contact
1030 AvatarMovementTerrainContact.geom = contacts[i]; 1045 AvatarMovementTerrainContact.geom = curContact;
1031 _perloopContact.Add(contacts[i]); 1046 _perloopContact.Add(curContact);
1032 if (m_global_contactcount < maxContactsbeforedeath) 1047 if (m_global_contactcount < maxContactsbeforedeath)
1033 { 1048 {
1034 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); 1049 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact);
@@ -1040,8 +1055,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1040 if (p2.PhysicsActorType == (int)ActorTypes.Agent) 1055 if (p2.PhysicsActorType == (int)ActorTypes.Agent)
1041 { 1056 {
1042 // Use the non moving terrain contact 1057 // Use the non moving terrain contact
1043 TerrainContact.geom = contacts[i]; 1058 TerrainContact.geom = curContact;
1044 _perloopContact.Add(contacts[i]); 1059 _perloopContact.Add(curContact);
1045 if (m_global_contactcount < maxContactsbeforedeath) 1060 if (m_global_contactcount < maxContactsbeforedeath)
1046 { 1061 {
1047 joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); 1062 joint = d.JointCreateContact(world, contactgroup, ref TerrainContact);
@@ -1066,8 +1081,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1066 material = ((OdePrim)p2).m_material; 1081 material = ((OdePrim)p2).m_material;
1067 1082
1068 //m_log.DebugFormat("Material: {0}", material); 1083 //m_log.DebugFormat("Material: {0}", material);
1069 m_materialContacts[material, movintYN].geom = contacts[i]; 1084 m_materialContacts[material, movintYN].geom = curContact;
1070 _perloopContact.Add(contacts[i]); 1085 _perloopContact.Add(curContact);
1071 1086
1072 if (m_global_contactcount < maxContactsbeforedeath) 1087 if (m_global_contactcount < maxContactsbeforedeath)
1073 { 1088 {
@@ -1092,8 +1107,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1092 if (p2 is OdePrim) 1107 if (p2 is OdePrim)
1093 material = ((OdePrim)p2).m_material; 1108 material = ((OdePrim)p2).m_material;
1094 //m_log.DebugFormat("Material: {0}", material); 1109 //m_log.DebugFormat("Material: {0}", material);
1095 m_materialContacts[material, movintYN].geom = contacts[i]; 1110 m_materialContacts[material, movintYN].geom = curContact;
1096 _perloopContact.Add(contacts[i]); 1111 _perloopContact.Add(curContact);
1097 1112
1098 if (m_global_contactcount < maxContactsbeforedeath) 1113 if (m_global_contactcount < maxContactsbeforedeath)
1099 { 1114 {
@@ -1121,20 +1136,20 @@ namespace OpenSim.Region.Physics.OdePlugin
1121 */ 1136 */
1122 //WaterContact.surface.soft_cfm = 0.0000f; 1137 //WaterContact.surface.soft_cfm = 0.0000f;
1123 //WaterContact.surface.soft_erp = 0.00000f; 1138 //WaterContact.surface.soft_erp = 0.00000f;
1124 if (contacts[i].depth > 0.1f) 1139 if (curContact.depth > 0.1f)
1125 { 1140 {
1126 contacts[i].depth *= 52; 1141 curContact.depth *= 52;
1127 //contacts[i].normal = new d.Vector3(0, 0, 1); 1142 //contact.normal = new d.Vector3(0, 0, 1);
1128 //contacts[i].pos = new d.Vector3(0, 0, contacts[i].pos.Z - 5f); 1143 //contact.pos = new d.Vector3(0, 0, contact.pos.Z - 5f);
1129 } 1144 }
1130 WaterContact.geom = contacts[i]; 1145 WaterContact.geom = curContact;
1131 _perloopContact.Add(contacts[i]); 1146 _perloopContact.Add(curContact);
1132 if (m_global_contactcount < maxContactsbeforedeath) 1147 if (m_global_contactcount < maxContactsbeforedeath)
1133 { 1148 {
1134 joint = d.JointCreateContact(world, contactgroup, ref WaterContact); 1149 joint = d.JointCreateContact(world, contactgroup, ref WaterContact);
1135 m_global_contactcount++; 1150 m_global_contactcount++;
1136 } 1151 }
1137 //m_log.Info("[PHYSICS]: Prim Water Contact" + contacts[i].depth); 1152 //m_log.Info("[PHYSICS]: Prim Water Contact" + contact.depth);
1138 } 1153 }
1139 else 1154 else
1140 { 1155 {
@@ -1145,8 +1160,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1145 if ((Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) 1160 if ((Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f))
1146 { 1161 {
1147 // Use the Movement prim contact 1162 // Use the Movement prim contact
1148 AvatarMovementprimContact.geom = contacts[i]; 1163 AvatarMovementprimContact.geom = curContact;
1149 _perloopContact.Add(contacts[i]); 1164 _perloopContact.Add(curContact);
1150 if (m_global_contactcount < maxContactsbeforedeath) 1165 if (m_global_contactcount < maxContactsbeforedeath)
1151 { 1166 {
1152 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); 1167 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact);
@@ -1156,8 +1171,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1156 else 1171 else
1157 { 1172 {
1158 // Use the non movement contact 1173 // Use the non movement contact
1159 contact.geom = contacts[i]; 1174 contact.geom = curContact;
1160 _perloopContact.Add(contacts[i]); 1175 _perloopContact.Add(curContact);
1161 1176
1162 if (m_global_contactcount < maxContactsbeforedeath) 1177 if (m_global_contactcount < maxContactsbeforedeath)
1163 { 1178 {
@@ -1175,8 +1190,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1175 material = ((OdePrim)p2).m_material; 1190 material = ((OdePrim)p2).m_material;
1176 1191
1177 //m_log.DebugFormat("Material: {0}", material); 1192 //m_log.DebugFormat("Material: {0}", material);
1178 m_materialContacts[material, 0].geom = contacts[i]; 1193 m_materialContacts[material, 0].geom = curContact;
1179 _perloopContact.Add(contacts[i]); 1194 _perloopContact.Add(curContact);
1180 1195
1181 if (m_global_contactcount < maxContactsbeforedeath) 1196 if (m_global_contactcount < maxContactsbeforedeath)
1182 { 1197 {
@@ -1194,7 +1209,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1194 } 1209 }
1195 1210
1196 } 1211 }
1197 collision_accounting_events(p1, p2, max_collision_depth); 1212 collision_accounting_events(p1, p2, maxDepthContact);
1198 if (count > geomContactPointsStartthrottle) 1213 if (count > geomContactPointsStartthrottle)
1199 { 1214 {
1200 // If there are more then 3 contact points, it's likely 1215 // If there are more then 3 contact points, it's likely
@@ -1278,7 +1293,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1278 return result; 1293 return result;
1279 } 1294 }
1280 1295
1281 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, float collisiondepth) 1296 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
1282 { 1297 {
1283 // obj1LocalID = 0; 1298 // obj1LocalID = 0;
1284 //returncollisions = false; 1299 //returncollisions = false;
@@ -1299,7 +1314,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1299 case ActorTypes.Agent: 1314 case ActorTypes.Agent:
1300 cc1 = (OdeCharacter)p1; 1315 cc1 = (OdeCharacter)p1;
1301 obj2LocalID = cc1.m_localID; 1316 obj2LocalID = cc1.m_localID;
1302 cc1.AddCollisionEvent(cc2.m_localID, collisiondepth); 1317 cc1.AddCollisionEvent(cc2.m_localID, contact);
1303 //ctype = (int)CollisionCategories.Character; 1318 //ctype = (int)CollisionCategories.Character;
1304 1319
1305 //if (cc1.CollidingObj) 1320 //if (cc1.CollidingObj)
@@ -1314,7 +1329,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1314 { 1329 {
1315 cp1 = (OdePrim) p1; 1330 cp1 = (OdePrim) p1;
1316 obj2LocalID = cp1.m_localID; 1331 obj2LocalID = cp1.m_localID;
1317 cp1.AddCollisionEvent(cc2.m_localID, collisiondepth); 1332 cp1.AddCollisionEvent(cc2.m_localID, contact);
1318 } 1333 }
1319 //ctype = (int)CollisionCategories.Geom; 1334 //ctype = (int)CollisionCategories.Geom;
1320 1335
@@ -1334,7 +1349,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1334 break; 1349 break;
1335 } 1350 }
1336 1351
1337 cc2.AddCollisionEvent(obj2LocalID, collisiondepth); 1352 cc2.AddCollisionEvent(obj2LocalID, contact);
1338 break; 1353 break;
1339 case ActorTypes.Prim: 1354 case ActorTypes.Prim:
1340 1355
@@ -1350,7 +1365,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1350 { 1365 {
1351 cc1 = (OdeCharacter) p1; 1366 cc1 = (OdeCharacter) p1;
1352 obj2LocalID = cc1.m_localID; 1367 obj2LocalID = cc1.m_localID;
1353 cc1.AddCollisionEvent(cp2.m_localID, collisiondepth); 1368 cc1.AddCollisionEvent(cp2.m_localID, contact);
1354 //ctype = (int)CollisionCategories.Character; 1369 //ctype = (int)CollisionCategories.Character;
1355 1370
1356 //if (cc1.CollidingObj) 1371 //if (cc1.CollidingObj)
@@ -1366,7 +1381,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1366 { 1381 {
1367 cp1 = (OdePrim) p1; 1382 cp1 = (OdePrim) p1;
1368 obj2LocalID = cp1.m_localID; 1383 obj2LocalID = cp1.m_localID;
1369 cp1.AddCollisionEvent(cp2.m_localID, collisiondepth); 1384 cp1.AddCollisionEvent(cp2.m_localID, contact);
1370 //ctype = (int)CollisionCategories.Geom; 1385 //ctype = (int)CollisionCategories.Geom;
1371 1386
1372 //if (cp1.CollidingObj) 1387 //if (cp1.CollidingObj)
@@ -1387,7 +1402,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1387 break; 1402 break;
1388 } 1403 }
1389 1404
1390 cp2.AddCollisionEvent(obj2LocalID, collisiondepth); 1405 cp2.AddCollisionEvent(obj2LocalID, contact);
1391 } 1406 }
1392 break; 1407 break;
1393 } 1408 }
@@ -1750,6 +1765,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1750 return result; 1765 return result;
1751 } 1766 }
1752 1767
1768 public override float TimeDilation
1769 {
1770 get { return m_timeDilation; }
1771 }
1772
1753 public override bool SupportsNINJAJoints 1773 public override bool SupportsNINJAJoints
1754 { 1774 {
1755 get { return m_NINJA_physics_joints_enabled; } 1775 get { return m_NINJA_physics_joints_enabled; }
@@ -2657,8 +2677,10 @@ namespace OpenSim.Region.Physics.OdePlugin
2657 2677
2658 // Figure out the Frames Per Second we're going at. 2678 // Figure out the Frames Per Second we're going at.
2659 //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size 2679 //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size
2660 2680
2661 fps = (step_time/ODE_STEPSIZE) * 1000; 2681 fps = (step_time / ODE_STEPSIZE) * 1000;
2682 // HACK: Using a time dilation of 1.0 to debug rubberbanding issues
2683 //m_timeDilation = Math.Min((step_time / ODE_STEPSIZE) / (0.09375f / ODE_STEPSIZE), 1.0f);
2662 2684
2663 step_time = 0.09375f; 2685 step_time = 0.09375f;
2664 2686
@@ -3519,7 +3541,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3519 public override void UnCombine(PhysicsScene pScene) 3541 public override void UnCombine(PhysicsScene pScene)
3520 { 3542 {
3521 IntPtr localGround = IntPtr.Zero; 3543 IntPtr localGround = IntPtr.Zero;
3522 float[] localHeightfield; 3544// float[] localHeightfield;
3523 bool proceed = false; 3545 bool proceed = false;
3524 List<IntPtr> geomDestroyList = new List<IntPtr>(); 3546 List<IntPtr> geomDestroyList = new List<IntPtr>();
3525 3547
@@ -3531,7 +3553,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3531 { 3553 {
3532 if (geom == localGround) 3554 if (geom == localGround)
3533 { 3555 {
3534 localHeightfield = TerrainHeightFieldHeights[geom]; 3556// localHeightfield = TerrainHeightFieldHeights[geom];
3535 proceed = true; 3557 proceed = true;
3536 } 3558 }
3537 else 3559 else
@@ -3553,7 +3575,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3553 // memory corruption 3575 // memory corruption
3554 if (TerrainHeightFieldHeights.ContainsKey(g)) 3576 if (TerrainHeightFieldHeights.ContainsKey(g))
3555 { 3577 {
3556 float[] removingHeightField = TerrainHeightFieldHeights[g]; 3578// float[] removingHeightField = TerrainHeightFieldHeights[g];
3557 TerrainHeightFieldHeights.Remove(g); 3579 TerrainHeightFieldHeights.Remove(g);
3558 3580
3559 if (RegionTerrain.ContainsKey(g)) 3581 if (RegionTerrain.ContainsKey(g))