aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs2
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs9
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs68
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs9
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs114
5 files changed, 140 insertions, 62 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 6e4e41f..865180f 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -740,6 +740,7 @@ namespace OpenSim.Region.Physics.OdePlugin
740 if (Shell != IntPtr.Zero) 740 if (Shell != IntPtr.Zero)
741 { 741 {
742 _parent_scene.geom_name_map.Remove(Shell); 742 _parent_scene.geom_name_map.Remove(Shell);
743 _parent_scene.actor_name_map.Remove(Shell);
743 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); 744 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
744 d.GeomDestroy(Shell); 745 d.GeomDestroy(Shell);
745 Shell = IntPtr.Zero; 746 Shell = IntPtr.Zero;
@@ -1188,6 +1189,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1188 } 1189 }
1189 else 1190 else
1190 { 1191 {
1192 _parent_scene.RemoveCollisionEventReporting(this);
1191 _parent_scene.RemoveCharacter(this); 1193 _parent_scene.RemoveCharacter(this);
1192 // destroy avatar capsule and related ODE data 1194 // destroy avatar capsule and related ODE data
1193 AvatarGeomAndBodyDestroy(); 1195 AvatarGeomAndBodyDestroy();
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
index e27be1e..e900c02 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
@@ -137,6 +137,7 @@ namespace OpenSim.Region.Physics.OdePlugin
137 float m_amdampY; 137 float m_amdampY;
138 float m_amdampZ; 138 float m_amdampZ;
139 139
140
140 public float FrictionFactor 141 public float FrictionFactor
141 { 142 {
142 get 143 get
@@ -145,6 +146,7 @@ namespace OpenSim.Region.Physics.OdePlugin
145 } 146 }
146 } 147 }
147 148
149
148 public ODEDynamics(OdePrim rootp) 150 public ODEDynamics(OdePrim rootp)
149 { 151 {
150 rootPrim = rootp; 152 rootPrim = rootp;
@@ -345,7 +347,7 @@ namespace OpenSim.Region.Physics.OdePlugin
345 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale; 347 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale;
346 m_lmEfect = 1.0f; // turn it on 348 m_lmEfect = 1.0f; // turn it on
347 349
348 m_ffactor = 0.01f; 350 m_ffactor = 0.0f;
349 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) 351 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
350 && !rootPrim.m_isSelected && !rootPrim.m_disabled) 352 && !rootPrim.m_isSelected && !rootPrim.m_disabled)
351 d.BodyEnable(rootPrim.Body); 353 d.BodyEnable(rootPrim.Body);
@@ -401,7 +403,7 @@ namespace OpenSim.Region.Physics.OdePlugin
401 m_lmEfect = 1.0f; // turn it on 403 m_lmEfect = 1.0f; // turn it on
402 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale; 404 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale;
403 405
404 m_ffactor = 0.01f; 406 m_ffactor = 0.0f;
405 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) 407 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
406 && !rootPrim.m_isSelected && !rootPrim.m_disabled) 408 && !rootPrim.m_isSelected && !rootPrim.m_disabled)
407 d.BodyEnable(rootPrim.Body); 409 d.BodyEnable(rootPrim.Body);
@@ -805,7 +807,8 @@ namespace OpenSim.Region.Physics.OdePlugin
805 } 807 }
806 808
807 m_lmEfect *= m_lmDecay; 809 m_lmEfect *= m_lmDecay;
808 m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared(); 810// m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared();
811 m_ffactor = 0.0f;
809 } 812 }
810 else 813 else
811 { 814 {
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index 9b3b51b..ff17a6e 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -275,6 +275,7 @@ namespace OpenSim.Region.Physics.OdePlugin
275 275
276 if (veh != null && veh.Type != Vehicle.TYPE_NONE) 276 if (veh != null && veh.Type != Vehicle.TYPE_NONE)
277 cdata.mu *= veh.FrictionFactor; 277 cdata.mu *= veh.FrictionFactor;
278// cdata.mu *= 0;
278 } 279 }
279 } 280 }
280 281
@@ -582,8 +583,6 @@ namespace OpenSim.Region.Physics.OdePlugin
582 if (value.IsFinite()) 583 if (value.IsFinite())
583 { 584 {
584 AddChange(changes.Velocity, value); 585 AddChange(changes.Velocity, value);
585// _velocity = value;
586
587 } 586 }
588 else 587 else
589 { 588 {
@@ -675,9 +674,7 @@ namespace OpenSim.Region.Physics.OdePlugin
675 { 674 {
676 if (value.IsFinite()) 675 if (value.IsFinite())
677 { 676 {
678 m_rotationalVelocity = value; 677 AddChange(changes.AngVelocity, value);
679 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
680 d.BodyEnable(Body);
681 } 678 }
682 else 679 else
683 { 680 {
@@ -686,7 +683,6 @@ namespace OpenSim.Region.Physics.OdePlugin
686 } 683 }
687 } 684 }
688 685
689
690 public override float Buoyancy 686 public override float Buoyancy
691 { 687 {
692 get { return m_buoyancy; } 688 get { return m_buoyancy; }
@@ -947,6 +943,8 @@ namespace OpenSim.Region.Physics.OdePlugin
947 CollisionEventsThisFrame = null; 943 CollisionEventsThisFrame = null;
948 } 944 }
949 m_eventsubscription = 0; 945 m_eventsubscription = 0;
946 // for now still done on odescene
947// _parent_scene.RemoveCollisionEventReporting(this);
950 } 948 }
951 949
952 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) 950 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
@@ -1736,17 +1734,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1736 1734
1737 d.BodySetAutoDisableFlag(Body, true); 1735 d.BodySetAutoDisableFlag(Body, true);
1738 d.BodySetAutoDisableSteps(Body, body_autodisable_frames); 1736 d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
1739// d.BodySetLinearDampingThreshold(Body, 0.01f); 1737 d.BodySetDamping(Body, .005f, .005f);
1740// d.BodySetAngularDampingThreshold(Body, 0.001f);
1741 d.BodySetDamping(Body, .002f, .002f);
1742
1743 if (m_targetSpace != IntPtr.Zero)
1744 {
1745 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1746 if (d.SpaceQuery(m_targetSpace, prim_geom))
1747 d.SpaceRemove(m_targetSpace, prim_geom);
1748 }
1749 1738
1739 if (m_targetSpace != IntPtr.Zero)
1740 {
1741 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1742 if (d.SpaceQuery(m_targetSpace, prim_geom))
1743 d.SpaceRemove(m_targetSpace, prim_geom);
1744 }
1750 1745
1751 if (childrenPrim.Count == 0) 1746 if (childrenPrim.Count == 0)
1752 { 1747 {
@@ -3295,6 +3290,13 @@ namespace OpenSim.Region.Physics.OdePlugin
3295 3290
3296 private void changevelocity(Vector3 newVel) 3291 private void changevelocity(Vector3 newVel)
3297 { 3292 {
3293 float len = newVel.LengthSquared();
3294 if (len > 100000.0f) // limit to 100m/s
3295 {
3296 len = 100.0f / (float)Math.Sqrt(len);
3297 newVel *= len;
3298 }
3299
3298 if (!m_isSelected) 3300 if (!m_isSelected)
3299 { 3301 {
3300 if (Body != IntPtr.Zero) 3302 if (Body != IntPtr.Zero)
@@ -3311,6 +3313,33 @@ namespace OpenSim.Region.Physics.OdePlugin
3311 _velocity = newVel; 3313 _velocity = newVel;
3312 } 3314 }
3313 3315
3316
3317 private void changeangvelocity(Vector3 newAngVel)
3318 {
3319 float len = newAngVel.LengthSquared();
3320 if (len > 144.0f) // limit to 12rad/s
3321 {
3322 len = 12.0f / (float)Math.Sqrt(len);
3323 newAngVel *= len;
3324 }
3325
3326 if (!m_isSelected)
3327 {
3328 if (Body != IntPtr.Zero)
3329 {
3330 if (m_disabled)
3331 enableBodySoft();
3332 else if (!d.BodyIsEnabled(Body))
3333 d.BodyEnable(Body);
3334
3335
3336 d.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z);
3337 }
3338 //resetCollisionAccounting();
3339 }
3340 m_rotationalVelocity = newAngVel;
3341 }
3342
3314 private void changeVolumedetetion(bool newVolDtc) 3343 private void changeVolumedetetion(bool newVolDtc)
3315 { 3344 {
3316 m_isVolumeDetect = newVolDtc; 3345 m_isVolumeDetect = newVolDtc;
@@ -3947,9 +3976,10 @@ namespace OpenSim.Region.Physics.OdePlugin
3947// case changes.Acceleration: 3976// case changes.Acceleration:
3948// changeacceleration((Vector3)arg); 3977// changeacceleration((Vector3)arg);
3949// break; 3978// break;
3950// case changes.AngVelocity: 3979
3951// changeangvelocity((Vector3)arg); 3980 case changes.AngVelocity:
3952// break; 3981 changeangvelocity((Vector3)arg);
3982 break;
3953 3983
3954 case changes.Force: 3984 case changes.Force:
3955 changeForce((Vector3)arg); 3985 changeForce((Vector3)arg);
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
index 0e4961b..2341186 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
@@ -1312,7 +1312,14 @@ namespace OdeAPI
1312 public static extern void GeomTriMeshSetRayCallback(IntPtr g, TriRayCallback callback); 1312 public static extern void GeomTriMeshSetRayCallback(IntPtr g, TriRayCallback callback);
1313 1313
1314 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGetConfiguration"), SuppressUnmanagedCodeSecurity] 1314 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGetConfiguration"), SuppressUnmanagedCodeSecurity]
1315 public static extern string GetConfiguration(string str); 1315 public static extern IntPtr iGetConfiguration();
1316
1317 public static string GetConfiguration()
1318 {
1319 IntPtr ptr = iGetConfiguration();
1320 string s = Marshal.PtrToStringAnsi(ptr);
1321 return s;
1322 }
1316 1323
1317 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dHashSpaceCreate"), SuppressUnmanagedCodeSecurity] 1324 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dHashSpaceCreate"), SuppressUnmanagedCodeSecurity]
1318 public static extern IntPtr HashSpaceCreate(IntPtr space); 1325 public static extern IntPtr HashSpaceCreate(IntPtr space);
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 6c72324..7848b35 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -237,20 +237,20 @@ namespace OpenSim.Region.Physics.OdePlugin
237 237
238 private d.NearCallback nearCallback; 238 private d.NearCallback nearCallback;
239 239
240 private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); 240 private HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
241 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); 241 private HashSet<OdePrim> _prims = new HashSet<OdePrim>();
242 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); 242 private HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
243 private readonly HashSet<OdePrim> _activegroups = new HashSet<OdePrim>(); 243 private HashSet<OdePrim> _activegroups = new HashSet<OdePrim>();
244 244
245 public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>(); 245 public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>();
246 246
247 /// <summary> 247 /// <summary>
248 /// A list of actors that should receive collision events. 248 /// A list of actors that should receive collision events.
249 /// </summary> 249 /// </summary>
250 private readonly List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>(); 250 private List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>();
251 private readonly List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>(); 251 private List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>();
252 252
253 private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>(); 253 private HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
254 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); 254 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
255 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>(); 255 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
256 256
@@ -264,26 +264,21 @@ namespace OpenSim.Region.Physics.OdePlugin
264 private volatile int m_global_contactcount = 0; 264 private volatile int m_global_contactcount = 0;
265 265
266 266
267 private readonly IntPtr contactgroup; 267 private IntPtr contactgroup;
268 268
269 public ContactData[] m_materialContactsData = new ContactData[8]; 269 public ContactData[] m_materialContactsData = new ContactData[8];
270 270
271 private readonly DoubleDictionary<Vector3, IntPtr, IntPtr> RegionTerrain = new DoubleDictionary<Vector3, IntPtr, IntPtr>(); 271 private Dictionary<Vector3, IntPtr> RegionTerrain = new Dictionary<Vector3, IntPtr>();
272 private readonly Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>(); 272 private Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>();
273 private readonly Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>(); 273 private Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>();
274 274
275 private int m_physicsiterations = 10; 275 private int m_physicsiterations = 10;
276 private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag 276 private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag
277 private readonly PhysicsActor PANull = new NullPhysicsActor(); 277 private PhysicsActor PANull = new NullPhysicsActor();
278 private float step_time = 0.0f; 278 private float step_time = 0.0f;
279 279
280 public IntPtr world; 280 public IntPtr world;
281 281
282 private uint obj2LocalID = 0;
283 private OdeCharacter cc1;
284 private OdePrim cp1;
285 private OdeCharacter cc2;
286 private OdePrim cp2;
287 282
288 // split the spaces acording to contents type 283 // split the spaces acording to contents type
289 // ActiveSpace contains characters and active prims 284 // ActiveSpace contains characters and active prims
@@ -408,8 +403,8 @@ namespace OpenSim.Region.Physics.OdePlugin
408// checkThread(); 403// checkThread();
409 mesher = meshmerizer; 404 mesher = meshmerizer;
410 m_config = config; 405 m_config = config;
411/* 406
412 string ode_config = d.GetConfiguration("ODE"); 407 string ode_config = d.GetConfiguration();
413 if (ode_config != null && ode_config != "") 408 if (ode_config != null && ode_config != "")
414 { 409 {
415 m_log.WarnFormat("ODE configuration: {0}", ode_config); 410 m_log.WarnFormat("ODE configuration: {0}", ode_config);
@@ -419,7 +414,7 @@ namespace OpenSim.Region.Physics.OdePlugin
419 OdeUbitLib = true; 414 OdeUbitLib = true;
420 } 415 }
421 } 416 }
422*/ 417
423 /* 418 /*
424 if (region != null) 419 if (region != null)
425 { 420 {
@@ -526,8 +521,8 @@ namespace OpenSim.Region.Physics.OdePlugin
526 d.WorldSetGravity(world, gravityx, gravityy, gravityz); 521 d.WorldSetGravity(world, gravityx, gravityy, gravityz);
527 d.WorldSetContactSurfaceLayer(world, contactsurfacelayer); 522 d.WorldSetContactSurfaceLayer(world, contactsurfacelayer);
528 523
529 d.WorldSetLinearDamping(world, 0.001f); 524 d.WorldSetLinearDamping(world, 0.002f);
530 d.WorldSetAngularDamping(world, 0.001f); 525 d.WorldSetAngularDamping(world, 0.002f);
531 d.WorldSetAngularDampingThreshold(world, 0f); 526 d.WorldSetAngularDampingThreshold(world, 0f);
532 d.WorldSetLinearDampingThreshold(world, 0f); 527 d.WorldSetLinearDampingThreshold(world, 0f);
533 d.WorldSetMaxAngularSpeed(world, 100f); 528 d.WorldSetMaxAngularSpeed(world, 100f);
@@ -921,6 +916,8 @@ namespace OpenSim.Region.Physics.OdePlugin
921 cfm = 0.0001f / cfm; 916 cfm = 0.0001f / cfm;
922 if (cfm > 0.01f) 917 if (cfm > 0.01f)
923 cfm = 0.01f; 918 cfm = 0.01f;
919 else if (cfm < 0.00001f)
920 cfm = 0.00001f;
924 921
925 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) 922 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
926 mu *= frictionMovementMult; 923 mu *= frictionMovementMult;
@@ -947,6 +944,8 @@ namespace OpenSim.Region.Physics.OdePlugin
947 cfm = 0.0001f / cfm; 944 cfm = 0.0001f / cfm;
948 if (cfm > 0.01f) 945 if (cfm > 0.01f)
949 cfm = 0.01f; 946 cfm = 0.01f;
947 else if (cfm < 0.00001f)
948 cfm = 0.00001f;
950 949
951 if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) 950 if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
952 { 951 {
@@ -989,6 +988,8 @@ namespace OpenSim.Region.Physics.OdePlugin
989 cfm = 0.0001f / cfm; 988 cfm = 0.0001f / cfm;
990 if (cfm > 0.01f) 989 if (cfm > 0.01f)
991 cfm = 0.01f; 990 cfm = 0.01f;
991 else if (cfm < 0.00001f)
992 cfm = 0.00001f;
992 993
993 if (curContact.side1 > 0) // should be 2 ? 994 if (curContact.side1 > 0) // should be 2 ?
994 IgnoreNegSides = true; 995 IgnoreNegSides = true;
@@ -1155,7 +1156,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1155 1156
1156 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) 1157 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
1157 { 1158 {
1158 obj2LocalID = 0; 1159
1160 OdeCharacter cc1;
1161 OdePrim cp1;
1162 OdeCharacter cc2;
1163 OdePrim cp2;
1164
1165 uint obj2LocalID = 0;
1159 bool p1events = p1.SubscribedEvents(); 1166 bool p1events = p1.SubscribedEvents();
1160 bool p2events = p2.SubscribedEvents(); 1167 bool p2events = p2.SubscribedEvents();
1161 1168
@@ -1892,18 +1899,22 @@ namespace OpenSim.Region.Physics.OdePlugin
1892 lock (SimulationLock) 1899 lock (SimulationLock)
1893 lock(OdeLock) 1900 lock(OdeLock)
1894 { 1901 {
1902 if (world == IntPtr.Zero)
1903 return 0;
1904
1895 // adjust number of iterations per step 1905 // adjust number of iterations per step
1896 try 1906
1897 { 1907// try
1908// {
1898 d.WorldSetQuickStepNumIterations(world, curphysiteractions); 1909 d.WorldSetQuickStepNumIterations(world, curphysiteractions);
1899 } 1910/* }
1900 catch (StackOverflowException) 1911 catch (StackOverflowException)
1901 { 1912 {
1902 m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); 1913 m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim.");
1903// ode.drelease(world); 1914// ode.drelease(world);
1904 base.TriggerPhysicsBasedRestart(); 1915 base.TriggerPhysicsBasedRestart();
1905 } 1916 }
1906 1917*/
1907 while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever 1918 while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever
1908 { 1919 {
1909 try 1920 try
@@ -1955,6 +1966,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1955 { 1966 {
1956 RemoveCharacter(defect); 1967 RemoveCharacter(defect);
1957 } 1968 }
1969 defects.Clear();
1958 } 1970 }
1959 } 1971 }
1960 1972
@@ -2060,13 +2072,13 @@ namespace OpenSim.Region.Physics.OdePlugin
2060 _badCharacter.Clear(); 2072 _badCharacter.Clear();
2061 } 2073 }
2062 } 2074 }
2063 2075/*
2064 int nactivegeoms = d.SpaceGetNumGeoms(ActiveSpace); 2076 int nactivegeoms = d.SpaceGetNumGeoms(ActiveSpace);
2065 int nstaticgeoms = d.SpaceGetNumGeoms(StaticSpace); 2077 int nstaticgeoms = d.SpaceGetNumGeoms(StaticSpace);
2066 int ntopgeoms = d.SpaceGetNumGeoms(TopSpace); 2078 int ntopgeoms = d.SpaceGetNumGeoms(TopSpace);
2067 int nbodies = d.NTotalBodies; 2079 int nbodies = d.NTotalBodies;
2068 int ngeoms = d.NTotalGeoms; 2080 int ngeoms = d.NTotalGeoms;
2069 2081*/
2070 // Finished with all sim stepping. If requested, dump world state to file for debugging. 2082 // Finished with all sim stepping. If requested, dump world state to file for debugging.
2071 // TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed? 2083 // TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed?
2072 // TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots? 2084 // TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots?
@@ -2383,11 +2395,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2383 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); 2395 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
2384 d.GeomSetRotation(GroundGeom, ref R); 2396 d.GeomSetRotation(GroundGeom, ref R);
2385 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); 2397 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
2386 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); 2398 RegionTerrain.Add(pOffset, GroundGeom);
2387// TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
2388 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 2399 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
2389 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); 2400 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
2390
2391 } 2401 }
2392 } 2402 }
2393 2403
@@ -2486,8 +2496,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2486 geom_name_map[GroundGeom] = "Terrain"; 2496 geom_name_map[GroundGeom] = "Terrain";
2487 2497
2488 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); 2498 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
2489 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); 2499 RegionTerrain.Add(pOffset, GroundGeom);
2490 // TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
2491 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 2500 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
2492 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); 2501 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
2493 } 2502 }
@@ -2649,19 +2658,42 @@ namespace OpenSim.Region.Physics.OdePlugin
2649 2658
2650 public override void Dispose() 2659 public override void Dispose()
2651 { 2660 {
2652 m_rayCastManager.Dispose();
2653 m_rayCastManager = null;
2654
2655 lock (OdeLock) 2661 lock (OdeLock)
2656 { 2662 {
2663 m_rayCastManager.Dispose();
2664 m_rayCastManager = null;
2665
2657 lock (_prims) 2666 lock (_prims)
2658 { 2667 {
2668 ChangesQueue.Clear();
2659 foreach (OdePrim prm in _prims) 2669 foreach (OdePrim prm in _prims)
2660 { 2670 {
2661 RemovePrim(prm); 2671 prm.DoAChange(changes.Remove, null);
2672 _collisionEventPrim.Remove(prm);
2662 } 2673 }
2674 _prims.Clear();
2663 } 2675 }
2664 2676
2677 OdeCharacter[] chtorem;
2678 lock (_characters)
2679 {
2680 chtorem = new OdeCharacter[_characters.Count];
2681 _characters.CopyTo(chtorem);
2682 }
2683
2684 ChangesQueue.Clear();
2685 foreach (OdeCharacter ch in chtorem)
2686 ch.DoAChange(changes.Remove, null);
2687
2688
2689 foreach (IntPtr GroundGeom in RegionTerrain.Values)
2690 {
2691 if (GroundGeom != IntPtr.Zero)
2692 d.GeomDestroy(GroundGeom);
2693 }
2694
2695 RegionTerrain.Clear();
2696
2665 if (TerrainHeightFieldHeightsHandlers.Count > 0) 2697 if (TerrainHeightFieldHeightsHandlers.Count > 0)
2666 { 2698 {
2667 foreach (GCHandle gch in TerrainHeightFieldHeightsHandlers.Values) 2699 foreach (GCHandle gch in TerrainHeightFieldHeightsHandlers.Values)
@@ -2671,6 +2703,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2671 } 2703 }
2672 } 2704 }
2673 2705
2706 TerrainHeightFieldHeightsHandlers.Clear();
2707 TerrainHeightFieldHeights.Clear();
2708
2674 if (WaterGeom != IntPtr.Zero) 2709 if (WaterGeom != IntPtr.Zero)
2675 { 2710 {
2676 d.GeomDestroy(WaterGeom); 2711 d.GeomDestroy(WaterGeom);
@@ -2691,6 +2726,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2691 2726
2692 2727
2693 d.WorldDestroy(world); 2728 d.WorldDestroy(world);
2729 world = IntPtr.Zero;
2694 //d.CloseODE(); 2730 //d.CloseODE();
2695 } 2731 }
2696 } 2732 }