aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs47
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs109
2 files changed, 71 insertions, 85 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 1363cfd..68999fc 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -137,7 +137,7 @@ namespace OpenSim.Region.Physics.OdePlugin
137 internal IntPtr Body = IntPtr.Zero; 137 internal IntPtr Body = IntPtr.Zero;
138 private OdeScene _parent_scene; 138 private OdeScene _parent_scene;
139 internal IntPtr Shell = IntPtr.Zero; 139 internal IntPtr Shell = IntPtr.Zero;
140 internal IntPtr Amotor = IntPtr.Zero; 140 private IntPtr Amotor = IntPtr.Zero;
141 private d.Mass ShellMass; 141 private d.Mass ShellMass;
142 142
143 private int m_eventsubscription = 0; 143 private int m_eventsubscription = 0;
@@ -195,13 +195,10 @@ namespace OpenSim.Region.Physics.OdePlugin
195 // new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f, 195 // new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f,
196 // 0.5f); 196 // 0.5f);
197 197
198 for (int i = 0; i < 11; i++) 198 // We can set taint and actual to be the same here, since the entire character will be set up when the
199 { 199 // m_tainted_isPhysical is processed.
200 m_colliderarr[i] = false; 200 SetTaintedCapsuleLength(size);
201 } 201 CAPSULE_LENGTH = m_tainted_CAPSULE_LENGTH;
202 CAPSULE_LENGTH = (size.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
203 //m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH.ToString());
204 m_tainted_CAPSULE_LENGTH = CAPSULE_LENGTH;
205 202
206 m_isPhysical = false; // current status: no ODE information exists 203 m_isPhysical = false; // current status: no ODE information exists
207 m_tainted_isPhysical = true; // new tainted status: need to create ODE information 204 m_tainted_isPhysical = true; // new tainted status: need to create ODE information
@@ -457,24 +454,28 @@ namespace OpenSim.Region.Physics.OdePlugin
457 get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } 454 get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); }
458 set 455 set
459 { 456 {
460 if (value.IsFinite()) 457 SetTaintedCapsuleLength(value);
461 {
462 m_pidControllerActive = true;
463
464 Vector3 SetSize = value;
465 m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
466// m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH);
467 458
468 // If we reset velocity here, then an avatar stalls when it crosses a border for the first time 459 // If we reset velocity here, then an avatar stalls when it crosses a border for the first time
469 // (as the height of the new root agent is set). 460 // (as the height of the new root agent is set).
470// Velocity = Vector3.Zero; 461// Velocity = Vector3.Zero;
471 462
472 _parent_scene.AddPhysicsActorTaint(this); 463 _parent_scene.AddPhysicsActorTaint(this);
473 } 464 }
474 else 465 }
475 { 466
476 m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Size from Scene on {0}", Name); 467 private void SetTaintedCapsuleLength(Vector3 size)
477 } 468 {
469 if (size.IsFinite())
470 {
471 m_pidControllerActive = true;
472
473 m_tainted_CAPSULE_LENGTH = (size.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
474// m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH);
475 }
476 else
477 {
478 m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Size for {0} in {1}", Name, _parent_scene.Name);
478 } 479 }
479 } 480 }
480 481
@@ -549,8 +550,8 @@ namespace OpenSim.Region.Physics.OdePlugin
549 { 550 {
550 get 551 get
551 { 552 {
552 float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH); 553 float AVvolume = (float)(Math.PI * Math.Pow(CAPSULE_RADIUS, 2) * CAPSULE_LENGTH);
553 return m_density*AVvolume; 554 return m_density * AVvolume;
554 } 555 }
555 } 556 }
556 557
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
2629Console.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 {