aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
authorTeravus Ovares2008-03-14 05:22:52 +0000
committerTeravus Ovares2008-03-14 05:22:52 +0000
commitabacfba287efe89ead9bff529d62f65a253eceb8 (patch)
treea6562417f9bdfa499bfae9f50caffbf11e713ea4 /OpenSim/Region/Physics/OdePlugin
parentUpdate svn properties. (diff)
downloadopensim-SC-abacfba287efe89ead9bff529d62f65a253eceb8.zip
opensim-SC-abacfba287efe89ead9bff529d62f65a253eceb8.tar.gz
opensim-SC-abacfba287efe89ead9bff529d62f65a253eceb8.tar.bz2
opensim-SC-abacfba287efe89ead9bff529d62f65a253eceb8.tar.xz
* Preliminary work with the ODEPlugin to collect collision data.
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs1
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs5
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs175
3 files changed, 175 insertions, 6 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 9bbbb22..dc12a9a 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -86,6 +86,7 @@ namespace OpenSim.Region.Physics.OdePlugin
86 private bool m_hackSentFall = false; 86 private bool m_hackSentFall = false;
87 private bool m_hackSentFly = false; 87 private bool m_hackSentFly = false;
88 public uint m_localID = 0; 88 public uint m_localID = 0;
89 public bool m_returnCollisions = false;
89 90
90 private float m_buoyancy = 0f; 91 private float m_buoyancy = 0f;
91 92
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 6a38037..5370ddd 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -61,6 +61,7 @@ namespace OpenSim.Region.Physics.OdePlugin
61 private bool m_taintPhysics = false; 61 private bool m_taintPhysics = false;
62 private bool m_collidesLand = true; 62 private bool m_collidesLand = true;
63 private bool m_collidesWater = false; 63 private bool m_collidesWater = false;
64 public bool m_returnCollisions = false;
64 65
65 // Default we're a Geometry 66 // Default we're a Geometry
66 private CollisionCategories m_collisionCategories = (CollisionCategories.Geom ); 67 private CollisionCategories m_collisionCategories = (CollisionCategories.Geom );
@@ -203,7 +204,9 @@ namespace OpenSim.Region.Physics.OdePlugin
203 204
204 public override uint LocalID 205 public override uint LocalID
205 { 206 {
206 set { m_localID = value; } 207 set {
208 //m_log.Info("[PHYSICS]: Setting TrackerID: " + value);
209 m_localID = value; }
207 } 210 }
208 211
209 public override bool Grabbed 212 public override bool Grabbed
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;