From 98a00cbce55d7b880b860f7e95a66e13c5f070b7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 20 Nov 2015 00:37:41 +0000 Subject: [PATCH] ubOde: add threading related calls new ode.dll may need. Hope this doesn't break with current linux ode library --- .../Region/PhysicsModules/ubOde/ODEPrim.cs | 6 +++++- .../Region/PhysicsModules/ubOde/ODEScene.cs | 21 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 1dbf164e43..24fceb9c2a 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs @@ -466,6 +466,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde { lock (_parent_scene.OdeLock) { + d.AllocateODEDataForThread(0); + d.Vector3 dtmp; if (!childPrim && Body != IntPtr.Zero) { @@ -892,9 +894,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde _velocity.Y = 0; _velocity.Z = 0; + d.AllocateODEDataForThread(0); + m_lastVelocity = _velocity; if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) - m_vehicle.Stop(); + m_vehicle.Stop(); if(Body != IntPtr.Zero) d.BodySetLinearVel(Body, 0, 0, 0); // stop it diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index 61e31a1b0f..aec7ec3101 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -366,7 +366,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde /// private void Initialization() { - // checkThread(); + d.AllocateODEDataForThread(~0U); + SimulationLock = new Object(); nearCallback = near; @@ -1290,7 +1291,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde public override void RemoveAvatar(PhysicsActor actor) { //m_log.Debug("[PHYSICS]:ODELOCK"); - ((OdeCharacter) actor).Destroy(); + lock (OdeLock) + { + d.AllocateODEDataForThread(0); + ((OdeCharacter) actor).Destroy(); + } } @@ -1319,6 +1324,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde OdePrim newPrim; lock (OdeLock) { + newPrim = new OdePrim(name, this, position, size, rotation, pbs, isphysical, isPhantom, shapeType, localID); lock (_prims) _prims.Add(newPrim); @@ -1547,6 +1553,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde return; } + d.AllocateODEDataForThread(~0U); + ODEchangeitem item; int donechanges = 0; @@ -1630,7 +1638,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde int changestimeMS = 0; int maxChangestime = (int)(reqTimeStep * 500f); // half the time int maxLoopTime = (int)(reqTimeStep * 1200f); // 1.2 the time - + + d.AllocateODEDataForThread(~0U); + if (ChangesQueue.Count > 0) { while (ChangesQueue.Dequeue(out item)) @@ -2260,6 +2270,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde lock (OdeLock) { + d.AllocateODEDataForThread(~0U); + IntPtr GroundGeom = IntPtr.Zero; if (RegionTerrain.TryGetValue(pOffset, out GroundGeom)) { @@ -2450,9 +2462,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde { lock (OdeLock) { + if (world == IntPtr.Zero) return; + d.AllocateODEDataForThread(~0U); + if (m_meshWorker != null) m_meshWorker.Stop();