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.cs381
1 files changed, 143 insertions, 238 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 003a91c..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,36 +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 dop1foot = true; 861 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) 862 switch (p2.PhysicsActorType)
865 { 863 {
866 case (int)ActorTypes.Agent: 864 case (int)ActorTypes.Agent:
@@ -871,7 +869,6 @@ namespace OpenSim.Region.Physics.OdePlugin
871 case (int)ActorTypes.Prim: 869 case (int)ActorTypes.Prim:
872 if (p2.Velocity.LengthSquared() > 0.0f) 870 if (p2.Velocity.LengthSquared() > 0.0f)
873 p2.CollidingObj = true; 871 p2.CollidingObj = true;
874 dop1foot = true;
875 break; 872 break;
876 873
877 default: 874 default:
@@ -886,33 +883,8 @@ namespace OpenSim.Region.Physics.OdePlugin
886 { 883 {
887 case (int)ActorTypes.Agent: 884 case (int)ActorTypes.Agent:
888 885
886 dop2ava = true;
889 887
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) 888 if (p1.Velocity.LengthSquared() > 0.0f)
917 p1.CollidingObj = true; 889 p1.CollidingObj = true;
918 break; 890 break;
@@ -1017,166 +989,78 @@ namespace OpenSim.Region.Physics.OdePlugin
1017 default: 989 default:
1018 break; 990 break;
1019 } 991 }
992
1020 if (ignore) 993 if (ignore)
1021 return; 994 return;
1022 995
1023 IntPtr Joint;
1024 996
1025 int i = 0; 997 d.ContactGeom maxContact = curContact;
998// if (IgnoreNegSides && curContact.side1 < 0)
999// maxContact.depth = float.MinValue;
1000
1001 d.ContactGeom minContact = curContact;
1002// if (IgnoreNegSides && curContact.side1 < 0)
1003// minContact.depth = float.MaxValue;
1004
1005 IntPtr Joint;
1006 bool FeetCollision = false;
1026 int ncontacts = 0; 1007 int ncontacts = 0;
1027 while(true)
1028 {
1029 1008
1030 if (IgnoreNegSides && curContact.side1 < 0)
1031 {
1032 if (++i >= count)
1033 break;
1034 1009
1035 if (!GetCurContactGeom(i, ref curContact)) 1010 int i = 0;
1036 break;
1037 }
1038 else
1039 1011
1012 while (true)
1040 { 1013 {
1041 if(dop1foot) 1014 if (m_global_contactcount >= maxContactsbeforedeath)
1042 { 1015 break;
1043 if (!(((OdeCharacter)p1).Collide(g1,false, ref curContact))) 1016
1044 { 1017// if (!(IgnoreNegSides && curContact.side1 < 0))
1045 if (++i >= count)
1046 break;
1047 else
1048 continue;
1049 }
1050 }
1051 else if(dop2foot)
1052 { 1018 {
1053 if(!(((OdeCharacter) p2).Collide(g2,true,ref curContact))) 1019 bool noskip = true;
1020 if (dop1ava)
1054 { 1021 {
1055 if (++i >= count) 1022 if (!(((OdeCharacter)p1).Collide(g1,false, ref curContact, ref FeetCollision)))
1056 break;
1057 else
1058 continue;
1059 }
1060 }
1061 1023
1062/* 1024 noskip = false;
1063 if (AvanormOverride) 1025 }
1064 { 1026 else if (dop2ava)
1065 if (curContact.depth > 0.3f)
1066 { 1027 {
1067 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)))
1068 p1.IsColliding = true; 1029 noskip = false;
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 } 1030 }
1075 1031
1076 else 1032 if (noskip)
1077 { 1033 {
1078 if (dop1foot) 1034 m_global_contactcount++;
1079 { 1035 ncontacts++;
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 1036
1106 } 1037 Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale);
1038 d.JointAttach(Joint, b1, b2);
1107 1039
1108 if (dop2foot) 1040 if (curContact.depth > maxContact.depth)
1109 { 1041 maxContact = 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 1042
1132 } 1043 if (curContact.depth < minContact.depth)
1044 minContact = curContact;
1133 } 1045 }
1134 } 1046 }
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 1047
1143 if (++i >= count) 1048 if (++i >= count)
1144 break; 1049 break;
1145 1050
1146 if (!GetCurContactGeom(i, ref curContact)) 1051 if (!GetCurContactGeom(i, ref curContact))
1147 break; 1052 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 } 1053 }
1160 }
1161 1054
1162 if(ncontacts > 0) 1055 if (ncontacts > 0)
1163 collision_accounting_events(p1, p2, maxDepthContact);
1164
1165/*
1166 if (notskipedcount > geomContactPointsStartthrottle)
1167 { 1056 {
1168 // If there are more then 3 contact points, it's likely 1057 ContactPoint maxDepthContact = new ContactPoint(
1169 // that we've got a pile of objects, so ... 1058 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 1059 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. 1060 maxContact.depth, FeetCollision
1172 this needs checking so out for now 1061 );
1173 if (b1 != IntPtr.Zero) 1062 collision_accounting_events(p1, p2, maxDepthContact);
1174 p1.ThrottleUpdates = true;
1175 if (b2 != IntPtr.Zero)
1176 p2.ThrottleUpdates = true;
1177
1178 } 1063 }
1179 */
1180 } 1064 }
1181 1065
1182 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) 1066 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
@@ -1267,10 +1151,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1267 // chr.CollidingGround = false; not done here 1151 // chr.CollidingGround = false; not done here
1268 chr.CollidingObj = false; 1152 chr.CollidingObj = false;
1269 // do colisions with static space 1153 // do colisions with static space
1270 d.SpaceCollide2(StaticSpace, chr.topbox, IntPtr.Zero, nearCallback); 1154 d.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, nearCallback);
1271 d.SpaceCollide2(StaticSpace, chr.midbox, IntPtr.Zero, nearCallback); 1155
1272 d.SpaceCollide2(StaticSpace, chr.feetbox, IntPtr.Zero, nearCallback); 1156 // chars with chars
1273 d.SpaceCollide2(StaticSpace, chr.bonebox, IntPtr.Zero, nearCallback); 1157 d.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback);
1274 // no coll with gnd 1158 // no coll with gnd
1275 } 1159 }
1276 } 1160 }
@@ -1312,16 +1196,25 @@ namespace OpenSim.Region.Physics.OdePlugin
1312 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");
1313 } 1197 }
1314 } 1198 }
1315 // finally colide active things amoung them 1199 // colide active amoung them
1316 try 1200 try
1317 { 1201 {
1318 d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback); 1202 d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback);
1319 } 1203 }
1320 catch (AccessViolationException) 1204 catch (AccessViolationException)
1321 { 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 {
1322 m_log.Warn("[PHYSICS]: Unable to collide in Active space"); 1215 m_log.Warn("[PHYSICS]: Unable to collide in Active space");
1323 } 1216 }
1324// _perloopContact.Clear(); 1217 // _perloopContact.Clear();
1325 } 1218 }
1326 1219
1327 #endregion 1220 #endregion
@@ -1357,13 +1250,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1357 1250
1358 #region Add/Remove Entities 1251 #region Add/Remove Entities
1359 1252
1360 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)
1361 { 1254 {
1362 Vector3 pos; 1255 Vector3 pos;
1363 pos.X = position.X; 1256 pos.X = position.X;
1364 pos.Y = position.Y; 1257 pos.Y = position.Y;
1365 pos.Z = position.Z; 1258 pos.Z = position.Z;
1366 OdeCharacter newAv = new OdeCharacter(avName, this, pos, size, avPIDD, avPIDP, avDensity, avMovementDivisorWalk, avMovementDivisorRun); 1259 OdeCharacter newAv = new OdeCharacter(localID,avName, this, pos, size, feetOffset, avDensity, avMovementDivisorWalk, avMovementDivisorRun);
1367 newAv.Flying = isFlying; 1260 newAv.Flying = isFlying;
1368 newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; 1261 newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset;
1369 1262
@@ -1806,7 +1699,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1806 foreach (OdeCharacter actor in _characters) 1699 foreach (OdeCharacter actor in _characters)
1807 { 1700 {
1808 if (actor != null) 1701 if (actor != null)
1809 actor.Move(ODE_STEPSIZE, defects); 1702 actor.Move(defects);
1810 } 1703 }
1811 if (defects.Count != 0) 1704 if (defects.Count != 0)
1812 { 1705 {
@@ -2817,5 +2710,17 @@ namespace OpenSim.Region.Physics.OdePlugin
2817 } 2710 }
2818 return new List<ContactResult>(); 2711 return new List<ContactResult>();
2819 } 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
2820 } 2725 }
2821} 2726}