aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs13
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs38
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs42
3 files changed, 62 insertions, 31 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
index 49020e9..cef7063 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
@@ -1578,6 +1578,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1578 } 1578 }
1579 } 1579 }
1580 m_eventsubscription = 0; 1580 m_eventsubscription = 0;
1581 _parent_scene.RemoveCollisionEventReporting(this);
1581 } 1582 }
1582 1583
1583 public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact) 1584 public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
@@ -1591,8 +1592,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1591 } 1592 }
1592 } 1593 }
1593 1594
1594 public void SendCollisions() 1595 public void SendCollisions(int timestep)
1595 { 1596 {
1597 if (m_cureventsubscription < 50000)
1598 m_cureventsubscription += timestep;
1599
1596 if (CollisionEventsThisFrame == null) 1600 if (CollisionEventsThisFrame == null)
1597 return; 1601 return;
1598 1602
@@ -1623,13 +1627,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1623 } 1627 }
1624 } 1628 }
1625 1629
1626 internal void AddCollisionFrameTime(int t)
1627 {
1628 // protect it from overflow crashing
1629 if (m_cureventsubscription < 50000)
1630 m_cureventsubscription += t;
1631 }
1632
1633 public override bool SubscribedEvents() 1630 public override bool SubscribedEvents()
1634 { 1631 {
1635 if (m_eventsubscription > 0) 1632 if (m_eventsubscription > 0)
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
index ebaa875..9f62644 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
65 internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively 65 internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
66 private bool m_fakeisVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively 66 private bool m_fakeisVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
67 67
68 protected bool m_building; 68 internal bool m_building;
69 protected bool m_forcePosOrRotation; 69 protected bool m_forcePosOrRotation;
70 private bool m_iscolliding; 70 private bool m_iscolliding;
71 71
@@ -1000,14 +1000,36 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1000 1000
1001 public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact) 1001 public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
1002 { 1002 {
1003
1003 if (CollisionEventsThisFrame == null) 1004 if (CollisionEventsThisFrame == null)
1004 CollisionEventsThisFrame = new CollisionEventUpdate(); 1005 CollisionEventsThisFrame = new CollisionEventUpdate();
1005// if(CollisionEventsThisFrame.Count < 32) 1006 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
1006 CollisionEventsThisFrame.AddCollider(CollidedWith, contact); 1007 _parent_scene.AddCollisionEventReporting(this);
1008 }
1009
1010 internal void SleeperAddCollisionEvents()
1011 {
1012 if (CollisionEventsThisFrame == null)
1013 return;
1014 if(CollisionEventsThisFrame.m_objCollisionList.Count == 0)
1015 return;
1016 foreach(KeyValuePair<uint,ContactPoint> kvp in CollisionEventsThisFrame.m_objCollisionList)
1017 {
1018 OdePrim other = _parent_scene.getPrim(kvp.Key);
1019 if(other == null)
1020 continue;
1021 ContactPoint cp = kvp.Value;
1022 cp.SurfaceNormal = - cp.SurfaceNormal;
1023 cp.RelativeSpeed = -cp.RelativeSpeed;
1024 other.AddCollisionEvent(ParentActor.LocalID,cp);
1025 }
1007 } 1026 }
1008 1027
1009 public void SendCollisions() 1028 public void SendCollisions(int timestep)
1010 { 1029 {
1030 if (m_cureventsubscription < 50000)
1031 m_cureventsubscription += timestep;
1032
1011 if (CollisionEventsThisFrame == null) 1033 if (CollisionEventsThisFrame == null)
1012 return; 1034 return;
1013 1035
@@ -1027,7 +1049,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1027 SentEmptyCollisionsEvent = true; 1049 SentEmptyCollisionsEvent = true;
1028 _parent_scene.RemoveCollisionEventReporting(this); 1050 _parent_scene.RemoveCollisionEventReporting(this);
1029 } 1051 }
1030 else 1052 else if(Body == IntPtr.Zero || d.BodyIsEnabled(Body))
1031 { 1053 {
1032 SentEmptyCollisionsEvent = false; 1054 SentEmptyCollisionsEvent = false;
1033 CollisionEventsThisFrame.Clear(); 1055 CollisionEventsThisFrame.Clear();
@@ -1035,12 +1057,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1035 } 1057 }
1036 } 1058 }
1037 1059
1038 internal void AddCollisionFrameTime(int t)
1039 {
1040 if (m_cureventsubscription < 50000)
1041 m_cureventsubscription += t;
1042 }
1043
1044 public override bool SubscribedEvents() 1060 public override bool SubscribedEvents()
1045 { 1061 {
1046 if (m_eventsubscription > 0) 1062 if (m_eventsubscription > 0)
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
index 8d87c30..6c5b405 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
@@ -228,8 +228,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
228 228
229 private d.NearCallback nearCallback; 229 private d.NearCallback nearCallback;
230 230
231 private Dictionary<uint,OdePrim> _prims = new Dictionary<uint,OdePrim>();
231 private HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); 232 private HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
232 private HashSet<OdePrim> _prims = new HashSet<OdePrim>();
233 private HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); 233 private HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
234 private HashSet<OdePrim> _activegroups = new HashSet<OdePrim>(); 234 private HashSet<OdePrim> _activegroups = new HashSet<OdePrim>();
235 235
@@ -1329,7 +1329,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1329 1329
1330 newPrim = new OdePrim(name, this, position, size, rotation, pbs, isphysical, isPhantom, shapeType, localID); 1330 newPrim = new OdePrim(name, this, position, size, rotation, pbs, isphysical, isPhantom, shapeType, localID);
1331 lock (_prims) 1331 lock (_prims)
1332 _prims.Add(newPrim); 1332 _prims[newPrim.LocalID] = newPrim;
1333 } 1333 }
1334 return newPrim; 1334 return newPrim;
1335 } 1335 }
@@ -1391,15 +1391,26 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1391 { 1391 {
1392// RemoveCollisionEventReporting(prim); 1392// RemoveCollisionEventReporting(prim);
1393 lock (_prims) 1393 lock (_prims)
1394 _prims.Remove(prim); 1394 _prims.Remove(prim.LocalID);
1395 } 1395 }
1396 1396
1397 } 1397 }
1398 1398
1399 public OdePrim getPrim(uint id)
1400 {
1401 lock (_prims)
1402 {
1403 if(_prims.ContainsKey(id))
1404 return _prims[id];
1405 else
1406 return null;
1407 }
1408 }
1409
1399 public bool havePrim(OdePrim prm) 1410 public bool havePrim(OdePrim prm)
1400 { 1411 {
1401 lock (_prims) 1412 lock (_prims)
1402 return _prims.Contains(prm); 1413 return _prims.ContainsKey(prm.LocalID);
1403 } 1414 }
1404 1415
1405 public bool haveActor(PhysicsActor actor) 1416 public bool haveActor(PhysicsActor actor)
@@ -1407,7 +1418,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1407 if (actor is OdePrim) 1418 if (actor is OdePrim)
1408 { 1419 {
1409 lock (_prims) 1420 lock (_prims)
1410 return _prims.Contains((OdePrim)actor); 1421 return _prims.ContainsKey(((OdePrim)actor).LocalID);
1411 } 1422 }
1412 else if (actor is OdeCharacter) 1423 else if (actor is OdeCharacter)
1413 { 1424 {
@@ -1708,6 +1719,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1708 m_rayCastManager.ProcessQueuedRequests(); 1719 m_rayCastManager.ProcessQueuedRequests();
1709 1720
1710 collision_optimized(); 1721 collision_optimized();
1722 List<OdePrim> sleepers = new List<OdePrim>();
1711 1723
1712 foreach (PhysicsActor obj in _collisionEventPrim) 1724 foreach (PhysicsActor obj in _collisionEventPrim)
1713 { 1725 {
@@ -1718,21 +1730,27 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1718 { 1730 {
1719 case ActorTypes.Agent: 1731 case ActorTypes.Agent:
1720 OdeCharacter cobj = (OdeCharacter)obj; 1732 OdeCharacter cobj = (OdeCharacter)obj;
1721 cobj.AddCollisionFrameTime((int)(odetimestepMS)); 1733 cobj.SendCollisions((int)(odetimestepMS));
1722 cobj.SendCollisions();
1723 break; 1734 break;
1724 1735
1725 case ActorTypes.Prim: 1736 case ActorTypes.Prim:
1726 OdePrim pobj = (OdePrim)obj; 1737 OdePrim pobj = (OdePrim)obj;
1727 if (!pobj.m_outbounds && (pobj.Body == IntPtr.Zero || d.BodyIsEnabled(pobj.Body))) 1738 if (!pobj.m_outbounds)
1728 { 1739 {
1729 pobj.AddCollisionFrameTime((int)(odetimestepMS)); 1740 pobj.SendCollisions((int)(odetimestepMS));
1730 pobj.SendCollisions(); 1741 if(pobj.Body != IntPtr.Zero && !pobj.m_isSelected &&
1742 !pobj.m_disabled && !pobj.m_building &&
1743 !d.BodyIsEnabled(pobj.Body))
1744 sleepers.Add(pobj);
1731 } 1745 }
1732 break; 1746 break;
1733 } 1747 }
1734 } 1748 }
1735 1749
1750 foreach(OdePrim prm in sleepers)
1751 prm.SleeperAddCollisionEvents();
1752 sleepers.Clear();
1753
1736 foreach (PhysicsActor obj in _collisionEventPrimRemove) 1754 foreach (PhysicsActor obj in _collisionEventPrimRemove)
1737 _collisionEventPrim.Remove(obj); 1755 _collisionEventPrim.Remove(obj);
1738 1756
@@ -2481,7 +2499,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2481 lock (_prims) 2499 lock (_prims)
2482 { 2500 {
2483 ChangesQueue.Clear(); 2501 ChangesQueue.Clear();
2484 foreach (OdePrim prm in _prims) 2502 foreach (OdePrim prm in _prims.Values)
2485 { 2503 {
2486 prm.DoAChange(changes.Remove, null); 2504 prm.DoAChange(changes.Remove, null);
2487 _collisionEventPrim.Remove(prm); 2505 _collisionEventPrim.Remove(prm);
@@ -2544,7 +2562,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2544 int cnt = 0; 2562 int cnt = 0;
2545 lock (_prims) 2563 lock (_prims)
2546 { 2564 {
2547 foreach (OdePrim prm in _prims) 2565 foreach (OdePrim prm in _prims.Values)
2548 { 2566 {
2549 if (prm.CollisionScore > 0) 2567 if (prm.CollisionScore > 0)
2550 { 2568 {