aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
diff options
context:
space:
mode:
authorMelanie2009-10-27 11:32:11 +0000
committerMelanie2009-10-27 11:32:11 +0000
commit31a848e97bd984ab0a85feca397ce419f6ae839a (patch)
tree4743f5eb7c12b3723ed4b986d19714d1b3a0a3ea /OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
parentCommented out instrumentation in ODEPrim.cs (diff)
parentFinally hunted down the Parallel deadlock. Packets were being handled asynchr... (diff)
downloadopensim-SC-31a848e97bd984ab0a85feca397ce419f6ae839a.zip
opensim-SC-31a848e97bd984ab0a85feca397ce419f6ae839a.tar.gz
opensim-SC-31a848e97bd984ab0a85feca397ce419f6ae839a.tar.bz2
opensim-SC-31a848e97bd984ab0a85feca397ce419f6ae839a.tar.xz
Merge branch 'master' into vehicles
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/OdePlugin.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs67
1 files changed, 33 insertions, 34 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 0a065be..2f42646 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -239,6 +239,7 @@ namespace OpenSim.Region.Physics.OdePlugin
239 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); 239 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>();
240 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); 240 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
241 private readonly HashSet<OdePrim> _taintedPrimH = new HashSet<OdePrim>(); 241 private readonly HashSet<OdePrim> _taintedPrimH = new HashSet<OdePrim>();
242 private readonly Object _taintedPrimLock = new Object();
242 private readonly List<OdePrim> _taintedPrimL = new List<OdePrim>(); 243 private readonly List<OdePrim> _taintedPrimL = new List<OdePrim>();
243 private readonly HashSet<OdeCharacter> _taintedActors = new HashSet<OdeCharacter>(); 244 private readonly HashSet<OdeCharacter> _taintedActors = new HashSet<OdeCharacter>();
244 private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>(); 245 private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>();
@@ -683,7 +684,7 @@ namespace OpenSim.Region.Physics.OdePlugin
683 /// </summary> 684 /// </summary>
684 /// <param name="pos"></param> 685 /// <param name="pos"></param>
685 /// <returns>Returns which split up space the given position is in.</returns> 686 /// <returns>Returns which split up space the given position is in.</returns>
686 public string whichspaceamIin(PhysicsVector pos) 687 public string whichspaceamIin(Vector3 pos)
687 { 688 {
688 return calculateSpaceForGeom(pos).ToString(); 689 return calculateSpaceForGeom(pos).ToString();
689 } 690 }
@@ -962,7 +963,7 @@ namespace OpenSim.Region.Physics.OdePlugin
962 963
963 //p2.CollidingObj = true; 964 //p2.CollidingObj = true;
964 contacts[i].depth = 0.00000003f; 965 contacts[i].depth = 0.00000003f;
965 p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 0.5f); 966 p2.Velocity = p2.Velocity + new Vector3(0f, 0f, 0.5f);
966 contacts[i].pos = 967 contacts[i].pos =
967 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), 968 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2),
968 contacts[i].pos.Y + (p1.Size.Y/2), 969 contacts[i].pos.Y + (p1.Size.Y/2),
@@ -980,7 +981,7 @@ namespace OpenSim.Region.Physics.OdePlugin
980 981
981 //p2.CollidingObj = true; 982 //p2.CollidingObj = true;
982 contacts[i].depth = 0.00000003f; 983 contacts[i].depth = 0.00000003f;
983 p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 0.5f); 984 p1.Velocity = p1.Velocity + new Vector3(0f, 0f, 0.5f);
984 contacts[i].pos = 985 contacts[i].pos =
985 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), 986 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2),
986 contacts[i].pos.Y + (p1.Size.Y/2), 987 contacts[i].pos.Y + (p1.Size.Y/2),
@@ -1645,9 +1646,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1645 1646
1646 #region Add/Remove Entities 1647 #region Add/Remove Entities
1647 1648
1648 public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) 1649 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
1649 { 1650 {
1650 PhysicsVector pos = new PhysicsVector(); 1651 Vector3 pos;
1651 pos.X = position.X; 1652 pos.X = position.X;
1652 pos.Y = position.Y; 1653 pos.Y = position.Y;
1653 pos.Z = position.Z; 1654 pos.Z = position.Z;
@@ -1697,18 +1698,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1697 1698
1698 } 1699 }
1699 1700
1700 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, 1701 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
1701 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) 1702 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
1702 { 1703 {
1703 1704
1704 PhysicsVector pos = new PhysicsVector(position.X, position.Y, position.Z); 1705 Vector3 pos = position;
1705 //pos.X = position.X; 1706 Vector3 siz = size;
1706 //pos.Y = position.Y;
1707 //pos.Z = position.Z;
1708 PhysicsVector siz = new PhysicsVector();
1709 siz.X = size.X;
1710 siz.Y = size.Y;
1711 siz.Z = size.Z;
1712 Quaternion rot = rotation; 1707 Quaternion rot = rotation;
1713 1708
1714 OdePrim newPrim; 1709 OdePrim newPrim;
@@ -1735,14 +1730,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1735 } 1730 }
1736 } 1731 }
1737 1732
1738 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 1733 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1739 PhysicsVector size, Quaternion rotation) //To be removed 1734 Vector3 size, Quaternion rotation) //To be removed
1740 { 1735 {
1741 return AddPrimShape(primName, pbs, position, size, rotation, false); 1736 return AddPrimShape(primName, pbs, position, size, rotation, false);
1742 } 1737 }
1743 1738
1744 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 1739 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1745 PhysicsVector size, Quaternion rotation, bool isPhysical) 1740 Vector3 size, Quaternion rotation, bool isPhysical)
1746 { 1741 {
1747 PhysicsActor result; 1742 PhysicsActor result;
1748 IMesh mesh = null; 1743 IMesh mesh = null;
@@ -1975,7 +1970,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1975 // this joint will just be added to a waiting list that is NOT processed during the main 1970 // this joint will just be added to a waiting list that is NOT processed during the main
1976 // Simulate() loop (to avoid deadlocks). After Simulate() is finished, we handle unprocessed joint requests. 1971 // Simulate() loop (to avoid deadlocks). After Simulate() is finished, we handle unprocessed joint requests.
1977 1972
1978 public override PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, PhysicsVector position, 1973 public override PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, Vector3 position,
1979 Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation) 1974 Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation)
1980 1975
1981 { 1976 {
@@ -1983,7 +1978,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1983 OdePhysicsJoint joint = new OdePhysicsJoint(); 1978 OdePhysicsJoint joint = new OdePhysicsJoint();
1984 joint.ObjectNameInScene = objectNameInScene; 1979 joint.ObjectNameInScene = objectNameInScene;
1985 joint.Type = jointType; 1980 joint.Type = jointType;
1986 joint.Position = new PhysicsVector(position.X, position.Y, position.Z); 1981 joint.Position = position;
1987 joint.Rotation = rotation; 1982 joint.Rotation = rotation;
1988 joint.RawParams = parms; 1983 joint.RawParams = parms;
1989 joint.BodyNames = new List<string>(bodyNames); 1984 joint.BodyNames = new List<string>(bodyNames);
@@ -2035,7 +2030,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2035 } 2030 }
2036 2031
2037 // normally called from within OnJointMoved, which is called from within a lock (OdeLock) 2032 // normally called from within OnJointMoved, which is called from within a lock (OdeLock)
2038 public override PhysicsVector GetJointAnchor(PhysicsJoint joint) 2033 public override Vector3 GetJointAnchor(PhysicsJoint joint)
2039 { 2034 {
2040 Debug.Assert(joint.IsInPhysicsEngine); 2035 Debug.Assert(joint.IsInPhysicsEngine);
2041 d.Vector3 pos = new d.Vector3(); 2036 d.Vector3 pos = new d.Vector3();
@@ -2057,14 +2052,14 @@ namespace OpenSim.Region.Physics.OdePlugin
2057 break; 2052 break;
2058 } 2053 }
2059 } 2054 }
2060 return new PhysicsVector(pos.X, pos.Y, pos.Z); 2055 return new Vector3(pos.X, pos.Y, pos.Z);
2061 } 2056 }
2062 2057
2063 // normally called from within OnJointMoved, which is called from within a lock (OdeLock) 2058 // normally called from within OnJointMoved, which is called from within a lock (OdeLock)
2064 // WARNING: ODE sometimes returns <0,0,0> as the joint axis! Therefore this function 2059 // WARNING: ODE sometimes returns <0,0,0> as the joint axis! Therefore this function
2065 // appears to be unreliable. Fortunately we can compute the joint axis ourselves by 2060 // appears to be unreliable. Fortunately we can compute the joint axis ourselves by
2066 // keeping track of the joint's original orientation relative to one of the involved bodies. 2061 // keeping track of the joint's original orientation relative to one of the involved bodies.
2067 public override PhysicsVector GetJointAxis(PhysicsJoint joint) 2062 public override Vector3 GetJointAxis(PhysicsJoint joint)
2068 { 2063 {
2069 Debug.Assert(joint.IsInPhysicsEngine); 2064 Debug.Assert(joint.IsInPhysicsEngine);
2070 d.Vector3 axis = new d.Vector3(); 2065 d.Vector3 axis = new d.Vector3();
@@ -2086,7 +2081,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2086 break; 2081 break;
2087 } 2082 }
2088 } 2083 }
2089 return new PhysicsVector(axis.X, axis.Y, axis.Z); 2084 return new Vector3(axis.X, axis.Y, axis.Z);
2090 } 2085 }
2091 2086
2092 2087
@@ -2254,7 +2249,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2254 /// <param name="pos">the position that the geom moved to</param> 2249 /// <param name="pos">the position that the geom moved to</param>
2255 /// <param name="currentspace">a pointer to the space it was in before it was moved.</param> 2250 /// <param name="currentspace">a pointer to the space it was in before it was moved.</param>
2256 /// <returns>a pointer to the new space it's in</returns> 2251 /// <returns>a pointer to the new space it's in</returns>
2257 public IntPtr recalculateSpaceForGeom(IntPtr geom, PhysicsVector pos, IntPtr currentspace) 2252 public IntPtr recalculateSpaceForGeom(IntPtr geom, Vector3 pos, IntPtr currentspace)
2258 { 2253 {
2259 // Called from setting the Position and Size of an ODEPrim so 2254 // Called from setting the Position and Size of an ODEPrim so
2260 // it's already in locked space. 2255 // it's already in locked space.
@@ -2401,7 +2396,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2401 /// </summary> 2396 /// </summary>
2402 /// <param name="pos"></param> 2397 /// <param name="pos"></param>
2403 /// <returns>a pointer to the space. This could be a new space or reused space.</returns> 2398 /// <returns>a pointer to the space. This could be a new space or reused space.</returns>
2404 public IntPtr calculateSpaceForGeom(PhysicsVector pos) 2399 public IntPtr calculateSpaceForGeom(Vector3 pos)
2405 { 2400 {
2406 int[] xyspace = calculateSpaceArrayItemFromPos(pos); 2401 int[] xyspace = calculateSpaceArrayItemFromPos(pos);
2407 //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); 2402 //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString());
@@ -2413,7 +2408,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2413 /// </summary> 2408 /// </summary>
2414 /// <param name="pos"></param> 2409 /// <param name="pos"></param>
2415 /// <returns>an array item based on the position</returns> 2410 /// <returns>an array item based on the position</returns>
2416 public int[] calculateSpaceArrayItemFromPos(PhysicsVector pos) 2411 public int[] calculateSpaceArrayItemFromPos(Vector3 pos)
2417 { 2412 {
2418 int[] returnint = new int[2]; 2413 int[] returnint = new int[2];
2419 2414
@@ -2572,7 +2567,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2572 if (prim is OdePrim) 2567 if (prim is OdePrim)
2573 { 2568 {
2574 OdePrim taintedprim = ((OdePrim) prim); 2569 OdePrim taintedprim = ((OdePrim) prim);
2575 lock (_taintedPrimH) 2570 lock (_taintedPrimLock)
2576 { 2571 {
2577 if (!(_taintedPrimH.Contains(taintedprim))) 2572 if (!(_taintedPrimH.Contains(taintedprim)))
2578 { 2573 {
@@ -2700,24 +2695,28 @@ namespace OpenSim.Region.Physics.OdePlugin
2700 // Modify other objects in the scene. 2695 // Modify other objects in the scene.
2701 processedtaints = false; 2696 processedtaints = false;
2702 2697
2703 lock (_taintedPrimL) 2698 lock (_taintedPrimLock)
2704 { 2699 {
2705 foreach (OdePrim prim in _taintedPrimL) 2700 foreach (OdePrim prim in _taintedPrimL)
2706 { 2701 {
2707
2708
2709 if (prim.m_taintremove) 2702 if (prim.m_taintremove)
2710 { 2703 {
2711//Console.WriteLine("Simulate calls RemovePrimThreadLocked"); 2704 //Console.WriteLine("Simulate calls RemovePrimThreadLocked");
2712 RemovePrimThreadLocked(prim); 2705 RemovePrimThreadLocked(prim);
2713 } 2706 }
2714 else 2707 else
2715 { 2708 {
2716//Console.WriteLine("Simulate calls ProcessTaints"); 2709 //Console.WriteLine("Simulate calls ProcessTaints");
2717 prim.ProcessTaints(timeStep); 2710 prim.ProcessTaints(timeStep);
2718 } 2711 }
2719 processedtaints = true; 2712 processedtaints = true;
2720 prim.m_collisionscore = 0; 2713 prim.m_collisionscore = 0;
2714
2715 // This loop can block up the Heartbeat for a very long time on large regions.
2716 // We need to let the Watchdog know that the Heartbeat is not dead
2717 // NOTE: This is currently commented out, but if things like OAR loading are
2718 // timing the heartbeat out we will need to uncomment it
2719 //Watchdog.UpdateThread();
2721 } 2720 }
2722 2721
2723 if (SupportsNINJAJoints) 2722 if (SupportsNINJAJoints)