aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs70
1 files changed, 36 insertions, 34 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 11638d7..0f341b9 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -247,6 +247,7 @@ namespace OpenSim.Region.Physics.OdePlugin
247 /// A list of actors that should receive collision events. 247 /// A list of actors that should receive collision events.
248 /// </summary> 248 /// </summary>
249 private readonly List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>(); 249 private readonly List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>();
250 private readonly List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>();
250 251
251 private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>(); 252 private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
252 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); 253 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
@@ -1073,6 +1074,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1073 if (!(p2events || p1events)) 1074 if (!(p2events || p1events))
1074 return; 1075 return;
1075 1076
1077 if (p1events)
1078 AddCollisionEventReporting(p1);
1079
1080 if (p2events)
1081 AddCollisionEventReporting(p2);
1082
1076 Vector3 vel = Vector3.Zero; 1083 Vector3 vel = Vector3.Zero;
1077 if (p2 != null && p2.IsPhysical) 1084 if (p2 != null && p2.IsPhysical)
1078 vel = p2.Velocity; 1085 vel = p2.Velocity;
@@ -1255,20 +1262,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1255 } 1262 }
1256 1263
1257 #endregion 1264 #endregion
1258
1259
1260
1261 /// <summary> 1265 /// <summary>
1262 /// Add actor to the list that should receive collision events in the simulate loop. 1266 /// Add actor to the list that should receive collision events in the simulate loop.
1263 /// </summary> 1267 /// </summary>
1264 /// <param name="obj"></param> 1268 /// <param name="obj"></param>
1265 public void AddCollisionEventReporting(PhysicsActor obj) 1269 public void AddCollisionEventReporting(PhysicsActor obj)
1266 { 1270 {
1267 lock (_collisionEventPrim) 1271 if (!_collisionEventPrim.Contains(obj))
1268 { 1272 _collisionEventPrim.Add(obj);
1269 if (!_collisionEventPrim.Contains(obj))
1270 _collisionEventPrim.Add(obj);
1271 }
1272 } 1273 }
1273 1274
1274 /// <summary> 1275 /// <summary>
@@ -1277,13 +1278,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1277 /// <param name="obj"></param> 1278 /// <param name="obj"></param>
1278 public void RemoveCollisionEventReporting(PhysicsActor obj) 1279 public void RemoveCollisionEventReporting(PhysicsActor obj)
1279 { 1280 {
1280 lock (_collisionEventPrim) 1281 if (_collisionEventPrim.Contains(obj) && !_collisionEventPrimRemove.Contains(obj))
1281 { 1282 _collisionEventPrimRemove.Add(obj);
1282 if (_collisionEventPrim.Contains(obj))
1283 _collisionEventPrim.Remove(obj);
1284 }
1285 } 1283 }
1286 1284
1285
1287 #region Add/Remove Entities 1286 #region Add/Remove Entities
1288 1287
1289 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) 1288 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
@@ -1472,6 +1471,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1472 { 1471 {
1473// lock (OdeLock) 1472// lock (OdeLock)
1474 { 1473 {
1474
1475 OdePrim p = (OdePrim)prim; 1475 OdePrim p = (OdePrim)prim;
1476 p.setPrimForRemoval(); 1476 p.setPrimForRemoval();
1477 } 1477 }
@@ -1890,33 +1890,35 @@ namespace OpenSim.Region.Physics.OdePlugin
1890 1890
1891 collision_optimized(); 1891 collision_optimized();
1892 1892
1893 lock (_collisionEventPrim) 1893 foreach (PhysicsActor obj in _collisionEventPrim)
1894 { 1894 {
1895 foreach (PhysicsActor obj in _collisionEventPrim) 1895 if (obj == null)
1896 continue;
1897
1898 switch ((ActorTypes)obj.PhysicsActorType)
1896 { 1899 {
1897 if (obj == null) 1900 case ActorTypes.Agent:
1898 continue; 1901 OdeCharacter cobj = (OdeCharacter)obj;
1902 cobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f));
1903 cobj.SendCollisions();
1904 break;
1899 1905
1900 switch ((ActorTypes)obj.PhysicsActorType) 1906 case ActorTypes.Prim:
1901 { 1907 OdePrim pobj = (OdePrim)obj;
1902 case ActorTypes.Agent: 1908 if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds))
1903 OdeCharacter cobj = (OdeCharacter)obj; 1909 {
1904 cobj.AddCollisionFrameTime((int)(ODE_STEPSIZE*1000.0f)); 1910 pobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f));
1905 cobj.SendCollisions(); 1911 pobj.SendCollisions();
1906 break; 1912 }
1907 1913 break;
1908 case ActorTypes.Prim:
1909 OdePrim pobj = (OdePrim)obj;
1910 if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds))
1911 {
1912 pobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f));
1913 pobj.SendCollisions();
1914 }
1915 break;
1916 }
1917 } 1914 }
1918 } 1915 }
1919 1916
1917 foreach (PhysicsActor obj in _collisionEventPrimRemove)
1918 _collisionEventPrim.Remove(obj);
1919
1920 _collisionEventPrimRemove.Clear();
1921
1920 // do a ode simulation step 1922 // do a ode simulation step
1921 d.WorldQuickStep(world, ODE_STEPSIZE); 1923 d.WorldQuickStep(world, ODE_STEPSIZE);
1922 d.JointGroupEmpty(contactgroup); 1924 d.JointGroupEmpty(contactgroup);