aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs358
1 files changed, 146 insertions, 212 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 54bc29f..fbf2f0d 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;
@@ -359,8 +362,7 @@ namespace OpenSim.Region.Physics.OdePlugin
359 362
360 nearCallback = near; 363 nearCallback = near;
361 364
362 m_rayCastManager = new ODERayCastRequestManager(this); 365 m_rayCastManager = new ODERayCastRequestManager(this);
363
364 366
365 lock (OdeLock) 367 lock (OdeLock)
366 { 368 {
@@ -372,21 +374,25 @@ namespace OpenSim.Region.Physics.OdePlugin
372 374
373 // now the major subspaces 375 // now the major subspaces
374 ActiveSpace = d.HashSpaceCreate(TopSpace); 376 ActiveSpace = d.HashSpaceCreate(TopSpace);
377 CharsSpace = d.HashSpaceCreate(TopSpace);
375 StaticSpace = d.HashSpaceCreate(TopSpace); 378 StaticSpace = d.HashSpaceCreate(TopSpace);
376 GroundSpace = d.HashSpaceCreate(TopSpace); 379 GroundSpace = d.HashSpaceCreate(TopSpace);
377 } 380 }
378 catch 381 catch
379 { 382 {
380 // i must RtC#FM 383 // i must RtC#FM
384 // i did!
381 } 385 }
382 386
383 d.HashSpaceSetLevels(TopSpace, -2, 8); 387 d.HashSpaceSetLevels(TopSpace, -2, 8);
384 d.HashSpaceSetLevels(ActiveSpace, -2, 8); 388 d.HashSpaceSetLevels(ActiveSpace, -2, 8);
389 d.HashSpaceSetLevels(CharsSpace, -4, 3);
385 d.HashSpaceSetLevels(StaticSpace, -2, 8); 390 d.HashSpaceSetLevels(StaticSpace, -2, 8);
386 d.HashSpaceSetLevels(GroundSpace, 0, 8); 391 d.HashSpaceSetLevels(GroundSpace, 0, 8);
387 392
388 // demote to second level 393 // demote to second level
389 d.SpaceSetSublevel(ActiveSpace, 1); 394 d.SpaceSetSublevel(ActiveSpace, 1);
395 d.SpaceSetSublevel(CharsSpace, 1);
390 d.SpaceSetSublevel(StaticSpace, 1); 396 d.SpaceSetSublevel(StaticSpace, 1);
391 d.SpaceSetSublevel(GroundSpace, 1); 397 d.SpaceSetSublevel(GroundSpace, 1);
392 398
@@ -396,11 +402,24 @@ namespace OpenSim.Region.Physics.OdePlugin
396 CollisionCategories.Phantom | 402 CollisionCategories.Phantom |
397 CollisionCategories.VolumeDtc 403 CollisionCategories.VolumeDtc
398 )); 404 ));
399 d.GeomSetCollideBits(ActiveSpace, 0); 405 d.GeomSetCollideBits(ActiveSpace, (uint)(CollisionCategories.Space |
406 CollisionCategories.Geom |
407 CollisionCategories.Character |
408 CollisionCategories.Phantom |
409 CollisionCategories.VolumeDtc
410 ));
411 d.GeomSetCategoryBits(CharsSpace, (uint)(CollisionCategories.Space |
412 CollisionCategories.Geom |
413 CollisionCategories.Character |
414 CollisionCategories.Phantom |
415 CollisionCategories.VolumeDtc
416 ));
417 d.GeomSetCollideBits(CharsSpace, 0);
418
400 d.GeomSetCategoryBits(StaticSpace, (uint)(CollisionCategories.Space | 419 d.GeomSetCategoryBits(StaticSpace, (uint)(CollisionCategories.Space |
401 CollisionCategories.Geom | 420 CollisionCategories.Geom |
402 CollisionCategories.Land | 421// CollisionCategories.Land |
403 CollisionCategories.Water | 422// CollisionCategories.Water |
404 CollisionCategories.Phantom | 423 CollisionCategories.Phantom |
405 CollisionCategories.VolumeDtc 424 CollisionCategories.VolumeDtc
406 )); 425 ));
@@ -412,6 +431,8 @@ namespace OpenSim.Region.Physics.OdePlugin
412 contactgroup = d.JointGroupCreate(0); 431 contactgroup = d.JointGroupCreate(0);
413 //contactgroup 432 //contactgroup
414 433
434 SharedRay = d.CreateRay(TopSpace, 1.0f);
435
415 d.WorldSetAutoDisableFlag(world, false); 436 d.WorldSetAutoDisableFlag(world, false);
416 } 437 }
417 } 438 }
@@ -468,7 +489,6 @@ namespace OpenSim.Region.Physics.OdePlugin
468 avDensity = physicsconfig.GetFloat("av_density", avDensity); 489 avDensity = physicsconfig.GetFloat("av_density", avDensity);
469 avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk); 490 avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk);
470 avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", avMovementDivisorRun); 491 avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", avMovementDivisorRun);
471 avCapRadius = physicsconfig.GetFloat("av_capsule_radius", avCapRadius);
472 492
473 contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision); 493 contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision);
474 494
@@ -494,7 +514,7 @@ namespace OpenSim.Region.Physics.OdePlugin
494 odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f); 514 odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f);
495 515
496 ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); 516 ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf);
497 GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); 517 GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf);
498 518
499 m_materialContactsData[(int)Material.Stone].mu = 0.8f; 519 m_materialContactsData[(int)Material.Stone].mu = 0.8f;
500 m_materialContactsData[(int)Material.Stone].bounce = 0.4f; 520 m_materialContactsData[(int)Material.Stone].bounce = 0.4f;
@@ -718,35 +738,35 @@ namespace OpenSim.Region.Physics.OdePlugin
718 738
719 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) 739 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
720 return; 740 return;
721/* 741 /*
722// debug 742 // debug
723 PhysicsActor dp2; 743 PhysicsActor dp2;
724 if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass) 744 if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass)
725 { 745 {
726 d.AABB aabb; 746 d.AABB aabb;
727 d.GeomGetAABB(g2, out aabb); 747 d.GeomGetAABB(g2, out aabb);
728 float x = aabb.MaxX - aabb.MinX; 748 float x = aabb.MaxX - aabb.MinX;
729 float y = aabb.MaxY - aabb.MinY; 749 float y = aabb.MaxY - aabb.MinY;
730 float z = aabb.MaxZ - aabb.MinZ; 750 float z = aabb.MaxZ - aabb.MinZ;
731 if (x > 60.0f || y > 60.0f || z > 60.0f) 751 if (x > 60.0f || y > 60.0f || z > 60.0f)
732 { 752 {
733 if (!actor_name_map.TryGetValue(g2, out dp2)) 753 if (!actor_name_map.TryGetValue(g2, out dp2))
734 m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 2"); 754 m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 2");
735 else 755 else
736 m_log.WarnFormat("[PHYSICS]: land versus large prim geo {0},size {1}, AABBsize <{2},{3},{4}>, at {5} ori {6},({7})", 756 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, 757 dp2.Name, dp2.Size, x, y, z,
738 dp2.Position.ToString(), 758 dp2.Position.ToString(),
739 dp2.Orientation.ToString(), 759 dp2.Orientation.ToString(),
740 dp2.Orientation.Length()); 760 dp2.Orientation.Length());
741 return; 761 return;
742 } 762 }
743 } 763 }
744// 764 //
745*/ 765 */
746 766
747 767
748 if(d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || 768 if (d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc ||
749 d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc) 769 d.GeomGetCategoryBits(g2) == (uint)CollisionCategories.VolumeDtc)
750 { 770 {
751 int cflags; 771 int cflags;
752 unchecked 772 unchecked
@@ -761,7 +781,7 @@ namespace OpenSim.Region.Physics.OdePlugin
761 catch (SEHException) 781 catch (SEHException)
762 { 782 {
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."); 783 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); 784 // ode.drelease(world);
765 base.TriggerPhysicsBasedRestart(); 785 base.TriggerPhysicsBasedRestart();
766 } 786 }
767 catch (Exception e) 787 catch (Exception e)
@@ -801,26 +821,25 @@ namespace OpenSim.Region.Physics.OdePlugin
801 821
802 // get first contact 822 // get first contact
803 d.ContactGeom curContact = new d.ContactGeom(); 823 d.ContactGeom curContact = new d.ContactGeom();
824
804 if (!GetCurContactGeom(0, ref curContact)) 825 if (!GetCurContactGeom(0, ref curContact))
805 return; 826 return;
806 // for now it's the one with max depth 827
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 828 // do volume detection case
813 if ( 829 if ((p1.IsVolumeDtc || p2.IsVolumeDtc))
814 (p1.IsVolumeDtc || p2.IsVolumeDtc))
815 { 830 {
831 ContactPoint maxDepthContact = new ContactPoint(
832 new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z),
833 new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z),
834 curContact.depth, false
835 );
836
816 collision_accounting_events(p1, p2, maxDepthContact); 837 collision_accounting_events(p1, p2, maxDepthContact);
817 return; 838 return;
818 } 839 }
819 840
820 // big messy collision analises 841 // big messy collision analises
821 842
822 Vector3 normoverride = Vector3.Zero; //damm c#
823
824 float mu = 0; 843 float mu = 0;
825 float bounce = 0; 844 float bounce = 0;
826 float cfm = 0.0001f; 845 float cfm = 0.0001f;
@@ -831,34 +850,15 @@ namespace OpenSim.Region.Physics.OdePlugin
831 ContactData contactdata1 = new ContactData(0, 0, false); 850 ContactData contactdata1 = new ContactData(0, 0, false);
832 ContactData contactdata2 = new ContactData(0, 0, false); 851 ContactData contactdata2 = new ContactData(0, 0, false);
833 852
834 bool dop1foot = false; 853 bool dop1ava = false;
835 bool dop2foot = false; 854 bool dop2ava = false;
836 bool ignore = false; 855 bool ignore = false;
837 bool AvanormOverride = false;
838 856
839 switch (p1.PhysicsActorType) 857 switch (p1.PhysicsActorType)
840 { 858 {
841 case (int)ActorTypes.Agent: 859 case (int)ActorTypes.Agent:
842 { 860 {
843 AvanormOverride = true; 861 dop1ava = true;
844 Vector3 tmp = p2.Position - p1.Position;
845 normoverride = p2.Velocity - p1.Velocity;
846 mu = normoverride.LengthSquared();
847
848 if (mu > 1e-6)
849 {
850 mu = 1.0f / (float)Math.Sqrt(mu);
851 normoverride *= mu;
852 mu = Vector3.Dot(tmp, normoverride);
853 if (mu > 0)
854 normoverride *= -1;
855 }
856 else
857 {
858 tmp.Normalize();
859 normoverride = -tmp;
860 }
861
862 switch (p2.PhysicsActorType) 862 switch (p2.PhysicsActorType)
863 { 863 {
864 case (int)ActorTypes.Agent: 864 case (int)ActorTypes.Agent:
@@ -869,7 +869,6 @@ namespace OpenSim.Region.Physics.OdePlugin
869 case (int)ActorTypes.Prim: 869 case (int)ActorTypes.Prim:
870 if (p2.Velocity.LengthSquared() > 0.0f) 870 if (p2.Velocity.LengthSquared() > 0.0f)
871 p2.CollidingObj = true; 871 p2.CollidingObj = true;
872 dop1foot = true;
873 break; 872 break;
874 873
875 default: 874 default:
@@ -883,30 +882,9 @@ namespace OpenSim.Region.Physics.OdePlugin
883 switch (p2.PhysicsActorType) 882 switch (p2.PhysicsActorType)
884 { 883 {
885 case (int)ActorTypes.Agent: 884 case (int)ActorTypes.Agent:
886 AvanormOverride = true;
887
888 Vector3 tmp = p2.Position - p1.Position;
889 normoverride = p2.Velocity - p1.Velocity;
890 mu = normoverride.LengthSquared();
891 if (mu > 1e-6)
892 {
893 mu = 1.0f / (float)Math.Sqrt(mu);
894 normoverride *= mu;
895 mu = Vector3.Dot(tmp, normoverride);
896 if (mu > 0)
897 normoverride *= -1;
898 }
899 else
900 {
901 tmp.Normalize();
902 normoverride = -tmp;
903 }
904 885
905 bounce = 0; 886 dop2ava = true;
906 mu = 0;
907 cfm = 0.0001f;
908 887
909 dop2foot = true;
910 if (p1.Velocity.LengthSquared() > 0.0f) 888 if (p1.Velocity.LengthSquared() > 0.0f)
911 p1.CollidingObj = true; 889 p1.CollidingObj = true;
912 break; 890 break;
@@ -1011,146 +989,78 @@ namespace OpenSim.Region.Physics.OdePlugin
1011 default: 989 default:
1012 break; 990 break;
1013 } 991 }
992
1014 if (ignore) 993 if (ignore)
1015 return; 994 return;
1016 995
1017 IntPtr Joint;
1018 996
1019 int i = 0; 997 d.ContactGeom maxContact = curContact;
1020 while(true) 998// if (IgnoreNegSides && curContact.side1 < 0)
1021 { 999// maxContact.depth = float.MinValue;
1022 1000
1023 if (IgnoreNegSides && curContact.side1 < 0) 1001 d.ContactGeom minContact = curContact;
1024 { 1002// if (IgnoreNegSides && curContact.side1 < 0)
1025 if (++i >= count) 1003// minContact.depth = float.MaxValue;
1026 break; 1004
1005 IntPtr Joint;
1006 bool FeetCollision = false;
1007 int ncontacts = 0;
1027 1008
1028 if (!GetCurContactGeom(i, ref curContact))
1029 break;
1030 }
1031 else
1032 1009
1010 int i = 0;
1011
1012 while (true)
1033 { 1013 {
1014 if (m_global_contactcount >= maxContactsbeforedeath)
1015 break;
1034 1016
1035 if (AvanormOverride) 1017// if (!(IgnoreNegSides && curContact.side1 < 0))
1036 { 1018 {
1037 if (curContact.depth > 0.3f) 1019 bool noskip = true;
1020 if (dop1ava)
1021 {
1022 if (!(((OdeCharacter)p1).Collide(g1,false, ref curContact, ref FeetCollision)))
1023
1024 noskip = false;
1025 }
1026 else if (dop2ava)
1038 { 1027 {
1039 if (dop1foot && (p1.Position.Z - curContact.pos.Z) > (p1.Size.Z - avCapRadius) * 0.5f) 1028 if (!(((OdeCharacter)p2).Collide(g2,true, ref curContact, ref FeetCollision)))
1040 p1.IsColliding = true; 1029 noskip = false;
1041 if (dop2foot && (p2.Position.Z - curContact.pos.Z) > (p2.Size.Z - avCapRadius) * 0.5f)
1042 p2.IsColliding = true;
1043 curContact.normal.X = normoverride.X;
1044 curContact.normal.Y = normoverride.Y;
1045 curContact.normal.Z = normoverride.Z;
1046 } 1030 }
1047 1031
1048 else 1032 if (noskip)
1049 { 1033 {
1050 if (dop1foot) 1034 m_global_contactcount++;
1051 { 1035 ncontacts++;
1052 float sz = p1.Size.Z;
1053 Vector3 vtmp = p1.Position;
1054 float ppos = curContact.pos.Z - vtmp.Z + (sz - avCapRadius) * 0.5f;
1055 if (ppos > 0f)
1056 {
1057 if (!p1.Flying)
1058 {
1059 d.AABB aabb;
1060 d.GeomGetAABB(g2, out aabb);
1061 float tmp = vtmp.Z - sz * .18f;
1062
1063 if (aabb.MaxZ < tmp)
1064 {
1065 vtmp.X = curContact.pos.X - vtmp.X;
1066 vtmp.Y = curContact.pos.Y - vtmp.Y;
1067 vtmp.Z = -0.2f;
1068 vtmp.Normalize();
1069 curContact.normal.X = vtmp.X;
1070 curContact.normal.Y = vtmp.Y;
1071 curContact.normal.Z = vtmp.Z;
1072 }
1073 }
1074 }
1075 else
1076 p1.IsColliding = true;
1077 1036
1078 } 1037 Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale);
1038 d.JointAttach(Joint, b1, b2);
1079 1039
1080 if (dop2foot) 1040 if (curContact.depth > maxContact.depth)
1081 { 1041 maxContact = curContact;
1082 float sz = p2.Size.Z;
1083 Vector3 vtmp = p2.Position;
1084 float ppos = curContact.pos.Z - vtmp.Z + (sz - avCapRadius) * 0.5f;
1085 if (ppos > 0f)
1086 {
1087 if (!p2.Flying)
1088 {
1089 d.AABB aabb;
1090 d.GeomGetAABB(g1, out aabb);
1091 float tmp = vtmp.Z - sz * .18f;
1092
1093 if (aabb.MaxZ < tmp)
1094 {
1095 vtmp.X = curContact.pos.X - vtmp.X;
1096 vtmp.Y = curContact.pos.Y - vtmp.Y;
1097 vtmp.Z = -0.2f;
1098 vtmp.Normalize();
1099 curContact.normal.X = vtmp.X;
1100 curContact.normal.Y = vtmp.Y;
1101 curContact.normal.Z = vtmp.Z;
1102 }
1103 }
1104 }
1105 else
1106 p2.IsColliding = true;
1107 1042
1108 } 1043 if (curContact.depth < minContact.depth)
1044 minContact = curContact;
1109 } 1045 }
1110 } 1046 }
1111 1047
1112 Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale);
1113 d.JointAttach(Joint, b1, b2);
1114
1115 if (++m_global_contactcount >= maxContactsbeforedeath)
1116 break;
1117
1118 if (++i >= count) 1048 if (++i >= count)
1119 break; 1049 break;
1120 1050
1121 if (!GetCurContactGeom(i, ref curContact)) 1051 if (!GetCurContactGeom(i, ref curContact))
1122 break; 1052 break;
1123
1124 if (curContact.depth > maxDepthContact.PenetrationDepth)
1125 {
1126 maxDepthContact.Position.X = curContact.pos.X;
1127 maxDepthContact.Position.Y = curContact.pos.Y;
1128 maxDepthContact.Position.Z = curContact.pos.Z;
1129 maxDepthContact.SurfaceNormal.X = curContact.normal.X;
1130 maxDepthContact.SurfaceNormal.Y = curContact.normal.Y;
1131 maxDepthContact.SurfaceNormal.Z = curContact.normal.Z;
1132 maxDepthContact.PenetrationDepth = curContact.depth;
1133 }
1134 } 1053 }
1135 }
1136
1137 collision_accounting_events(p1, p2, maxDepthContact);
1138 1054
1139/* 1055 if (ncontacts > 0)
1140 if (notskipedcount > geomContactPointsStartthrottle)
1141 { 1056 {
1142 // If there are more then 3 contact points, it's likely 1057 ContactPoint maxDepthContact = new ContactPoint(
1143 // that we've got a pile of objects, so ... 1058 new Vector3(maxContact.pos.X, maxContact.pos.Y, maxContact.pos.Z),
1144 // We don't want to send out hundreds of terse updates over and over again 1059 new Vector3(minContact.normal.X, minContact.normal.Y, minContact.normal.Z),
1145 // so lets throttle them and send them again after it's somewhat sorted out. 1060 maxContact.depth, FeetCollision
1146 this needs checking so out for now 1061 );
1147 if (b1 != IntPtr.Zero) 1062 collision_accounting_events(p1, p2, maxDepthContact);
1148 p1.ThrottleUpdates = true;
1149 if (b2 != IntPtr.Zero)
1150 p2.ThrottleUpdates = true;
1151
1152 } 1063 }
1153 */
1154 } 1064 }
1155 1065
1156 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) 1066 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
@@ -1234,14 +1144,17 @@ namespace OpenSim.Region.Physics.OdePlugin
1234 { 1144 {
1235 foreach (OdeCharacter chr in _characters) 1145 foreach (OdeCharacter chr in _characters)
1236 { 1146 {
1237 if (chr == null || chr.Shell == IntPtr.Zero || chr.Body == IntPtr.Zero) 1147 if (chr == null || chr.Body == IntPtr.Zero)
1238 continue; 1148 continue;
1239 1149
1240 chr.IsColliding = false; 1150 chr.IsColliding = false;
1241 // chr.CollidingGround = false; not done here 1151 // chr.CollidingGround = false; not done here
1242 chr.CollidingObj = false; 1152 chr.CollidingObj = false;
1243 // do colisions with static space 1153 // do colisions with static space
1244 d.SpaceCollide2(StaticSpace, chr.Shell, IntPtr.Zero, nearCallback); 1154 d.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, nearCallback);
1155
1156 // chars with chars
1157 d.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback);
1245 // no coll with gnd 1158 // no coll with gnd
1246 } 1159 }
1247 } 1160 }
@@ -1283,16 +1196,25 @@ namespace OpenSim.Region.Physics.OdePlugin
1283 m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); 1196 m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space");
1284 } 1197 }
1285 } 1198 }
1286 // finally colide active things amoung them 1199 // colide active amoung them
1287 try 1200 try
1288 { 1201 {
1289 d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback); 1202 d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback);
1290 } 1203 }
1291 catch (AccessViolationException) 1204 catch (AccessViolationException)
1292 { 1205 {
1206 m_log.Warn("[PHYSICS]: Unable to collide Active with Characters space");
1207 }
1208 // and with chars
1209 try
1210 {
1211 d.SpaceCollide2(CharsSpace,ActiveSpace, IntPtr.Zero, nearCallback);
1212 }
1213 catch (AccessViolationException)
1214 {
1293 m_log.Warn("[PHYSICS]: Unable to collide in Active space"); 1215 m_log.Warn("[PHYSICS]: Unable to collide in Active space");
1294 } 1216 }
1295// _perloopContact.Clear(); 1217 // _perloopContact.Clear();
1296 } 1218 }
1297 1219
1298 #endregion 1220 #endregion
@@ -1328,13 +1250,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1328 1250
1329 #region Add/Remove Entities 1251 #region Add/Remove Entities
1330 1252
1331 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) 1253 public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying)
1332 { 1254 {
1333 Vector3 pos; 1255 Vector3 pos;
1334 pos.X = position.X; 1256 pos.X = position.X;
1335 pos.Y = position.Y; 1257 pos.Y = position.Y;
1336 pos.Z = position.Z; 1258 pos.Z = position.Z;
1337 OdeCharacter newAv = new OdeCharacter(avName, this, pos, size, avPIDD, avPIDP, avCapRadius, avDensity, avMovementDivisorWalk, avMovementDivisorRun); 1259 OdeCharacter newAv = new OdeCharacter(localID,avName, this, pos, size, feetOffset, avDensity, avMovementDivisorWalk, avMovementDivisorRun);
1338 newAv.Flying = isFlying; 1260 newAv.Flying = isFlying;
1339 newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; 1261 newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset;
1340 1262
@@ -1777,7 +1699,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1777 foreach (OdeCharacter actor in _characters) 1699 foreach (OdeCharacter actor in _characters)
1778 { 1700 {
1779 if (actor != null) 1701 if (actor != null)
1780 actor.Move(ODE_STEPSIZE, defects); 1702 actor.Move(defects);
1781 } 1703 }
1782 if (defects.Count != 0) 1704 if (defects.Count != 0)
1783 { 1705 {
@@ -2788,5 +2710,17 @@ namespace OpenSim.Region.Physics.OdePlugin
2788 } 2710 }
2789 return new List<ContactResult>(); 2711 return new List<ContactResult>();
2790 } 2712 }
2713
2714 public override int SitAvatar(PhysicsActor actor, Vector3 AbsolutePosition, Vector3 CameraPosition, Vector3 offset, Vector3 AvatarSize, SitAvatarCallback PhysicsSitResponse)
2715 {
2716 Util.FireAndForget( delegate
2717 {
2718 ODESitAvatar sitAvatar = new ODESitAvatar(this, m_rayCastManager);
2719 if(sitAvatar != null)
2720 sitAvatar.Sit(actor, AbsolutePosition, CameraPosition, offset, AvatarSize, PhysicsSitResponse);
2721 });
2722 return 1;
2723 }
2724
2791 } 2725 }
2792} 2726}