aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorMelanie2011-10-26 17:55:53 +0200
committerMelanie2011-10-26 17:55:53 +0200
commitc763419043773c93dbbc865ec35f7ecf856a641a (patch)
treeac9f99c33ae788e6b7fdfd0843c2ae584a896dc6 /OpenSim/Region/Physics
parentFix a missing locking call (diff)
parentMerge branch 'master' into bigmerge (diff)
downloadopensim-SC-c763419043773c93dbbc865ec35f7ecf856a641a.zip
opensim-SC-c763419043773c93dbbc865ec35f7ecf856a641a.tar.gz
opensim-SC-c763419043773c93dbbc865ec35f7ecf856a641a.tar.bz2
opensim-SC-c763419043773c93dbbc865ec35f7ecf856a641a.tar.xz
Merge branch 'bigmerge' of ssh://3dhosting.de/var/git/careminster into bigmerge
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs2
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs2
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs2
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs47
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs12
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs18
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs17
8 files changed, 47 insertions, 55 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 682eb80..9a6857b 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -443,7 +443,7 @@ public class BSCharacter : PhysicsActor
443 443
444 Dictionary<uint, ContactPoint> contactPoints = new Dictionary<uint, ContactPoint>(); 444 Dictionary<uint, ContactPoint> contactPoints = new Dictionary<uint, ContactPoint>();
445 contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); 445 contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
446 CollisionEventUpdate args = new CollisionEventUpdate(LocalID, (int)type, 1, contactPoints); 446 CollisionEventUpdate args = new CollisionEventUpdate(contactPoints);
447 base.SendCollisionUpdate(args); 447 base.SendCollisionUpdate(args);
448 } 448 }
449 449
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index bb8d601..8782e62 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -1350,7 +1350,7 @@ public sealed class BSPrim : PhysicsActor
1350 // create the event for the collision 1350 // create the event for the collision
1351 Dictionary<uint, ContactPoint> contactPoints = new Dictionary<uint, ContactPoint>(); 1351 Dictionary<uint, ContactPoint> contactPoints = new Dictionary<uint, ContactPoint>();
1352 contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); 1352 contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
1353 CollisionEventUpdate args = new CollisionEventUpdate(LocalID, (int)type, 1, contactPoints); 1353 CollisionEventUpdate args = new CollisionEventUpdate(contactPoints);
1354 base.SendCollisionUpdate(args); 1354 base.SendCollisionUpdate(args);
1355 } 1355 }
1356} 1356}
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
index 1bce760..58e2e4c 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs
@@ -1299,7 +1299,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1299 { 1299 {
1300 if (m_eventsubscription > 0) 1300 if (m_eventsubscription > 0)
1301 { 1301 {
1302 CollisionEventsThisFrame.addCollider(CollidedWith, contact); 1302 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
1303 } 1303 }
1304 } 1304 }
1305 1305
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
index 82f1b94..5f802d0 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -2438,7 +2438,7 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!");
2438 { 2438 {
2439 if (CollisionEventsThisFrame == null) 2439 if (CollisionEventsThisFrame == null)
2440 CollisionEventsThisFrame = new CollisionEventUpdate(); 2440 CollisionEventsThisFrame = new CollisionEventUpdate();
2441 CollisionEventsThisFrame.addCollider(CollidedWith, contact); 2441 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
2442 } 2442 }
2443 2443
2444 public void SendCollisions() 2444 public void SendCollisions()
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 96dcfb6..362f997 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -66,42 +66,29 @@ namespace OpenSim.Region.Physics.Manager
66 } 66 }
67 } 67 }
68 68
69 /// <summary>
70 /// Used to pass collision information to OnCollisionUpdate listeners.
71 /// </summary>
69 public class CollisionEventUpdate : EventArgs 72 public class CollisionEventUpdate : EventArgs
70 { 73 {
71 // Raising the event on the object, so don't need to provide location.. further up the tree knows that info. 74 /// <summary>
75 /// Number of collision events in this update.
76 /// </summary>
77 public int Count { get { return m_objCollisionList.Count; } }
72 78
73 public int m_colliderType; 79 public Dictionary<uint, ContactPoint> m_objCollisionList;
74 public int m_GenericStartEnd;
75 //public uint m_LocalID;
76 public Dictionary<uint, ContactPoint> m_objCollisionList = new Dictionary<uint, ContactPoint>();
77 80
78 public CollisionEventUpdate(uint localID, int colliderType, int GenericStartEnd, Dictionary<uint, ContactPoint> objCollisionList) 81 public CollisionEventUpdate(Dictionary<uint, ContactPoint> objCollisionList)
79 { 82 {
80 m_colliderType = colliderType;
81 m_GenericStartEnd = GenericStartEnd;
82 m_objCollisionList = objCollisionList; 83 m_objCollisionList = objCollisionList;
83 } 84 }
84 85
85 public CollisionEventUpdate() 86 public CollisionEventUpdate()
86 { 87 {
87 m_colliderType = (int) ActorTypes.Unknown;
88 m_GenericStartEnd = 1;
89 m_objCollisionList = new Dictionary<uint, ContactPoint>(); 88 m_objCollisionList = new Dictionary<uint, ContactPoint>();
90 } 89 }
91 90
92 public int collidertype 91 public void AddCollider(uint localID, ContactPoint contact)
93 {
94 get { return m_colliderType; }
95 set { m_colliderType = value; }
96 }
97
98 public int GenericStartEnd
99 {
100 get { return m_GenericStartEnd; }
101 set { m_GenericStartEnd = value; }
102 }
103
104 public void addCollider(uint localID, ContactPoint contact)
105 { 92 {
106 if (!m_objCollisionList.ContainsKey(localID)) 93 if (!m_objCollisionList.ContainsKey(localID))
107 { 94 {
@@ -113,6 +100,14 @@ namespace OpenSim.Region.Physics.Manager
113 m_objCollisionList[localID] = contact; 100 m_objCollisionList[localID] = contact;
114 } 101 }
115 } 102 }
103
104 /// <summary>
105 /// Clear added collision events.
106 /// </summary>
107 public void Clear()
108 {
109 m_objCollisionList.Clear();
110 }
116 } 111 }
117 112
118 public abstract class PhysicsActor 113 public abstract class PhysicsActor
@@ -127,7 +122,13 @@ namespace OpenSim.Region.Physics.Manager
127 public event VelocityUpdate OnVelocityUpdate; 122 public event VelocityUpdate OnVelocityUpdate;
128 public event OrientationUpdate OnOrientationUpdate; 123 public event OrientationUpdate OnOrientationUpdate;
129 public event RequestTerseUpdate OnRequestTerseUpdate; 124 public event RequestTerseUpdate OnRequestTerseUpdate;
125
126 /// <summary>
127 /// Subscribers to this event must synchronously handle the dictionary of collisions received, since the event
128 /// object is reused in subsequent physics frames.
129 /// </summary>
130 public event CollisionUpdate OnCollisionUpdate; 130 public event CollisionUpdate OnCollisionUpdate;
131
131 public event OutOfBounds OnOutOfBounds; 132 public event OutOfBounds OnOutOfBounds;
132#pragma warning restore 67 133#pragma warning restore 67
133 134
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index e9bab66..c22d27f 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -1210,11 +1210,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1210 { 1210 {
1211 m_requestedUpdateFrequency = ms; 1211 m_requestedUpdateFrequency = ms;
1212 m_eventsubscription = ms; 1212 m_eventsubscription = ms;
1213 CollisionEventsThisFrame.Clear();
1213 _parent_scene.AddCollisionEventReporting(this); 1214 _parent_scene.AddCollisionEventReporting(this);
1214 } 1215 }
1215 1216
1216 public override void UnSubscribeEvents() 1217 public override void UnSubscribeEvents()
1217 { 1218 {
1219 CollisionEventsThisFrame.Clear();
1218 _parent_scene.RemoveCollisionEventReporting(this); 1220 _parent_scene.RemoveCollisionEventReporting(this);
1219 m_requestedUpdateFrequency = 0; 1221 m_requestedUpdateFrequency = 0;
1220 m_eventsubscription = 0; 1222 m_eventsubscription = 0;
@@ -1227,7 +1229,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1227// m_log.DebugFormat( 1229// m_log.DebugFormat(
1228// "[PHYSICS]: Adding collision event for {0}, collidedWith {1}, contact {2}", "", CollidedWith, contact); 1230// "[PHYSICS]: Adding collision event for {0}, collidedWith {1}, contact {2}", "", CollidedWith, contact);
1229 1231
1230 CollisionEventsThisFrame.addCollider(CollidedWith, contact); 1232 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
1231 } 1233 }
1232 } 1234 }
1233 1235
@@ -1235,11 +1237,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1235 { 1237 {
1236 if (m_eventsubscription > m_requestedUpdateFrequency) 1238 if (m_eventsubscription > m_requestedUpdateFrequency)
1237 { 1239 {
1238 if (CollisionEventsThisFrame != null) 1240 base.SendCollisionUpdate(CollisionEventsThisFrame);
1239 { 1241
1240 base.SendCollisionUpdate(CollisionEventsThisFrame); 1242 CollisionEventsThisFrame.Clear();
1241 }
1242 CollisionEventsThisFrame = new CollisionEventUpdate();
1243 m_eventsubscription = 0; 1243 m_eventsubscription = 0;
1244 } 1244 }
1245 } 1245 }
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 6638cbd..3a17511 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -191,7 +191,7 @@ namespace OpenSim.Region.Physics.OdePlugin
191 private d.Mass pMass; 191 private d.Mass pMass;
192 192
193 private int m_eventsubscription; 193 private int m_eventsubscription;
194 private CollisionEventUpdate CollisionEventsThisFrame; 194 private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
195 195
196 private IntPtr m_linkJoint = IntPtr.Zero; 196 private IntPtr m_linkJoint = IntPtr.Zero;
197 197
@@ -3020,23 +3020,13 @@ Console.WriteLine(" JointCreateFixed");
3020 3020
3021 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) 3021 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
3022 { 3022 {
3023 if (CollisionEventsThisFrame == null) 3023 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
3024 CollisionEventsThisFrame = new CollisionEventUpdate();
3025
3026 CollisionEventsThisFrame.addCollider(CollidedWith, contact);
3027 } 3024 }
3028 3025
3029 public void SendCollisions() 3026 public void SendCollisions()
3030 { 3027 {
3031 if (CollisionEventsThisFrame == null) 3028 if (CollisionEventsThisFrame.Count > 0)
3032 return; 3029 base.SendCollisionUpdate(CollisionEventsThisFrame);
3033
3034 base.SendCollisionUpdate(CollisionEventsThisFrame);
3035
3036 if (CollisionEventsThisFrame.m_objCollisionList.Count == 0)
3037 CollisionEventsThisFrame = null;
3038 else
3039 CollisionEventsThisFrame = new CollisionEventUpdate();
3040 } 3030 }
3041 3031
3042 public override bool SubscribedEvents() 3032 public override bool SubscribedEvents()
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 0810ae0..c3279c6 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -1633,6 +1633,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1633 /// <param name="obj"></param> 1633 /// <param name="obj"></param>
1634 internal void AddCollisionEventReporting(PhysicsActor obj) 1634 internal void AddCollisionEventReporting(PhysicsActor obj)
1635 { 1635 {
1636// m_log.DebugFormat("[PHYSICS]: Adding {0} to collision event reporting", obj.SOPName);
1637
1636 lock (_collisionEventPrim) 1638 lock (_collisionEventPrim)
1637 { 1639 {
1638 if (!_collisionEventPrim.Contains(obj)) 1640 if (!_collisionEventPrim.Contains(obj))
@@ -1646,11 +1648,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1646 /// <param name="obj"></param> 1648 /// <param name="obj"></param>
1647 internal void RemoveCollisionEventReporting(PhysicsActor obj) 1649 internal void RemoveCollisionEventReporting(PhysicsActor obj)
1648 { 1650 {
1651// m_log.DebugFormat("[PHYSICS]: Removing {0} from collision event reporting", obj.SOPName);
1652
1649 lock (_collisionEventPrim) 1653 lock (_collisionEventPrim)
1650 { 1654 _collisionEventPrim.Remove(obj);
1651 if (!_collisionEventPrim.Contains(obj))
1652 _collisionEventPrim.Remove(obj);
1653 }
1654 } 1655 }
1655 1656
1656 #region Add/Remove Entities 1657 #region Add/Remove Entities
@@ -2859,14 +2860,14 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2859 { 2860 {
2860 //if (timeStep < 0.2f) 2861 //if (timeStep < 0.2f)
2861 { 2862 {
2862 foreach (OdePrim actor in _activeprims) 2863 foreach (OdePrim prim in _activeprims)
2863 { 2864 {
2864 if (actor.IsPhysical && (d.BodyIsEnabled(actor.Body) || !actor._zeroFlag)) 2865 if (prim.IsPhysical && (d.BodyIsEnabled(prim.Body) || !prim._zeroFlag))
2865 { 2866 {
2866 actor.UpdatePositionAndVelocity(); 2867 prim.UpdatePositionAndVelocity();
2867 2868
2868 if (SupportsNINJAJoints) 2869 if (SupportsNINJAJoints)
2869 SimulateActorPendingJoints(actor); 2870 SimulateActorPendingJoints(prim);
2870 } 2871 }
2871 } 2872 }
2872 } 2873 }