diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 4a468af..eea899f 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -79,7 +79,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
79 | private HashSet<BSPhysObject> m_objectsWithCollisions = new HashSet<BSPhysObject>(); | 79 | private HashSet<BSPhysObject> m_objectsWithCollisions = new HashSet<BSPhysObject>(); |
80 | // Following is a kludge and can be removed when avatar animation updating is | 80 | // Following is a kludge and can be removed when avatar animation updating is |
81 | // moved to a better place. | 81 | // moved to a better place. |
82 | private HashSet<BSCharacter> m_avatarsWithCollisions = new HashSet<BSCharacter>(); | 82 | private HashSet<BSPhysObject> m_avatarsWithCollisions = new HashSet<BSPhysObject>(); |
83 | 83 | ||
84 | // List of all the objects that have vehicle properties and should be called | 84 | // List of all the objects that have vehicle properties and should be called |
85 | // to update each physics step. | 85 | // to update each physics step. |
@@ -132,8 +132,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
132 | private EntityProperties[] m_updateArray; | 132 | private EntityProperties[] m_updateArray; |
133 | private GCHandle m_updateArrayPinnedHandle; | 133 | private GCHandle m_updateArrayPinnedHandle; |
134 | 134 | ||
135 | private bool _meshSculptedPrim = true; // cause scuplted prims to get meshed | 135 | public bool ShouldMeshSculptedPrim { get; private set; } // cause scuplted prims to get meshed |
136 | private bool _forceSimplePrimMeshing = false; // if a cube or sphere, let Bullet do internal shapes | 136 | public bool ShouldForceSimplePrimMeshing { get; private set; } // if a cube or sphere, let Bullet do internal shapes |
137 | 137 | ||
138 | public float PID_D { get; private set; } // derivative | 138 | public float PID_D { get; private set; } // derivative |
139 | public float PID_P { get; private set; } // proportional | 139 | public float PID_P { get; private set; } // proportional |
@@ -153,6 +153,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
153 | { | 153 | { |
154 | get { return new Vector3(0f, 0f, Params.gravity); } | 154 | get { return new Vector3(0f, 0f, Params.gravity); } |
155 | } | 155 | } |
156 | // Just the Z value of the gravity | ||
157 | public float DefaultGravityZ | ||
158 | { | ||
159 | get { return Params.gravity; } | ||
160 | } | ||
156 | 161 | ||
157 | public float MaximumObjectMass { get; private set; } | 162 | public float MaximumObjectMass { get; private set; } |
158 | 163 | ||
@@ -171,8 +176,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
171 | callback = c; | 176 | callback = c; |
172 | } | 177 | } |
173 | } | 178 | } |
179 | private Object _taintLock = new Object(); // lock for using the next object | ||
174 | private List<TaintCallbackEntry> _taintedObjects; | 180 | private List<TaintCallbackEntry> _taintedObjects; |
175 | private Object _taintLock = new Object(); | ||
176 | 181 | ||
177 | // A pointer to an instance if this structure is passed to the C++ code | 182 | // A pointer to an instance if this structure is passed to the C++ code |
178 | // Used to pass basic configuration values to the unmanaged code. | 183 | // Used to pass basic configuration values to the unmanaged code. |
@@ -478,6 +483,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
478 | 483 | ||
479 | // Some of the prims operate with special vehicle properties | 484 | // Some of the prims operate with special vehicle properties |
480 | ProcessVehicles(timeStep); | 485 | ProcessVehicles(timeStep); |
486 | numTaints += _taintedObjects.Count; | ||
481 | ProcessTaints(); // the vehicles might have added taints | 487 | ProcessTaints(); // the vehicles might have added taints |
482 | 488 | ||
483 | // step the physical world one interval | 489 | // step the physical world one interval |
@@ -506,6 +512,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
506 | // Get a value for 'now' so all the collision and update routines don't have to get their own | 512 | // Get a value for 'now' so all the collision and update routines don't have to get their own |
507 | SimulationNowTime = Util.EnvironmentTickCount(); | 513 | SimulationNowTime = Util.EnvironmentTickCount(); |
508 | 514 | ||
515 | // This is a kludge to get avatar movement updates. | ||
516 | // ODE sends collisions for avatars even if there are have been no collisions. This updates | ||
517 | // avatar animations and stuff. | ||
518 | // If you fix avatar animation updates, remove this overhead and let collisions happen. | ||
519 | m_objectsWithCollisions = new HashSet<BSPhysObject>(m_avatarsWithCollisions); | ||
520 | |||
509 | // If there were collisions, process them by sending the event to the prim. | 521 | // If there were collisions, process them by sending the event to the prim. |
510 | // Collisions must be processed before updates. | 522 | // Collisions must be processed before updates. |
511 | if (collidersCount > 0) | 523 | if (collidersCount > 0) |
@@ -527,13 +539,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
527 | bsp.SendCollisions(); | 539 | bsp.SendCollisions(); |
528 | m_objectsWithCollisions.Clear(); | 540 | m_objectsWithCollisions.Clear(); |
529 | 541 | ||
530 | // This is a kludge to get avatar movement updated. | ||
531 | // ODE sends collisions even if there are none and this is used to update | ||
532 | // avatar animations and stuff. | ||
533 | foreach (BSPhysObject bpo in m_avatarsWithCollisions) | ||
534 | bpo.SendCollisions(); | ||
535 | // m_avatarsWithCollisions.Clear(); | ||
536 | |||
537 | // If any of the objects had updated properties, tell the object it has been changed by the physics engine | 542 | // If any of the objects had updated properties, tell the object it has been changed by the physics engine |
538 | if (updatedEntityCount > 0) | 543 | if (updatedEntityCount > 0) |
539 | { | 544 | { |
@@ -544,7 +549,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
544 | if (PhysObjects.TryGetValue(entprop.ID, out pobj)) | 549 | if (PhysObjects.TryGetValue(entprop.ID, out pobj)) |
545 | { | 550 | { |
546 | pobj.UpdateProperties(entprop); | 551 | pobj.UpdateProperties(entprop); |
547 | continue; | ||
548 | } | 552 | } |
549 | } | 553 | } |
550 | } | 554 | } |
@@ -600,8 +604,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
600 | 604 | ||
601 | // DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith); | 605 | // DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith); |
602 | 606 | ||
603 | collider.Collide(collidingWith, collidee, type, collidePoint, collideNormal, penetration); | 607 | if (collider.Collide(collidingWith, collidee, type, collidePoint, collideNormal, penetration)) |
604 | m_objectsWithCollisions.Add(collider); | 608 | { |
609 | // If a collision was posted, remember to send it to the simulator | ||
610 | m_objectsWithCollisions.Add(collider); | ||
611 | } | ||
605 | 612 | ||
606 | return; | 613 | return; |
607 | } | 614 | } |
@@ -619,9 +626,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
619 | public override void SetWaterLevel(float baseheight) | 626 | public override void SetWaterLevel(float baseheight) |
620 | { | 627 | { |
621 | m_waterLevel = baseheight; | 628 | m_waterLevel = baseheight; |
622 | // TODO: pass to physics engine so things will float? | ||
623 | } | 629 | } |
624 | public float GetWaterLevel() | 630 | // Someday.... |
631 | public float GetWaterLevelAtXYZ(Vector3 loc) | ||
625 | { | 632 | { |
626 | return m_waterLevel; | 633 | return m_waterLevel; |
627 | } | 634 | } |
@@ -672,7 +679,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
672 | 679 | ||
673 | // int iPropertiesNotSupportedDefault = 0; | 680 | // int iPropertiesNotSupportedDefault = 0; |
674 | 681 | ||
675 | if (pbs.SculptEntry && !_meshSculptedPrim) | 682 | if (pbs.SculptEntry && !ShouldMeshSculptedPrim) |
676 | { | 683 | { |
677 | // Render sculpties as boxes | 684 | // Render sculpties as boxes |
678 | return false; | 685 | return false; |
@@ -680,7 +687,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
680 | 687 | ||
681 | // if it's a standard box or sphere with no cuts, hollows, twist or top shear, return false since Bullet | 688 | // if it's a standard box or sphere with no cuts, hollows, twist or top shear, return false since Bullet |
682 | // can use an internal representation for the prim | 689 | // can use an internal representation for the prim |
683 | if (!_forceSimplePrimMeshing) | 690 | if (!ShouldForceSimplePrimMeshing) |
684 | { | 691 | { |
685 | if ((pbs.ProfileShape == ProfileShape.Square && pbs.PathCurve == (byte)Extrusion.Straight) | 692 | if ((pbs.ProfileShape == ProfileShape.Square && pbs.PathCurve == (byte)Extrusion.Straight) |
686 | || (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1 | 693 | || (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1 |
@@ -782,7 +789,10 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
782 | if (!m_initialized) return; | 789 | if (!m_initialized) return; |
783 | 790 | ||
784 | lock (_taintLock) | 791 | lock (_taintLock) |
792 | { | ||
785 | _taintedObjects.Add(new TaintCallbackEntry(ident, callback)); | 793 | _taintedObjects.Add(new TaintCallbackEntry(ident, callback)); |
794 | } | ||
795 | |||
786 | return; | 796 | return; |
787 | } | 797 | } |
788 | 798 | ||
@@ -919,14 +929,14 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
919 | { | 929 | { |
920 | new ParameterDefn("MeshSculptedPrim", "Whether to create meshes for sculpties", | 930 | new ParameterDefn("MeshSculptedPrim", "Whether to create meshes for sculpties", |
921 | ConfigurationParameters.numericTrue, | 931 | ConfigurationParameters.numericTrue, |
922 | (s,cf,p,v) => { s._meshSculptedPrim = cf.GetBoolean(p, s.BoolNumeric(v)); }, | 932 | (s,cf,p,v) => { s.ShouldMeshSculptedPrim = cf.GetBoolean(p, s.BoolNumeric(v)); }, |
923 | (s) => { return s.NumericBool(s._meshSculptedPrim); }, | 933 | (s) => { return s.NumericBool(s.ShouldMeshSculptedPrim); }, |
924 | (s,p,l,v) => { s._meshSculptedPrim = s.BoolNumeric(v); } ), | 934 | (s,p,l,v) => { s.ShouldMeshSculptedPrim = s.BoolNumeric(v); } ), |
925 | new ParameterDefn("ForceSimplePrimMeshing", "If true, only use primitive meshes for objects", | 935 | new ParameterDefn("ForceSimplePrimMeshing", "If true, only use primitive meshes for objects", |
926 | ConfigurationParameters.numericFalse, | 936 | ConfigurationParameters.numericFalse, |
927 | (s,cf,p,v) => { s._forceSimplePrimMeshing = cf.GetBoolean(p, s.BoolNumeric(v)); }, | 937 | (s,cf,p,v) => { s.ShouldForceSimplePrimMeshing = cf.GetBoolean(p, s.BoolNumeric(v)); }, |
928 | (s) => { return s.NumericBool(s._forceSimplePrimMeshing); }, | 938 | (s) => { return s.NumericBool(s.ShouldForceSimplePrimMeshing); }, |
929 | (s,p,l,v) => { s._forceSimplePrimMeshing = s.BoolNumeric(v); } ), | 939 | (s,p,l,v) => { s.ShouldForceSimplePrimMeshing = s.BoolNumeric(v); } ), |
930 | 940 | ||
931 | new ParameterDefn("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)", | 941 | new ParameterDefn("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)", |
932 | 8f, | 942 | 8f, |
@@ -1162,8 +1172,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1162 | (s,cf,p,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = cf.GetFloat(p, v); }, | 1172 | (s,cf,p,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = cf.GetFloat(p, v); }, |
1163 | (s) => { return s.m_params[0].linkConstraintTransMotorMaxForce; }, | 1173 | (s) => { return s.m_params[0].linkConstraintTransMotorMaxForce; }, |
1164 | (s,p,l,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = v; } ), | 1174 | (s,p,l,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = v; } ), |
1165 | new ParameterDefn("LinkConstraintCFM", "Amount constraint can be violated. 0=none, 1=all. Default=0", | 1175 | new ParameterDefn("LinkConstraintCFM", "Amount constraint can be violated. 0=no violation, 1=infinite. Default=0.1", |
1166 | 0.0f, | 1176 | 0.1f, |
1167 | (s,cf,p,v) => { s.m_params[0].linkConstraintCFM = cf.GetFloat(p, v); }, | 1177 | (s,cf,p,v) => { s.m_params[0].linkConstraintCFM = cf.GetFloat(p, v); }, |
1168 | (s) => { return s.m_params[0].linkConstraintCFM; }, | 1178 | (s) => { return s.m_params[0].linkConstraintCFM; }, |
1169 | (s,p,l,v) => { s.m_params[0].linkConstraintCFM = v; } ), | 1179 | (s,p,l,v) => { s.m_params[0].linkConstraintCFM = v; } ), |
@@ -1172,6 +1182,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1172 | (s,cf,p,v) => { s.m_params[0].linkConstraintERP = cf.GetFloat(p, v); }, | 1182 | (s,cf,p,v) => { s.m_params[0].linkConstraintERP = cf.GetFloat(p, v); }, |
1173 | (s) => { return s.m_params[0].linkConstraintERP; }, | 1183 | (s) => { return s.m_params[0].linkConstraintERP; }, |
1174 | (s,p,l,v) => { s.m_params[0].linkConstraintERP = v; } ), | 1184 | (s,p,l,v) => { s.m_params[0].linkConstraintERP = v; } ), |
1185 | new ParameterDefn("LinkConstraintSolverIterations", "Number of solver iterations when computing constraint. (0 = Bullet default)", | ||
1186 | 40, | ||
1187 | (s,cf,p,v) => { s.m_params[0].linkConstraintSolverIterations = cf.GetFloat(p, v); }, | ||
1188 | (s) => { return s.m_params[0].linkConstraintSolverIterations; }, | ||
1189 | (s,p,l,v) => { s.m_params[0].linkConstraintSolverIterations = v; } ), | ||
1175 | 1190 | ||
1176 | new ParameterDefn("DetailedStats", "Frames between outputting detailed phys stats. (0 is off)", | 1191 | new ParameterDefn("DetailedStats", "Frames between outputting detailed phys stats. (0 is off)", |
1177 | 0f, | 1192 | 0f, |