aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs3
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs3
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs1
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs4
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs16
-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
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs6
9 files changed, 196 insertions, 18 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 1f4cdd5..041dc4e 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -545,6 +545,9 @@ namespace OpenSim.Region.Environment.Scenes
545 new Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X, 545 new Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X,
546 dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z), 546 dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z),
547 dupe.RootPart.PhysActor.IsPhysical); 547 dupe.RootPart.PhysActor.IsPhysical);
548
549 dupe.RootPart.PhysActor.LocalID = dupe.RootPart.LocalId;
550
548 dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); 551 dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true);
549 } 552 }
550 // Now we've made a copy that replaces this one, we need to 553 // Now we've made a copy that replaces this one, we need to
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index b708d04..ffb9d36 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -785,7 +785,7 @@ namespace OpenSim.Region.Environment.Scenes
785 new PhysicsVector(Scale.X, Scale.Y, Scale.Z), 785 new PhysicsVector(Scale.X, Scale.Y, Scale.Z),
786 new Quaternion(RotationOffset.W, RotationOffset.X, 786 new Quaternion(RotationOffset.W, RotationOffset.X,
787 RotationOffset.Y, RotationOffset.Z), RigidBody); 787 RotationOffset.Y, RotationOffset.Z), RigidBody);
788 788 PhysActor.LocalID = LocalId;
789 789
790 DoPhysicsPropertyUpdate(RigidBody, true); 790 DoPhysicsPropertyUpdate(RigidBody, true);
791 } 791 }
@@ -1305,6 +1305,7 @@ namespace OpenSim.Region.Environment.Scenes
1305 new PhysicsVector(Scale.X, Scale.Y, Scale.Z), 1305 new PhysicsVector(Scale.X, Scale.Y, Scale.Z),
1306 new Quaternion(RotationOffset.W, RotationOffset.X, 1306 new Quaternion(RotationOffset.W, RotationOffset.X,
1307 RotationOffset.Y, RotationOffset.Z), usePhysics); 1307 RotationOffset.Y, RotationOffset.Z), usePhysics);
1308 PhysActor.LocalID = LocalId;
1308 DoPhysicsPropertyUpdate(usePhysics, true); 1309 DoPhysicsPropertyUpdate(usePhysics, true);
1309 } 1310 }
1310 else 1311 else
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 2f35fe3..1731cd9 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -1809,6 +1809,7 @@ namespace OpenSim.Region.Environment.Scenes
1809 } 1809 }
1810 //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; 1810 //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
1811 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 1811 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
1812 m_physicsActor.LocalID = LocalId;
1812 } 1813 }
1813 1814
1814 // Event called by the physics plugin to tell the avatar about a collision. 1815 // Event called by the physics plugin to tell the avatar about a collision.
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
index 2b05bb6..8666862 100644
--- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
@@ -90,6 +90,7 @@ namespace OpenSim.Region.Environment.Scenes
90 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 90 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
91 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 91 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
92 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); 92 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
93 rootPart.PhysActor.LocalID = rootPart.LocalId;
93 rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); 94 rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
94 } 95 }
95 primCount++; 96 primCount++;
@@ -192,6 +193,9 @@ namespace OpenSim.Region.Environment.Scenes
192 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 193 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
193 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 194 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
194 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); 195 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
196
197 rootPart.PhysActor.LocalID = rootPart.LocalId;
198
195 rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); 199 rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
196 rootPart.Velocity = receivedVelocity; 200 rootPart.Velocity = receivedVelocity;
197 } 201 }
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 2a35d43..9b8e1e1 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -52,28 +52,28 @@ namespace OpenSim.Region.Physics.Manager
52 52
53 53
54 public int m_colliderType; 54 public int m_colliderType;
55 public bool m_startOrEnd; 55 public int m_GenericStartEnd;
56 //public uint m_LocalID; 56 //public uint m_LocalID;
57 public List<uint> m_objCollisionList; 57 public List<uint> m_objCollisionList;
58 58
59 public CollisionEventUpdate(uint localID, int colliderType, bool startOrEnd, List<uint> objCollisionList) 59 public CollisionEventUpdate(uint localID, int colliderType, int GenericStartEnd, List<uint> objCollisionList)
60 { 60 {
61 m_colliderType = colliderType; 61 m_colliderType = colliderType;
62 m_startOrEnd = startOrEnd; 62 m_GenericStartEnd = GenericStartEnd;
63 m_objCollisionList = objCollisionList; 63 m_objCollisionList = objCollisionList;
64 } 64 }
65 65
66 public CollisionEventUpdate(bool startOrEnd) 66 public CollisionEventUpdate(bool startOrEnd)
67 { 67 {
68 m_colliderType = (int) ActorTypes.Unknown; 68 m_colliderType = (int) ActorTypes.Unknown;
69 m_startOrEnd = startOrEnd; 69 m_GenericStartEnd = m_GenericStartEnd;
70 m_objCollisionList = null; 70 m_objCollisionList = null;
71 } 71 }
72 72
73 public CollisionEventUpdate() 73 public CollisionEventUpdate()
74 { 74 {
75 m_colliderType = (int) ActorTypes.Unknown; 75 m_colliderType = (int) ActorTypes.Unknown;
76 m_startOrEnd = false; 76 m_GenericStartEnd = 1;
77 m_objCollisionList = null; 77 m_objCollisionList = null;
78 } 78 }
79 79
@@ -83,10 +83,10 @@ namespace OpenSim.Region.Physics.Manager
83 set { m_colliderType = value; } 83 set { m_colliderType = value; }
84 } 84 }
85 85
86 public bool startOrEnd 86 public int GenericStartEnd
87 { 87 {
88 get { return m_startOrEnd; } 88 get { return m_GenericStartEnd; }
89 set { m_startOrEnd = value; } 89 set { m_GenericStartEnd = value; }
90 } 90 }
91 91
92 public void addCollider(uint localID) 92 public void addCollider(uint localID)
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;
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
index b091e04..efd9894 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
@@ -134,17 +134,17 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
134 134
135 public void collision_start(uint localID, LLUUID itemID) 135 public void collision_start(uint localID, LLUUID itemID)
136 { 136 {
137 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_start", EventQueueManager.llDetectNull); 137 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_start", EventQueueManager.llDetectNull, new object[] { (int)1 });
138 } 138 }
139 139
140 public void collision(uint localID, LLUUID itemID) 140 public void collision(uint localID, LLUUID itemID)
141 { 141 {
142 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision", EventQueueManager.llDetectNull); 142 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision", EventQueueManager.llDetectNull, new object[] { (int)1 });
143 } 143 }
144 144
145 public void collision_end(uint localID, LLUUID itemID) 145 public void collision_end(uint localID, LLUUID itemID)
146 { 146 {
147 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_end", EventQueueManager.llDetectNull); 147 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_end", EventQueueManager.llDetectNull, new object[] { (int)1 });
148 } 148 }
149 149
150 public void land_collision_start(uint localID, LLUUID itemID) 150 public void land_collision_start(uint localID, LLUUID itemID)