aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs366
1 files changed, 130 insertions, 236 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 003a91c..15eb01f 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -147,6 +147,7 @@ namespace OpenSim.Region.Physics.OdePlugin
147 PIDHoverActive, 147 PIDHoverActive,
148 148
149 Size, 149 Size,
150 AvatarSize,
150 Shape, 151 Shape,
151 PhysRepData, 152 PhysRepData,
152 AddPhysRep, 153 AddPhysRep,
@@ -177,7 +178,9 @@ namespace OpenSim.Region.Physics.OdePlugin
177 public changes what; 178 public changes what;
178 public Object arg; 179 public Object arg;
179 } 180 }
180 181
182
183
181 public class OdeScene : PhysicsScene 184 public class OdeScene : PhysicsScene
182 { 185 {
183 private readonly ILog m_log; 186 private readonly ILog m_log;
@@ -224,9 +227,6 @@ namespace OpenSim.Region.Physics.OdePlugin
224// private IntPtr WaterHeightmapData = IntPtr.Zero; 227// private IntPtr WaterHeightmapData = IntPtr.Zero;
225// private GCHandle WaterMapHandler = new GCHandle(); 228// private GCHandle WaterMapHandler = new GCHandle();
226 229
227 public float avPIDD = 2200f; // make it visible
228 public float avPIDP = 900f; // make it visible
229 private float avCapRadius = 0.37f;
230 private float avDensity = 3f; 230 private float avDensity = 3f;
231 private float avMovementDivisorWalk = 1.3f; 231 private float avMovementDivisorWalk = 1.3f;
232 private float avMovementDivisorRun = 0.8f; 232 private float avMovementDivisorRun = 0.8f;
@@ -299,9 +299,12 @@ namespace OpenSim.Region.Physics.OdePlugin
299 299
300 public IntPtr TopSpace; // the global space 300 public IntPtr TopSpace; // the global space
301 public IntPtr ActiveSpace; // space for active prims 301 public IntPtr ActiveSpace; // space for active prims
302 public IntPtr CharsSpace; // space for active prims
302 public IntPtr StaticSpace; // space for the static things around 303 public IntPtr StaticSpace; // space for the static things around
303 public IntPtr GroundSpace; // space for ground 304 public IntPtr GroundSpace; // space for ground
304 305
306 public IntPtr SharedRay;
307
305 // some speedup variables 308 // some speedup variables
306 private int spaceGridMaxX; 309 private int spaceGridMaxX;
307 private int spaceGridMaxY; 310 private int spaceGridMaxY;
@@ -372,21 +375,25 @@ namespace OpenSim.Region.Physics.OdePlugin
372 375
373 // now the major subspaces 376 // now the major subspaces
374 ActiveSpace = d.HashSpaceCreate(TopSpace); 377 ActiveSpace = d.HashSpaceCreate(TopSpace);
378 CharsSpace = d.HashSpaceCreate(TopSpace);
375 StaticSpace = d.HashSpaceCreate(TopSpace); 379 StaticSpace = d.HashSpaceCreate(TopSpace);
376 GroundSpace = d.HashSpaceCreate(TopSpace); 380 GroundSpace = d.HashSpaceCreate(TopSpace);
377 } 381 }
378 catch 382 catch
379 { 383 {
380 // i must RtC#FM 384 // i must RtC#FM
385 // i did!
381 } 386 }
382 387
383 d.HashSpaceSetLevels(TopSpace, -2, 8); 388 d.HashSpaceSetLevels(TopSpace, -2, 8);
384 d.HashSpaceSetLevels(ActiveSpace, -2, 8); 389 d.HashSpaceSetLevels(ActiveSpace, -2, 8);
390 d.HashSpaceSetLevels(CharsSpace, -4, 3);
385 d.HashSpaceSetLevels(StaticSpace, -2, 8); 391 d.HashSpaceSetLevels(StaticSpace, -2, 8);
386 d.HashSpaceSetLevels(GroundSpace, 0, 8); 392 d.HashSpaceSetLevels(GroundSpace, 0, 8);
387 393
388 // demote to second level 394 // demote to second level
389 d.SpaceSetSublevel(ActiveSpace, 1); 395 d.SpaceSetSublevel(ActiveSpace, 1);
396 d.SpaceSetSublevel(CharsSpace, 1);
390 d.SpaceSetSublevel(StaticSpace, 1); 397 d.SpaceSetSublevel(StaticSpace, 1);
391 d.SpaceSetSublevel(GroundSpace, 1); 398 d.SpaceSetSublevel(GroundSpace, 1);
392 399
@@ -396,11 +403,24 @@ namespace OpenSim.Region.Physics.OdePlugin
396 CollisionCategories.Phantom | 403 CollisionCategories.Phantom |
397 CollisionCategories.VolumeDtc 404 CollisionCategories.VolumeDtc
398 )); 405 ));
399 d.GeomSetCollideBits(ActiveSpace, 0); 406 d.GeomSetCollideBits(ActiveSpace, (uint)(CollisionCategories.Space |
407 CollisionCategories.Geom |
408 CollisionCategories.Character |
409 CollisionCategories.Phantom |
410 CollisionCategories.VolumeDtc
411 ));
412 d.GeomSetCategoryBits(CharsSpace, (uint)(CollisionCategories.Space |
413 CollisionCategories.Geom |
414 CollisionCategories.Character |
415 CollisionCategories.Phantom |
416 CollisionCategories.VolumeDtc
417 ));
418 d.GeomSetCollideBits(CharsSpace, 0);
419
400 d.GeomSetCategoryBits(StaticSpace, (uint)(CollisionCategories.Space | 420 d.GeomSetCategoryBits(StaticSpace, (uint)(CollisionCategories.Space |
401 CollisionCategories.Geom | 421 CollisionCategories.Geom |
402 CollisionCategories.Land | 422// CollisionCategories.Land |
403 CollisionCategories.Water | 423// CollisionCategories.Water |
404 CollisionCategories.Phantom | 424 CollisionCategories.Phantom |
405 CollisionCategories.VolumeDtc 425 CollisionCategories.VolumeDtc
406 )); 426 ));
@@ -412,6 +432,8 @@ namespace OpenSim.Region.Physics.OdePlugin
412 contactgroup = d.JointGroupCreate(0); 432 contactgroup = d.JointGroupCreate(0);
413 //contactgroup 433 //contactgroup
414 434
435 SharedRay = d.CreateRay(TopSpace, 1.0f);
436
415 d.WorldSetAutoDisableFlag(world, false); 437 d.WorldSetAutoDisableFlag(world, false);
416 } 438 }
417 } 439 }
@@ -468,7 +490,6 @@ namespace OpenSim.Region.Physics.OdePlugin
468 avDensity = physicsconfig.GetFloat("av_density", avDensity); 490 avDensity = physicsconfig.GetFloat("av_density", avDensity);
469 avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk); 491 avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk);
470 avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", avMovementDivisorRun); 492 avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", avMovementDivisorRun);
471 avCapRadius = physicsconfig.GetFloat("av_capsule_radius", avCapRadius);
472 493
473 contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision); 494 contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision);
474 495
@@ -494,7 +515,7 @@ namespace OpenSim.Region.Physics.OdePlugin
494 odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f); 515 odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f);
495 516
496 ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); 517 ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf);
497 GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); 518 GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf);
498 519
499 m_materialContactsData[(int)Material.Stone].mu = 0.8f; 520 m_materialContactsData[(int)Material.Stone].mu = 0.8f;
500 m_materialContactsData[(int)Material.Stone].bounce = 0.4f; 521 m_materialContactsData[(int)Material.Stone].bounce = 0.4f;
@@ -718,35 +739,35 @@ namespace OpenSim.Region.Physics.OdePlugin
718 739
719 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) 740 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
720 return; 741 return;
721/* 742 /*
722// debug 743 // debug
723 PhysicsActor dp2; 744 PhysicsActor dp2;
724 if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass) 745 if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass)
725 { 746 {
726 d.AABB aabb; 747 d.AABB aabb;
727 d.GeomGetAABB(g2, out aabb); 748 d.GeomGetAABB(g2, out aabb);
728 float x = aabb.MaxX - aabb.MinX; 749 float x = aabb.MaxX - aabb.MinX;
729 float y = aabb.MaxY - aabb.MinY; 750 float y = aabb.MaxY - aabb.MinY;
730 float z = aabb.MaxZ - aabb.MinZ; 751 float z = aabb.MaxZ - aabb.MinZ;
731 if (x > 60.0f || y > 60.0f || z > 60.0f) 752 if (x > 60.0f || y > 60.0f || z > 60.0f)
732 { 753 {
733 if (!actor_name_map.TryGetValue(g2, out dp2)) 754 if (!actor_name_map.TryGetValue(g2, out dp2))
734 m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 2"); 755 m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 2");
735 else 756 else
736 m_log.WarnFormat("[PHYSICS]: land versus large prim geo {0},size {1}, AABBsize <{2},{3},{4}>, at {5} ori {6},({7})", 757 m_log.WarnFormat("[PHYSICS]: land versus large prim geo {0},size {1}, AABBsize <{2},{3},{4}>, at {5} ori {6},({7})",
737 dp2.Name, dp2.Size, x, y, z, 758 dp2.Name, dp2.Size, x, y, z,
738 dp2.Position.ToString(), 759 dp2.Position.ToString(),
739 dp2.Orientation.ToString(), 760 dp2.Orientation.ToString(),
740 dp2.Orientation.Length()); 761 dp2.Orientation.Length());
741 return; 762 return;
742 } 763 }
743 } 764 }
744// 765 //
745*/ 766 */
746 767
747 768
748 if(d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || 769 if (d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc ||
749 d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc) 770 d.GeomGetCategoryBits(g2) == (uint)CollisionCategories.VolumeDtc)
750 { 771 {
751 int cflags; 772 int cflags;
752 unchecked 773 unchecked
@@ -761,7 +782,7 @@ namespace OpenSim.Region.Physics.OdePlugin
761 catch (SEHException) 782 catch (SEHException)
762 { 783 {
763 m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); 784 m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim.");
764// ode.drelease(world); 785 // ode.drelease(world);
765 base.TriggerPhysicsBasedRestart(); 786 base.TriggerPhysicsBasedRestart();
766 } 787 }
767 catch (Exception e) 788 catch (Exception e)
@@ -801,26 +822,25 @@ namespace OpenSim.Region.Physics.OdePlugin
801 822
802 // get first contact 823 // get first contact
803 d.ContactGeom curContact = new d.ContactGeom(); 824 d.ContactGeom curContact = new d.ContactGeom();
825
804 if (!GetCurContactGeom(0, ref curContact)) 826 if (!GetCurContactGeom(0, ref curContact))
805 return; 827 return;
806 // for now it's the one with max depth 828
807 ContactPoint maxDepthContact = new ContactPoint(
808 new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z),
809 new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z),
810 curContact.depth
811 );
812 // do volume detection case 829 // do volume detection case
813 if ( 830 if ((p1.IsVolumeDtc || p2.IsVolumeDtc))
814 (p1.IsVolumeDtc || p2.IsVolumeDtc))
815 { 831 {
832 ContactPoint maxDepthContact = new ContactPoint(
833 new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z),
834 new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z),
835 curContact.depth, false
836 );
837
816 collision_accounting_events(p1, p2, maxDepthContact); 838 collision_accounting_events(p1, p2, maxDepthContact);
817 return; 839 return;
818 } 840 }
819 841
820 // big messy collision analises 842 // big messy collision analises
821 843
822 Vector3 normoverride = Vector3.Zero; //damm c#
823
824 float mu = 0; 844 float mu = 0;
825 float bounce = 0; 845 float bounce = 0;
826 float cfm = 0.0001f; 846 float cfm = 0.0001f;
@@ -831,36 +851,15 @@ namespace OpenSim.Region.Physics.OdePlugin
831 ContactData contactdata1 = new ContactData(0, 0, false); 851 ContactData contactdata1 = new ContactData(0, 0, false);
832 ContactData contactdata2 = new ContactData(0, 0, false); 852 ContactData contactdata2 = new ContactData(0, 0, false);
833 853
834 bool dop1foot = false; 854 bool dop1ava = false;
835 bool dop2foot = false; 855 bool dop2ava = false;
836 bool ignore = false; 856 bool ignore = false;
837 bool AvanormOverride = false;
838 857
839 switch (p1.PhysicsActorType) 858 switch (p1.PhysicsActorType)
840 { 859 {
841 case (int)ActorTypes.Agent: 860 case (int)ActorTypes.Agent:
842 { 861 {
843 dop1foot = true; 862 dop1ava = true;
844
845 AvanormOverride = true;
846 Vector3 tmp = p2.Position - p1.Position;
847 normoverride = p2.Velocity - p1.Velocity;
848 mu = normoverride.LengthSquared();
849
850 if (mu > 1e-6)
851 {
852 mu = 1.0f / (float)Math.Sqrt(mu);
853 normoverride *= mu;
854 mu = Vector3.Dot(tmp, normoverride);
855 if (mu > 0)
856 normoverride *= -1;
857 }
858 else
859 {
860 tmp.Normalize();
861 normoverride = -tmp;
862 }
863
864 switch (p2.PhysicsActorType) 863 switch (p2.PhysicsActorType)
865 { 864 {
866 case (int)ActorTypes.Agent: 865 case (int)ActorTypes.Agent:
@@ -871,7 +870,6 @@ namespace OpenSim.Region.Physics.OdePlugin
871 case (int)ActorTypes.Prim: 870 case (int)ActorTypes.Prim:
872 if (p2.Velocity.LengthSquared() > 0.0f) 871 if (p2.Velocity.LengthSquared() > 0.0f)
873 p2.CollidingObj = true; 872 p2.CollidingObj = true;
874 dop1foot = true;
875 break; 873 break;
876 874
877 default: 875 default:
@@ -886,33 +884,8 @@ namespace OpenSim.Region.Physics.OdePlugin
886 { 884 {
887 case (int)ActorTypes.Agent: 885 case (int)ActorTypes.Agent:
888 886
887 dop2ava = true;
889 888
890 dop2foot = true;
891
892 AvanormOverride = true;
893
894 Vector3 tmp = p2.Position - p1.Position;
895 normoverride = p2.Velocity - p1.Velocity;
896 mu = normoverride.LengthSquared();
897 if (mu > 1e-6)
898 {
899 mu = 1.0f / (float)Math.Sqrt(mu);
900 normoverride *= mu;
901 mu = Vector3.Dot(tmp, normoverride);
902 if (mu > 0)
903 normoverride *= -1;
904 }
905 else
906 {
907 tmp.Normalize();
908 normoverride = -tmp;
909 }
910
911 bounce = 0;
912 mu = 0;
913 cfm = 0.0001f;
914
915 dop2foot = true;
916 if (p1.Velocity.LengthSquared() > 0.0f) 889 if (p1.Velocity.LengthSquared() > 0.0f)
917 p1.CollidingObj = true; 890 p1.CollidingObj = true;
918 break; 891 break;
@@ -1017,166 +990,78 @@ namespace OpenSim.Region.Physics.OdePlugin
1017 default: 990 default:
1018 break; 991 break;
1019 } 992 }
993
1020 if (ignore) 994 if (ignore)
1021 return; 995 return;
1022 996
1023 IntPtr Joint;
1024 997
1025 int i = 0; 998 d.ContactGeom maxContact = curContact;
999// if (IgnoreNegSides && curContact.side1 < 0)
1000// maxContact.depth = float.MinValue;
1001
1002 d.ContactGeom minContact = curContact;
1003// if (IgnoreNegSides && curContact.side1 < 0)
1004// minContact.depth = float.MaxValue;
1005
1006 IntPtr Joint;
1007 bool FeetCollision = false;
1026 int ncontacts = 0; 1008 int ncontacts = 0;
1027 while(true)
1028 {
1029 1009
1030 if (IgnoreNegSides && curContact.side1 < 0)
1031 {
1032 if (++i >= count)
1033 break;
1034 1010
1035 if (!GetCurContactGeom(i, ref curContact)) 1011 int i = 0;
1036 break;
1037 }
1038 else
1039 1012
1013 while (true)
1040 { 1014 {
1041 if(dop1foot) 1015 if (m_global_contactcount >= maxContactsbeforedeath)
1016 break;
1017
1018// if (!(IgnoreNegSides && curContact.side1 < 0))
1042 { 1019 {
1043 if (!(((OdeCharacter)p1).Collide(g1,false, ref curContact))) 1020 bool noskip = true;
1021 if (dop1ava)
1044 { 1022 {
1045 if (++i >= count) 1023 if (!(((OdeCharacter)p1).Collide(g1,false, ref curContact, ref FeetCollision)))
1046 break; 1024
1047 else 1025 noskip = false;
1048 continue;
1049 } 1026 }
1050 } 1027 else if (dop2ava)
1051 else if(dop2foot)
1052 {
1053 if(!(((OdeCharacter) p2).Collide(g2,true,ref curContact)))
1054 { 1028 {
1055 if (++i >= count) 1029 if (!(((OdeCharacter)p2).Collide(g2,true, ref curContact, ref FeetCollision)))
1056 break; 1030 noskip = false;
1057 else
1058 continue;
1059 } 1031 }
1060 }
1061 1032
1062/* 1033 if (noskip)
1063 if (AvanormOverride)
1064 {
1065 if (curContact.depth > 0.3f)
1066 { 1034 {
1067 if (dop1foot && (p1.Position.Z - curContact.pos.Z) > (p1.Size.Z - avCapRadius) * 0.5f) 1035 m_global_contactcount++;
1068 p1.IsColliding = true; 1036 ncontacts++;
1069 if (dop2foot && (p2.Position.Z - curContact.pos.Z) > (p2.Size.Z - avCapRadius) * 0.5f)
1070 p2.IsColliding = true;
1071 curContact.normal.X = normoverride.X;
1072 curContact.normal.Y = normoverride.Y;
1073 curContact.normal.Z = normoverride.Z;
1074 }
1075 1037
1076 else 1038 Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale);
1077 { 1039 d.JointAttach(Joint, b1, b2);
1078 if (dop1foot)
1079 {
1080 float sz = p1.Size.Z;
1081 Vector3 vtmp = p1.Position;
1082 float ppos = curContact.pos.Z - vtmp.Z + (sz - avCapRadius) * 0.5f;
1083 if (ppos > 0f)
1084 {
1085 if (!p1.Flying)
1086 {
1087 d.AABB aabb;
1088 d.GeomGetAABB(g2, out aabb);
1089 float tmp = vtmp.Z - sz * .18f;
1090
1091 if (aabb.MaxZ < tmp)
1092 {
1093 vtmp.X = curContact.pos.X - vtmp.X;
1094 vtmp.Y = curContact.pos.Y - vtmp.Y;
1095 vtmp.Z = -0.2f;
1096 vtmp.Normalize();
1097 curContact.normal.X = vtmp.X;
1098 curContact.normal.Y = vtmp.Y;
1099 curContact.normal.Z = vtmp.Z;
1100 }
1101 }
1102 }
1103 else
1104 p1.IsColliding = true;
1105 1040
1106 } 1041 if (curContact.depth > maxContact.depth)
1042 maxContact = curContact;
1107 1043
1108 if (dop2foot) 1044 if (curContact.depth < minContact.depth)
1109 { 1045 minContact = curContact;
1110 float sz = p2.Size.Z;
1111 Vector3 vtmp = p2.Position;
1112 vtmp.Z -= sz * 0.5f;
1113 vtmp.Z += 0.5f;
1114 float ppos = vtmp.Z - curContact.pos.Z;
1115 if (ppos > 0f)
1116 {
1117 if (!p2.Flying)
1118 {
1119 float tmp = vtmp.Z - sz * .18f;
1120 vtmp.X = curContact.pos.X - vtmp.X;
1121 vtmp.Y = curContact.pos.Y - vtmp.Y;
1122 vtmp.Z = curContact.pos.Z - vtmp.Z;
1123 vtmp.Normalize();
1124 curContact.normal.X = vtmp.X;
1125 curContact.normal.Y = vtmp.Y;
1126 curContact.normal.Z = vtmp.Z;
1127 }
1128 }
1129// else
1130 p2.IsColliding = true;
1131
1132 }
1133 } 1046 }
1134 } 1047 }
1135*/
1136 ncontacts++;
1137 Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale);
1138 d.JointAttach(Joint, b1, b2);
1139
1140 if (++m_global_contactcount >= maxContactsbeforedeath)
1141 break;
1142 1048
1143 if (++i >= count) 1049 if (++i >= count)
1144 break; 1050 break;
1145 1051
1146 if (!GetCurContactGeom(i, ref curContact)) 1052 if (!GetCurContactGeom(i, ref curContact))
1147 break; 1053 break;
1148
1149 if (curContact.depth > maxDepthContact.PenetrationDepth)
1150 {
1151 maxDepthContact.Position.X = curContact.pos.X;
1152 maxDepthContact.Position.Y = curContact.pos.Y;
1153 maxDepthContact.Position.Z = curContact.pos.Z;
1154 maxDepthContact.SurfaceNormal.X = curContact.normal.X;
1155 maxDepthContact.SurfaceNormal.Y = curContact.normal.Y;
1156 maxDepthContact.SurfaceNormal.Z = curContact.normal.Z;
1157 maxDepthContact.PenetrationDepth = curContact.depth;
1158 }
1159 } 1054 }
1160 }
1161 1055
1162 if(ncontacts > 0) 1056 if (ncontacts > 0)
1163 collision_accounting_events(p1, p2, maxDepthContact);
1164
1165/*
1166 if (notskipedcount > geomContactPointsStartthrottle)
1167 { 1057 {
1168 // If there are more then 3 contact points, it's likely 1058 ContactPoint maxDepthContact = new ContactPoint(
1169 // that we've got a pile of objects, so ... 1059 new Vector3(maxContact.pos.X, maxContact.pos.Y, maxContact.pos.Z),
1170 // We don't want to send out hundreds of terse updates over and over again 1060 new Vector3(minContact.normal.X, minContact.normal.Y, minContact.normal.Z),
1171 // so lets throttle them and send them again after it's somewhat sorted out. 1061 maxContact.depth, FeetCollision
1172 this needs checking so out for now 1062 );
1173 if (b1 != IntPtr.Zero) 1063 collision_accounting_events(p1, p2, maxDepthContact);
1174 p1.ThrottleUpdates = true;
1175 if (b2 != IntPtr.Zero)
1176 p2.ThrottleUpdates = true;
1177
1178 } 1064 }
1179 */
1180 } 1065 }
1181 1066
1182 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) 1067 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
@@ -1267,10 +1152,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1267 // chr.CollidingGround = false; not done here 1152 // chr.CollidingGround = false; not done here
1268 chr.CollidingObj = false; 1153 chr.CollidingObj = false;
1269 // do colisions with static space 1154 // do colisions with static space
1270 d.SpaceCollide2(StaticSpace, chr.topbox, IntPtr.Zero, nearCallback); 1155 d.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, nearCallback);
1271 d.SpaceCollide2(StaticSpace, chr.midbox, IntPtr.Zero, nearCallback); 1156
1272 d.SpaceCollide2(StaticSpace, chr.feetbox, IntPtr.Zero, nearCallback); 1157 // chars with chars
1273 d.SpaceCollide2(StaticSpace, chr.bonebox, IntPtr.Zero, nearCallback); 1158 d.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback);
1274 // no coll with gnd 1159 // no coll with gnd
1275 } 1160 }
1276 } 1161 }
@@ -1312,16 +1197,25 @@ namespace OpenSim.Region.Physics.OdePlugin
1312 m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); 1197 m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space");
1313 } 1198 }
1314 } 1199 }
1315 // finally colide active things amoung them 1200 // colide active amoung them
1316 try 1201 try
1317 { 1202 {
1318 d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback); 1203 d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback);
1319 } 1204 }
1320 catch (AccessViolationException) 1205 catch (AccessViolationException)
1321 { 1206 {
1207 m_log.Warn("[PHYSICS]: Unable to collide Active with Characters space");
1208 }
1209 // and with chars
1210 try
1211 {
1212 d.SpaceCollide2(CharsSpace,ActiveSpace, IntPtr.Zero, nearCallback);
1213 }
1214 catch (AccessViolationException)
1215 {
1322 m_log.Warn("[PHYSICS]: Unable to collide in Active space"); 1216 m_log.Warn("[PHYSICS]: Unable to collide in Active space");
1323 } 1217 }
1324// _perloopContact.Clear(); 1218 // _perloopContact.Clear();
1325 } 1219 }
1326 1220
1327 #endregion 1221 #endregion
@@ -1357,13 +1251,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1357 1251
1358 #region Add/Remove Entities 1252 #region Add/Remove Entities
1359 1253
1360 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) 1254 public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying)
1361 { 1255 {
1362 Vector3 pos; 1256 Vector3 pos;
1363 pos.X = position.X; 1257 pos.X = position.X;
1364 pos.Y = position.Y; 1258 pos.Y = position.Y;
1365 pos.Z = position.Z; 1259 pos.Z = position.Z;
1366 OdeCharacter newAv = new OdeCharacter(avName, this, pos, size, avPIDD, avPIDP, avDensity, avMovementDivisorWalk, avMovementDivisorRun); 1260 OdeCharacter newAv = new OdeCharacter(localID,avName, this, pos, size, feetOffset, avDensity, avMovementDivisorWalk, avMovementDivisorRun);
1367 newAv.Flying = isFlying; 1261 newAv.Flying = isFlying;
1368 newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; 1262 newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset;
1369 1263
@@ -1806,7 +1700,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1806 foreach (OdeCharacter actor in _characters) 1700 foreach (OdeCharacter actor in _characters)
1807 { 1701 {
1808 if (actor != null) 1702 if (actor != null)
1809 actor.Move(ODE_STEPSIZE, defects); 1703 actor.Move(defects);
1810 } 1704 }
1811 if (defects.Count != 0) 1705 if (defects.Count != 0)
1812 { 1706 {