aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/OdePlugin.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs175
1 files changed, 170 insertions, 5 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 9f160a5..31627b6 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -79,6 +79,25 @@ namespace OpenSim.Region.Physics.OdePlugin
79 } 79 }
80 } 80 }
81 81
82
83 public enum StatusIndicators : int
84 {
85 Generic = 0,
86 Start = 1,
87 End = 2
88 }
89
90
91 public struct sCollisionData
92 {
93 public uint ColliderLocalId;
94 public uint CollidedWithLocalId;
95 public int NumberOfCollisions;
96 public int CollisionType;
97 public int StatusIndicator;
98 public int lastframe;
99 }
100
82 [Flags] 101 [Flags]
83 public enum CollisionCategories : int 102 public enum CollisionCategories : int
84 { 103 {
@@ -97,6 +116,7 @@ namespace OpenSim.Region.Physics.OdePlugin
97 public class OdeScene : PhysicsScene 116 public class OdeScene : PhysicsScene
98 { 117 {
99 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 118 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
119 private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>();
100 120
101 CollisionLocker ode; 121 CollisionLocker ode;
102 122
@@ -110,6 +130,8 @@ namespace OpenSim.Region.Physics.OdePlugin
110 130
111 private float waterlevel = 0f; 131 private float waterlevel = 0f;
112 private int framecount = 0; 132 private int framecount = 0;
133 private int m_returncollisions = 10;
134
113 private IntPtr contactgroup; 135 private IntPtr contactgroup;
114 private IntPtr LandGeom = (IntPtr) 0; 136 private IntPtr LandGeom = (IntPtr) 0;
115 137
@@ -146,10 +168,20 @@ namespace OpenSim.Region.Physics.OdePlugin
146 private float step_time = 0.0f; 168 private float step_time = 0.0f;
147 private int ms = 0; 169 private int ms = 0;
148 public IntPtr world; 170 public IntPtr world;
171 private bool returncollisions = false;
172 private uint obj1LocalID = 0;
173 private uint obj2LocalID = 0;
174 private int ctype = 0;
175 private OdeCharacter cc1;
176 private OdePrim cp1;
177 private OdeCharacter cc2;
178 private OdePrim cp2;
179 private int cStartStop = 0;
180 private string cDictKey = "";
149 181
150 public IntPtr space; 182 public IntPtr space;
151 183
152 private IntPtr tmpSpace; 184 //private IntPtr tmpSpace;
153 // split static geometry collision handling into spaces of 30 meters 185 // split static geometry collision handling into spaces of 30 meters
154 public IntPtr[,] staticPrimspace = new IntPtr[(int) (300/metersInSpace),(int) (300/metersInSpace)]; 186 public IntPtr[,] staticPrimspace = new IntPtr[(int) (300/metersInSpace),(int) (300/metersInSpace)];
155 187
@@ -357,10 +389,10 @@ namespace OpenSim.Region.Physics.OdePlugin
357 389
358 lock (contacts) 390 lock (contacts)
359 { 391 {
360 if (g1 == (IntPtr)0) 392 //if (g1 == (IntPtr)0)
361 m_log.Info("g1=0"); 393 //m_log.Info("g1=0");
362 if (g2 == (IntPtr)0) 394 //if (g2 == (IntPtr)0)
363 m_log.Info("g2=0"); 395 //m_log.Info("g2=0");
364 396
365 count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); 397 count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf);
366 } 398 }
@@ -400,6 +432,10 @@ namespace OpenSim.Region.Physics.OdePlugin
400 // We only need to test p2 for 'jump crouch purposes' 432 // We only need to test p2 for 'jump crouch purposes'
401 p2.IsColliding = true; 433 p2.IsColliding = true;
402 434
435 if ((framecount % m_returncollisions) == 0)
436 collision_accounting_events(p1, p2);
437
438
403 switch (p1.PhysicsActorType) 439 switch (p1.PhysicsActorType)
404 { 440 {
405 case (int)ActorTypes.Agent: 441 case (int)ActorTypes.Agent:
@@ -437,6 +473,8 @@ namespace OpenSim.Region.Physics.OdePlugin
437 (p1.PhysicsActorType == (int) ActorTypes.Agent && 473 (p1.PhysicsActorType == (int) ActorTypes.Agent &&
438 p2.PhysicsActorType == (int) ActorTypes.Prim)) 474 p2.PhysicsActorType == (int) ActorTypes.Prim))
439 { 475 {
476
477
440 # region disabled code1 478 # region disabled code1
441 //contacts[i].depth = contacts[i].depth * 4.15f; 479 //contacts[i].depth = contacts[i].depth * 4.15f;
442 /* 480 /*
@@ -472,6 +510,7 @@ namespace OpenSim.Region.Physics.OdePlugin
472 } 510 }
473 */ 511 */
474 #endregion 512 #endregion
513
475 } 514 }
476 515
477 516
@@ -651,6 +690,132 @@ namespace OpenSim.Region.Physics.OdePlugin
651 690
652 } 691 }
653 692
693 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2)
694 {
695 obj1LocalID = 0;
696 returncollisions = false;
697 obj2LocalID = 0;
698 ctype = 0;
699 cStartStop = 0;
700
701 switch ((ActorTypes)p2.PhysicsActorType)
702 {
703 case ActorTypes.Agent:
704 cc2 = (OdeCharacter)p2;
705 if (cc2.m_returnCollisions)
706 {
707 obj1LocalID = cc2.m_localID;
708 switch ((ActorTypes)p1.PhysicsActorType)
709 {
710 case ActorTypes.Agent:
711 cc1 = (OdeCharacter)p1;
712 obj2LocalID = cc1.m_localID;
713 ctype = (int)CollisionCategories.Character;
714
715 if (cc1.CollidingObj)
716 cStartStop = (int)StatusIndicators.Generic;
717 else
718 cStartStop = (int)StatusIndicators.Start;
719
720 returncollisions = true;
721 break;
722 case ActorTypes.Prim:
723 cp1 = (OdePrim)p1;
724 obj2LocalID = cp1.m_localID;
725 ctype = (int)CollisionCategories.Geom;
726
727 if (cp1.CollidingObj)
728 cStartStop = (int)StatusIndicators.Generic;
729 else
730 cStartStop = (int)StatusIndicators.Start;
731
732 returncollisions = true;
733 break;
734
735 case ActorTypes.Ground:
736 case ActorTypes.Unknown:
737 obj2LocalID = 0;
738 ctype = (int)CollisionCategories.Land;
739 returncollisions = true;
740 break;
741 }
742
743
744 }
745
746 break;
747 case ActorTypes.Prim:
748 cp2 = (OdePrim)p2;
749 if (cp2.m_returnCollisions)
750 {
751 obj1LocalID = cp2.m_localID;
752 switch ((ActorTypes)p1.PhysicsActorType)
753 {
754 case ActorTypes.Agent:
755 cc1 = (OdeCharacter)p1;
756 obj2LocalID = cc1.m_localID;
757 ctype = (int)CollisionCategories.Character;
758
759 if (cc1.CollidingObj)
760 cStartStop = (int)StatusIndicators.Generic;
761 else
762 cStartStop = (int)StatusIndicators.Start;
763 returncollisions = true;
764
765 break;
766 case ActorTypes.Prim:
767 cp1 = (OdePrim)p1;
768 obj2LocalID = cp1.m_localID;
769 ctype = (int)CollisionCategories.Geom;
770
771 if (cp1.CollidingObj)
772 cStartStop = (int)StatusIndicators.Generic;
773 else
774 cStartStop = (int)StatusIndicators.Start;
775
776 returncollisions = true;
777 break;
778
779 case ActorTypes.Ground:
780 case ActorTypes.Unknown:
781 obj2LocalID = 0;
782 ctype = (int)CollisionCategories.Land;
783
784 returncollisions = true;
785 break;
786 }
787 }
788
789 break;
790 }
791 if (returncollisions)
792 {
793
794 lock (m_storedCollisions)
795 {
796 cDictKey = obj1LocalID.ToString() + obj2LocalID.ToString() + cStartStop.ToString() + ctype.ToString();
797 if (m_storedCollisions.ContainsKey(cDictKey))
798 {
799 sCollisionData objd = m_storedCollisions[cDictKey];
800 objd.NumberOfCollisions += 1;
801 objd.lastframe = framecount;
802 m_storedCollisions[cDictKey] = objd;
803 }
804 else
805 {
806 sCollisionData objd = new sCollisionData();
807 objd.ColliderLocalId = obj1LocalID;
808 objd.CollidedWithLocalId = obj2LocalID;
809 objd.CollisionType = ctype;
810 objd.NumberOfCollisions = 1;
811 objd.lastframe = framecount;
812 objd.StatusIndicator = cStartStop;
813 m_storedCollisions.Add(cDictKey, objd);
814 }
815 }
816 }
817 }
818
654 public int TriArrayCallback(IntPtr trimesh, IntPtr refObject, int[] triangleIndex, int triCount) 819 public int TriArrayCallback(IntPtr trimesh, IntPtr refObject, int[] triangleIndex, int triCount)
655 { 820 {
656 /* String name1 = null; 821 /* String name1 = null;