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.cs196
1 files changed, 39 insertions, 157 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index f126644..d426112 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -60,6 +60,29 @@ namespace OpenSim.Region.Physics.OdePlugin
60 public int lastframe; 60 public int lastframe;
61 } 61 }
62 62
63 public class ODEPhysRepData
64 {
65 public PhysicsActor actor;
66 public IntPtr geo = IntPtr.Zero;
67 public IntPtr triMeshData = IntPtr.Zero;
68 public IMesh mesh;
69 public IntPtr curSpace = IntPtr.Zero;
70 public PrimitiveBaseShape pbs;
71
72 public Vector3 size = Vector3.Zero;
73 public Vector3 OBB = Vector3.Zero;
74 public Vector3 OBBOffset = Vector3.Zero;
75
76 public float volume;
77
78 public float physCost = 0.0f;
79 public float streamCost = 0;
80 public byte shapetype = 0;
81 public bool canColide = true;
82 public bool hasOBB = false;
83 public bool hasMeshVolume = false;
84 }
85
63 // colision flags of things others can colide with 86 // colision flags of things others can colide with
64 // rays, sensors, probes removed since can't be colided with 87 // rays, sensors, probes removed since can't be colided with
65 // The top space where things are placed provided further selection 88 // The top space where things are placed provided further selection
@@ -230,11 +253,6 @@ namespace OpenSim.Region.Physics.OdePlugin
230 private float minimumGroundFlightOffset = 3f; 253 private float minimumGroundFlightOffset = 3f;
231 public float maximumMassObject = 10000.01f; 254 public float maximumMassObject = 10000.01f;
232 255
233 public bool meshSculptedPrim = true;
234 public bool forceSimplePrimMeshing = false;
235
236 public float meshSculptLOD = 32;
237 public float MeshSculptphysicalLOD = 32;
238 256
239 public float geomDefaultDensity = 10.000006836f; 257 public float geomDefaultDensity = 10.000006836f;
240 258
@@ -302,6 +320,7 @@ namespace OpenSim.Region.Physics.OdePlugin
302 public IntPtr TopSpace; // the global space 320 public IntPtr TopSpace; // the global space
303 public IntPtr ActiveSpace; // space for active prims 321 public IntPtr ActiveSpace; // space for active prims
304 public IntPtr StaticSpace; // space for the static things around 322 public IntPtr StaticSpace; // space for the static things around
323 public IntPtr WorkSpace; // no collisions work space
305 324
306 // some speedup variables 325 // some speedup variables
307 private int spaceGridMaxX; 326 private int spaceGridMaxX;
@@ -328,7 +347,7 @@ namespace OpenSim.Region.Physics.OdePlugin
328 private PhysicsScene m_parentScene = null; 347 private PhysicsScene m_parentScene = null;
329 348
330 private ODERayCastRequestManager m_rayCastManager; 349 private ODERayCastRequestManager m_rayCastManager;
331 350 public ODEMeshWorker m_meshWorker;
332 351
333/* maybe needed if ode uses tls 352/* maybe needed if ode uses tls
334 private void checkThread() 353 private void checkThread()
@@ -361,6 +380,8 @@ namespace OpenSim.Region.Physics.OdePlugin
361 nearCallback = near; 380 nearCallback = near;
362 381
363 m_rayCastManager = new ODERayCastRequestManager(this); 382 m_rayCastManager = new ODERayCastRequestManager(this);
383
384
364 lock (OdeLock) 385 lock (OdeLock)
365 { 386 {
366 // Create the world and the first space 387 // Create the world and the first space
@@ -372,6 +393,7 @@ namespace OpenSim.Region.Physics.OdePlugin
372 // now the major subspaces 393 // now the major subspaces
373 ActiveSpace = d.HashSpaceCreate(TopSpace); 394 ActiveSpace = d.HashSpaceCreate(TopSpace);
374 StaticSpace = d.HashSpaceCreate(TopSpace); 395 StaticSpace = d.HashSpaceCreate(TopSpace);
396 WorkSpace = d.HashSpaceCreate(TopSpace);
375 } 397 }
376 catch 398 catch
377 { 399 {
@@ -381,10 +403,12 @@ namespace OpenSim.Region.Physics.OdePlugin
381 d.HashSpaceSetLevels(TopSpace, -2, 8); 403 d.HashSpaceSetLevels(TopSpace, -2, 8);
382 d.HashSpaceSetLevels(ActiveSpace, -2, 8); 404 d.HashSpaceSetLevels(ActiveSpace, -2, 8);
383 d.HashSpaceSetLevels(StaticSpace, -2, 8); 405 d.HashSpaceSetLevels(StaticSpace, -2, 8);
406 d.HashSpaceSetLevels(WorkSpace, -2, 8);
384 407
385 // demote to second level 408 // demote to second level
386 d.SpaceSetSublevel(ActiveSpace, 1); 409 d.SpaceSetSublevel(ActiveSpace, 1);
387 d.SpaceSetSublevel(StaticSpace, 1); 410 d.SpaceSetSublevel(StaticSpace, 1);
411 d.SpaceSetSublevel(WorkSpace, 1);
388 412
389 d.GeomSetCategoryBits(ActiveSpace, (uint)(CollisionCategories.Space | 413 d.GeomSetCategoryBits(ActiveSpace, (uint)(CollisionCategories.Space |
390 CollisionCategories.Geom | 414 CollisionCategories.Geom |
@@ -402,6 +426,9 @@ namespace OpenSim.Region.Physics.OdePlugin
402 )); 426 ));
403 d.GeomSetCollideBits(StaticSpace, 0); 427 d.GeomSetCollideBits(StaticSpace, 0);
404 428
429 d.GeomSetCategoryBits(WorkSpace, 0);
430 d.GeomSetCollideBits(WorkSpace, 0);
431
405 contactgroup = d.JointGroupCreate(0); 432 contactgroup = d.JointGroupCreate(0);
406 //contactgroup 433 //contactgroup
407 434
@@ -440,9 +467,11 @@ namespace OpenSim.Region.Physics.OdePlugin
440 467
441 int contactsPerCollision = 80; 468 int contactsPerCollision = 80;
442 469
470 IConfig physicsconfig = null;
471
443 if (m_config != null) 472 if (m_config != null)
444 { 473 {
445 IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; 474 physicsconfig = m_config.Configs["ODEPhysicsSettings"];
446 if (physicsconfig != null) 475 if (physicsconfig != null)
447 { 476 {
448 gravityx = physicsconfig.GetFloat("world_gravityx", gravityx); 477 gravityx = physicsconfig.GetFloat("world_gravityx", gravityx);
@@ -469,27 +498,7 @@ namespace OpenSim.Region.Physics.OdePlugin
469 498
470 geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", geomDefaultDensity); 499 geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", geomDefaultDensity);
471 bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", bodyFramesAutoDisable); 500 bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", bodyFramesAutoDisable);
472/* 501
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); 502 physics_logging = physicsconfig.GetBoolean("physics_logging", false);
494 physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0); 503 physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0);
495 physics_logging_append_existing_logfile = physicsconfig.GetBoolean("physics_logging_append_existing_logfile", false); 504 physics_logging_append_existing_logfile = physicsconfig.GetBoolean("physics_logging_append_existing_logfile", false);
@@ -499,6 +508,8 @@ namespace OpenSim.Region.Physics.OdePlugin
499 } 508 }
500 } 509 }
501 510
511 m_meshWorker = new ODEMeshWorker(this, m_log, meshmerizer, WorkSpace, physicsconfig);
512
502 HalfOdeStep = ODE_STEPSIZE * 0.5f; 513 HalfOdeStep = ODE_STEPSIZE * 0.5f;
503 odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f); 514 odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f);
504 515
@@ -1615,135 +1626,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1615 1626
1616 #endregion 1627 #endregion
1617 1628
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 1629
1748 /// <summary> 1630 /// <summary>
1749 /// Called to queue a change to a actor 1631 /// Called to queue a change to a actor