diff options
author | Robert Adams | 2012-10-09 12:58:06 -0700 |
---|---|---|
committer | Robert Adams | 2012-10-11 14:01:07 -0700 |
commit | 68698975f1537725a1f53bc4b2db2cfc798ac7f3 (patch) | |
tree | 7a021b67a3bde146160a1e7d8befef053698e71e /OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |
parent | BulletSim: Fix crash when linking large physical linksets. (diff) | |
download | opensim-SC_OLD-68698975f1537725a1f53bc4b2db2cfc798ac7f3.zip opensim-SC_OLD-68698975f1537725a1f53bc4b2db2cfc798ac7f3.tar.gz opensim-SC_OLD-68698975f1537725a1f53bc4b2db2cfc798ac7f3.tar.bz2 opensim-SC_OLD-68698975f1537725a1f53bc4b2db2cfc798ac7f3.tar.xz |
BulletSim: Add Force* operations to objects to allow direct push to engine.
Update BSDynamics to use same (don't want to delay updates til next taint-time.
Suppress queuing a taint update for position and orientation calls if value
does not change.
Move Bullet timing statistics call from C# back to C++ code.
Throttle taints per simulation step and add parameter to set.
By default, don't create hulls for physical objects. Add a
parameter to turn on and off.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSScene.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 65 |
1 files changed, 47 insertions, 18 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index eed915d..33ac116 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -90,10 +90,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
90 | // let my minuions use my logger | 90 | // let my minuions use my logger |
91 | public ILog Logger { get { return m_log; } } | 91 | public ILog Logger { get { return m_log; } } |
92 | 92 | ||
93 | // If non-zero, the number of simulation steps between calls to the physics | ||
94 | // engine to output detailed physics stats. Debug logging level must be on also. | ||
95 | private int m_detailedStatsStep = 0; | ||
96 | |||
97 | public IMesher mesher; | 93 | public IMesher mesher; |
98 | // Level of Detail values kept as float because that's what the Meshmerizer wants | 94 | // Level of Detail values kept as float because that's what the Meshmerizer wants |
99 | public float MeshLOD { get; private set; } | 95 | public float MeshLOD { get; private set; } |
@@ -112,6 +108,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
112 | private float m_fixedTimeStep; | 108 | private float m_fixedTimeStep; |
113 | private long m_simulationStep = 0; | 109 | private long m_simulationStep = 0; |
114 | public long SimulationStep { get { return m_simulationStep; } } | 110 | public long SimulationStep { get { return m_simulationStep; } } |
111 | private int m_taintsToProcessPerStep; | ||
115 | 112 | ||
116 | // A value of the time now so all the collision and update routines do not have to get their own | 113 | // A value of the time now so all the collision and update routines do not have to get their own |
117 | // Set to 'now' just before all the prims and actors are called for collisions and updates | 114 | // Set to 'now' just before all the prims and actors are called for collisions and updates |
@@ -131,6 +128,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
131 | 128 | ||
132 | public bool ShouldMeshSculptedPrim { get; private set; } // cause scuplted prims to get meshed | 129 | public bool ShouldMeshSculptedPrim { get; private set; } // cause scuplted prims to get meshed |
133 | public bool ShouldForceSimplePrimMeshing { get; private set; } // if a cube or sphere, let Bullet do internal shapes | 130 | public bool ShouldForceSimplePrimMeshing { get; private set; } // if a cube or sphere, let Bullet do internal shapes |
131 | public bool ShouldUseHullsForPhysicalObjects { get; private set; } // 'true' if should create hulls for physical objects | ||
134 | 132 | ||
135 | public float PID_D { get; private set; } // derivative | 133 | public float PID_D { get; private set; } // derivative |
136 | public float PID_P { get; private set; } // proportional | 134 | public float PID_P { get; private set; } // proportional |
@@ -582,15 +580,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
582 | } | 580 | } |
583 | } | 581 | } |
584 | 582 | ||
585 | // If enabled, call into the physics engine to dump statistics | ||
586 | if (m_detailedStatsStep > 0) | ||
587 | { | ||
588 | if ((m_simulationStep % m_detailedStatsStep) == 0) | ||
589 | { | ||
590 | BulletSimAPI.DumpBulletStatistics(); | ||
591 | } | ||
592 | } | ||
593 | |||
594 | // The physics engine returns the number of milliseconds it simulated this call. | 583 | // The physics engine returns the number of milliseconds it simulated this call. |
595 | // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS. | 584 | // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS. |
596 | // Since Bullet normally does 5 or 6 substeps, this will normally sum to about 60 FPS. | 585 | // Since Bullet normally does 5 or 6 substeps, this will normally sum to about 60 FPS. |
@@ -617,7 +606,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
617 | BSPhysObject collidee = null; | 606 | BSPhysObject collidee = null; |
618 | PhysObjects.TryGetValue(collidingWith, out collidee); | 607 | PhysObjects.TryGetValue(collidingWith, out collidee); |
619 | 608 | ||
620 | DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith); | 609 | // DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith); |
621 | 610 | ||
622 | if (collider.Collide(collidingWith, collidee, collidePoint, collideNormal, penetration)) | 611 | if (collider.Collide(collidingWith, collidee, collidePoint, collideNormal, penetration)) |
623 | { | 612 | { |
@@ -704,6 +693,35 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
704 | if (_taintedObjects.Count > 0) // save allocating new list if there is nothing to process | 693 | if (_taintedObjects.Count > 0) // save allocating new list if there is nothing to process |
705 | { | 694 | { |
706 | // swizzle a new list into the list location so we can process what's there | 695 | // swizzle a new list into the list location so we can process what's there |
696 | int taintCount = m_taintsToProcessPerStep; | ||
697 | TaintCallbackEntry oneCallback = new TaintCallbackEntry(); | ||
698 | while (_taintedObjects.Count > 0 && taintCount-- > 0) | ||
699 | { | ||
700 | bool gotOne = false; | ||
701 | lock (_taintLock) | ||
702 | { | ||
703 | if (_taintedObjects.Count > 0) | ||
704 | { | ||
705 | oneCallback = _taintedObjects[0]; | ||
706 | _taintedObjects.RemoveAt(0); | ||
707 | gotOne = true; | ||
708 | } | ||
709 | } | ||
710 | if (gotOne) | ||
711 | { | ||
712 | try | ||
713 | { | ||
714 | DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", DetailLogZero, oneCallback.ident); // DEBUG DEBUG DEBUG | ||
715 | oneCallback.callback(); | ||
716 | } | ||
717 | catch (Exception e) | ||
718 | { | ||
719 | m_log.ErrorFormat("{0}: ProcessTaints: {1}: Exception: {2}", LogHeader, oneCallback.ident, e); | ||
720 | } | ||
721 | } | ||
722 | } | ||
723 | /* | ||
724 | // swizzle a new list into the list location so we can process what's there | ||
707 | List<TaintCallbackEntry> oldList; | 725 | List<TaintCallbackEntry> oldList; |
708 | lock (_taintLock) | 726 | lock (_taintLock) |
709 | { | 727 | { |
@@ -724,6 +742,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
724 | } | 742 | } |
725 | } | 743 | } |
726 | oldList.Clear(); | 744 | oldList.Clear(); |
745 | */ | ||
727 | } | 746 | } |
728 | } | 747 | } |
729 | 748 | ||
@@ -835,6 +854,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
835 | (s,cf,p,v) => { s.ShouldForceSimplePrimMeshing = cf.GetBoolean(p, s.BoolNumeric(v)); }, | 854 | (s,cf,p,v) => { s.ShouldForceSimplePrimMeshing = cf.GetBoolean(p, s.BoolNumeric(v)); }, |
836 | (s) => { return s.NumericBool(s.ShouldForceSimplePrimMeshing); }, | 855 | (s) => { return s.NumericBool(s.ShouldForceSimplePrimMeshing); }, |
837 | (s,p,l,v) => { s.ShouldForceSimplePrimMeshing = s.BoolNumeric(v); } ), | 856 | (s,p,l,v) => { s.ShouldForceSimplePrimMeshing = s.BoolNumeric(v); } ), |
857 | new ParameterDefn("UseHullsForPhysicalObjects", "If true, create hulls for physical objects", | ||
858 | ConfigurationParameters.numericFalse, | ||
859 | (s,cf,p,v) => { s.ShouldUseHullsForPhysicalObjects = cf.GetBoolean(p, s.BoolNumeric(v)); }, | ||
860 | (s) => { return s.NumericBool(s.ShouldUseHullsForPhysicalObjects); }, | ||
861 | (s,p,l,v) => { s.ShouldUseHullsForPhysicalObjects = s.BoolNumeric(v); } ), | ||
838 | 862 | ||
839 | new ParameterDefn("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)", | 863 | new ParameterDefn("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)", |
840 | 8f, | 864 | 8f, |
@@ -877,6 +901,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
877 | (s,cf,p,v) => { s.m_maxUpdatesPerFrame = cf.GetInt(p, (int)v); }, | 901 | (s,cf,p,v) => { s.m_maxUpdatesPerFrame = cf.GetInt(p, (int)v); }, |
878 | (s) => { return (float)s.m_maxUpdatesPerFrame; }, | 902 | (s) => { return (float)s.m_maxUpdatesPerFrame; }, |
879 | (s,p,l,v) => { s.m_maxUpdatesPerFrame = (int)v; } ), | 903 | (s,p,l,v) => { s.m_maxUpdatesPerFrame = (int)v; } ), |
904 | new ParameterDefn("MaxTaintsToProcessPerStep", "Number of update taints to process before each simulation step", | ||
905 | 100f, | ||
906 | (s,cf,p,v) => { s.m_taintsToProcessPerStep = cf.GetInt(p, (int)v); }, | ||
907 | (s) => { return (float)s.m_taintsToProcessPerStep; }, | ||
908 | (s,p,l,v) => { s.m_taintsToProcessPerStep = (int)v; } ), | ||
880 | new ParameterDefn("MaxObjectMass", "Maximum object mass (10000.01)", | 909 | new ParameterDefn("MaxObjectMass", "Maximum object mass (10000.01)", |
881 | 10000.01f, | 910 | 10000.01f, |
882 | (s,cf,p,v) => { s.MaximumObjectMass = cf.GetFloat(p, v); }, | 911 | (s,cf,p,v) => { s.MaximumObjectMass = cf.GetFloat(p, v); }, |
@@ -1086,11 +1115,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1086 | (s) => { return s.m_params[0].linkConstraintSolverIterations; }, | 1115 | (s) => { return s.m_params[0].linkConstraintSolverIterations; }, |
1087 | (s,p,l,v) => { s.m_params[0].linkConstraintSolverIterations = v; } ), | 1116 | (s,p,l,v) => { s.m_params[0].linkConstraintSolverIterations = v; } ), |
1088 | 1117 | ||
1089 | new ParameterDefn("DetailedStats", "Frames between outputting detailed phys stats. (0 is off)", | 1118 | new ParameterDefn("LogPhysicsStatisticsFrames", "Frames between outputting detailed phys stats. (0 is off)", |
1090 | 0f, | 1119 | 0f, |
1091 | (s,cf,p,v) => { s.m_detailedStatsStep = cf.GetInt(p, (int)v); }, | 1120 | (s,cf,p,v) => { s.m_params[0].physicsLoggingFrames = cf.GetInt(p, (int)v); }, |
1092 | (s) => { return (float)s.m_detailedStatsStep; }, | 1121 | (s) => { return (float)s.m_params[0].physicsLoggingFrames; }, |
1093 | (s,p,l,v) => { s.m_detailedStatsStep = (int)v; } ), | 1122 | (s,p,l,v) => { s.m_params[0].physicsLoggingFrames = (int)v; } ), |
1094 | }; | 1123 | }; |
1095 | 1124 | ||
1096 | // Convert a boolean to our numeric true and false values | 1125 | // Convert a boolean to our numeric true and false values |