aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs99
1 files changed, 46 insertions, 53 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 89568b6..d1c1c25 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -193,8 +193,15 @@ namespace OpenSim.Region.Physics.OdePlugin
193 /// Avatars in the physics scene. 193 /// Avatars in the physics scene.
194 /// </summary> 194 /// </summary>
195 private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); 195 private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
196 196
197 /// <summary>
198 /// Prims in the physics scene.
199 /// </summary>
197 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); 200 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>();
201
202 /// <summary>
203 /// Prims in the physics scene that are subject to physics, not just collisions.
204 /// </summary>
198 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); 205 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
199 206
200 /// <summary> 207 /// <summary>
@@ -1565,45 +1572,42 @@ namespace OpenSim.Region.Physics.OdePlugin
1565 //} 1572 //}
1566 } 1573 }
1567 1574
1568 lock (_activeprims) 1575 List<OdePrim> removeprims = null;
1576 foreach (OdePrim chr in _activeprims)
1569 { 1577 {
1570 List<OdePrim> removeprims = null; 1578 if (chr.Body != IntPtr.Zero && d.BodyIsEnabled(chr.Body) && (!chr.m_disabled))
1571 foreach (OdePrim chr in _activeprims)
1572 { 1579 {
1573 if (chr.Body != IntPtr.Zero && d.BodyIsEnabled(chr.Body) && (!chr.m_disabled)) 1580 try
1574 { 1581 {
1575 try 1582 lock (chr)
1576 { 1583 {
1577 lock (chr) 1584 if (space != IntPtr.Zero && chr.prim_geom != IntPtr.Zero && chr.m_taintremove == false)
1578 { 1585 {
1579 if (space != IntPtr.Zero && chr.prim_geom != IntPtr.Zero && chr.m_taintremove == false) 1586 d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback);
1580 { 1587 }
1581 d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback); 1588 else
1582 } 1589 {
1583 else 1590 if (removeprims == null)
1584 { 1591 {
1585 if (removeprims == null) 1592 removeprims = new List<OdePrim>();
1586 {
1587 removeprims = new List<OdePrim>();
1588 }
1589 removeprims.Add(chr);
1590 m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed. Removed it from the active prim list. This needs to be fixed!");
1591 } 1593 }
1594 removeprims.Add(chr);
1595 m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed. Removed it from the active prim list. This needs to be fixed!");
1592 } 1596 }
1593 } 1597 }
1594 catch (AccessViolationException) 1598 }
1595 { 1599 catch (AccessViolationException)
1596 m_log.Warn("[PHYSICS]: Unable to space collide"); 1600 {
1597 } 1601 m_log.Warn("[PHYSICS]: Unable to space collide");
1598 } 1602 }
1599 } 1603 }
1604 }
1600 1605
1601 if (removeprims != null) 1606 if (removeprims != null)
1607 {
1608 foreach (OdePrim chr in removeprims)
1602 { 1609 {
1603 foreach (OdePrim chr in removeprims) 1610 _activeprims.Remove(chr);
1604 {
1605 _activeprims.Remove(chr);
1606 }
1607 } 1611 }
1608 } 1612 }
1609 } 1613 }
@@ -1770,13 +1774,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1770 internal void ActivatePrim(OdePrim prim) 1774 internal void ActivatePrim(OdePrim prim)
1771 { 1775 {
1772 // adds active prim.. (ones that should be iterated over in collisions_optimized 1776 // adds active prim.. (ones that should be iterated over in collisions_optimized
1773 lock (_activeprims) 1777 if (!_activeprims.Contains(prim))
1774 { 1778 _activeprims.Add(prim);
1775 if (!_activeprims.Contains(prim)) 1779 //else
1776 _activeprims.Add(prim); 1780 // m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent");
1777 //else
1778 // m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent");
1779 }
1780 } 1781 }
1781 1782
1782 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 1783 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
@@ -2150,8 +2151,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2150 /// <param name="prim"></param> 2151 /// <param name="prim"></param>
2151 internal void DeactivatePrim(OdePrim prim) 2152 internal void DeactivatePrim(OdePrim prim)
2152 { 2153 {
2153 lock (_activeprims) 2154 _activeprims.Remove(prim);
2154 _activeprims.Remove(prim);
2155 } 2155 }
2156 2156
2157 public override void RemovePrim(PhysicsActor prim) 2157 public override void RemovePrim(PhysicsActor prim)
@@ -2818,13 +2818,10 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2818 } 2818 }
2819 2819
2820 // Move other active objects 2820 // Move other active objects
2821 lock (_activeprims) 2821 foreach (OdePrim prim in _activeprims)
2822 { 2822 {
2823 foreach (OdePrim prim in _activeprims) 2823 prim.m_collisionscore = 0;
2824 { 2824 prim.Move(timeStep);
2825 prim.m_collisionscore = 0;
2826 prim.Move(timeStep);
2827 }
2828 } 2825 }
2829 2826
2830 //if ((framecount % m_randomizeWater) == 0) 2827 //if ((framecount % m_randomizeWater) == 0)
@@ -2893,20 +2890,16 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2893 defects.Clear(); 2890 defects.Clear();
2894 } 2891 }
2895 2892
2896 lock (_activeprims) 2893 //if (timeStep < 0.2f)
2894
2895 foreach (OdePrim prim in _activeprims)
2897 { 2896 {
2898 //if (timeStep < 0.2f) 2897 if (prim.IsPhysical && (d.BodyIsEnabled(prim.Body) || !prim._zeroFlag))
2899 { 2898 {
2900 foreach (OdePrim prim in _activeprims) 2899 prim.UpdatePositionAndVelocity();
2901 {
2902 if (prim.IsPhysical && (d.BodyIsEnabled(prim.Body) || !prim._zeroFlag))
2903 {
2904 prim.UpdatePositionAndVelocity();
2905 2900
2906 if (SupportsNINJAJoints) 2901 if (SupportsNINJAJoints)
2907 SimulateActorPendingJoints(prim); 2902 SimulateActorPendingJoints(prim);
2908 }
2909 }
2910 } 2903 }
2911 } 2904 }
2912 2905