diff options
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 109 |
1 files changed, 47 insertions, 62 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index c1a3e61..04ba738 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs | |||
@@ -205,27 +205,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
205 | private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); | 205 | private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); |
206 | 206 | ||
207 | /// <summary> | 207 | /// <summary> |
208 | /// Used to lock on manipulation of _taintedPrimL and _taintedPrimH | 208 | /// Prims that the simulator has created/deleted/updated and so need updating in ODE. |
209 | /// </summary> | 209 | /// </summary> |
210 | private readonly Object _taintedPrimLock = new Object(); | 210 | private readonly HashSet<OdePrim> _taintedPrims = new HashSet<OdePrim>(); |
211 | |||
212 | /// <summary> | ||
213 | /// List of tainted prims. | ||
214 | /// </summary> | ||
215 | /// <remarks> | ||
216 | /// A tainted prim is one that has taints to process before performing any other operations. The list is | ||
217 | /// cleared after processing. | ||
218 | /// </remarks> | ||
219 | private readonly List<OdePrim> _taintedPrimL = new List<OdePrim>(); | ||
220 | |||
221 | /// <summary> | ||
222 | /// HashSet of tainted prims. | ||
223 | /// </summary> | ||
224 | /// <remarks> | ||
225 | /// A tainted prim is one that has taints to process before performing any other operations. The hashset is | ||
226 | /// cleared after processing. | ||
227 | /// </remarks> | ||
228 | private readonly HashSet<OdePrim> _taintedPrimH = new HashSet<OdePrim>(); | ||
229 | 211 | ||
230 | /// <summary> | 212 | /// <summary> |
231 | /// Record a character that has taints to be processed. | 213 | /// Record a character that has taints to be processed. |
@@ -767,7 +749,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
767 | } | 749 | } |
768 | catch (AccessViolationException) | 750 | catch (AccessViolationException) |
769 | { | 751 | { |
770 | m_log.Warn("[ODE SCENE]: Unable to collide test a space"); | 752 | m_log.Error("[ODE SCENE]: Unable to collide test a space"); |
771 | return; | 753 | return; |
772 | } | 754 | } |
773 | //Colliding a space or a geom with a space or a geom. so drill down | 755 | //Colliding a space or a geom with a space or a geom. so drill down |
@@ -829,7 +811,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
829 | } | 811 | } |
830 | catch (Exception e) | 812 | catch (Exception e) |
831 | { | 813 | { |
832 | m_log.WarnFormat("[ODE SCENE]: Unable to collide test an object: {0}", e.Message); | 814 | m_log.ErrorFormat("[ODE SCENE]: Unable to collide test an object: {0}", e.Message); |
833 | return; | 815 | return; |
834 | } | 816 | } |
835 | 817 | ||
@@ -1554,7 +1536,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1554 | } | 1536 | } |
1555 | catch (AccessViolationException) | 1537 | catch (AccessViolationException) |
1556 | { | 1538 | { |
1557 | m_log.WarnFormat("[ODE SCENE]: Unable to space collide {0}", Name); | 1539 | m_log.ErrorFormat("[ODE SCENE]: Unable to space collide {0}", Name); |
1558 | } | 1540 | } |
1559 | 1541 | ||
1560 | //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y); | 1542 | //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y); |
@@ -1585,13 +1567,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1585 | removeprims = new List<OdePrim>(); | 1567 | removeprims = new List<OdePrim>(); |
1586 | } | 1568 | } |
1587 | removeprims.Add(chr); | 1569 | removeprims.Add(chr); |
1588 | m_log.Debug("[ODE SCENE]: 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!"); | 1570 | m_log.Error( |
1571 | "[ODE SCENE]: 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!"); | ||
1589 | } | 1572 | } |
1590 | } | 1573 | } |
1591 | } | 1574 | } |
1592 | catch (AccessViolationException) | 1575 | catch (AccessViolationException) |
1593 | { | 1576 | { |
1594 | m_log.Warn("[ODE SCENE]: Unable to space collide"); | 1577 | m_log.Error("[ODE SCENE]: Unable to space collide"); |
1595 | } | 1578 | } |
1596 | } | 1579 | } |
1597 | } | 1580 | } |
@@ -1716,7 +1699,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1716 | 1699 | ||
1717 | public override void RemoveAvatar(PhysicsActor actor) | 1700 | public override void RemoveAvatar(PhysicsActor actor) |
1718 | { | 1701 | { |
1719 | //m_log.Debug("[PHYSICS]:ODELOCK"); | 1702 | // m_log.DebugFormat( |
1703 | // "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2}", | ||
1704 | // actor.Name, actor.LocalID, Name); | ||
1705 | |||
1720 | ((OdeCharacter) actor).Destroy(); | 1706 | ((OdeCharacter) actor).Destroy(); |
1721 | } | 1707 | } |
1722 | 1708 | ||
@@ -1726,6 +1712,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1726 | { | 1712 | { |
1727 | _characters.Add(chr); | 1713 | _characters.Add(chr); |
1728 | 1714 | ||
1715 | // m_log.DebugFormat( | ||
1716 | // "[ODE SCENE]: Adding physics character {0} {1} to physics scene {2}. Count now {3}", | ||
1717 | // chr.Name, chr.LocalID, Name, _characters.Count); | ||
1718 | |||
1729 | if (chr.bad) | 1719 | if (chr.bad) |
1730 | m_log.ErrorFormat("[ODE SCENE]: Added BAD actor {0} to characters list", chr.m_uuid); | 1720 | m_log.ErrorFormat("[ODE SCENE]: Added BAD actor {0} to characters list", chr.m_uuid); |
1731 | } | 1721 | } |
@@ -1740,11 +1730,19 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1740 | internal void RemoveCharacter(OdeCharacter chr) | 1730 | internal void RemoveCharacter(OdeCharacter chr) |
1741 | { | 1731 | { |
1742 | if (_characters.Contains(chr)) | 1732 | if (_characters.Contains(chr)) |
1733 | { | ||
1743 | _characters.Remove(chr); | 1734 | _characters.Remove(chr); |
1735 | |||
1736 | // m_log.DebugFormat( | ||
1737 | // "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2}. Count now {3}", | ||
1738 | // chr.Name, chr.LocalID, Name, _characters.Count); | ||
1739 | } | ||
1744 | else | 1740 | else |
1741 | { | ||
1745 | m_log.ErrorFormat( | 1742 | m_log.ErrorFormat( |
1746 | "[ODE SCENE]: Tried to remove character {0} {1} but they are not in the list!", | 1743 | "[ODE SCENE]: Tried to remove character {0} {1} but they are not in the list!", |
1747 | chr.Name, chr.LocalID); | 1744 | chr.Name, chr.LocalID); |
1745 | } | ||
1748 | } | 1746 | } |
1749 | 1747 | ||
1750 | private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, | 1748 | private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, |
@@ -1782,7 +1780,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1782 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | 1780 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, |
1783 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) | 1781 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) |
1784 | { | 1782 | { |
1785 | // m_log.DebugFormat("[ODE SCENE]: Adding physics actor to {0} {1}", primName, localid); | 1783 | // m_log.DebugFormat("[ODE SCENE]: Adding physics prim {0} {1} to physics scene {2}", primName, localid, Name); |
1786 | 1784 | ||
1787 | return AddPrim(primName, position, size, rotation, pbs, isPhysical, localid); | 1785 | return AddPrim(primName, position, size, rotation, pbs, isPhysical, localid); |
1788 | } | 1786 | } |
@@ -2621,29 +2619,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2621 | if (actor is OdePrim) | 2619 | if (actor is OdePrim) |
2622 | { | 2620 | { |
2623 | OdePrim taintedprim = ((OdePrim)actor); | 2621 | OdePrim taintedprim = ((OdePrim)actor); |
2624 | lock (_taintedPrimLock) | 2622 | lock (_taintedPrims) |
2625 | { | 2623 | _taintedPrims.Add(taintedprim); |
2626 | if (!(_taintedPrimH.Contains(taintedprim))) | ||
2627 | { | ||
2628 | #if SPAM | ||
2629 | Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); | ||
2630 | #endif | ||
2631 | _taintedPrimH.Add(taintedprim); // HashSet for searching | ||
2632 | _taintedPrimL.Add(taintedprim); // List for ordered readout | ||
2633 | } | ||
2634 | } | ||
2635 | } | 2624 | } |
2636 | else if (actor is OdeCharacter) | 2625 | else if (actor is OdeCharacter) |
2637 | { | 2626 | { |
2638 | OdeCharacter taintedchar = ((OdeCharacter)actor); | 2627 | OdeCharacter taintedchar = ((OdeCharacter)actor); |
2639 | lock (_taintedActors) | 2628 | lock (_taintedActors) |
2640 | { | 2629 | { |
2641 | if (!(_taintedActors.Contains(taintedchar))) | 2630 | _taintedActors.Add(taintedchar); |
2642 | { | 2631 | if (taintedchar.bad) |
2643 | _taintedActors.Add(taintedchar); | 2632 | m_log.ErrorFormat("[ODE SCENE]: Added BAD actor {0} to tainted actors", taintedchar.m_uuid); |
2644 | if (taintedchar.bad) | ||
2645 | m_log.DebugFormat("[ODE SCENE]: Added BAD actor {0} to tainted actors", taintedchar.m_uuid); | ||
2646 | } | ||
2647 | } | 2633 | } |
2648 | } | 2634 | } |
2649 | } | 2635 | } |
@@ -2740,19 +2726,15 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); | |||
2740 | { | 2726 | { |
2741 | lock (_taintedActors) | 2727 | lock (_taintedActors) |
2742 | { | 2728 | { |
2743 | if (_taintedActors.Count > 0) | 2729 | foreach (OdeCharacter character in _taintedActors) |
2744 | { | 2730 | character.ProcessTaints(); |
2745 | foreach (OdeCharacter character in _taintedActors) | ||
2746 | character.ProcessTaints(); | ||
2747 | 2731 | ||
2748 | if (_taintedActors.Count > 0) | 2732 | _taintedActors.Clear(); |
2749 | _taintedActors.Clear(); | ||
2750 | } | ||
2751 | } | 2733 | } |
2752 | 2734 | ||
2753 | lock (_taintedPrimLock) | 2735 | lock (_taintedPrims) |
2754 | { | 2736 | { |
2755 | foreach (OdePrim prim in _taintedPrimL) | 2737 | foreach (OdePrim prim in _taintedPrims) |
2756 | { | 2738 | { |
2757 | if (prim.m_taintremove) | 2739 | if (prim.m_taintremove) |
2758 | { | 2740 | { |
@@ -2777,12 +2759,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); | |||
2777 | if (SupportsNINJAJoints) | 2759 | if (SupportsNINJAJoints) |
2778 | SimulatePendingNINJAJoints(); | 2760 | SimulatePendingNINJAJoints(); |
2779 | 2761 | ||
2780 | if (_taintedPrimL.Count > 0) | 2762 | _taintedPrims.Clear(); |
2781 | { | ||
2782 | //Console.WriteLine("Simulate calls Clear of _taintedPrim list"); | ||
2783 | _taintedPrimH.Clear(); | ||
2784 | _taintedPrimL.Clear(); | ||
2785 | } | ||
2786 | } | 2763 | } |
2787 | 2764 | ||
2788 | // Move characters | 2765 | // Move characters |
@@ -2793,6 +2770,10 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); | |||
2793 | { | 2770 | { |
2794 | foreach (OdeCharacter actor in defects) | 2771 | foreach (OdeCharacter actor in defects) |
2795 | { | 2772 | { |
2773 | m_log.ErrorFormat( | ||
2774 | "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when moving", | ||
2775 | actor.Name, actor.LocalID, Name); | ||
2776 | |||
2796 | RemoveCharacter(actor); | 2777 | RemoveCharacter(actor); |
2797 | actor.DestroyOdeStructures(); | 2778 | actor.DestroyOdeStructures(); |
2798 | } | 2779 | } |
@@ -2854,7 +2835,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); | |||
2854 | foreach (OdeCharacter actor in _characters) | 2835 | foreach (OdeCharacter actor in _characters) |
2855 | { | 2836 | { |
2856 | if (actor.bad) | 2837 | if (actor.bad) |
2857 | m_log.WarnFormat("[ODE SCENE]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid); | 2838 | m_log.ErrorFormat("[ODE SCENE]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid); |
2858 | 2839 | ||
2859 | actor.UpdatePositionAndVelocity(defects); | 2840 | actor.UpdatePositionAndVelocity(defects); |
2860 | } | 2841 | } |
@@ -2863,6 +2844,10 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); | |||
2863 | { | 2844 | { |
2864 | foreach (OdeCharacter actor in defects) | 2845 | foreach (OdeCharacter actor in defects) |
2865 | { | 2846 | { |
2847 | m_log.ErrorFormat( | ||
2848 | "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when updating position and velocity", | ||
2849 | actor.Name, actor.LocalID, Name); | ||
2850 | |||
2866 | RemoveCharacter(actor); | 2851 | RemoveCharacter(actor); |
2867 | actor.DestroyOdeStructures(); | 2852 | actor.DestroyOdeStructures(); |
2868 | } | 2853 | } |
@@ -3445,7 +3430,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); | |||
3445 | private void SetTerrain(float[] heightMap, Vector3 pOffset) | 3430 | private void SetTerrain(float[] heightMap, Vector3 pOffset) |
3446 | { | 3431 | { |
3447 | int startTime = Util.EnvironmentTickCount(); | 3432 | int startTime = Util.EnvironmentTickCount(); |
3448 | m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0}", Name); | 3433 | m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", Name, pOffset); |
3449 | 3434 | ||
3450 | // this._heightmap[i] = (double)heightMap[i]; | 3435 | // this._heightmap[i] = (double)heightMap[i]; |
3451 | // dbm (danx0r) -- creating a buffer zone of one extra sample all around | 3436 | // dbm (danx0r) -- creating a buffer zone of one extra sample all around |
@@ -3559,7 +3544,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); | |||
3559 | 3544 | ||
3560 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | 3545 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); |
3561 | d.GeomSetRotation(GroundGeom, ref R); | 3546 | d.GeomSetRotation(GroundGeom, ref R); |
3562 | d.GeomSetPosition(GroundGeom, (pOffset.X + ((int)Constants.RegionSize * 0.5f)) - 1, (pOffset.Y + ((int)Constants.RegionSize * 0.5f)) - 1, 0); | 3547 | d.GeomSetPosition(GroundGeom, (pOffset.X + ((int)Constants.RegionSize * 0.5f)), (pOffset.Y + ((int)Constants.RegionSize * 0.5f)), 0); |
3563 | IntPtr testGround = IntPtr.Zero; | 3548 | IntPtr testGround = IntPtr.Zero; |
3564 | if (RegionTerrain.TryGetValue(pOffset, out testGround)) | 3549 | if (RegionTerrain.TryGetValue(pOffset, out testGround)) |
3565 | { | 3550 | { |