aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs5
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs13
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs8
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs152
4 files changed, 81 insertions, 97 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 771a2ea..0462866 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -144,7 +144,10 @@ namespace OpenSim.Region.Physics.OdePlugin
144 internal UUID m_uuid { get; private set; } 144 internal UUID m_uuid { get; private set; }
145 internal bool bad = false; 145 internal bool bad = false;
146 146
147 public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, CollisionLocker dode, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) 147 public OdeCharacter(
148 String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p,
149 float capsule_radius, float tensor, float density, float height_fudge_factor,
150 float walk_divisor, float rundivisor)
148 { 151 {
149 m_uuid = UUID.Random(); 152 m_uuid = UUID.Random();
150 153
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 19fecf3..447304b 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -144,8 +144,6 @@ namespace OpenSim.Region.Physics.OdePlugin
144 144
145 public uint m_localID { get; private set; } 145 public uint m_localID { get; private set; }
146 146
147 private CollisionLocker ode;
148
149 private bool m_taintforce = false; 147 private bool m_taintforce = false;
150 private bool m_taintaddangularforce = false; 148 private bool m_taintaddangularforce = false;
151 private Vector3 m_force; 149 private Vector3 m_force;
@@ -203,13 +201,14 @@ namespace OpenSim.Region.Physics.OdePlugin
203 201
204 internal int m_material = (int)Material.Wood; 202 internal int m_material = (int)Material.Wood;
205 203
206 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size, 204 public OdePrim(
207 Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) 205 String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
206 Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
208 { 207 {
209 Name = primName; 208 Name = primName;
210 m_vehicle = new ODEDynamics(); 209 m_vehicle = new ODEDynamics();
211 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); 210 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
212 ode = dode; 211
213 if (!pos.IsFinite()) 212 if (!pos.IsFinite())
214 { 213 {
215 pos = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 214 pos = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f),
@@ -1390,7 +1389,6 @@ Console.WriteLine("CreateGeom:");
1390 catch (AccessViolationException) 1389 catch (AccessViolationException)
1391 { 1390 {
1392 m_log.WarnFormat("[PHYSICS]: Unable to create physics proxy for object {0}", Name); 1391 m_log.WarnFormat("[PHYSICS]: Unable to create physics proxy for object {0}", Name);
1393 ode.dunlock(_parent_scene.world);
1394 return; 1392 return;
1395 } 1393 }
1396 } 1394 }
@@ -1405,7 +1403,6 @@ Console.WriteLine("CreateGeom:");
1405 catch (AccessViolationException) 1403 catch (AccessViolationException)
1406 { 1404 {
1407 m_log.WarnFormat("[PHYSICS]: Unable to create physics proxy for object {0}", Name); 1405 m_log.WarnFormat("[PHYSICS]: Unable to create physics proxy for object {0}", Name);
1408 ode.dunlock(_parent_scene.world);
1409 return; 1406 return;
1410 } 1407 }
1411 } 1408 }
@@ -1421,7 +1418,6 @@ Console.WriteLine("CreateGeom:");
1421 catch (AccessViolationException) 1418 catch (AccessViolationException)
1422 { 1419 {
1423 m_log.WarnFormat("[PHYSICS]: Unable to create physics proxy for object {0}", Name); 1420 m_log.WarnFormat("[PHYSICS]: Unable to create physics proxy for object {0}", Name);
1424 ode.dunlock(_parent_scene.world);
1425 return; 1421 return;
1426 } 1422 }
1427 } 1423 }
@@ -1437,7 +1433,6 @@ Console.WriteLine("CreateGeom:");
1437 catch (AccessViolationException) 1433 catch (AccessViolationException)
1438 { 1434 {
1439 m_log.WarnFormat("[PHYSICS]: Unable to create physics proxy for object {0}", Name); 1435 m_log.WarnFormat("[PHYSICS]: Unable to create physics proxy for object {0}", Name);
1440 ode.dunlock(_parent_scene.world);
1441 return; 1436 return;
1442 } 1437 }
1443 } 1438 }
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index ebd46ab..716161a 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -48,14 +48,8 @@ namespace OpenSim.Region.Physics.OdePlugin
48 { 48 {
49 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 49 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 private CollisionLocker m_ode;
52 private OdeScene m_scene; 51 private OdeScene m_scene;
53 52
54 public OdePlugin()
55 {
56 m_ode = new CollisionLocker();
57 }
58
59 public bool Init() 53 public bool Init()
60 { 54 {
61 return true; 55 return true;
@@ -69,7 +63,7 @@ namespace OpenSim.Region.Physics.OdePlugin
69 // http://opensimulator.org/mantis/view.php?id=2750). 63 // http://opensimulator.org/mantis/view.php?id=2750).
70 d.InitODE(); 64 d.InitODE();
71 65
72 m_scene = new OdeScene(m_ode, sceneIdentifier); 66 m_scene = new OdeScene(sceneIdentifier);
73 } 67 }
74 return (m_scene); 68 return (m_scene);
75 } 69 }
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index ffcb004..03ff6d8 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -105,8 +105,6 @@ namespace OpenSim.Region.Physics.OdePlugin
105 private readonly ILog m_log; 105 private readonly ILog m_log;
106 // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); 106 // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>();
107 107
108 CollisionLocker ode;
109
110 private Random fluidRandomizer = new Random(Environment.TickCount); 108 private Random fluidRandomizer = new Random(Environment.TickCount);
111 109
112 private const uint m_regionWidth = Constants.RegionSize; 110 private const uint m_regionWidth = Constants.RegionSize;
@@ -312,13 +310,12 @@ namespace OpenSim.Region.Physics.OdePlugin
312 /// Sets many properties that ODE requires to be stable 310 /// Sets many properties that ODE requires to be stable
313 /// These settings need to be tweaked 'exactly' right or weird stuff happens. 311 /// These settings need to be tweaked 'exactly' right or weird stuff happens.
314 /// </summary> 312 /// </summary>
315 public OdeScene(CollisionLocker dode, string sceneIdentifier) 313 public OdeScene(string sceneIdentifier)
316 { 314 {
317 m_log 315 m_log
318 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + sceneIdentifier); 316 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + sceneIdentifier);
319 317
320 OdeLock = new Object(); 318 OdeLock = new Object();
321 ode = dode;
322 nearCallback = near; 319 nearCallback = near;
323 triCallback = TriCallback; 320 triCallback = TriCallback;
324 triArrayCallback = TriArrayCallback; 321 triArrayCallback = TriArrayCallback;
@@ -767,8 +764,8 @@ namespace OpenSim.Region.Physics.OdePlugin
767 } 764 }
768 catch (SEHException) 765 catch (SEHException)
769 { 766 {
770 m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); 767 m_log.Error(
771 ode.drelease(world); 768 "[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim.");
772 base.TriggerPhysicsBasedRestart(); 769 base.TriggerPhysicsBasedRestart();
773 } 770 }
774 catch (Exception e) 771 catch (Exception e)
@@ -1665,7 +1662,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1665 pos.X = position.X; 1662 pos.X = position.X;
1666 pos.Y = position.Y; 1663 pos.Y = position.Y;
1667 pos.Z = position.Z; 1664 pos.Z = position.Z;
1668 OdeCharacter newAv = new OdeCharacter(avName, this, pos, ode, size, avPIDD, avPIDP, avCapRadius, avStandupTensor, avDensity, avHeightFudgeFactor, avMovementDivisorWalk, avMovementDivisorRun); 1665
1666 OdeCharacter newAv
1667 = new OdeCharacter(
1668 avName, this, pos, size, avPIDD, avPIDP,
1669 avCapRadius, avStandupTensor, avDensity, avHeightFudgeFactor,
1670 avMovementDivisorWalk, avMovementDivisorRun);
1671
1669 newAv.Flying = isFlying; 1672 newAv.Flying = isFlying;
1670 newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; 1673 newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset;
1671 1674
@@ -1721,7 +1724,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1721 OdePrim newPrim; 1724 OdePrim newPrim;
1722 lock (OdeLock) 1725 lock (OdeLock)
1723 { 1726 {
1724 newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical, ode); 1727 newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical);
1725 1728
1726 lock (_prims) 1729 lock (_prims)
1727 _prims.Add(newPrim); 1730 _prims.Add(newPrim);
@@ -2158,84 +2161,80 @@ namespace OpenSim.Region.Physics.OdePlugin
2158 lock (prim) 2161 lock (prim)
2159 { 2162 {
2160 RemoveCollisionEventReporting(prim); 2163 RemoveCollisionEventReporting(prim);
2161 lock (ode) 2164
2165 if (prim.prim_geom != IntPtr.Zero)
2162 { 2166 {
2163 if (prim.prim_geom != IntPtr.Zero) 2167 prim.ResetTaints();
2164 {
2165 prim.ResetTaints();
2166 2168
2167 if (prim.IsPhysical) 2169 if (prim.IsPhysical)
2170 {
2171 prim.disableBody();
2172 if (prim.childPrim)
2168 { 2173 {
2169 prim.disableBody(); 2174 prim.childPrim = false;
2170 if (prim.childPrim) 2175 prim.Body = IntPtr.Zero;
2171 { 2176 prim.m_disabled = true;
2172 prim.childPrim = false; 2177 prim.IsPhysical = false;
2173 prim.Body = IntPtr.Zero; 2178 }
2174 prim.m_disabled = true;
2175 prim.IsPhysical = false;
2176 }
2177 2179
2178 2180
2179 } 2181 }
2180 // we don't want to remove the main space 2182 // we don't want to remove the main space
2181 2183
2182 // If the geometry is in the targetspace, remove it from the target space 2184 // If the geometry is in the targetspace, remove it from the target space
2183 //m_log.Warn(prim.m_targetSpace); 2185 //m_log.Warn(prim.m_targetSpace);
2184 2186
2185 //if (prim.m_targetSpace != IntPtr.Zero) 2187 //if (prim.m_targetSpace != IntPtr.Zero)
2186 //{ 2188 //{
2187 //if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom)) 2189 //if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
2188 //{ 2190 //{
2189 2191
2190 //if (d.GeomIsSpace(prim.m_targetSpace)) 2192 //if (d.GeomIsSpace(prim.m_targetSpace))
2191 //{ 2193 //{
2192 //waitForSpaceUnlock(prim.m_targetSpace); 2194 //waitForSpaceUnlock(prim.m_targetSpace);
2193 //d.SpaceRemove(prim.m_targetSpace, prim.prim_geom); 2195 //d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
2194 prim.m_targetSpace = IntPtr.Zero; 2196 prim.m_targetSpace = IntPtr.Zero;
2195 //} 2197 //}
2196 //else 2198 //else
2197 //{ 2199 //{
2198 // m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" + 2200 // m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
2199 //((OdePrim)prim).m_targetSpace.ToString()); 2201 //((OdePrim)prim).m_targetSpace.ToString());
2200 //} 2202 //}
2201 2203
2202 //} 2204 //}
2203 //} 2205 //}
2204 //m_log.Warn(prim.prim_geom); 2206 //m_log.Warn(prim.prim_geom);
2205 2207
2206 if (!prim.RemoveGeom()) 2208 if (!prim.RemoveGeom())
2207 m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene"); 2209 m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene");
2208 2210
2209 lock (_prims) 2211 lock (_prims)
2210 _prims.Remove(prim); 2212 _prims.Remove(prim);
2211 2213
2212 //If there are no more geometries in the sub-space, we don't need it in the main space anymore 2214 //If there are no more geometries in the sub-space, we don't need it in the main space anymore
2213 //if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0) 2215 //if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0)
2214 //{ 2216 //{
2215 //if (prim.m_targetSpace != null) 2217 //if (prim.m_targetSpace != null)
2216 //{ 2218 //{
2217 //if (d.GeomIsSpace(prim.m_targetSpace)) 2219 //if (d.GeomIsSpace(prim.m_targetSpace))
2218 //{ 2220 //{
2219 //waitForSpaceUnlock(prim.m_targetSpace); 2221 //waitForSpaceUnlock(prim.m_targetSpace);
2220 //d.SpaceRemove(space, prim.m_targetSpace); 2222 //d.SpaceRemove(space, prim.m_targetSpace);
2221 // free up memory used by the space. 2223 // free up memory used by the space.
2222 //d.SpaceDestroy(prim.m_targetSpace); 2224 //d.SpaceDestroy(prim.m_targetSpace);
2223 //int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position); 2225 //int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position);
2224 //resetSpaceArrayItemToZero(xyspace[0], xyspace[1]); 2226 //resetSpaceArrayItemToZero(xyspace[0], xyspace[1]);
2225 //} 2227 //}
2226 //else 2228 //else
2227 //{ 2229 //{
2228 //m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" + 2230 //m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
2229 //((OdePrim) prim).m_targetSpace.ToString()); 2231 //((OdePrim) prim).m_targetSpace.ToString());
2230 //} 2232 //}
2231 //} 2233 //}
2232 //} 2234 //}
2233 2235
2234 if (SupportsNINJAJoints) 2236 if (SupportsNINJAJoints)
2235 { 2237 RemoveAllJointsConnectedToActorThreadLocked(prim);
2236 RemoveAllJointsConnectedToActorThreadLocked(prim);
2237 }
2238 }
2239 } 2238 }
2240 } 2239 }
2241 } 2240 }
@@ -2835,16 +2834,9 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2835 catch (Exception e) 2834 catch (Exception e)
2836 { 2835 {
2837 m_log.ErrorFormat("[PHYSICS]: {0}, {1}, {2}", e.Message, e.TargetSite, e); 2836 m_log.ErrorFormat("[PHYSICS]: {0}, {1}, {2}", e.Message, e.TargetSite, e);
2838 ode.dunlock(world);
2839 } 2837 }
2840 2838
2841 step_time -= ODE_STEPSIZE; 2839 step_time -= ODE_STEPSIZE;
2842 //}
2843 //else
2844 //{
2845 //fps = 0;
2846 //}
2847 //}
2848 } 2840 }
2849 2841
2850 lock (_characters) 2842 lock (_characters)