aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorTeravus Ovares2008-10-17 05:09:23 +0000
committerTeravus Ovares2008-10-17 05:09:23 +0000
commita6df2011f7d749b88669f9f6b37e3ddc54f23c06 (patch)
treec52301a946281512f1b78a866741fd66f769b76a
parentUpdate svn properties, minor formatting cleanup. (diff)
downloadopensim-SC-a6df2011f7d749b88669f9f6b37e3ddc54f23c06.zip
opensim-SC-a6df2011f7d749b88669f9f6b37e3ddc54f23c06.tar.gz
opensim-SC-a6df2011f7d749b88669f9f6b37e3ddc54f23c06.tar.bz2
opensim-SC-a6df2011f7d749b88669f9f6b37e3ddc54f23c06.tar.xz
* Adds a lot of stability and performance to the physics engine. The avatar bounces less and things are a bit less explosive.
* Additionally, you can probably get more physical prim now together.. though, I think this puts us back on par with where we were in the beginning of the year on number of physical objects. Experiment. Make videos. Send Feedback. Enjoy.
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs87
1 files changed, 86 insertions, 1 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 2108c35..1dcec12 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -205,6 +205,7 @@ namespace OpenSim.Region.Physics.OdePlugin
205 private List<OdePrim> _prims = new List<OdePrim>(); 205 private List<OdePrim> _prims = new List<OdePrim>();
206 private List<OdePrim> _activeprims = new List<OdePrim>(); 206 private List<OdePrim> _activeprims = new List<OdePrim>();
207 private List<OdePrim> _taintedPrim = new List<OdePrim>(); 207 private List<OdePrim> _taintedPrim = new List<OdePrim>();
208 private List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>();
208 private List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>(); 209 private List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>();
209 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); 210 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
210 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>(); 211 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
@@ -574,12 +575,17 @@ namespace OpenSim.Region.Physics.OdePlugin
574 575
575 for (int i = 0; i < count; i++) 576 for (int i = 0; i < count; i++)
576 { 577 {
578 if (checkDupe(contacts[i],p2.PhysicsActorType))
579 {
580 continue;
581 }
582
577 max_collision_depth = (contacts[i].depth > max_collision_depth) ? contacts[i].depth : max_collision_depth; 583 max_collision_depth = (contacts[i].depth > max_collision_depth) ? contacts[i].depth : max_collision_depth;
578 //m_log.Warn("[CCOUNT]: " + count); 584 //m_log.Warn("[CCOUNT]: " + count);
579 IntPtr joint; 585 IntPtr joint;
580 // If we're colliding with terrain, use 'TerrainContact' instead of contact. 586 // If we're colliding with terrain, use 'TerrainContact' instead of contact.
581 // allows us to have different settings 587 // allows us to have different settings
582 588
583 // We only need to test p2 for 'jump crouch purposes' 589 // We only need to test p2 for 'jump crouch purposes'
584 p2.IsColliding = true; 590 p2.IsColliding = true;
585 591
@@ -764,12 +770,16 @@ namespace OpenSim.Region.Physics.OdePlugin
764 { 770 {
765 // Use the movement terrain contact 771 // Use the movement terrain contact
766 AvatarMovementTerrainContact.geom = contacts[i]; 772 AvatarMovementTerrainContact.geom = contacts[i];
773
774 _perloopContact.Add(contacts[i]);
775
767 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); 776 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact);
768 } 777 }
769 else 778 else
770 { 779 {
771 // Use the non moving terrain contact 780 // Use the non moving terrain contact
772 TerrainContact.geom = contacts[i]; 781 TerrainContact.geom = contacts[i];
782 _perloopContact.Add(contacts[i]);
773 joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); 783 joint = d.JointCreateContact(world, contactgroup, ref TerrainContact);
774 } 784 }
775 } 785 }
@@ -792,6 +802,8 @@ namespace OpenSim.Region.Physics.OdePlugin
792 } 802 }
793 WaterContact.geom = contacts[i]; 803 WaterContact.geom = contacts[i];
794 804
805 _perloopContact.Add(contacts[i]);
806
795 joint = d.JointCreateContact(world, contactgroup, ref WaterContact); 807 joint = d.JointCreateContact(world, contactgroup, ref WaterContact);
796 808
797 //m_log.Info("[PHYSICS]: Prim Water Contact" + contacts[i].depth); 809 //m_log.Info("[PHYSICS]: Prim Water Contact" + contacts[i].depth);
@@ -806,12 +818,14 @@ namespace OpenSim.Region.Physics.OdePlugin
806 { 818 {
807 // Use the Movement prim contact 819 // Use the Movement prim contact
808 AvatarMovementprimContact.geom = contacts[i]; 820 AvatarMovementprimContact.geom = contacts[i];
821 _perloopContact.Add(contacts[i]);
809 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); 822 joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact);
810 } 823 }
811 else 824 else
812 { 825 {
813 // Use the non movement contact 826 // Use the non movement contact
814 contact.geom = contacts[i]; 827 contact.geom = contacts[i];
828 _perloopContact.Add(contacts[i]);
815 joint = d.JointCreateContact(world, contactgroup, ref contact); 829 joint = d.JointCreateContact(world, contactgroup, ref contact);
816 } 830 }
817 } 831 }
@@ -832,6 +846,73 @@ namespace OpenSim.Region.Physics.OdePlugin
832 } 846 }
833 } 847 }
834 848
849 private bool checkDupe(d.ContactGeom contactGeom, int atype)
850 {
851 bool result = false;
852 //return result;
853 ActorTypes at = (ActorTypes)atype;
854 lock (_perloopContact)
855 {
856 foreach (d.ContactGeom contact in _perloopContact)
857 {
858 //if ((contact.g1 == contactGeom.g1 && contact.g2 == contactGeom.g2))
859 //{
860 // || (contact.g2 == contactGeom.g1 && contact.g1 == contactGeom.g2)
861 if (at == ActorTypes.Agent)
862 {
863 if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
864 {
865
866 if (Math.Abs(contact.depth - contactGeom.depth) < 0.272f)
867 {
868 //contactGeom.depth *= .00005f;
869 //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
870 // m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
871 result = true;
872 break;
873 }
874 else
875 {
876 //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
877 }
878 }
879 else
880 {
881 //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
882 //int i = 0;
883 }
884 }
885 else if (at == ActorTypes.Prim)
886 {
887 //d.AABB aabb1 = new d.AABB();
888 //d.AABB aabb2 = new d.AABB();
889
890 //d.GeomGetAABB(contactGeom.g2, out aabb2);
891 //d.GeomGetAABB(contactGeom.g1, out aabb1);
892 //aabb1.
893 if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom)
894 {
895 if (contactGeom.normal.X == contact.normal.X && contactGeom.normal.Y == contact.normal.Y && contactGeom.normal.Z == contact.normal.Z)
896 {
897 if (Math.Abs(contact.depth - contactGeom.depth) < 0.272f)
898 {
899 result = true;
900 break;
901 }
902 }
903 //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth));
904 //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z));
905 }
906
907 }
908
909 //}
910
911 }
912 }
913 return result;
914 }
915
835 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, float collisiondepth) 916 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, float collisiondepth)
836 { 917 {
837 // obj1LocalID = 0; 918 // obj1LocalID = 0;
@@ -1012,6 +1093,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1012 /// <param name="timeStep"></param> 1093 /// <param name="timeStep"></param>
1013 private void collision_optimized(float timeStep) 1094 private void collision_optimized(float timeStep)
1014 { 1095 {
1096 _perloopContact.Clear();
1097
1015 foreach (OdeCharacter chr in _characters) 1098 foreach (OdeCharacter chr in _characters)
1016 { 1099 {
1017 // Reset the collision values to false 1100 // Reset the collision values to false
@@ -1082,6 +1165,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1082 } 1165 }
1083 } 1166 }
1084 } 1167 }
1168
1169 _perloopContact.Clear();
1085 } 1170 }
1086 1171
1087 #endregion 1172 #endregion