aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
authorTeravus Ovares2007-11-12 21:45:49 +0000
committerTeravus Ovares2007-11-12 21:45:49 +0000
commit5952441fcc886902f7b2f72eb839ae49d2c85012 (patch)
treeff7ea06cbdaa36e14b1d14da79d5535cb0dcba14 /OpenSim/Region/Physics/OdePlugin
parentfix compile issue on mono (diff)
downloadopensim-SC_OLD-5952441fcc886902f7b2f72eb839ae49d2c85012.zip
opensim-SC_OLD-5952441fcc886902f7b2f72eb839ae49d2c85012.tar.gz
opensim-SC_OLD-5952441fcc886902f7b2f72eb839ae49d2c85012.tar.bz2
opensim-SC_OLD-5952441fcc886902f7b2f72eb839ae49d2c85012.tar.xz
* Added a lot of Glue to help with reporting proper collisions.
* ODE - Fixed the iscolliding property to report a static true when colliding. * Added reporting of collisions to call UpdateMovementAnimations * Added Jump - air animation (with arms outstretched). * Added Fall Animations * ODE - Added a small amount of X, Y motion control while jumping or Falling * ODE - Avatar movement animations are still a bit odd sometimes, and had to get this up there.
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs110
1 files changed, 93 insertions, 17 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 98c5995..c93b96f 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -89,6 +89,7 @@ namespace OpenSim.Region.Physics.OdePlugin
89 private d.ContactGeom[] contacts = new d.ContactGeom[30]; 89 private d.ContactGeom[] contacts = new d.ContactGeom[30];
90 private d.Contact contact; 90 private d.Contact contact;
91 private d.Contact TerrainContact; 91 private d.Contact TerrainContact;
92
92 private int m_physicsiterations = 10; 93 private int m_physicsiterations = 10;
93 private float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag 94 private float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag
94 private PhysicsActor PANull = new NullPhysicsActor(); 95 private PhysicsActor PANull = new NullPhysicsActor();
@@ -208,11 +209,16 @@ namespace OpenSim.Region.Physics.OdePlugin
208 } 209 }
209 210
210 211
211 d.JointAttach(joint, b1, b2); 212 d.JointAttach(joint, b1, b2);
212 213
213 214
215 PhysicsActor p1;
214 PhysicsActor p2; 216 PhysicsActor p2;
215 217
218 if (!actor_name_map.TryGetValue(g2, out p1))
219 {
220 p1 = PANull;
221 }
216 if (!actor_name_map.TryGetValue(g2, out p2)) 222 if (!actor_name_map.TryGetValue(g2, out p2))
217 { 223 {
218 p2 = PANull; 224 p2 = PANull;
@@ -220,6 +226,17 @@ namespace OpenSim.Region.Physics.OdePlugin
220 226
221 // We only need to test p2 for 'jump crouch purposes' 227 // We only need to test p2 for 'jump crouch purposes'
222 p2.IsColliding = true; 228 p2.IsColliding = true;
229 switch(p1.PhysicsActorType) {
230 case (int)ActorTypes.Agent:
231 p2.CollidingObj = true;
232 break;
233 case (int)ActorTypes.Prim:
234 p2.CollidingObj = true;
235 break;
236 case (int)ActorTypes.Unknown:
237 p2.CollidingGround = true;
238 break;
239 }
223 if (count > 3) 240 if (count > 3)
224 { 241 {
225 p2.ThrottleUpdates = true; 242 p2.ThrottleUpdates = true;
@@ -237,6 +254,8 @@ namespace OpenSim.Region.Physics.OdePlugin
237 254
238 255
239 chr.IsColliding = false; 256 chr.IsColliding = false;
257 chr.CollidingGround = false;
258 chr.CollidingObj = false;
240 d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback); 259 d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback);
241 foreach (OdeCharacter ch2 in _characters) 260 foreach (OdeCharacter ch2 in _characters)
242 /// should be a separate space -- lots of avatars will be N**2 slow 261 /// should be a separate space -- lots of avatars will be N**2 slow
@@ -308,11 +327,9 @@ namespace OpenSim.Region.Physics.OdePlugin
308 p = (OdePrim) prim; 327 p = (OdePrim) prim;
309 p.disableBody(); 328 p.disableBody();
310 } 329 }
311 if (!((OdePrim)prim).prim_geom.Equals(null)) 330
312 { 331 d.GeomDestroy(((OdePrim)prim).prim_geom);
313 if (((OdePrim)prim).prim_geom != (IntPtr) 0) 332
314 d.GeomDestroy(((OdePrim)prim).prim_geom);
315 }
316 _prims.Remove((OdePrim)prim); 333 _prims.Remove((OdePrim)prim);
317 334
318 } 335 }
@@ -642,8 +659,9 @@ namespace OpenSim.Region.Physics.OdePlugin
642 public static float CAPSULE_LENGTH = 0.79f; 659 public static float CAPSULE_LENGTH = 0.79f;
643 private bool flying = false; 660 private bool flying = false;
644 private bool m_iscolliding = false; 661 private bool m_iscolliding = false;
662 private bool m_wascolliding = false;
645 663
646 private bool[] m_colliderarr = new bool[10]; 664 private bool[] m_colliderarr = new bool[11];
647 665
648 private bool jumping = false; 666 private bool jumping = false;
649 //private float gravityAccel; 667 //private float gravityAccel;
@@ -661,7 +679,7 @@ namespace OpenSim.Region.Physics.OdePlugin
661 _acceleration = new PhysicsVector(); 679 _acceleration = new PhysicsVector();
662 _parent_scene = parent_scene; 680 _parent_scene = parent_scene;
663 681
664 for (int i = 0; i < 10; i++) 682 for (int i = 0; i < 11; i++)
665 { 683 {
666 m_colliderarr[i] = false; 684 m_colliderarr[i] = false;
667 } 685 }
@@ -679,7 +697,11 @@ namespace OpenSim.Region.Physics.OdePlugin
679 parent_scene.geom_name_map[Shell] = avName; 697 parent_scene.geom_name_map[Shell] = avName;
680 parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 698 parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
681 } 699 }
682 700 public override int PhysicsActorType
701 {
702 get { return (int)ActorTypes.Agent; }
703 set { return; }
704 }
683 public override bool IsPhysical 705 public override bool IsPhysical
684 { 706 {
685 get { return false; } 707 get { return false; }
@@ -705,16 +727,16 @@ namespace OpenSim.Region.Physics.OdePlugin
705 int truecount=0; 727 int truecount=0;
706 int falsecount=0; 728 int falsecount=0;
707 729
708 if (m_colliderarr.Length >= 6) 730 if (m_colliderarr.Length >= 10)
709 { 731 {
710 for (i = 0; i < 6; i++) 732 for (i = 0; i < 10; i++)
711 { 733 {
712 m_colliderarr[i] = m_colliderarr[i + 1]; 734 m_colliderarr[i] = m_colliderarr[i + 1];
713 } 735 }
714 } 736 }
715 m_colliderarr[6] = value; 737 m_colliderarr[10] = value;
716 738
717 for (i = 0; i < 7; i++) 739 for (i = 0; i < 11; i++)
718 { 740 {
719 if (m_colliderarr[i]) 741 if (m_colliderarr[i])
720 { 742 {
@@ -728,7 +750,7 @@ namespace OpenSim.Region.Physics.OdePlugin
728 750
729 // Equal truecounts and false counts means we're colliding with something. 751 // Equal truecounts and false counts means we're colliding with something.
730 752
731 if (falsecount > truecount) 753 if (falsecount > 1.2 * truecount)
732 { 754 {
733 m_iscolliding = false; 755 m_iscolliding = false;
734 } 756 }
@@ -736,9 +758,25 @@ namespace OpenSim.Region.Physics.OdePlugin
736 { 758 {
737 m_iscolliding = true; 759 m_iscolliding = true;
738 } 760 }
761 if (m_wascolliding != m_iscolliding)
762 {
763 base.SendCollisionUpdate(new CollisionEventUpdate());
764 }
765 m_wascolliding = m_iscolliding;
739 } 766 }
740 } 767 }
741 public override PhysicsVector Position 768 public override bool CollidingGround
769 {
770 get { return false; }
771 set { return; }
772 }
773 public override bool CollidingObj
774 {
775 get { return false; }
776 set { return; }
777 }
778
779 public override PhysicsVector Position
742 { 780 {
743 get { return _position; } 781 get { return _position; }
744 set 782 set
@@ -869,8 +907,30 @@ namespace OpenSim.Region.Physics.OdePlugin
869 { 907 {
870 d.Vector3 pos = d.BodyGetPosition(Body); 908 d.Vector3 pos = d.BodyGetPosition(Body);
871 vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; 909 vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P;
910 if (_target_velocity.X > 0)
911 {
912 vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D;
913 }
914 if (_target_velocity.Y > 0)
915 {
916 vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D;
917 }
918 }
919 else if (!m_iscolliding && !flying)
920 {
921 d.Vector3 pos = d.BodyGetPosition(Body);
922 if (_target_velocity.X > 0)
923 {
924 vec.X = ((_target_velocity.X - vel.X)/1.2f) * PID_D;
925 }
926 if (_target_velocity.Y > 0)
927 {
928 vec.Y = ((_target_velocity.Y - vel.Y)/1.2f) * PID_D;
929 }
930
872 } 931 }
873 932
933
874 if (flying) 934 if (flying)
875 { 935 {
876 vec.Z = (_target_velocity.Z - vel.Z)*PID_D; 936 vec.Z = (_target_velocity.Z - vel.Z)*PID_D;
@@ -1012,6 +1072,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1012 // don't do .add() here; old geoms get recycled with the same hash 1072 // don't do .add() here; old geoms get recycled with the same hash
1013 } 1073 }
1014 } 1074 }
1075 public override int PhysicsActorType
1076 {
1077 get { return (int)ActorTypes.Prim; }
1078 set { return; }
1079 }
1015 public void enableBody() 1080 public void enableBody()
1016 { 1081 {
1017 // Sets the geom to a body 1082 // Sets the geom to a body
@@ -1028,6 +1093,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1028 d.GeomSetBody(prim_geom, Body); 1093 d.GeomSetBody(prim_geom, Body);
1029 d.BodySetAutoDisableFlag(Body, true); 1094 d.BodySetAutoDisableFlag(Body, true);
1030 d.BodySetAutoDisableSteps(Body,20); 1095 d.BodySetAutoDisableSteps(Body,20);
1096
1031 _parent_scene.addActivePrim(this); 1097 _parent_scene.addActivePrim(this);
1032 } 1098 }
1033 public void setMass() 1099 public void setMass()
@@ -1122,6 +1188,16 @@ namespace OpenSim.Region.Physics.OdePlugin
1122 get { return iscolliding; } 1188 get { return iscolliding; }
1123 set { iscolliding = value; } 1189 set { iscolliding = value; }
1124 } 1190 }
1191 public override bool CollidingGround
1192 {
1193 get { return false; }
1194 set { return; }
1195 }
1196 public override bool CollidingObj
1197 {
1198 get { return false; }
1199 set { return; }
1200 }
1125 public override bool ThrottleUpdates 1201 public override bool ThrottleUpdates
1126 { 1202 {
1127 get { return m_throttleUpdates; } 1203 get { return m_throttleUpdates; }