aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs16
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs6
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs11
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs7
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs91
-rw-r--r--OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs2
6 files changed, 68 insertions, 65 deletions
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 49f60f8..798a0a4 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -25,8 +25,10 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using log4net;
28using System; 29using System;
29using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection;
30using OpenSim.Framework; 32using OpenSim.Framework;
31using OpenMetaverse; 33using OpenMetaverse;
32 34
@@ -46,10 +48,10 @@ namespace OpenSim.Region.Physics.Manager
46 48
47 public enum PIDHoverType 49 public enum PIDHoverType
48 { 50 {
49 Ground 51 Ground,
50 , GroundAndWater 52 GroundAndWater,
51 , Water 53 Water,
52 , Absolute 54 Absolute
53 } 55 }
54 56
55 public struct ContactPoint 57 public struct ContactPoint
@@ -114,6 +116,8 @@ namespace OpenSim.Region.Physics.Manager
114 116
115 public abstract class PhysicsActor 117 public abstract class PhysicsActor
116 { 118 {
119// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
120
117 public delegate void RequestTerseUpdate(); 121 public delegate void RequestTerseUpdate();
118 public delegate void CollisionUpdate(EventArgs e); 122 public delegate void CollisionUpdate(EventArgs e);
119 public delegate void OutOfBounds(Vector3 pos); 123 public delegate void OutOfBounds(Vector3 pos);
@@ -197,10 +201,10 @@ namespace OpenSim.Region.Physics.Manager
197 { 201 {
198 CollisionUpdate handler = OnCollisionUpdate; 202 CollisionUpdate handler = OnCollisionUpdate;
199 203
204// m_log.DebugFormat("[PHYSICS ACTOR]: Sending collision for {0}", LocalID);
205
200 if (handler != null) 206 if (handler != null)
201 {
202 handler(e); 207 handler(e);
203 }
204 } 208 }
205 209
206 public virtual void SetMaterial (int material) 210 public virtual void SetMaterial (int material)
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 3630510..c37d588 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -108,7 +108,6 @@ namespace OpenSim.Region.Physics.OdePlugin
108 /// </summary> 108 /// </summary>
109 private Vector3 m_taintForce; 109 private Vector3 m_taintForce;
110 110
111 internal uint m_localID = 0;
112 // taints and their non-tainted counterparts 111 // taints and their non-tainted counterparts
113 private bool m_isPhysical = false; // the current physical status 112 private bool m_isPhysical = false; // the current physical status
114 private bool m_tainted_isPhysical = false; // set when the physical status is tainted (false=not existing in physics engine, true=existing) 113 private bool m_tainted_isPhysical = false; // set when the physical status is tainted (false=not existing in physics engine, true=existing)
@@ -231,11 +230,6 @@ namespace OpenSim.Region.Physics.OdePlugin
231 set { m_alwaysRun = value; } 230 set { m_alwaysRun = value; }
232 } 231 }
233 232
234 public override uint LocalID
235 {
236 set { m_localID = value; }
237 }
238
239 public override bool Grabbed 233 public override bool Grabbed
240 { 234 {
241 set { return; } 235 set { return; }
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index ffd6dc0..f07cf46 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -142,8 +142,6 @@ namespace OpenSim.Region.Physics.OdePlugin
142 public bool m_taintselected { get; private set; } 142 public bool m_taintselected { get; private set; }
143 public bool m_taintCollidesWater { get; private set; } 143 public bool m_taintCollidesWater { get; private set; }
144 144
145 public uint m_localID { get; private set; }
146
147 private bool m_taintforce = false; 145 private bool m_taintforce = false;
148 private bool m_taintaddangularforce = false; 146 private bool m_taintaddangularforce = false;
149 private Vector3 m_force; 147 private Vector3 m_force;
@@ -290,13 +288,6 @@ namespace OpenSim.Region.Physics.OdePlugin
290 set { return; } 288 set { return; }
291 } 289 }
292 290
293 public override uint LocalID
294 {
295 set {
296 //m_log.Info("[PHYSICS]: Setting TrackerID: " + value);
297 m_localID = value; }
298 }
299
300 public override bool Grabbed 291 public override bool Grabbed
301 { 292 {
302 set { return; } 293 set { return; }
@@ -1058,7 +1049,7 @@ Console.WriteLine("ZProcessTaints for " + Name);
1058 private void AddChildPrim(OdePrim prim) 1049 private void AddChildPrim(OdePrim prim)
1059 { 1050 {
1060//Console.WriteLine("AddChildPrim " + Name); 1051//Console.WriteLine("AddChildPrim " + Name);
1061 if (this.m_localID != prim.m_localID) 1052 if (LocalID != prim.LocalID)
1062 { 1053 {
1063 if (Body == IntPtr.Zero) 1054 if (Body == IntPtr.Zero)
1064 { 1055 {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
index 9d7aa94..7e3ec63 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs
@@ -378,12 +378,13 @@ namespace OpenSim.Region.Physics.OdePlugin
378 // Loop over contacts, build results. 378 // Loop over contacts, build results.
379 for (int i = 0; i < count; i++) 379 for (int i = 0; i < count; i++)
380 { 380 {
381 if (p1 != null) { 381 if (p1 != null)
382 {
382 if (p1 is OdePrim) 383 if (p1 is OdePrim)
383 { 384 {
384 ContactResult collisionresult = new ContactResult(); 385 ContactResult collisionresult = new ContactResult();
385 386
386 collisionresult.ConsumerID = ((OdePrim)p1).m_localID; 387 collisionresult.ConsumerID = p1.LocalID;
387 collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z); 388 collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z);
388 collisionresult.Depth = contacts[i].depth; 389 collisionresult.Depth = contacts[i].depth;
389 collisionresult.Normal = new Vector3(contacts[i].normal.X, contacts[i].normal.Y, 390 collisionresult.Normal = new Vector3(contacts[i].normal.X, contacts[i].normal.Y,
@@ -399,7 +400,7 @@ namespace OpenSim.Region.Physics.OdePlugin
399 { 400 {
400 ContactResult collisionresult = new ContactResult(); 401 ContactResult collisionresult = new ContactResult();
401 402
402 collisionresult.ConsumerID = ((OdePrim)p2).m_localID; 403 collisionresult.ConsumerID = p2.LocalID;
403 collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z); 404 collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z);
404 collisionresult.Depth = contacts[i].depth; 405 collisionresult.Depth = contacts[i].depth;
405 collisionresult.Normal = new Vector3(contacts[i].normal.X, contacts[i].normal.Y, 406 collisionresult.Normal = new Vector3(contacts[i].normal.X, contacts[i].normal.Y,
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index c3279c6..43d852b 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -219,9 +219,14 @@ namespace OpenSim.Region.Physics.OdePlugin
219 private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>(); 219 private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>();
220 220
221 /// <summary> 221 /// <summary>
222 /// A list of actors that should receive collision events. 222 /// A dictionary of actors that should receive collision events.
223 /// </summary> 223 /// </summary>
224 private readonly List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>(); 224 private readonly Dictionary<uint, PhysicsActor> _collisionEventPrim = new Dictionary<uint, PhysicsActor>();
225
226 /// <summary>
227 /// A dictionary of collision event changes that are waiting to be processed.
228 /// </summary>
229 private readonly Dictionary<uint, PhysicsActor> _collisionEventPrimChanges = new Dictionary<uint, PhysicsActor>();
225 230
226 private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>(); 231 private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
227 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); 232 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
@@ -1301,8 +1306,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1301 { 1306 {
1302 case ActorTypes.Agent: 1307 case ActorTypes.Agent:
1303 cc1 = (OdeCharacter)p1; 1308 cc1 = (OdeCharacter)p1;
1304 obj2LocalID = cc1.m_localID; 1309 obj2LocalID = cc1.LocalID;
1305 cc1.AddCollisionEvent(cc2.m_localID, contact); 1310 cc1.AddCollisionEvent(cc2.LocalID, contact);
1306 //ctype = (int)CollisionCategories.Character; 1311 //ctype = (int)CollisionCategories.Character;
1307 1312
1308 //if (cc1.CollidingObj) 1313 //if (cc1.CollidingObj)
@@ -1317,8 +1322,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1317 if (p1 is OdePrim) 1322 if (p1 is OdePrim)
1318 { 1323 {
1319 cp1 = (OdePrim) p1; 1324 cp1 = (OdePrim) p1;
1320 obj2LocalID = cp1.m_localID; 1325 obj2LocalID = cp1.LocalID;
1321 cp1.AddCollisionEvent(cc2.m_localID, contact); 1326 cp1.AddCollisionEvent(cc2.LocalID, contact);
1322 } 1327 }
1323 //ctype = (int)CollisionCategories.Geom; 1328 //ctype = (int)CollisionCategories.Geom;
1324 1329
@@ -1354,8 +1359,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1354 if (p1 is OdeCharacter) 1359 if (p1 is OdeCharacter)
1355 { 1360 {
1356 cc1 = (OdeCharacter) p1; 1361 cc1 = (OdeCharacter) p1;
1357 obj2LocalID = cc1.m_localID; 1362 obj2LocalID = cc1.LocalID;
1358 cc1.AddCollisionEvent(cp2.m_localID, contact); 1363 cc1.AddCollisionEvent(cp2.LocalID, contact);
1359 //ctype = (int)CollisionCategories.Character; 1364 //ctype = (int)CollisionCategories.Character;
1360 1365
1361 //if (cc1.CollidingObj) 1366 //if (cc1.CollidingObj)
@@ -1370,8 +1375,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1370 if (p1 is OdePrim) 1375 if (p1 is OdePrim)
1371 { 1376 {
1372 cp1 = (OdePrim) p1; 1377 cp1 = (OdePrim) p1;
1373 obj2LocalID = cp1.m_localID; 1378 obj2LocalID = cp1.LocalID;
1374 cp1.AddCollisionEvent(cp2.m_localID, contact); 1379 cp1.AddCollisionEvent(cp2.LocalID, contact);
1375 //ctype = (int)CollisionCategories.Geom; 1380 //ctype = (int)CollisionCategories.Geom;
1376 1381
1377 //if (cp1.CollidingObj) 1382 //if (cp1.CollidingObj)
@@ -1633,13 +1638,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1633 /// <param name="obj"></param> 1638 /// <param name="obj"></param>
1634 internal void AddCollisionEventReporting(PhysicsActor obj) 1639 internal void AddCollisionEventReporting(PhysicsActor obj)
1635 { 1640 {
1636// m_log.DebugFormat("[PHYSICS]: Adding {0} to collision event reporting", obj.SOPName); 1641// m_log.DebugFormat("[PHYSICS]: Adding {0} {1} to collision event reporting", obj.SOPName, obj.LocalID);
1637 1642
1638 lock (_collisionEventPrim) 1643 lock (_collisionEventPrimChanges)
1639 { 1644 _collisionEventPrimChanges[obj.LocalID] = obj;
1640 if (!_collisionEventPrim.Contains(obj))
1641 _collisionEventPrim.Add(obj);
1642 }
1643 } 1645 }
1644 1646
1645 /// <summary> 1647 /// <summary>
@@ -1648,10 +1650,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1648 /// <param name="obj"></param> 1650 /// <param name="obj"></param>
1649 internal void RemoveCollisionEventReporting(PhysicsActor obj) 1651 internal void RemoveCollisionEventReporting(PhysicsActor obj)
1650 { 1652 {
1651// m_log.DebugFormat("[PHYSICS]: Removing {0} from collision event reporting", obj.SOPName); 1653// m_log.DebugFormat("[PHYSICS]: Removing {0} {1} from collision event reporting", obj.SOPName, obj.LocalID);
1652 1654
1653 lock (_collisionEventPrim) 1655 lock (_collisionEventPrimChanges)
1654 _collisionEventPrim.Remove(obj); 1656 _collisionEventPrimChanges[obj.LocalID] = null;
1655 } 1657 }
1656 1658
1657 #region Add/Remove Entities 1659 #region Add/Remove Entities
@@ -1752,9 +1754,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1752 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 1754 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1753 Vector3 size, Quaternion rotation, bool isPhysical, uint localid) 1755 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
1754 { 1756 {
1755#if SPAM 1757// m_log.DebugFormat("[ODE SCENE]: Adding physics actor to {0} {1}", primName, localid);
1756 m_log.DebugFormat("[PHYSICS]: Adding physics actor to {0}", primName);
1757#endif
1758 1758
1759 return AddPrim(primName, position, size, rotation, pbs, isPhysical, localid); 1759 return AddPrim(primName, position, size, rotation, pbs, isPhysical, localid);
1760 } 1760 }
@@ -2663,6 +2663,22 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2663// m_physicsiterations = 10; 2663// m_physicsiterations = 10;
2664// } 2664// }
2665 2665
2666 // We change _collisionEventPrimChanges to avoid locking _collisionEventPrim itself and causing potential
2667 // deadlock if the collision event tries to lock something else later on which is already locked by a
2668 // caller that is adding or removing the collision event.
2669 lock (_collisionEventPrimChanges)
2670 {
2671 foreach (KeyValuePair<uint, PhysicsActor> kvp in _collisionEventPrimChanges)
2672 {
2673 if (kvp.Value == null)
2674 _collisionEventPrim.Remove(kvp.Key);
2675 else
2676 _collisionEventPrim[kvp.Key] = kvp.Value;
2677 }
2678
2679 _collisionEventPrimChanges.Clear();
2680 }
2681
2666 if (SupportsNINJAJoints) 2682 if (SupportsNINJAJoints)
2667 { 2683 {
2668 DeleteRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks 2684 DeleteRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks
@@ -2790,25 +2806,22 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2790 2806
2791 collision_optimized(); 2807 collision_optimized();
2792 2808
2793 lock (_collisionEventPrim) 2809 foreach (PhysicsActor obj in _collisionEventPrim.Values)
2794 { 2810 {
2795 foreach (PhysicsActor obj in _collisionEventPrim) 2811// m_log.DebugFormat("[PHYSICS]: Assessing {0} {1} for collision events", obj.SOPName, obj.LocalID);
2796 {
2797// m_log.DebugFormat("[PHYSICS]: Assessing {0} for collision events", obj.SOPName);
2798 2812
2799 switch ((ActorTypes)obj.PhysicsActorType) 2813 switch ((ActorTypes)obj.PhysicsActorType)
2800 { 2814 {
2801 case ActorTypes.Agent: 2815 case ActorTypes.Agent:
2802 OdeCharacter cobj = (OdeCharacter)obj; 2816 OdeCharacter cobj = (OdeCharacter)obj;
2803 cobj.AddCollisionFrameTime(100); 2817 cobj.AddCollisionFrameTime(100);
2804 cobj.SendCollisions(); 2818 cobj.SendCollisions();
2805 break; 2819 break;
2806 2820
2807 case ActorTypes.Prim: 2821 case ActorTypes.Prim:
2808 OdePrim pobj = (OdePrim)obj; 2822 OdePrim pobj = (OdePrim)obj;
2809 pobj.SendCollisions(); 2823 pobj.SendCollisions();
2810 break; 2824 break;
2811 }
2812 } 2825 }
2813 } 2826 }
2814 2827
@@ -3731,7 +3744,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
3731 { 3744 {
3732 if (prm.CollisionScore > 0) 3745 if (prm.CollisionScore > 0)
3733 { 3746 {
3734 returncolliders.Add(prm.m_localID, prm.CollisionScore); 3747 returncolliders.Add(prm.LocalID, prm.CollisionScore);
3735 cnt++; 3748 cnt++;
3736 prm.CollisionScore = 0f; 3749 prm.CollisionScore = 0f;
3737 if (cnt > 25) 3750 if (cnt > 25)
diff --git a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
index 2ea810f..cbc6b95 100644
--- a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
+++ b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
@@ -104,7 +104,7 @@ namespace OpenSim.Region.Physics.OdePlugin.Tests
104 m_log.Info("TargetSpace: " + oprim.m_targetSpace + " - SceneMainSpace: " + pscene.space); 104 m_log.Info("TargetSpace: " + oprim.m_targetSpace + " - SceneMainSpace: " + pscene.space);
105 105
106 Assert.That(!oprim.m_taintadd); 106 Assert.That(!oprim.m_taintadd);
107 m_log.Info("Prim Position (" + oprim.m_localID + "): " + prim.Position.ToString()); 107 m_log.Info("Prim Position (" + oprim.LocalID + "): " + prim.Position);
108 108
109 // Make sure we're above the ground 109 // Make sure we're above the ground
110 //Assert.That(prim.Position.Z > 20f); 110 //Assert.That(prim.Position.Z > 20f);