aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/PhysicsModules/UbitOde/OdeScene.cs171
1 files changed, 52 insertions, 119 deletions
diff --git a/OpenSim/Region/PhysicsModules/UbitOde/OdeScene.cs b/OpenSim/Region/PhysicsModules/UbitOde/OdeScene.cs
index 6ad42bc..8d3066d 100644
--- a/OpenSim/Region/PhysicsModules/UbitOde/OdeScene.cs
+++ b/OpenSim/Region/PhysicsModules/UbitOde/OdeScene.cs
@@ -169,17 +169,14 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
169 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UBITODEPhysicsScene")] 169 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UBITODEPhysicsScene")]
170 public class ODEScene : PhysicsScene, INonSharedRegionModule 170 public class ODEScene : PhysicsScene, INonSharedRegionModule
171 { 171 {
172 private readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString()); 172 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
173 public string LogHeader = "[UbitODE]";
174 private bool m_Enabled = false;
175 173
176 // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); 174 private bool m_Enabled = false;
177 175
178 public bool OdeUbitLib = false; 176 public bool OdeUbitLib = false;
179 public bool m_suportCombine = false; // mega suport not tested 177 public bool m_suportCombine = false; // mega suport not tested
180 178
181// private int threadid = 0; 179// private int threadid = 0;
182// private Random fluidRandomizer = new Random(Environment.TickCount);
183 180
184// const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce; 181// const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce;
185 182
@@ -331,6 +328,7 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
331 } 328 }
332 */ 329 */
333 #region INonSharedRegionModule 330 #region INonSharedRegionModule
331
334 public string Name 332 public string Name
335 { 333 {
336 get { return "UbitODE"; } 334 get { return "UbitODE"; }
@@ -350,24 +348,10 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
350 string physics = config.GetString("physics", string.Empty); 348 string physics = config.GetString("physics", string.Empty);
351 if (physics == Name) 349 if (physics == Name)
352 { 350 {
353 m_Enabled = true;
354 m_config = source; 351 m_config = source;
355 352 m_Enabled = true;
356 // We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether
357 // it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports
358 // will find it already loaded later on.
359 //
360 // This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be
361 // controlled in Ode.NET.dll.config
362 if (Util.IsWindows())
363 Util.LoadArchSpecificWindowsDll("ode.dll");
364
365 // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
366 // http://opensimulator.org/mantis/view.php?id=2750).
367 d.InitODE();
368 } 353 }
369 } 354 }
370
371 } 355 }
372 356
373 public void Close() 357 public void Close()
@@ -380,42 +364,66 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
380 return; 364 return;
381 365
382 EngineType = Name; 366 EngineType = Name;
383 EngineType = Name;
384 PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName; 367 PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName;
385 368
386 scene.RegisterModuleInterface<PhysicsScene>(this); 369 OdeLock = new Object();
370
371 // We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether
372 // it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports
373 // will find it already loaded later on.
374 //
375 // This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be
376 // controlled in Ode.NET.dll.config
377 if (Util.IsWindows())
378 Util.LoadArchSpecificWindowsDll("ode.dll");
379
380 // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
381 // http://opensimulator.org/mantis/view.php?id=2750).
382 d.InitODE();
383
384 string ode_config = d.GetConfiguration();
385 if (ode_config != null && ode_config != "")
386 {
387 m_log.InfoFormat("[UbitODE] ode library configuration: {0}", ode_config);
388
389 if (ode_config.Contains("ODE_Ubit"))
390 {
391 OdeUbitLib = true;
392 }
393 }
387 394
388 Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ); 395 Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
389 396
397 mesher = scene.RequestModuleInterface<IMesher>();
398 if (mesher == null)
399 {
400 m_log.WarnFormat("[UbitODE] No mesher. module disabled");
401 m_Enabled = false;
402 return;
403 }
404
405 scene.RegisterModuleInterface<PhysicsScene>(this);
406
390 Initialization(extent); 407 Initialization(extent);
391 408
392 base.Initialise(scene.PhysicsRequestAsset, 409 base.Initialise(scene.PhysicsRequestAsset,
393 (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[scene.RegionInfo.RegionSizeX * scene.RegionInfo.RegionSizeY]), 410 (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[scene.RegionInfo.RegionSizeX * scene.RegionInfo.RegionSizeY]),
394 (float)scene.RegionInfo.RegionSettings.WaterHeight); 411 (float)scene.RegionInfo.RegionSettings.WaterHeight);
395 412
413
414 scene.PhysicsEnabled = true;
396 } 415 }
397 416
398 public void RemoveRegion(Scene scene) 417 public void RemoveRegion(Scene scene)
399 { 418 {
400 if (!m_Enabled) 419// if (!m_Enabled)
401 return; 420// return;
402 } 421 }
403 422
404 public void RegionLoaded(Scene scene) 423 public void RegionLoaded(Scene scene)
405 { 424 {
406 if (!m_Enabled) 425// if (!m_Enabled)
407 return; 426// return;
408
409 mesher = scene.RequestModuleInterface<IMesher>();
410 if (mesher == null)
411 {
412 m_log.WarnFormat("{0} No mesher. module disabled", LogHeader);
413 m_Enabled = false;
414 return;
415 }
416
417 region_loaded();
418 scene.PhysicsEnabled = true;
419 } 427 }
420 #endregion 428 #endregion
421 429
@@ -426,16 +434,20 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
426 /// </summary> 434 /// </summary>
427 private void Initialization(Vector3 regionExtent) 435 private void Initialization(Vector3 regionExtent)
428 { 436 {
429
430 // checkThread(); 437 // checkThread();
431
432 OdeLock = new Object();
433 SimulationLock = new Object(); 438 SimulationLock = new Object();
434 439
435 nearCallback = near; 440 nearCallback = near;
436 441
437 m_rayCastManager = new ODERayCastRequestManager(this); 442 m_rayCastManager = new ODERayCastRequestManager(this);
438 443
444 WorldExtents.X = regionExtent.X;
445 m_regionWidth = (uint)regionExtent.X;
446 WorldExtents.Y = regionExtent.Y;
447 m_regionHeight = (uint)regionExtent.Y;
448
449 m_suportCombine = false;
450
439 lock (OdeLock) 451 lock (OdeLock)
440 { 452 {
441 // Create the world and the first space 453 // Create the world and the first space
@@ -506,27 +518,9 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
506 d.WorldSetAutoDisableFlag(world, false); 518 d.WorldSetAutoDisableFlag(world, false);
507 } 519 }
508 520
509 WorldExtents.X = regionExtent.X;
510 m_regionWidth = (uint)regionExtent.X;
511 WorldExtents.Y = regionExtent.Y;
512 m_regionHeight = (uint)regionExtent.Y;
513 521
514 m_suportCombine = false;
515 // checkThread(); 522 // checkThread();
516 }
517 523
518 private void region_loaded()
519 {
520 string ode_config = d.GetConfiguration();
521 if (ode_config != null && ode_config != "")
522 {
523 m_log.WarnFormat("ODE configuration: {0}", ode_config);
524
525 if (ode_config.Contains("ODE_Ubit"))
526 {
527 OdeUbitLib = true;
528 }
529 }
530 524
531 // Defaults 525 // Defaults
532 526
@@ -567,7 +561,6 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
567 } 561 }
568 } 562 }
569 563
570
571 d.WorldSetCFM(world, comumContactCFM); 564 d.WorldSetCFM(world, comumContactCFM);
572 d.WorldSetERP(world, comumContactERP); 565 d.WorldSetERP(world, comumContactERP);
573 566
@@ -2500,7 +2493,6 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
2500 } 2493 }
2501 } 2494 }
2502 2495
2503
2504 public override void DeleteTerrain() 2496 public override void DeleteTerrain()
2505 { 2497 {
2506 } 2498 }
@@ -2514,66 +2506,7 @@ namespace OpenSim.Region.PhysicsModule.UbitOde
2514 { 2506 {
2515 return m_suportCombine; 2507 return m_suportCombine;
2516 } 2508 }
2517/*
2518 public override void UnCombine(PhysicsScene pScene)
2519 {
2520 IntPtr localGround = IntPtr.Zero;
2521// float[] localHeightfield;
2522 bool proceed = false;
2523 List<IntPtr> geomDestroyList = new List<IntPtr>();
2524 2509
2525 lock (OdeLock)
2526 {
2527 if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround))
2528 {
2529 foreach (IntPtr geom in TerrainHeightFieldHeights.Keys)
2530 {
2531 if (geom == localGround)
2532 {
2533// localHeightfield = TerrainHeightFieldHeights[geom];
2534 proceed = true;
2535 }
2536 else
2537 {
2538 geomDestroyList.Add(geom);
2539 }
2540 }
2541
2542 if (proceed)
2543 {
2544 m_worldOffset = Vector3.Zero;
2545 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
2546 m_parentScene = null;
2547
2548 foreach (IntPtr g in geomDestroyList)
2549 {
2550 // removingHeightField needs to be done or the garbage collector will
2551 // collect the terrain data before we tell ODE to destroy it causing
2552 // memory corruption
2553 if (TerrainHeightFieldHeights.ContainsKey(g))
2554 {
2555// float[] removingHeightField = TerrainHeightFieldHeights[g];
2556 TerrainHeightFieldHeights.Remove(g);
2557
2558 if (RegionTerrain.ContainsKey(g))
2559 {
2560 RegionTerrain.Remove(g);
2561 }
2562
2563 d.GeomDestroy(g);
2564 //removingHeightField = new float[0];
2565 }
2566 }
2567
2568 }
2569 else
2570 {
2571 m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data.");
2572 }
2573 }
2574 }
2575 }
2576*/
2577 public override void SetWaterLevel(float baseheight) 2510 public override void SetWaterLevel(float baseheight)
2578 { 2511 {
2579 waterlevel = baseheight; 2512 waterlevel = baseheight;