aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs321
1 files changed, 77 insertions, 244 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index f126644..5e4c2a5 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -60,6 +60,7 @@ namespace OpenSim.Region.Physics.OdePlugin
60 public int lastframe; 60 public int lastframe;
61 } 61 }
62 62
63
63 // colision flags of things others can colide with 64 // colision flags of things others can colide with
64 // rays, sensors, probes removed since can't be colided with 65 // rays, sensors, probes removed since can't be colided with
65 // The top space where things are placed provided further selection 66 // The top space where things are placed provided further selection
@@ -109,6 +110,17 @@ namespace OpenSim.Region.Physics.OdePlugin
109 110
110 light = 7 // compatibility with old viewers 111 light = 7 // compatibility with old viewers
111 } 112 }
113
114 public enum AssetState : byte
115 {
116 noNeedAsset = 0,
117 needAsset = 1,
118 loadingAsset = 2,
119 procAsset = 3,
120 AssetOK = 4,
121
122 AssetFailed = 0xff
123 }
112 124
113 public enum changes : int 125 public enum changes : int
114 { 126 {
@@ -147,6 +159,8 @@ namespace OpenSim.Region.Physics.OdePlugin
147 159
148 Size, 160 Size,
149 Shape, 161 Shape,
162 PhysRepData,
163 AddPhysRep,
150 164
151 CollidesWater, 165 CollidesWater,
152 VolumeDtc, 166 VolumeDtc,
@@ -230,11 +244,6 @@ namespace OpenSim.Region.Physics.OdePlugin
230 private float minimumGroundFlightOffset = 3f; 244 private float minimumGroundFlightOffset = 3f;
231 public float maximumMassObject = 10000.01f; 245 public float maximumMassObject = 10000.01f;
232 246
233 public bool meshSculptedPrim = true;
234 public bool forceSimplePrimMeshing = false;
235
236 public float meshSculptLOD = 32;
237 public float MeshSculptphysicalLOD = 32;
238 247
239 public float geomDefaultDensity = 10.000006836f; 248 public float geomDefaultDensity = 10.000006836f;
240 249
@@ -313,7 +322,7 @@ namespace OpenSim.Region.Physics.OdePlugin
313 private IntPtr[] staticPrimspaceOffRegion; 322 private IntPtr[] staticPrimspaceOffRegion;
314 323
315 public Object OdeLock; 324 public Object OdeLock;
316 private static Object SimulationLock; 325 public static Object SimulationLock;
317 326
318 public IMesher mesher; 327 public IMesher mesher;
319 328
@@ -328,7 +337,7 @@ namespace OpenSim.Region.Physics.OdePlugin
328 private PhysicsScene m_parentScene = null; 337 private PhysicsScene m_parentScene = null;
329 338
330 private ODERayCastRequestManager m_rayCastManager; 339 private ODERayCastRequestManager m_rayCastManager;
331 340 public ODEMeshWorker m_meshWorker;
332 341
333/* maybe needed if ode uses tls 342/* maybe needed if ode uses tls
334 private void checkThread() 343 private void checkThread()
@@ -361,6 +370,8 @@ namespace OpenSim.Region.Physics.OdePlugin
361 nearCallback = near; 370 nearCallback = near;
362 371
363 m_rayCastManager = new ODERayCastRequestManager(this); 372 m_rayCastManager = new ODERayCastRequestManager(this);
373
374
364 lock (OdeLock) 375 lock (OdeLock)
365 { 376 {
366 // Create the world and the first space 377 // Create the world and the first space
@@ -402,6 +413,7 @@ namespace OpenSim.Region.Physics.OdePlugin
402 )); 413 ));
403 d.GeomSetCollideBits(StaticSpace, 0); 414 d.GeomSetCollideBits(StaticSpace, 0);
404 415
416
405 contactgroup = d.JointGroupCreate(0); 417 contactgroup = d.JointGroupCreate(0);
406 //contactgroup 418 //contactgroup
407 419
@@ -440,9 +452,11 @@ namespace OpenSim.Region.Physics.OdePlugin
440 452
441 int contactsPerCollision = 80; 453 int contactsPerCollision = 80;
442 454
455 IConfig physicsconfig = null;
456
443 if (m_config != null) 457 if (m_config != null)
444 { 458 {
445 IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; 459 physicsconfig = m_config.Configs["ODEPhysicsSettings"];
446 if (physicsconfig != null) 460 if (physicsconfig != null)
447 { 461 {
448 gravityx = physicsconfig.GetFloat("world_gravityx", gravityx); 462 gravityx = physicsconfig.GetFloat("world_gravityx", gravityx);
@@ -469,27 +483,7 @@ namespace OpenSim.Region.Physics.OdePlugin
469 483
470 geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", geomDefaultDensity); 484 geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", geomDefaultDensity);
471 bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", bodyFramesAutoDisable); 485 bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", bodyFramesAutoDisable);
472/* 486
473 bodyPIDD = physicsconfig.GetFloat("body_pid_derivative", bodyPIDD);
474 bodyPIDG = physicsconfig.GetFloat("body_pid_gain", bodyPIDG);
475*/
476 forceSimplePrimMeshing = physicsconfig.GetBoolean("force_simple_prim_meshing", forceSimplePrimMeshing);
477 meshSculptedPrim = physicsconfig.GetBoolean("mesh_sculpted_prim", meshSculptedPrim);
478 meshSculptLOD = physicsconfig.GetFloat("mesh_lod", meshSculptLOD);
479 MeshSculptphysicalLOD = physicsconfig.GetFloat("mesh_physical_lod", MeshSculptphysicalLOD);
480/*
481 if (Environment.OSVersion.Platform == PlatformID.Unix)
482 {
483 avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", avPIDD);
484 avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", avPIDP);
485 }
486 else
487 {
488
489 avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", avPIDD);
490 avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", avPIDP);
491 }
492*/
493 physics_logging = physicsconfig.GetBoolean("physics_logging", false); 487 physics_logging = physicsconfig.GetBoolean("physics_logging", false);
494 physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0); 488 physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0);
495 physics_logging_append_existing_logfile = physicsconfig.GetBoolean("physics_logging_append_existing_logfile", false); 489 physics_logging_append_existing_logfile = physicsconfig.GetBoolean("physics_logging_append_existing_logfile", false);
@@ -499,6 +493,8 @@ namespace OpenSim.Region.Physics.OdePlugin
499 } 493 }
500 } 494 }
501 495
496 m_meshWorker = new ODEMeshWorker(this, m_log, meshmerizer, physicsconfig);
497
502 HalfOdeStep = ODE_STEPSIZE * 0.5f; 498 HalfOdeStep = ODE_STEPSIZE * 0.5f;
503 odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f); 499 odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f);
504 500
@@ -1295,6 +1291,15 @@ namespace OpenSim.Region.Physics.OdePlugin
1295 _collisionEventPrimRemove.Add(obj); 1291 _collisionEventPrimRemove.Add(obj);
1296 } 1292 }
1297 1293
1294 public override float TimeDilation
1295 {
1296 get { return m_timeDilation; }
1297 }
1298
1299 public override bool SupportsNINJAJoints
1300 {
1301 get { return false; }
1302 }
1298 1303
1299 #region Add/Remove Entities 1304 #region Add/Remove Entities
1300 1305
@@ -1350,117 +1355,59 @@ namespace OpenSim.Region.Physics.OdePlugin
1350 ((OdeCharacter) actor).Destroy(); 1355 ((OdeCharacter) actor).Destroy();
1351 } 1356 }
1352 1357
1353 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
1354 PrimitiveBaseShape pbs, bool isphysical, uint localID)
1355 {
1356 Vector3 pos = position;
1357 Vector3 siz = size;
1358 Quaternion rot = rotation;
1359 1358
1360 OdePrim newPrim; 1359 public void addActivePrim(OdePrim activatePrim)
1361 lock (OdeLock) 1360 {
1361 // adds active prim..
1362 lock (_activeprims)
1362 { 1363 {
1363 newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical,false,0,localID); 1364 if (!_activeprims.Contains(activatePrim))
1364 1365 _activeprims.Add(activatePrim);
1365 lock (_prims)
1366 _prims.Add(newPrim);
1367 } 1366 }
1368 return newPrim;
1369 } 1367 }
1370 1368
1371 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, 1369 public void addActiveGroups(OdePrim activatePrim)
1372 PrimitiveBaseShape pbs, bool isphysical, bool isPhantom, uint localID)
1373 { 1370 {
1374 Vector3 pos = position; 1371 lock (_activegroups)
1375 Vector3 siz = size;
1376 Quaternion rot = rotation;
1377
1378 OdePrim newPrim;
1379 lock (OdeLock)
1380 { 1372 {
1381 newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical, isPhantom, 0, localID); 1373 if (!_activegroups.Contains(activatePrim))
1382 1374 _activegroups.Add(activatePrim);
1383 lock (_prims)
1384 _prims.Add(newPrim);
1385 } 1375 }
1386 return newPrim;
1387 } 1376 }
1388 1377
1389 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, 1378 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
1390 PrimitiveBaseShape pbs, bool isphysical, bool isPhantom, byte shapeType, uint localID) 1379 PrimitiveBaseShape pbs, bool isphysical, bool isPhantom, byte shapeType, uint localID)
1391 { 1380 {
1392 Vector3 pos = position;
1393 Vector3 siz = size;
1394 Quaternion rot = rotation;
1395
1396 OdePrim newPrim; 1381 OdePrim newPrim;
1397 lock (OdeLock) 1382 lock (OdeLock)
1398 { 1383 {
1399 newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical, isPhantom, shapeType, localID); 1384 newPrim = new OdePrim(name, this, position, size, rotation, pbs, isphysical, isPhantom, shapeType, localID);
1400
1401 lock (_prims) 1385 lock (_prims)
1402 _prims.Add(newPrim); 1386 _prims.Add(newPrim);
1403 } 1387 }
1404 return newPrim; 1388 return newPrim;
1405 } 1389 }
1406 1390
1407 public void addActivePrim(OdePrim activatePrim)
1408 {
1409 // adds active prim..
1410 lock (_activeprims)
1411 {
1412 if (!_activeprims.Contains(activatePrim))
1413 _activeprims.Add(activatePrim);
1414 }
1415 }
1416
1417 public void addActiveGroups(OdePrim activatePrim)
1418 {
1419 lock (_activegroups)
1420 {
1421 if (!_activegroups.Contains(activatePrim))
1422 _activegroups.Add(activatePrim);
1423 }
1424 }
1425
1426 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 1391 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1427 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, uint localid) 1392 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, uint localid)
1428 { 1393 {
1429 return AddPrim(primName, position, size, rotation, pbs, isPhysical, isPhantom, localid); 1394 return AddPrim(primName, position, size, rotation, pbs, isPhysical, isPhantom, 0 , localid);
1430 } 1395 }
1431 1396
1432 1397
1433 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 1398 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1434 Vector3 size, Quaternion rotation, bool isPhysical, uint localid) 1399 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
1435 { 1400 {
1436#if SPAM 1401 return AddPrim(primName, position, size, rotation, pbs, isPhysical,false, 0, localid);
1437 m_log.DebugFormat("[PHYSICS]: Adding physics actor to {0}", primName);
1438#endif
1439
1440 return AddPrim(primName, position, size, rotation, pbs, isPhysical, localid);
1441 } 1402 }
1442 1403
1443 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, 1404 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1444 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, byte shapeType, uint localid) 1405 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, byte shapeType, uint localid)
1445 { 1406 {
1446#if SPAM
1447 m_log.DebugFormat("[PHYSICS]: Adding physics actor to {0}", primName);
1448#endif
1449 1407
1450 return AddPrim(primName, position, size, rotation, pbs, isPhysical,isPhantom, shapeType, localid); 1408 return AddPrim(primName, position, size, rotation, pbs, isPhysical,isPhantom, shapeType, localid);
1451 } 1409 }
1452 1410
1453 public override float TimeDilation
1454 {
1455 get { return m_timeDilation; }
1456 }
1457
1458 public override bool SupportsNINJAJoints
1459 {
1460 get { return false; }
1461 }
1462
1463
1464 public void remActivePrim(OdePrim deactivatePrim) 1411 public void remActivePrim(OdePrim deactivatePrim)
1465 { 1412 {
1466 lock (_activeprims) 1413 lock (_activeprims)
@@ -1513,6 +1460,28 @@ namespace OpenSim.Region.Physics.OdePlugin
1513 } 1460 }
1514 1461
1515 } 1462 }
1463
1464 public bool havePrim(OdePrim prm)
1465 {
1466 lock (_prims)
1467 return _prims.Contains(prm);
1468 }
1469
1470 public bool haveActor(PhysicsActor actor)
1471 {
1472 if (actor is OdePrim)
1473 {
1474 lock (_prims)
1475 return _prims.Contains((OdePrim)actor);
1476 }
1477 else if (actor is OdeCharacter)
1478 {
1479 lock (_characters)
1480 return _characters.Contains((OdeCharacter)actor);
1481 }
1482 return false;
1483 }
1484
1516 #endregion 1485 #endregion
1517 1486
1518 #region Space Separation Calculation 1487 #region Space Separation Calculation
@@ -1615,135 +1584,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1615 1584
1616 #endregion 1585 #endregion
1617 1586
1618 /// <summary>
1619 /// Routine to figure out if we need to mesh this prim with our mesher
1620 /// </summary>
1621 /// <param name="pbs"></param>
1622 /// <returns></returns>
1623 public bool needsMeshing(PrimitiveBaseShape pbs)
1624 {
1625 // check sculpts or meshs
1626 if (pbs.SculptEntry)
1627 {
1628 if (meshSculptedPrim)
1629 return true;
1630
1631 if (pbs.SculptType == (byte)SculptType.Mesh) // always do meshs
1632 return true;
1633
1634 return false;
1635 }
1636
1637 if (forceSimplePrimMeshing)
1638 return true;
1639
1640 // if it's a standard box or sphere with no cuts, hollows, twist or top shear, return false since ODE can use an internal representation for the prim
1641
1642 if ((pbs.ProfileShape == ProfileShape.Square && pbs.PathCurve == (byte)Extrusion.Straight)
1643 || (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1
1644 && pbs.Scale.X == pbs.Scale.Y && pbs.Scale.Y == pbs.Scale.Z))
1645 {
1646
1647 if (pbs.ProfileBegin == 0 && pbs.ProfileEnd == 0
1648 && pbs.ProfileHollow == 0
1649 && pbs.PathTwist == 0 && pbs.PathTwistBegin == 0
1650 && pbs.PathBegin == 0 && pbs.PathEnd == 0
1651 && pbs.PathTaperX == 0 && pbs.PathTaperY == 0
1652 && pbs.PathScaleX == 100 && pbs.PathScaleY == 100
1653 && pbs.PathShearX == 0 && pbs.PathShearY == 0)
1654 {
1655#if SPAM
1656 m_log.Warn("NonMesh");
1657#endif
1658 return false;
1659 }
1660 }
1661
1662 // following code doesn't give meshs to boxes and spheres ever
1663 // and it's odd.. so for now just return true if asked to force meshs
1664 // hopefully mesher will fail if doesn't suport so things still get basic boxes
1665
1666 int iPropertiesNotSupportedDefault = 0;
1667
1668 if (pbs.ProfileHollow != 0)
1669 iPropertiesNotSupportedDefault++;
1670
1671 if ((pbs.PathBegin != 0) || pbs.PathEnd != 0)
1672 iPropertiesNotSupportedDefault++;
1673
1674 if ((pbs.PathTwistBegin != 0) || (pbs.PathTwist != 0))
1675 iPropertiesNotSupportedDefault++;
1676
1677 if ((pbs.ProfileBegin != 0) || pbs.ProfileEnd != 0)
1678 iPropertiesNotSupportedDefault++;
1679
1680 if ((pbs.PathScaleX != 100) || (pbs.PathScaleY != 100))
1681 iPropertiesNotSupportedDefault++;
1682
1683 if ((pbs.PathShearX != 0) || (pbs.PathShearY != 0))
1684 iPropertiesNotSupportedDefault++;
1685
1686 if (pbs.ProfileShape == ProfileShape.Circle && pbs.PathCurve == (byte)Extrusion.Straight)
1687 iPropertiesNotSupportedDefault++;
1688
1689 if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1 && (pbs.Scale.X != pbs.Scale.Y || pbs.Scale.Y != pbs.Scale.Z || pbs.Scale.Z != pbs.Scale.X))
1690 iPropertiesNotSupportedDefault++;
1691
1692 if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte) Extrusion.Curve1)
1693 iPropertiesNotSupportedDefault++;
1694
1695 // test for torus
1696 if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.Square)
1697 {
1698 if (pbs.PathCurve == (byte)Extrusion.Curve1)
1699 {
1700 iPropertiesNotSupportedDefault++;
1701 }
1702 }
1703 else if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
1704 {
1705 if (pbs.PathCurve == (byte)Extrusion.Straight)
1706 {
1707 iPropertiesNotSupportedDefault++;
1708 }
1709
1710 // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits
1711 else if (pbs.PathCurve == (byte)Extrusion.Curve1)
1712 {
1713 iPropertiesNotSupportedDefault++;
1714 }
1715 }
1716 else if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
1717 {
1718 if (pbs.PathCurve == (byte)Extrusion.Curve1 || pbs.PathCurve == (byte)Extrusion.Curve2)
1719 {
1720 iPropertiesNotSupportedDefault++;
1721 }
1722 }
1723 else if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
1724 {
1725 if (pbs.PathCurve == (byte)Extrusion.Straight)
1726 {
1727 iPropertiesNotSupportedDefault++;
1728 }
1729 else if (pbs.PathCurve == (byte)Extrusion.Curve1)
1730 {
1731 iPropertiesNotSupportedDefault++;
1732 }
1733 }
1734
1735 if (iPropertiesNotSupportedDefault == 0)
1736 {
1737#if SPAM
1738 m_log.Warn("NonMesh");
1739#endif
1740 return false;
1741 }
1742#if SPAM
1743 m_log.Debug("Mesh");
1744#endif
1745 return true;
1746 }
1747 1587
1748 /// <summary> 1588 /// <summary>
1749 /// Called to queue a change to a actor 1589 /// Called to queue a change to a actor
@@ -1814,20 +1654,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1814 { 1654 {
1815 if (world == IntPtr.Zero) 1655 if (world == IntPtr.Zero)
1816 return 0; 1656 return 0;
1657
1658 d.WorldSetQuickStepNumIterations(world, curphysiteractions);
1817 1659
1818 // adjust number of iterations per step
1819
1820// try
1821// {
1822 d.WorldSetQuickStepNumIterations(world, curphysiteractions);
1823/* }
1824 catch (StackOverflowException)
1825 {
1826 m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim.");
1827// ode.drelease(world);
1828 base.TriggerPhysicsBasedRestart();
1829 }
1830*/
1831 while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever 1660 while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever
1832 { 1661 {
1833 try 1662 try
@@ -1855,8 +1684,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1855 } 1684 }
1856 catch 1685 catch
1857 { 1686 {
1858 m_log.Warn("[PHYSICS]: doChange failed for a actor"); 1687 m_log.WarnFormat("[PHYSICS]: doChange failed for a actor {0} {1}",
1859 }; 1688 item.actor.Name, item.what.ToString());
1689 }
1860 } 1690 }
1861 ttmp = Util.EnvironmentTickCountSubtract(ttmpstart); 1691 ttmp = Util.EnvironmentTickCountSubtract(ttmpstart);
1862 if (ttmp > 20) 1692 if (ttmp > 20)
@@ -2599,6 +2429,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2599*/ 2429*/
2600 public override void Dispose() 2430 public override void Dispose()
2601 { 2431 {
2432 if (m_meshWorker != null)
2433 m_meshWorker.Stop();
2434
2602 lock (OdeLock) 2435 lock (OdeLock)
2603 { 2436 {
2604 m_rayCastManager.Dispose(); 2437 m_rayCastManager.Dispose();