aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs544
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs16
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs4
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs366
4 files changed, 520 insertions, 410 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 3d5be3e..b769c88 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -74,7 +74,6 @@ namespace OpenSim.Region.Physics.OdePlugin
74 74
75 private Vector3 _position; 75 private Vector3 _position;
76 private Vector3 _zeroPosition; 76 private Vector3 _zeroPosition;
77 private bool _zeroFlag = false;
78 private Vector3 _velocity; 77 private Vector3 _velocity;
79 private Vector3 _target_velocity; 78 private Vector3 _target_velocity;
80 private Vector3 _acceleration; 79 private Vector3 _acceleration;
@@ -84,21 +83,21 @@ namespace OpenSim.Region.Physics.OdePlugin
84 private float m_mass = 80f; 83 private float m_mass = 80f;
85 public float m_density = 60f; 84 public float m_density = 60f;
86 private bool m_pidControllerActive = true; 85 private bool m_pidControllerActive = true;
87 public float PID_D = 800.0f;
88 public float PID_P = 900.0f;
89 //private static float POSTURE_SERVO = 10000.0f;
90 86
87 const float basePID_D = 0.55f; // scaled for unit mass unit time (2200 /(50*80))
88 const float basePID_P = 0.225f; // scaled for unit mass unit time (900 /(50*80))
89 public float PID_D;
90 public float PID_P;
91 91
92 private float m_invElipSizeX; 92 private float timeStep;
93 private float m_invElipSizeY; 93 private float invtimeStep;
94 94
95 private float m_feetOffset = 0;
95 private float feetOff = 0; 96 private float feetOff = 0;
96 private float feetSZ = 0.5f; 97 private float feetSZ = 0.5f;
97 const float feetScale = 0.9f; 98 const float feetScale = 0.8f;
98 const float invFeetScale = 1.0f / 0.9f;
99 const float sizeZAdjust = 0.15f;
100 private float boneOff = 0; 99 private float boneOff = 0;
101 100 private float m_lastVelocitySqr = 0;
102 101
103 public float walkDivisor = 1.3f; 102 public float walkDivisor = 1.3f;
104 public float runDivisor = 0.8f; 103 public float runDivisor = 0.8f;
@@ -107,6 +106,9 @@ namespace OpenSim.Region.Physics.OdePlugin
107 private bool m_iscollidingGround = false; 106 private bool m_iscollidingGround = false;
108 private bool m_iscollidingObj = false; 107 private bool m_iscollidingObj = false;
109 private bool m_alwaysRun = false; 108 private bool m_alwaysRun = false;
109
110 private bool _zeroFlag = false;
111
110 private int m_requestedUpdateFrequency = 0; 112 private int m_requestedUpdateFrequency = 0;
111 private uint m_localID = 0; 113 private uint m_localID = 0;
112 public bool m_returnCollisions = false; 114 public bool m_returnCollisions = false;
@@ -124,6 +126,7 @@ namespace OpenSim.Region.Physics.OdePlugin
124 int m_colliderfilter = 0; 126 int m_colliderfilter = 0;
125 int m_colliderGroundfilter = 0; 127 int m_colliderGroundfilter = 0;
126 int m_colliderObjectfilter = 0; 128 int m_colliderObjectfilter = 0;
129 bool m_collisionException = false;
127 130
128 // Default we're a Character 131 // Default we're a Character
129 private CollisionCategories m_collisionCategories = (CollisionCategories.Character); 132 private CollisionCategories m_collisionCategories = (CollisionCategories.Character);
@@ -136,10 +139,11 @@ namespace OpenSim.Region.Physics.OdePlugin
136 // we do land collisions not ode | CollisionCategories.Land); 139 // we do land collisions not ode | CollisionCategories.Land);
137 public IntPtr Body = IntPtr.Zero; 140 public IntPtr Body = IntPtr.Zero;
138 private OdeScene _parent_scene; 141 private OdeScene _parent_scene;
139 public IntPtr topbox = IntPtr.Zero; 142 private IntPtr topbox = IntPtr.Zero;
140 public IntPtr midbox = IntPtr.Zero; 143 private IntPtr midbox = IntPtr.Zero;
141 public IntPtr feetbox = IntPtr.Zero; 144 private IntPtr feetbox = IntPtr.Zero;
142 public IntPtr bonebox = IntPtr.Zero; 145 private IntPtr bbox = IntPtr.Zero;
146 public IntPtr collider = IntPtr.Zero;
143 147
144 public IntPtr Amotor = IntPtr.Zero; 148 public IntPtr Amotor = IntPtr.Zero;
145 149
@@ -147,6 +151,7 @@ namespace OpenSim.Region.Physics.OdePlugin
147 151
148 152
149 153
154
150 public int m_eventsubscription = 0; 155 public int m_eventsubscription = 0;
151 private int m_cureventsubscription = 0; 156 private int m_cureventsubscription = 0;
152 private CollisionEventUpdate CollisionEventsThisFrame = null; 157 private CollisionEventUpdate CollisionEventsThisFrame = null;
@@ -160,9 +165,13 @@ namespace OpenSim.Region.Physics.OdePlugin
160 165
161 166
162 167
163 public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pid_d, float pid_p, float density, float walk_divisor, float rundivisor) 168 public OdeCharacter(uint localID, String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pfeetOffset, float density, float walk_divisor, float rundivisor)
164 { 169 {
165 m_uuid = UUID.Random(); 170 m_uuid = UUID.Random();
171 m_localID = localID;
172
173 timeStep = parent_scene.ODE_STEPSIZE;
174 invtimeStep = 1 / timeStep;
166 175
167 if (pos.IsFinite()) 176 if (pos.IsFinite())
168 { 177 {
@@ -184,8 +193,6 @@ namespace OpenSim.Region.Physics.OdePlugin
184 193
185 _parent_scene = parent_scene; 194 _parent_scene = parent_scene;
186 195
187 PID_D = pid_d;
188 PID_P = pid_p;
189 196
190 m_size.X = pSize.X; 197 m_size.X = pSize.X;
191 m_size.Y = pSize.Y; 198 m_size.Y = pSize.Y;
@@ -198,12 +205,15 @@ namespace OpenSim.Region.Physics.OdePlugin
198 if(m_size.Z <0.01f) 205 if(m_size.Z <0.01f)
199 m_size.Z = 0.01f; 206 m_size.Z = 0.01f;
200 207
208 m_feetOffset = pfeetOffset;
201 m_orientation = Quaternion.Identity; 209 m_orientation = Quaternion.Identity;
202 m_density = density; 210 m_density = density;
203 211
204 // force lower density for testing 212 // force lower density for testing
205 m_density = 3.0f; 213 m_density = 3.0f;
206 214
215 m_density *= 1.4f; // scale to have mass similar to capsule
216
207 mu = parent_scene.AvatarFriction; 217 mu = parent_scene.AvatarFriction;
208 218
209 walkDivisor = walk_divisor; 219 walkDivisor = walk_divisor;
@@ -211,6 +221,9 @@ namespace OpenSim.Region.Physics.OdePlugin
211 221
212 m_mass = m_density * m_size.X * m_size.Y * m_size.Z; ; // sure we have a default 222 m_mass = m_density * m_size.X * m_size.Y * m_size.Z; ; // sure we have a default
213 223
224 PID_D = basePID_D * m_mass * invtimeStep;
225 PID_P = basePID_P * m_mass * invtimeStep;
226
214 m_isPhysical = false; // current status: no ODE information exists 227 m_isPhysical = false; // current status: no ODE information exists
215 228
216 Name = avName; 229 Name = avName;
@@ -292,7 +305,7 @@ namespace OpenSim.Region.Physics.OdePlugin
292 set 305 set
293 { 306 {
294 flying = value; 307 flying = value;
295 // m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying); 308// m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying);
296 } 309 }
297 } 310 }
298 311
@@ -336,25 +349,25 @@ namespace OpenSim.Region.Physics.OdePlugin
336 get { return m_iscollidingGround; } 349 get { return m_iscollidingGround; }
337 set 350 set
338 { 351 {
339 /* we now control this 352/* we now control this
340 if (value) 353 if (value)
341 { 354 {
342 m_colliderGroundfilter += 2; 355 m_colliderGroundfilter += 2;
343 if (m_colliderGroundfilter > 2) 356 if (m_colliderGroundfilter > 2)
344 m_colliderGroundfilter = 2; 357 m_colliderGroundfilter = 2;
345 } 358 }
346 else 359 else
347 { 360 {
348 m_colliderGroundfilter--; 361 m_colliderGroundfilter--;
349 if (m_colliderGroundfilter < 0) 362 if (m_colliderGroundfilter < 0)
350 m_colliderGroundfilter = 0; 363 m_colliderGroundfilter = 0;
351 } 364 }
352 365
353 if (m_colliderGroundfilter == 0) 366 if (m_colliderGroundfilter == 0)
354 m_iscollidingGround = false; 367 m_iscollidingGround = false;
355 else 368 else
356 m_iscollidingGround = true; 369 m_iscollidingGround = true;
357 */ 370 */
358 } 371 }
359 372
360 } 373 }
@@ -386,7 +399,7 @@ namespace OpenSim.Region.Physics.OdePlugin
386 else 399 else
387 m_iscollidingObj = true; 400 m_iscollidingObj = true;
388 401
389 // m_iscollidingObj = value; 402// m_iscollidingObj = value;
390 403
391 if (m_iscollidingObj) 404 if (m_iscollidingObj)
392 m_pidControllerActive = false; 405 m_pidControllerActive = false;
@@ -475,6 +488,28 @@ namespace OpenSim.Region.Physics.OdePlugin
475 } 488 }
476 } 489 }
477 490
491 public override void setAvatarSize(Vector3 size, float feetOffset)
492 {
493 if (size.IsFinite())
494 {
495 if (size.X < 0.01f)
496 size.X = 0.01f;
497 if (size.Y < 0.01f)
498 size.Y = 0.01f;
499 if (size.Z < 0.01f)
500 size.Z = 0.01f;
501
502 strAvatarSize st = new strAvatarSize();
503 st.size = size;
504 st.offset = feetOffset;
505 AddChange(changes.AvatarSize, st);
506 }
507 else
508 {
509 m_log.Warn("[PHYSICS]: Got a NaN AvatarSize from Scene on a Character");
510 }
511
512 }
478 /// <summary> 513 /// <summary>
479 /// This creates the Avatar's physical Surrogate at the position supplied 514 /// This creates the Avatar's physical Surrogate at the position supplied
480 /// </summary> 515 /// </summary>
@@ -491,7 +526,7 @@ namespace OpenSim.Region.Physics.OdePlugin
491 { 526 {
492 get 527 get
493 { 528 {
494 return m_density * m_size.X * m_size.Y * m_size.Z; 529 return m_mass;
495 } 530 }
496 } 531 }
497 public override void link(PhysicsActor obj) 532 public override void link(PhysicsActor obj)
@@ -612,8 +647,8 @@ namespace OpenSim.Region.Physics.OdePlugin
612 get { return m_orientation; } 647 get { return m_orientation; }
613 set 648 set
614 { 649 {
615 // fakeori = value; 650// fakeori = value;
616 // givefakeori++; 651// givefakeori++;
617 652
618 value.Normalize(); 653 value.Normalize();
619 AddChange(changes.Orientation, value); 654 AddChange(changes.Orientation, value);
@@ -668,33 +703,72 @@ namespace OpenSim.Region.Physics.OdePlugin
668 AddChange(changes.Momentum, momentum); 703 AddChange(changes.Momentum, momentum);
669 } 704 }
670 705
706 private void ajustCollider()
707 {
708 float vq = _velocity.LengthSquared();
709 if (m_lastVelocitySqr != vq)
710 {
711 m_lastVelocitySqr = vq;
712 if (vq > 100.0f)
713 {
714 Vector3 off = _velocity;
715 float t = 0.5f * timeStep;
716 off = off * t;
717 d.GeomSetOffsetPosition(bbox, off.X, off.Y, off.Z);
718 off.X = 2.0f * (m_size.X + Math.Abs(off.X));
719 off.Y = 2.0f * (m_size.Y + Math.Abs(off.Y));
720 off.Z = m_size.Z + 2.0f * Math.Abs(off.Z);
721 d.GeomBoxSetLengths(bbox, off.X, off.Y, off.Z);
722
723 d.GeomSetCategoryBits(bbox, (uint)m_collisionCategories);
724 d.GeomSetCollideBits(bbox, (uint)m_collisionFlags);
725 d.GeomSetCategoryBits(topbox, 0);
726 d.GeomSetCollideBits(topbox, 0);
727 d.GeomSetCategoryBits(midbox, 0);
728 d.GeomSetCollideBits(midbox, 0);
729 d.GeomSetCategoryBits(feetbox, 0);
730 d.GeomSetCollideBits(feetbox, 0);
731 }
732 else
733 {
734 d.GeomSetCategoryBits(bbox, 0);
735 d.GeomSetCollideBits(bbox, 0);
736 d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories);
737 d.GeomSetCollideBits(topbox, (uint)m_collisionFlags);
738 d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories);
739 d.GeomSetCollideBits(midbox, (uint)m_collisionFlags);
740 d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories);
741 d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags);
742 }
743 }
744 }
745
671 private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ) 746 private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ)
672 { 747 {
673 // sizes one day should came from visual parameters 748 // sizes one day should came from visual parameters
674 float sz = m_size.Z + sizeZAdjust; 749 float sx = m_size.X;
675 750 float sy = m_size.Y;
676 m_invElipSizeX = 1.0f / m_size.X; 751 float sz = m_size.Z;
677 m_invElipSizeY = 1.0f / m_size.Y; 752
678 753 float topsx = sx * 0.9f;
679 float topsx = m_size.X; 754 float midsx = sx;
680 float midsx = m_size.X; 755 float feetsx = sx * feetScale;
681 float feetsx = m_size.X * feetScale; 756 float bonesx = sx * 0.2f;
682 float bonesx = feetsx * 0.2f; 757
683 758 float topsy = sy * 0.4f;
684 float topsy = m_size.Y * 0.5f; 759 float midsy = sy;
685 float midsy = m_size.Y; 760 float feetsy = sy * feetScale * 0.8f;
686 float feetsy = m_size.Y * feetScale;
687 float bonesy = feetsy * 0.2f; 761 float bonesy = feetsy * 0.2f;
688 762
689 float topsz = sz * 0.15f; 763 float topsz = sz * 0.15f;
690 float feetsz = sz * 0.3f; 764 float feetsz = sz * 0.45f;
691 if (feetsz > 0.6f) 765 if (feetsz > 0.6f)
692 feetsz = 0.6f; 766 feetsz = 0.6f;
693 767
694 float midsz = sz - topsz - feetsz; 768 float midsz = sz - topsz - feetsz;
695 float bonesz = sz; 769 float bonesz = sz;
696 770
697 float bot = -sz * 0.5f; 771 float bot = -sz * 0.5f + m_feetOffset;
698 772
699 boneOff = bot + 0.3f; 773 boneOff = bot + 0.3f;
700 774
@@ -708,47 +782,37 @@ namespace OpenSim.Region.Physics.OdePlugin
708 bot += midsz; 782 bot += midsz;
709 float topz = bot + topsz * 0.5f; 783 float topz = bot + topsz * 0.5f;
710 784
711 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); 785 _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
712
713 feetbox = d.CreateBox(_parent_scene.ActiveSpace, feetsx, feetsy, feetsz);
714 d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories);
715 d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags);
716
717 midbox = d.CreateBox(_parent_scene.ActiveSpace, midsx, midsy, midsz);
718 d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories);
719 d.GeomSetCollideBits(midbox, (uint)m_collisionFlags);
720
721 topbox = d.CreateBox(_parent_scene.ActiveSpace, topsx, topsy, topsz);
722 d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories);
723 d.GeomSetCollideBits(topbox, (uint)m_collisionFlags);
724 786
725 bonebox = d.CreateBox(_parent_scene.ActiveSpace, bonesx, bonesy, bonesz); 787 collider = d.HashSpaceCreate(_parent_scene.CharsSpace);
726 d.GeomSetCategoryBits(bonebox, (uint)m_collisionCategories); 788 d.HashSpaceSetLevels(collider, -4, 3);
727 d.GeomSetCollideBits(bonebox, (uint)m_collisionFlags); 789 d.SpaceSetSublevel(collider, 3);
790 d.SpaceSetCleanup(collider, false);
791 d.GeomSetCategoryBits(collider, (uint)m_collisionCategories);
792 d.GeomSetCollideBits(collider, (uint)m_collisionFlags);
728 793
729 d.MassSetBox(out ShellMass, m_density, m_size.X , m_size.Y, m_size.Z); 794 feetbox = d.CreateBox(collider, feetsx, feetsy, feetsz);
795 midbox = d.CreateBox(collider, midsx, midsy, midsz);
796 topbox = d.CreateBox(collider, topsx, topsy, topsz);
797 bbox = d.CreateBox(collider, m_size.X, m_size.Y, m_size.Z);
730 798
731 m_mass = ShellMass.mass; // update mass 799 m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass
732 800
733 // rescale PID parameters 801 d.MassSetBoxTotal(out ShellMass, m_mass, m_size.X, m_size.Y, m_size.Z);
734 PID_D = _parent_scene.avPIDD;
735 PID_P = _parent_scene.avPIDP;
736 802
737 // rescale PID parameters so that this aren't affected by mass 803 PID_D = basePID_D * m_mass / _parent_scene.ODE_STEPSIZE;
738 // and so don't get unstable for some masses 804 PID_P = basePID_P * m_mass / _parent_scene.ODE_STEPSIZE;
739 // also scale by ode time step so you don't need to refix them
740
741 PID_D /= 50 * 80; //scale to original mass of around 80 and 50 ODE fps
742 PID_D *= m_mass / _parent_scene.ODE_STEPSIZE;
743 PID_P /= 50 * 80;
744 PID_P *= m_mass / _parent_scene.ODE_STEPSIZE;
745 805
746 Body = d.BodyCreate(_parent_scene.world); 806 Body = d.BodyCreate(_parent_scene.world);
747 807
748 _zeroFlag = false; 808 _zeroFlag = false;
809 m_collisionException = false;
749 m_pidControllerActive = true; 810 m_pidControllerActive = true;
750 m_freemove = false; 811 m_freemove = false;
751 812
813 _velocity = Vector3.Zero;
814 m_lastVelocitySqr = 0;
815
752 d.BodySetAutoDisableFlag(Body, false); 816 d.BodySetAutoDisableFlag(Body, false);
753 d.BodySetPosition(Body, npositionX, npositionY, npositionZ); 817 d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
754 818
@@ -760,12 +824,15 @@ namespace OpenSim.Region.Physics.OdePlugin
760 d.GeomSetBody(feetbox, Body); 824 d.GeomSetBody(feetbox, Body);
761 d.GeomSetBody(midbox, Body); 825 d.GeomSetBody(midbox, Body);
762 d.GeomSetBody(topbox, Body); 826 d.GeomSetBody(topbox, Body);
763 d.GeomSetBody(bonebox, Body); 827 d.GeomSetBody(bbox, Body);
764 828
765 d.GeomSetOffsetPosition(feetbox, 0, 0, feetz); 829 d.GeomSetOffsetPosition(feetbox, 0, 0, feetz);
766 d.GeomSetOffsetPosition(midbox, 0, 0, midz); 830 d.GeomSetOffsetPosition(midbox, 0, 0, midz);
767 d.GeomSetOffsetPosition(topbox, 0, 0, topz); 831 d.GeomSetOffsetPosition(topbox, 0, 0, topz);
768 832
833 ajustCollider();
834
835
769 // The purpose of the AMotor here is to keep the avatar's physical 836 // The purpose of the AMotor here is to keep the avatar's physical
770 // surrogate from rotating while moving 837 // surrogate from rotating while moving
771 Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); 838 Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
@@ -828,86 +895,136 @@ namespace OpenSim.Region.Physics.OdePlugin
828 if (topbox != IntPtr.Zero) 895 if (topbox != IntPtr.Zero)
829 { 896 {
830 _parent_scene.actor_name_map.Remove(topbox); 897 _parent_scene.actor_name_map.Remove(topbox);
831 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); 898 _parent_scene.waitForSpaceUnlock(collider);
832 d.GeomDestroy(topbox); 899 d.GeomDestroy(topbox);
833 topbox = IntPtr.Zero; 900 topbox = IntPtr.Zero;
834 } 901 }
835 if (midbox != IntPtr.Zero) 902 if (midbox != IntPtr.Zero)
836 { 903 {
837 _parent_scene.actor_name_map.Remove(midbox); 904 _parent_scene.actor_name_map.Remove(midbox);
838 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); 905 _parent_scene.waitForSpaceUnlock(collider);
839 d.GeomDestroy(midbox); 906 d.GeomDestroy(midbox);
840 midbox = IntPtr.Zero; 907 midbox = IntPtr.Zero;
841 } 908 }
842 if (feetbox != IntPtr.Zero) 909 if (feetbox != IntPtr.Zero)
843 { 910 {
844 _parent_scene.actor_name_map.Remove(feetbox); 911 _parent_scene.actor_name_map.Remove(feetbox);
845 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); 912 _parent_scene.waitForSpaceUnlock(collider);
846 d.GeomDestroy(feetbox); 913 d.GeomDestroy(feetbox);
847 feetbox = IntPtr.Zero; 914 feetbox = IntPtr.Zero;
848 } 915 }
849 916
850 if (bonebox != IntPtr.Zero) 917 if (bbox != IntPtr.Zero)
851 { 918 {
852 _parent_scene.actor_name_map.Remove(bonebox); 919 _parent_scene.actor_name_map.Remove(bbox);
853 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); 920 _parent_scene.waitForSpaceUnlock(collider);
854 d.GeomDestroy(bonebox); 921 d.GeomDestroy(bbox);
855 bonebox = IntPtr.Zero; 922 bbox = IntPtr.Zero;
923 }
924
925 if (collider != IntPtr.Zero)
926 {
927 d.SpaceDestroy(collider);
928 collider = IntPtr.Zero;
856 } 929 }
857 930
858 } 931 }
859 932
860 public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact) 933 //in place 2D rotation around Z assuming rot is normalised and is a rotation around Z
934 public void RotateXYonZ(ref float x, ref float y, ref Quaternion rot)
861 { 935 {
936 float sin = 2.0f * rot.Z * rot.W;
937 float cos = rot.W * rot.W - rot.Z * rot.Z;
938 float tx = x;
862 939
863 if (me == bonebox) // inner bone 940 x = tx * cos - y * sin;
864 { 941 y = tx * sin + y * cos;
865 if (contact.pos.Z - _position.Z < boneOff) 942 }
866 IsColliding = true; 943 public void RotateXYonZ(ref float x, ref float y, ref float sin, ref float cos)
867 return true; 944 {
868 } 945 float tx = x;
946 x = tx * cos - y * sin;
947 y = tx * sin + y * cos;
948 }
949 public void invRotateXYonZ(ref float x, ref float y, ref float sin, ref float cos)
950 {
951 float tx = x;
952 x = tx * cos + y * sin;
953 y = -tx * sin + y * cos;
954 }
869 955
870 if (me == topbox) // keep a box head 956 public void invRotateXYonZ(ref float x, ref float y, ref Quaternion rot)
871 return true; 957 {
958 float sin = - 2.0f * rot.Z * rot.W;
959 float cos = rot.W * rot.W - rot.Z * rot.Z;
960 float tx = x;
872 961
873 // rotate elipsoide assuming only rotation around Z 962 x = tx * cos - y * sin;
874 float ca = m_orientation.W * m_orientation.W - m_orientation.Z * m_orientation.Z; 963 y = tx * sin + y * cos;
875 float sa = 2 * m_orientation.W * m_orientation.Z; 964 }
876 965
877 float isx;
878 float isy;
879 966
880 if (me == feetbox) // feet have narrow bounds 967 public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact, ref bool feetcollision)
881 { 968 {
969 feetcollision = false;
970 if (m_collisionException)
971 return false;
882 972
883 isx = m_invElipSizeX * invFeetScale; 973 if (me == bbox) // if moving fast
884 isy = m_invElipSizeY * invFeetScale;
885 }
886 else
887 { 974 {
888 isx = m_invElipSizeX; 975 // force a full inelastic collision
889 isy = m_invElipSizeY; 976 m_collisionException = true;
977
978 Vector3 off = m_size * 0.5f;
979 off.X += contact.depth;
980 off.Y += contact.depth;
981 off.Z += contact.depth;
982 if (reverse)
983 {
984 off.X *= -contact.normal.X;
985 off.Y *= -contact.normal.Y;
986 off.Z *= -contact.normal.Z;
987 }
988 else
989 {
990 off.X *= contact.normal.X;
991 off.Y *= contact.normal.Y;
992 off.Z *= contact.normal.Z;
993 }
994
995 off.X += contact.pos.X;
996 off.Y += contact.pos.Y;
997 off.Z += contact.pos.Z;
998
999 _position = off;
1000 return false;
890 } 1001 }
891 1002
892 float a = isx * ca - isy * sa; 1003 if (me == topbox) // keep a box head
893 float b = isx * sa + isy * ca; 1004 return true;
894 1005
1006 float t;
895 float offx = contact.pos.X - _position.X; 1007 float offx = contact.pos.X - _position.X;
896 float er = offx * a;
897 er *= er;
898
899 float offy = contact.pos.Y - _position.Y; 1008 float offy = contact.pos.Y - _position.Y;
900 float ty = offy * b;
901 er += ty * ty;
902 1009
903 if (me == midbox) 1010 if (me == midbox)
904 { 1011 {
905 if (er > 4.0f) // no collision 1012 if (Math.Abs(contact.normal.Z) > 0.95f)
906 return false; 1013 {
907 if (er < 0.2f) 1014 float nz = contact.normal.Z;
908 return true; 1015 if (!reverse)
1016 nz = -nz;
1017
1018 if (nz > 0)
1019 return true; // missed head TODO
1020
1021 // missed feet collision?
1022
909 1023
910 float t = offx * offx + offy * offy; 1024 return true;
1025 }
1026
1027 t = offx * offx + offy * offy;
911 t = (float)Math.Sqrt(t); 1028 t = (float)Math.Sqrt(t);
912 t = 1 / t; 1029 t = 1 / t;
913 offx *= t; 1030 offx *= t;
@@ -930,40 +1047,58 @@ namespace OpenSim.Region.Physics.OdePlugin
930 1047
931 else if (me == feetbox) 1048 else if (me == feetbox)
932 { 1049 {
933 float c = feetSZ * 2;
934 float h = contact.pos.Z - _position.Z; 1050 float h = contact.pos.Z - _position.Z;
935 float offz = h - feetOff; // distance from top of feetbox
936 1051
937 float tz = offz / c; 1052 if (Math.Abs(contact.normal.Z) > 0.95f)
938 er += tz * tz; 1053 {
1054 if (contact.normal.Z > 0)
1055 contact.normal.Z = 1.0f;
1056 else
1057 contact.normal.Z = -1.0f;
1058 contact.normal.X = 0.0f;
1059 contact.normal.Y = 0.0f;
1060 feetcollision = true;
1061 if (h < boneOff)
1062 IsColliding = true;
1063 return true;
1064 }
1065
1066
1067 float offz = h - feetOff; // distance from top of feetbox
939 1068
940 if (er > 4.0f) // no collision 1069 if (offz > 0)
941 return false; 1070 return false;
942 1071
943 if (er > 0.2f) 1072 if (offz > -0.01)
944 { 1073 {
945 float t = offx * offx + offy * offy + offz * offz; 1074 offx = 0;
1075 offy = 0;
1076 offz = -1.0f;
1077 }
1078 else
1079 {
1080 t = offx * offx + offy * offy + offz * offz;
946 t = (float)Math.Sqrt(t); 1081 t = (float)Math.Sqrt(t);
947 t = 1 / t; 1082 t = 1 / t;
948 offx *= t; 1083 offx *= t;
949 offy *= t; 1084 offy *= t;
950 offz *= t; 1085 offz *= t;
951
952 if (reverse)
953 {
954 contact.normal.X = offx;
955 contact.normal.Y = offy;
956 contact.normal.Z = offz;
957 }
958 else
959 {
960 contact.normal.X = -offx;
961 contact.normal.Y = -offy;
962 contact.normal.Z = -offz;
963 }
964 } 1086 }
965 1087
966 if(h < boneOff) 1088 if (reverse)
1089 {
1090 contact.normal.X = offx;
1091 contact.normal.Y = offy;
1092 contact.normal.Z = offz;
1093 }
1094 else
1095 {
1096 contact.normal.X = -offx;
1097 contact.normal.Y = -offy;
1098 contact.normal.Z = -offz;
1099 }
1100 feetcollision = true;
1101 if (h < boneOff)
967 IsColliding = true; 1102 IsColliding = true;
968 } 1103 }
969 else 1104 else
@@ -977,11 +1112,28 @@ namespace OpenSim.Region.Physics.OdePlugin
977 /// This is the avatar's movement control + PID Controller 1112 /// This is the avatar's movement control + PID Controller
978 /// </summary> 1113 /// </summary>
979 /// <param name="timeStep"></param> 1114 /// <param name="timeStep"></param>
980 public void Move(float timeStep, List<OdeCharacter> defects) 1115 public void Move(List<OdeCharacter> defects)
981 { 1116 {
982 if (Body == IntPtr.Zero) 1117 if (Body == IntPtr.Zero)
983 return; 1118 return;
984 1119
1120 if (m_collisionException)
1121 {
1122 d.BodySetPosition(Body,_position.X, _position.Y, _position.Z);
1123 d.BodySetLinearVel(Body, 0, 0, 0);
1124
1125 float v = _velocity.Length();
1126 if (v != 0)
1127 {
1128 v = 6.0f / v;
1129 _velocity = _velocity * v;
1130 d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
1131 }
1132 ajustCollider();
1133 m_collisionException = false;
1134 return;
1135 }
1136
985 d.Vector3 dtmp = d.BodyGetPosition(Body); 1137 d.Vector3 dtmp = d.BodyGetPosition(Body);
986 Vector3 localpos = new Vector3(dtmp.X, dtmp.Y, dtmp.Z); 1138 Vector3 localpos = new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
987 1139
@@ -1055,9 +1207,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1055 1207
1056 //****************************************** 1208 //******************************************
1057 // colide with land 1209 // colide with land
1210
1058 d.AABB aabb; 1211 d.AABB aabb;
1059 d.GeomGetAABB(feetbox, out aabb); 1212 d.GeomGetAABB(feetbox, out aabb);
1060 float chrminZ = aabb.MinZ - 0.04f; // move up a bit 1213 float chrminZ = aabb.MinZ; ; // move up a bit
1061 Vector3 posch = localpos; 1214 Vector3 posch = localpos;
1062 1215
1063 float ftmp; 1216 float ftmp;
@@ -1100,11 +1253,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1100 contact.PenetrationDepth = depth; 1253 contact.PenetrationDepth = depth;
1101 contact.Position.X = localpos.X; 1254 contact.Position.X = localpos.X;
1102 contact.Position.Y = localpos.Y; 1255 contact.Position.Y = localpos.Y;
1103 contact.Position.Z = chrminZ; 1256 contact.Position.Z = terrainheight;
1104 contact.SurfaceNormal.X = 0f; 1257 contact.SurfaceNormal.X = 0.0f;
1105 contact.SurfaceNormal.Y = 0f; 1258 contact.SurfaceNormal.Y = 0.0f;
1106 contact.SurfaceNormal.Z = -1f; 1259 contact.SurfaceNormal.Z = -1f;
1107 contact.RelativeSpeed = -vel.Z; 1260 contact.RelativeSpeed = -vel.Z;
1261 contact.CharacterFeet = true;
1108 AddCollisionEvent(0, contact); 1262 AddCollisionEvent(0, contact);
1109 1263
1110 vec.Z *= 0.5f; 1264 vec.Z *= 0.5f;
@@ -1123,6 +1277,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1123 m_iscollidingGround = false; 1277 m_iscollidingGround = false;
1124 } 1278 }
1125 1279
1280
1126 //****************************************** 1281 //******************************************
1127 1282
1128 bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f); 1283 bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f);
@@ -1258,21 +1413,58 @@ namespace OpenSim.Region.Physics.OdePlugin
1258 } 1413 }
1259 1414
1260 // update our local ideia of position velocity and aceleration 1415 // update our local ideia of position velocity and aceleration
1416 // _position = localpos;
1261 _position = localpos; 1417 _position = localpos;
1418
1262 if (_zeroFlag) 1419 if (_zeroFlag)
1263 { 1420 {
1264 _velocity = Vector3.Zero; 1421 _velocity = Vector3.Zero;
1265 _acceleration = Vector3.Zero; 1422 _acceleration = Vector3.Zero;
1423 m_rotationalVelocity = Vector3.Zero;
1266 } 1424 }
1267 else 1425 else
1268 { 1426 {
1269 _acceleration = _velocity; // previus velocity 1427 Vector3 a =_velocity; // previus velocity
1270 _velocity = vel; 1428 SetSmooth(ref _velocity, ref vel, 2);
1271 _acceleration = (vel - _acceleration) / timeStep; 1429 a = (_velocity - a) * invtimeStep;
1430 SetSmooth(ref _acceleration, ref a, 2);
1431
1432 dtmp = d.BodyGetAngularVel(Body);
1433 m_rotationalVelocity.X = 0f;
1434 m_rotationalVelocity.Y = 0f;
1435 m_rotationalVelocity.Z = dtmp.Z;
1436 Math.Round(m_rotationalVelocity.Z,3);
1272 } 1437 }
1273 1438 ajustCollider();
1439 }
1440
1441 public void round(ref Vector3 v, int digits)
1442 {
1443 v.X = (float)Math.Round(v.X, digits);
1444 v.Y = (float)Math.Round(v.Y, digits);
1445 v.Z = (float)Math.Round(v.Z, digits);
1446 }
1447
1448 public void SetSmooth(ref Vector3 dst, ref Vector3 value)
1449 {
1450 dst.X = 0.1f * dst.X + 0.9f * value.X;
1451 dst.Y = 0.1f * dst.Y + 0.9f * value.Y;
1452 dst.Z = 0.1f * dst.Z + 0.9f * value.Z;
1453 }
1454
1455 public void SetSmooth(ref Vector3 dst, ref Vector3 value, int rounddigits)
1456 {
1457 dst.X = 0.4f * dst.X + 0.6f * value.X;
1458 dst.X = (float)Math.Round(dst.X, rounddigits);
1459
1460 dst.Y = 0.4f * dst.Y + 0.6f * value.Y;
1461 dst.Y = (float)Math.Round(dst.Y, rounddigits);
1462
1463 dst.Z = 0.4f * dst.Z + 0.6f * value.Z;
1464 dst.Z = (float)Math.Round(dst.Z, rounddigits);
1274 } 1465 }
1275 1466
1467
1276 /// <summary> 1468 /// <summary>
1277 /// Updates the reported position and velocity. 1469 /// Updates the reported position and velocity.
1278 /// Used to copy variables from unmanaged space at heartbeat rate and also trigger scene updates acording 1470 /// Used to copy variables from unmanaged space at heartbeat rate and also trigger scene updates acording
@@ -1399,10 +1591,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1399 1591
1400 AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z); 1592 AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z);
1401 1593
1402 _parent_scene.actor_name_map[topbox] = (PhysicsActor)this; 1594 _parent_scene.actor_name_map[collider] = (PhysicsActor)this;
1403 _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
1404 _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this; 1595 _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
1405 _parent_scene.actor_name_map[bonebox] = (PhysicsActor)this; 1596 _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
1597 _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
1598 _parent_scene.actor_name_map[bbox] = (PhysicsActor)this;
1406 _parent_scene.AddCharacter(this); 1599 _parent_scene.AddCharacter(this);
1407 } 1600 }
1408 else 1601 else
@@ -1431,6 +1624,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1431 { 1624 {
1432 } 1625 }
1433 1626
1627 private void changeAvatarSize(strAvatarSize st)
1628 {
1629 m_feetOffset = st.offset;
1630 changeSize(st.size);
1631 }
1632
1434 private void changeSize(Vector3 pSize) 1633 private void changeSize(Vector3 pSize)
1435 { 1634 {
1436 if (pSize.IsFinite()) 1635 if (pSize.IsFinite())
@@ -1449,13 +1648,16 @@ namespace OpenSim.Region.Physics.OdePlugin
1449 _position.Z + (m_size.Z - oldsz) * 0.5f); 1648 _position.Z + (m_size.Z - oldsz) * 0.5f);
1450 1649
1451 Velocity = Vector3.Zero; 1650 Velocity = Vector3.Zero;
1651
1452 1652
1453 _parent_scene.actor_name_map[topbox] = (PhysicsActor)this; 1653 _parent_scene.actor_name_map[collider] = (PhysicsActor)this;
1454 _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
1455 _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this; 1654 _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this;
1456 _parent_scene.actor_name_map[bonebox] = (PhysicsActor)this; 1655 _parent_scene.actor_name_map[midbox] = (PhysicsActor)this;
1656 _parent_scene.actor_name_map[topbox] = (PhysicsActor)this;
1657 _parent_scene.actor_name_map[bbox] = (PhysicsActor)this;
1457 } 1658 }
1458 m_freemove = false; 1659 m_freemove = false;
1660 m_collisionException = false;
1459 m_pidControllerActive = true; 1661 m_pidControllerActive = true;
1460 } 1662 }
1461 else 1663 else
@@ -1564,6 +1766,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1564 1766
1565 if (Body != IntPtr.Zero) 1767 if (Body != IntPtr.Zero)
1566 d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z); 1768 d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z);
1769 ajustCollider();
1567 } 1770 }
1568 1771
1569 private void donullchange() 1772 private void donullchange()
@@ -1572,7 +1775,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1572 1775
1573 public bool DoAChange(changes what, object arg) 1776 public bool DoAChange(changes what, object arg)
1574 { 1777 {
1575 if (topbox == IntPtr.Zero && what != changes.Add && what != changes.Remove) 1778 if (collider == IntPtr.Zero && what != changes.Add && what != changes.Remove)
1576 { 1779 {
1577 return false; 1780 return false;
1578 } 1781 }
@@ -1638,6 +1841,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1638 changeSize((Vector3)arg); 1841 changeSize((Vector3)arg);
1639 break; 1842 break;
1640 1843
1844 case changes.AvatarSize:
1845 changeAvatarSize((strAvatarSize)arg);
1846 break;
1847
1641 case changes.Momentum: 1848 case changes.Momentum:
1642 changeMomentum((Vector3)arg); 1849 changeMomentum((Vector3)arg);
1643 break; 1850 break;
@@ -1685,5 +1892,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1685 { 1892 {
1686 _parent_scene.AddChange((PhysicsActor)this, what, arg); 1893 _parent_scene.AddChange((PhysicsActor)this, what, arg);
1687 } 1894 }
1895
1896 private struct strAvatarSize
1897 {
1898 public Vector3 size;
1899 public float offset;
1900 }
1901
1688 } 1902 }
1689} 1903}
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index dc247a9..faa9488 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Region.Physics.OdePlugin
84 84
85 private Vector3 _position; 85 private Vector3 _position;
86 private Vector3 _velocity; 86 private Vector3 _velocity;
87 private Vector3 _torque; 87 private Vector3 m_torque;
88 private Vector3 m_lastVelocity; 88 private Vector3 m_lastVelocity;
89 private Vector3 m_lastposition; 89 private Vector3 m_lastposition;
90 private Vector3 m_rotationalVelocity; 90 private Vector3 m_rotationalVelocity;
@@ -597,7 +597,7 @@ namespace OpenSim.Region.Physics.OdePlugin
597 if (!IsPhysical || Body == IntPtr.Zero) 597 if (!IsPhysical || Body == IntPtr.Zero)
598 return Vector3.Zero; 598 return Vector3.Zero;
599 599
600 return _torque; 600 return m_torque;
601 } 601 }
602 602
603 set 603 set
@@ -2425,10 +2425,10 @@ namespace OpenSim.Region.Physics.OdePlugin
2425 { 2425 {
2426 if (!childPrim) 2426 if (!childPrim)
2427 { 2427 {
2428 m_force = Vector3.Zero; 2428// m_force = Vector3.Zero;
2429 m_forceacc = Vector3.Zero; 2429 m_forceacc = Vector3.Zero;
2430 m_angularForceacc = Vector3.Zero; 2430 m_angularForceacc = Vector3.Zero;
2431 _torque = Vector3.Zero; 2431// m_torque = Vector3.Zero;
2432 _velocity = Vector3.Zero; 2432 _velocity = Vector3.Zero;
2433 _acceleration = Vector3.Zero; 2433 _acceleration = Vector3.Zero;
2434 m_rotationalVelocity = Vector3.Zero; 2434 m_rotationalVelocity = Vector3.Zero;
@@ -2521,7 +2521,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2521 prm.m_collisionCategories = m_collisionCategories; 2521 prm.m_collisionCategories = m_collisionCategories;
2522 prm.m_collisionFlags = m_collisionFlags; 2522 prm.m_collisionFlags = m_collisionFlags;
2523 2523
2524 if (prm.prim_geom != null) 2524 if (prm.prim_geom != IntPtr.Zero)
2525 { 2525 {
2526 2526
2527 if (prm.m_NoColide) 2527 if (prm.m_NoColide)
@@ -2542,7 +2542,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2542// ((OdePrim)_parent).ChildSelectedChange(true); 2542// ((OdePrim)_parent).ChildSelectedChange(true);
2543 2543
2544 2544
2545 if (prim_geom != null) 2545 if (prim_geom != IntPtr.Zero)
2546 { 2546 {
2547 if (m_NoColide) 2547 if (m_NoColide)
2548 { 2548 {
@@ -2968,7 +2968,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2968 d.BodyEnable(Body); 2968 d.BodyEnable(Body);
2969 2969
2970 } 2970 }
2971 _torque = newtorque; 2971 m_torque = newtorque;
2972 } 2972 }
2973 } 2973 }
2974 2974
@@ -3364,7 +3364,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3364 3364
3365 Vector3 trq; 3365 Vector3 trq;
3366 3366
3367 trq = _torque; 3367 trq = m_torque;
3368 trq += m_angularForceacc; 3368 trq += m_angularForceacc;
3369 m_angularForceacc = Vector3.Zero; 3369 m_angularForceacc = Vector3.Zero;
3370 if (trq.X != 0 || trq.Y != 0 || trq.Z != 0) 3370 if (trq.X != 0 || trq.Y != 0 || trq.Z != 0)
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
index 799a324..561ab1c 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
@@ -324,7 +324,10 @@ namespace OpenSim.Region.Physics.OdePlugin
324 { 324 {
325 // Collide tests 325 // Collide tests
326 if ((CurrentRayFilter & FilterActiveSpace) != 0) 326 if ((CurrentRayFilter & FilterActiveSpace) != 0)
327 {
327 d.SpaceCollide2(ray, m_scene.ActiveSpace, IntPtr.Zero, nearCallback); 328 d.SpaceCollide2(ray, m_scene.ActiveSpace, IntPtr.Zero, nearCallback);
329 d.SpaceCollide2(ray, m_scene.CharsSpace, IntPtr.Zero, nearCallback);
330 }
328 if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount)) 331 if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount))
329 d.SpaceCollide2(ray, m_scene.StaticSpace, IntPtr.Zero, nearCallback); 332 d.SpaceCollide2(ray, m_scene.StaticSpace, IntPtr.Zero, nearCallback);
330 if ((CurrentRayFilter & RayFilterFlags.land) != 0 && (m_contactResults.Count < CurrentMaxCount)) 333 if ((CurrentRayFilter & RayFilterFlags.land) != 0 && (m_contactResults.Count < CurrentMaxCount))
@@ -552,7 +555,6 @@ namespace OpenSim.Region.Physics.OdePlugin
552 break; 555 break;
553 556
554 default: 557 default:
555 return;
556 break; 558 break;
557 } 559 }
558 } 560 }
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 {