aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin
diff options
context:
space:
mode:
authorRobert Adams2012-03-26 08:49:12 -0700
committerRobert Adams2012-03-26 08:49:12 -0700
commitf8879e06d26aad63d6e9ba776b2425951d7150c1 (patch)
treebf63b4b6c7f791926da99e2658cd1002139b5a32 /OpenSim/Region/Physics/BulletSPlugin
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
parentBulletSim: update BulletSim.dll and libBulletSim.so with latest versions (diff)
downloadopensim-SC_OLD-f8879e06d26aad63d6e9ba776b2425951d7150c1.zip
opensim-SC_OLD-f8879e06d26aad63d6e9ba776b2425951d7150c1.tar.gz
opensim-SC_OLD-f8879e06d26aad63d6e9ba776b2425951d7150c1.tar.bz2
opensim-SC_OLD-f8879e06d26aad63d6e9ba776b2425951d7150c1.tar.xz
Merge branch 'bulletsim1'
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs17
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs4
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs17
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs121
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs19
5 files changed, 138 insertions, 40 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 0cab5d1..20708d9 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -94,7 +94,7 @@ public class BSCharacter : PhysicsActor
94 _flying = isFlying; 94 _flying = isFlying;
95 _orientation = Quaternion.Identity; 95 _orientation = Quaternion.Identity;
96 _velocity = Vector3.Zero; 96 _velocity = Vector3.Zero;
97 _buoyancy = isFlying ? 1f : 0f; 97 _buoyancy = ComputeBuoyancyFromFlying(isFlying);
98 _scale = new Vector3(1f, 1f, 1f); 98 _scale = new Vector3(1f, 1f, 1f);
99 _density = _scene.Params.avatarDensity; 99 _density = _scene.Params.avatarDensity;
100 ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale 100 ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale
@@ -110,7 +110,7 @@ public class BSCharacter : PhysicsActor
110 shapeData.Buoyancy = _buoyancy; 110 shapeData.Buoyancy = _buoyancy;
111 shapeData.Static = ShapeData.numericFalse; 111 shapeData.Static = ShapeData.numericFalse;
112 shapeData.Friction = _scene.Params.avatarFriction; 112 shapeData.Friction = _scene.Params.avatarFriction;
113 shapeData.Restitution = _scene.Params.defaultRestitution; 113 shapeData.Restitution = _scene.Params.avatarRestitution;
114 114
115 // do actual create at taint time 115 // do actual create at taint time
116 _scene.TaintedObject(delegate() 116 _scene.TaintedObject(delegate()
@@ -260,13 +260,13 @@ public class BSCharacter : PhysicsActor
260 get { return _flying; } 260 get { return _flying; }
261 set { 261 set {
262 _flying = value; 262 _flying = value;
263 _scene.TaintedObject(delegate() 263 // simulate flying by changing the effect of gravity
264 { 264 this.Buoyancy = ComputeBuoyancyFromFlying(_flying);
265 // simulate flying by changing the effect of gravity
266 BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _flying ? 1f : 0f);
267 });
268 } 265 }
269 } 266 }
267 private float ComputeBuoyancyFromFlying(bool ifFlying) {
268 return ifFlying ? 1f : 0f;
269 }
270 public override bool 270 public override bool
271 SetAlwaysRun { 271 SetAlwaysRun {
272 get { return _setAlwaysRun; } 272 get { return _setAlwaysRun; }
@@ -299,6 +299,7 @@ public class BSCharacter : PhysicsActor
299 get { return _kinematic; } 299 get { return _kinematic; }
300 set { _kinematic = value; } 300 set { _kinematic = value; }
301 } 301 }
302 // neg=fall quickly, 0=1g, 1=0g, pos=float up
302 public override float Buoyancy { 303 public override float Buoyancy {
303 get { return _buoyancy; } 304 get { return _buoyancy; }
304 set { _buoyancy = value; 305 set { _buoyancy = value;
@@ -355,7 +356,7 @@ public class BSCharacter : PhysicsActor
355 } 356 }
356 else 357 else
357 { 358 {
358 m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader); 359 m_log.ErrorFormat("{0}: Got a NaN force applied to a Character", LogHeader);
359 } 360 }
360 //m_lastUpdateSent = false; 361 //m_lastUpdateSent = false;
361 } 362 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 046726d..eb20eb3 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -821,7 +821,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
821 */ 821 */
822 822
823 // Get what the body is doing, this includes 'external' influences 823 // Get what the body is doing, this includes 'external' influences
824 Vector3 angularVelocity = m_prim.AngularVelocity; 824 Vector3 angularVelocity = m_prim.RotationalVelocity;
825 // Vector3 angularVelocity = Vector3.Zero; 825 // Vector3 angularVelocity = Vector3.Zero;
826 826
827 if (m_angularMotorApply > 0) 827 if (m_angularMotorApply > 0)
@@ -910,7 +910,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
910 m_lastAngularVelocity -= m_lastAngularVelocity * decayamount; 910 m_lastAngularVelocity -= m_lastAngularVelocity * decayamount;
911 911
912 // Apply to the body 912 // Apply to the body
913 m_prim.AngularVelocity = m_lastAngularVelocity; 913 m_prim.RotationalVelocity = m_lastAngularVelocity;
914 914
915 } //end MoveAngular 915 } //end MoveAngular
916 internal void LimitRotation(float timestep) 916 internal void LimitRotation(float timestep)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 898436b..f122df9 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -85,7 +85,6 @@ public sealed class BSPrim : PhysicsActor
85 private OMV.Vector3 _rotationalVelocity; 85 private OMV.Vector3 _rotationalVelocity;
86 private bool _kinematic; 86 private bool _kinematic;
87 private float _buoyancy; 87 private float _buoyancy;
88 private OMV.Vector3 _angularVelocity;
89 88
90 private List<BSPrim> _childrenPrims; 89 private List<BSPrim> _childrenPrims;
91 private BSPrim _parentPrim; 90 private BSPrim _parentPrim;
@@ -119,7 +118,6 @@ public sealed class BSPrim : PhysicsActor
119 _buoyancy = 1f; 118 _buoyancy = 1f;
120 _velocity = OMV.Vector3.Zero; 119 _velocity = OMV.Vector3.Zero;
121 _rotationalVelocity = OMV.Vector3.Zero; 120 _rotationalVelocity = OMV.Vector3.Zero;
122 _angularVelocity = OMV.Vector3.Zero;
123 _hullKey = 0; 121 _hullKey = 0;
124 _meshKey = 0; 122 _meshKey = 0;
125 _pbs = pbs; 123 _pbs = pbs;
@@ -146,7 +144,7 @@ public sealed class BSPrim : PhysicsActor
146 // called when this prim is being destroyed and we should free all the resources 144 // called when this prim is being destroyed and we should free all the resources
147 public void Destroy() 145 public void Destroy()
148 { 146 {
149 // m_log.DebugFormat("{0}: Destroy", LogHeader); 147 // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID);
150 // Undo any vehicle properties 148 // Undo any vehicle properties
151 _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); 149 _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE);
152 _scene.RemoveVehiclePrim(this); // just to make sure 150 _scene.RemoveVehiclePrim(this); // just to make sure
@@ -203,7 +201,7 @@ public sealed class BSPrim : PhysicsActor
203 201
204 // link me to the specified parent 202 // link me to the specified parent
205 public override void link(PhysicsActor obj) { 203 public override void link(PhysicsActor obj) {
206 BSPrim parent = (BSPrim)obj; 204 BSPrim parent = obj as BSPrim;
207 // m_log.DebugFormat("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, obj.LocalID); 205 // m_log.DebugFormat("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, obj.LocalID);
208 // TODO: decide if this parent checking needs to happen at taint time 206 // TODO: decide if this parent checking needs to happen at taint time
209 if (_parentPrim == null) 207 if (_parentPrim == null)
@@ -527,10 +525,6 @@ public sealed class BSPrim : PhysicsActor
527 }); 525 });
528 } 526 }
529 } 527 }
530 public OMV.Vector3 AngularVelocity {
531 get { return _angularVelocity; }
532 set { _angularVelocity = value; }
533 }
534 public override bool Kinematic { 528 public override bool Kinematic {
535 get { return _kinematic; } 529 get { return _kinematic; }
536 set { _kinematic = value; 530 set { _kinematic = value;
@@ -993,7 +987,7 @@ public sealed class BSPrim : PhysicsActor
993 } 987 }
994 988
995 // m_log.DebugFormat("{0}: CreateGeomMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}", 989 // m_log.DebugFormat("{0}: CreateGeomMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}",
996 // LogHeader, _localID, _meshKey, indices.Length, vertices.Count); 990 // LogHeader, _localID, _meshKey, indices.Length, vertices.Count);
997 BulletSimAPI.CreateMesh(_scene.WorldID, _meshKey, indices.GetLength(0), indices, 991 BulletSimAPI.CreateMesh(_scene.WorldID, _meshKey, indices.GetLength(0), indices,
998 vertices.Count, verticesAsFloats); 992 vertices.Count, verticesAsFloats);
999 993
@@ -1127,7 +1121,7 @@ public sealed class BSPrim : PhysicsActor
1127 return; 1121 return;
1128 } 1122 }
1129 1123
1130 // Create an object in Bullet 1124 // Create an object in Bullet if it has not already been created
1131 // No locking here because this is done when the physics engine is not simulating 1125 // No locking here because this is done when the physics engine is not simulating
1132 private void CreateObject() 1126 private void CreateObject()
1133 { 1127 {
@@ -1324,7 +1318,8 @@ public sealed class BSPrim : PhysicsActor
1324 _velocity = entprop.Velocity; 1318 _velocity = entprop.Velocity;
1325 _acceleration = entprop.Acceleration; 1319 _acceleration = entprop.Acceleration;
1326 _rotationalVelocity = entprop.RotationalVelocity; 1320 _rotationalVelocity = entprop.RotationalVelocity;
1327 // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}", LogHeader, LocalID, changed, _position, _orientation); 1321 // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}, vel={5}, acc={6}, rvel={7}",
1322 // LogHeader, LocalID, changed, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
1328 base.RequestPhysicsterseUpdate(); 1323 base.RequestPhysicsterseUpdate();
1329 } 1324 }
1330 } 1325 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index e9a849c..6963af5 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -37,14 +37,18 @@ using OpenMetaverse;
37using OpenSim.Region.Framework; 37using OpenSim.Region.Framework;
38 38
39// TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim) 39// TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim)
40// Debug linkset
41// Test with multiple regions in one simulator
40// Adjust character capsule size when height is adjusted (ScenePresence.SetHeight) 42// Adjust character capsule size when height is adjusted (ScenePresence.SetHeight)
41// Test sculpties 43// Test sculpties
42// Compute physics FPS reasonably 44// Compute physics FPS reasonably
43// Based on material, set density and friction 45// Based on material, set density and friction
44// More efficient memory usage in passing hull information from BSPrim to BulletSim 46// More efficient memory usage when passing hull information from BSPrim to BulletSim
45// Four states of prim: Physical, regular, phantom and selected. Are we modeling these correctly? 47// Four states of prim: Physical, regular, phantom and selected. Are we modeling these correctly?
46// In SL one can set both physical and phantom (gravity, does not effect others, makes collisions with ground) 48// In SL one can set both physical and phantom (gravity, does not effect others, makes collisions with ground)
47// At the moment, physical and phantom causes object to drop through the terrain 49// At the moment, physical and phantom causes object to drop through the terrain
50// Physical phantom objects and related typing (collision options )
51// Check out llVolumeDetect. Must do something for that.
48// Should prim.link() and prim.delink() membership checking happen at taint time? 52// Should prim.link() and prim.delink() membership checking happen at taint time?
49// Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once 53// Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once
50// Do attachments need to be handled separately? Need collision events. Do not collide with VolumeDetect 54// Do attachments need to be handled separately? Need collision events. Do not collide with VolumeDetect
@@ -52,6 +56,16 @@ using OpenSim.Region.Framework;
52// Implement LockAngularMotion 56// Implement LockAngularMotion
53// Decide if clearing forces is the right thing to do when setting position (BulletSim::SetObjectTranslation) 57// Decide if clearing forces is the right thing to do when setting position (BulletSim::SetObjectTranslation)
54// Does NeedsMeshing() really need to exclude all the different shapes? 58// Does NeedsMeshing() really need to exclude all the different shapes?
59// Remove mesh and Hull stuff. Use mesh passed to bullet and use convexdecom from bullet.
60// Add PID movement operations. What does ScenePresence.MoveToTarget do?
61// Check terrain size. 128 or 127?
62// Multiple contact points on collision?
63// See code in ode::near... calls to collision_accounting_events()
64// (This might not be a problem. ODE collects all the collisions with one object in one tick.)
65// Use collision masks for collision with terrain and phantom objects
66// Figure out how to not allocate a new Dictionary and List for every collision
67// in BSPrim.Collide() and BSCharacter.Collide(). Can the same ones be reused?
68// Raycast
55// 69//
56namespace OpenSim.Region.Physics.BulletSPlugin 70namespace OpenSim.Region.Physics.BulletSPlugin
57{ 71{
@@ -164,6 +178,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
164 if (m_log.IsDebugEnabled) 178 if (m_log.IsDebugEnabled)
165 { 179 {
166 m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader); 180 m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader);
181 // the handle is saved to it doesn't get freed after this call
167 m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger); 182 m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger);
168 BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle); 183 BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle);
169 } 184 }
@@ -172,7 +187,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
172 187
173 mesher = meshmerizer; 188 mesher = meshmerizer;
174 // The bounding box for the simulated world 189 // The bounding box for the simulated world
175 Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, 4096f); 190 Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, 8192f);
176 191
177 // m_log.DebugFormat("{0}: Initialize: Calling BulletSimAPI.Initialize.", LogHeader); 192 // m_log.DebugFormat("{0}: Initialize: Calling BulletSimAPI.Initialize.", LogHeader);
178 m_worldID = BulletSimAPI.Initialize(worldExtent, m_paramsHandle.AddrOfPinnedObject(), 193 m_worldID = BulletSimAPI.Initialize(worldExtent, m_paramsHandle.AddrOfPinnedObject(),
@@ -220,10 +235,20 @@ public class BSScene : PhysicsScene, IPhysicsParameters
220 parms.terrainFriction = 0.5f; 235 parms.terrainFriction = 0.5f;
221 parms.terrainHitFraction = 0.8f; 236 parms.terrainHitFraction = 0.8f;
222 parms.terrainRestitution = 0f; 237 parms.terrainRestitution = 0f;
223 parms.avatarFriction = 0.0f; 238 parms.avatarFriction = 0.5f;
239 parms.avatarRestitution = 0.0f;
224 parms.avatarDensity = 60f; 240 parms.avatarDensity = 60f;
225 parms.avatarCapsuleRadius = 0.37f; 241 parms.avatarCapsuleRadius = 0.37f;
226 parms.avatarCapsuleHeight = 1.5f; // 2.140599f 242 parms.avatarCapsuleHeight = 1.5f; // 2.140599f
243 parms.avatarContactProcessingThreshold = 0.1f;
244
245 parms.maxPersistantManifoldPoolSize = 0f;
246 parms.shouldDisableContactPoolDynamicAllocation = ConfigurationParameters.numericTrue;
247 parms.shouldForceUpdateAllAabbs = ConfigurationParameters.numericFalse;
248 parms.shouldRandomizeSolverOrder = ConfigurationParameters.numericFalse;
249 parms.shouldSplitSimulationIslands = ConfigurationParameters.numericFalse;
250 parms.shouldEnableFrictionCaching = ConfigurationParameters.numericFalse;
251 parms.numberOfSolverIterations = 0f; // means use default
227 252
228 if (config != null) 253 if (config != null)
229 { 254 {
@@ -265,14 +290,40 @@ public class BSScene : PhysicsScene, IPhysicsParameters
265 parms.terrainHitFraction = pConfig.GetFloat("TerrainHitFraction", parms.terrainHitFraction); 290 parms.terrainHitFraction = pConfig.GetFloat("TerrainHitFraction", parms.terrainHitFraction);
266 parms.terrainRestitution = pConfig.GetFloat("TerrainRestitution", parms.terrainRestitution); 291 parms.terrainRestitution = pConfig.GetFloat("TerrainRestitution", parms.terrainRestitution);
267 parms.avatarFriction = pConfig.GetFloat("AvatarFriction", parms.avatarFriction); 292 parms.avatarFriction = pConfig.GetFloat("AvatarFriction", parms.avatarFriction);
293 parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution);
268 parms.avatarDensity = pConfig.GetFloat("AvatarDensity", parms.avatarDensity); 294 parms.avatarDensity = pConfig.GetFloat("AvatarDensity", parms.avatarDensity);
269 parms.avatarCapsuleRadius = pConfig.GetFloat("AvatarCapsuleRadius", parms.avatarCapsuleRadius); 295 parms.avatarCapsuleRadius = pConfig.GetFloat("AvatarCapsuleRadius", parms.avatarCapsuleRadius);
270 parms.avatarCapsuleHeight = pConfig.GetFloat("AvatarCapsuleHeight", parms.avatarCapsuleHeight); 296 parms.avatarCapsuleHeight = pConfig.GetFloat("AvatarCapsuleHeight", parms.avatarCapsuleHeight);
297 parms.avatarContactProcessingThreshold = pConfig.GetFloat("AvatarContactProcessingThreshold", parms.avatarContactProcessingThreshold);
298
299 parms.maxPersistantManifoldPoolSize = pConfig.GetFloat("MaxPersistantManifoldPoolSize", parms.maxPersistantManifoldPoolSize);
300 parms.shouldDisableContactPoolDynamicAllocation = ParamBoolean(pConfig, "ShouldDisableContactPoolDynamicAllocation", parms.shouldDisableContactPoolDynamicAllocation);
301 parms.shouldForceUpdateAllAabbs = ParamBoolean(pConfig, "ShouldForceUpdateAllAabbs", parms.shouldForceUpdateAllAabbs);
302 parms.shouldRandomizeSolverOrder = ParamBoolean(pConfig, "ShouldRandomizeSolverOrder", parms.shouldRandomizeSolverOrder);
303 parms.shouldSplitSimulationIslands = ParamBoolean(pConfig, "ShouldSplitSimulationIslands", parms.shouldSplitSimulationIslands);
304 parms.shouldEnableFrictionCaching = ParamBoolean(pConfig, "ShouldEnableFrictionCaching", parms.shouldEnableFrictionCaching);
305 parms.numberOfSolverIterations = pConfig.GetFloat("NumberOfSolverIterations", parms.numberOfSolverIterations);
271 } 306 }
272 } 307 }
273 m_params[0] = parms; 308 m_params[0] = parms;
274 } 309 }
275 310
311 // A helper function that handles a true/false parameter and returns the proper float number encoding
312 float ParamBoolean(IConfig config, string parmName, float deflt)
313 {
314 float ret = deflt;
315 if (config.Contains(parmName))
316 {
317 ret = ConfigurationParameters.numericFalse;
318 if (config.GetBoolean(parmName, false))
319 {
320 ret = ConfigurationParameters.numericTrue;
321 }
322 }
323 return ret;
324 }
325
326
276 // Called directly from unmanaged code so don't do much 327 // Called directly from unmanaged code so don't do much
277 private void BulletLogger(string msg) 328 private void BulletLogger(string msg)
278 { 329 {
@@ -391,16 +442,16 @@ public class BSScene : PhysicsScene, IPhysicsParameters
391 { 442 {
392 EntityProperties entprop = m_updateArray[ii]; 443 EntityProperties entprop = m_updateArray[ii];
393 // m_log.DebugFormat("{0}: entprop[{1}]: id={2}, pos={3}", LogHeader, ii, entprop.ID, entprop.Position); 444 // m_log.DebugFormat("{0}: entprop[{1}]: id={2}, pos={3}", LogHeader, ii, entprop.ID, entprop.Position);
394 BSCharacter actor;
395 if (m_avatars.TryGetValue(entprop.ID, out actor))
396 {
397 actor.UpdateProperties(entprop);
398 continue;
399 }
400 BSPrim prim; 445 BSPrim prim;
401 if (m_prims.TryGetValue(entprop.ID, out prim)) 446 if (m_prims.TryGetValue(entprop.ID, out prim))
402 { 447 {
403 prim.UpdateProperties(entprop); 448 prim.UpdateProperties(entprop);
449 continue;
450 }
451 BSCharacter actor;
452 if (m_avatars.TryGetValue(entprop.ID, out actor))
453 {
454 actor.UpdateProperties(entprop);
404 } 455 }
405 } 456 }
406 } 457 }
@@ -470,12 +521,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters
470 521
471 public override void DeleteTerrain() 522 public override void DeleteTerrain()
472 { 523 {
473 m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader); 524 // m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader);
474 } 525 }
475 526
476 public override void Dispose() 527 public override void Dispose()
477 { 528 {
478 m_log.DebugFormat("{0}: Dispose()", LogHeader); 529 // m_log.DebugFormat("{0}: Dispose()", LogHeader);
479 } 530 }
480 531
481 public override Dictionary<uint, float> GetTopColliders() 532 public override Dictionary<uint, float> GetTopColliders()
@@ -699,9 +750,23 @@ public class BSScene : PhysicsScene, IPhysicsParameters
699 new PhysParameterEntry("DeactivationTime", "Seconds before considering an object potentially static" ), 750 new PhysParameterEntry("DeactivationTime", "Seconds before considering an object potentially static" ),
700 new PhysParameterEntry("LinearSleepingThreshold", "Seconds to measure linear movement before considering static" ), 751 new PhysParameterEntry("LinearSleepingThreshold", "Seconds to measure linear movement before considering static" ),
701 new PhysParameterEntry("AngularSleepingThreshold", "Seconds to measure angular movement before considering static" ), 752 new PhysParameterEntry("AngularSleepingThreshold", "Seconds to measure angular movement before considering static" ),
702 // new PhysParameterEntry("CcdMotionThreshold", "" ), 753 new PhysParameterEntry("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" ),
703 // new PhysParameterEntry("CcdSweptSphereRadius", "" ), 754 new PhysParameterEntry("CcdSweptSphereRadius", "Continuious collision detection test radius" ),
704 new PhysParameterEntry("ContactProcessingThreshold", "Distance between contacts before doing collision check" ), 755 new PhysParameterEntry("ContactProcessingThreshold", "Distance between contacts before doing collision check" ),
756 // Can only change the following at initialization time. Change the INI file and reboot.
757 new PhysParameterEntry("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default)"),
758 new PhysParameterEntry("ShouldDisableContactPoolDynamicAllocation", "Enable to allow large changes in object count"),
759 new PhysParameterEntry("ShouldForceUpdateAllAabbs", "Enable to recomputer AABBs every simulator step"),
760 new PhysParameterEntry("ShouldRandomizeSolverOrder", "Enable for slightly better stacking interaction"),
761 new PhysParameterEntry("ShouldSplitSimulationIslands", "Enable splitting active object scanning islands"),
762 new PhysParameterEntry("ShouldEnableFrictionCaching", "Enable friction computation caching"),
763 new PhysParameterEntry("NumberOfSolverIterations", "Number of internal iterations (0 means default)"),
764
765 new PhysParameterEntry("Friction", "Set friction parameter for a specific object" ),
766 new PhysParameterEntry("Restitution", "Set restitution parameter for a specific object" ),
767
768 new PhysParameterEntry("Friction", "Set friction parameter for a specific object" ),
769 new PhysParameterEntry("Restitution", "Set restitution parameter for a specific object" ),
705 770
706 new PhysParameterEntry("TerrainFriction", "Factor to reduce movement against terrain surface" ), 771 new PhysParameterEntry("TerrainFriction", "Factor to reduce movement against terrain surface" ),
707 new PhysParameterEntry("TerrainHitFraction", "Distance to measure hit collisions" ), 772 new PhysParameterEntry("TerrainHitFraction", "Distance to measure hit collisions" ),
@@ -710,7 +775,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
710 new PhysParameterEntry("AvatarDensity", "Density of an avatar. Changed on avatar recreation." ), 775 new PhysParameterEntry("AvatarDensity", "Density of an avatar. Changed on avatar recreation." ),
711 new PhysParameterEntry("AvatarRestitution", "Bouncyness. Changed on avatar recreation." ), 776 new PhysParameterEntry("AvatarRestitution", "Bouncyness. Changed on avatar recreation." ),
712 new PhysParameterEntry("AvatarCapsuleRadius", "Radius of space around an avatar" ), 777 new PhysParameterEntry("AvatarCapsuleRadius", "Radius of space around an avatar" ),
713 new PhysParameterEntry("AvatarCapsuleHeight", "Default height of space around avatar" ) 778 new PhysParameterEntry("AvatarCapsuleHeight", "Default height of space around avatar" ),
779 new PhysParameterEntry("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions")
780
714 }; 781 };
715 782
716 #region IPhysicsParameters 783 #region IPhysicsParameters
@@ -733,6 +800,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
733 switch (lparm) 800 switch (lparm)
734 { 801 {
735 case "detailedstats": m_detailedStatsStep = (int)val; break; 802 case "detailedstats": m_detailedStatsStep = (int)val; break;
803
736 case "meshlod": m_meshLOD = (int)val; break; 804 case "meshlod": m_meshLOD = (int)val; break;
737 case "sculptlod": m_sculptLOD = (int)val; break; 805 case "sculptlod": m_sculptLOD = (int)val; break;
738 case "maxsubstep": m_maxSubSteps = (int)val; break; 806 case "maxsubstep": m_maxSubSteps = (int)val; break;
@@ -743,7 +811,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
743 case "defaultdensity": m_params[0].defaultDensity = val; break; 811 case "defaultdensity": m_params[0].defaultDensity = val; break;
744 case "defaultrestitution": m_params[0].defaultRestitution = val; break; 812 case "defaultrestitution": m_params[0].defaultRestitution = val; break;
745 case "collisionmargin": m_params[0].collisionMargin = val; break; 813 case "collisionmargin": m_params[0].collisionMargin = val; break;
746 case "gravity": m_params[0].gravity = val; TaintedUpdateParameter(lparm, PhysParameterEntry.APPLY_TO_NONE, val); break; 814 case "gravity": m_params[0].gravity = val; TaintedUpdateParameter(lparm, localID, val); break;
747 815
748 case "lineardamping": UpdateParameterPrims(ref m_params[0].linearDamping, lparm, localID, val); break; 816 case "lineardamping": UpdateParameterPrims(ref m_params[0].linearDamping, lparm, localID, val); break;
749 case "angulardamping": UpdateParameterPrims(ref m_params[0].angularDamping, lparm, localID, val); break; 817 case "angulardamping": UpdateParameterPrims(ref m_params[0].angularDamping, lparm, localID, val); break;
@@ -753,6 +821,20 @@ public class BSScene : PhysicsScene, IPhysicsParameters
753 case "ccdmotionthreshold": UpdateParameterPrims(ref m_params[0].ccdMotionThreshold, lparm, localID, val); break; 821 case "ccdmotionthreshold": UpdateParameterPrims(ref m_params[0].ccdMotionThreshold, lparm, localID, val); break;
754 case "ccdsweptsphereradius": UpdateParameterPrims(ref m_params[0].ccdSweptSphereRadius, lparm, localID, val); break; 822 case "ccdsweptsphereradius": UpdateParameterPrims(ref m_params[0].ccdSweptSphereRadius, lparm, localID, val); break;
755 case "contactprocessingthreshold": UpdateParameterPrims(ref m_params[0].contactProcessingThreshold, lparm, localID, val); break; 823 case "contactprocessingthreshold": UpdateParameterPrims(ref m_params[0].contactProcessingThreshold, lparm, localID, val); break;
824 // the following are used only at initialization time so setting them makes no sense
825 // case "maxPersistantmanifoldpoolSize": m_params[0].maxPersistantManifoldPoolSize = val; break;
826 // case "shoulddisablecontactpooldynamicallocation": m_params[0].shouldDisableContactPoolDynamicAllocation = val; break;
827 // case "shouldforceupdateallaabbs": m_params[0].shouldForceUpdateAllAabbs = val; break;
828 // case "shouldrandomizesolverorder": m_params[0].shouldRandomizeSolverOrder = val; break;
829 // case "shouldsplitsimulationislands": m_params[0].shouldSplitSimulationIslands = val; break;
830 // case "shouldenablefrictioncaching": m_params[0].shouldEnableFrictionCaching = val; break;
831 // case "numberofsolveriterations": m_params[0].numberOfSolverIterations = val; break;
832
833 case "friction": TaintedUpdateParameter(lparm, localID, val); break;
834 case "restitution": TaintedUpdateParameter(lparm, localID, val); break;
835
836 case "friction": TaintedUpdateParameter(lparm, localID, val); break;
837 case "restitution": TaintedUpdateParameter(lparm, localID, val); break;
756 838
757 // set a terrain physical feature and cause terrain to be recalculated 839 // set a terrain physical feature and cause terrain to be recalculated
758 case "terrainfriction": m_params[0].terrainFriction = val; TaintedUpdateParameter("terrain", 0, val); break; 840 case "terrainfriction": m_params[0].terrainFriction = val; TaintedUpdateParameter("terrain", 0, val); break;
@@ -764,6 +846,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
764 case "avatarrestitution": UpdateParameterAvatars(ref m_params[0].avatarRestitution, "avatar", localID, val); break; 846 case "avatarrestitution": UpdateParameterAvatars(ref m_params[0].avatarRestitution, "avatar", localID, val); break;
765 case "avatarcapsuleradius": UpdateParameterAvatars(ref m_params[0].avatarCapsuleRadius, "avatar", localID, val); break; 847 case "avatarcapsuleradius": UpdateParameterAvatars(ref m_params[0].avatarCapsuleRadius, "avatar", localID, val); break;
766 case "avatarcapsuleheight": UpdateParameterAvatars(ref m_params[0].avatarCapsuleHeight, "avatar", localID, val); break; 848 case "avatarcapsuleheight": UpdateParameterAvatars(ref m_params[0].avatarCapsuleHeight, "avatar", localID, val); break;
849 case "avatarcontactprocessingthreshold": UpdateParameterAvatars(ref m_params[0].avatarContactProcessingThreshold, "avatar", localID, val); break;
767 850
768 default: ret = false; break; 851 default: ret = false; break;
769 } 852 }
@@ -856,6 +939,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters
856 case "ccdmotionthreshold": val = m_params[0].ccdMotionThreshold; break; 939 case "ccdmotionthreshold": val = m_params[0].ccdMotionThreshold; break;
857 case "ccdsweptsphereradius": val = m_params[0].ccdSweptSphereRadius; break; 940 case "ccdsweptsphereradius": val = m_params[0].ccdSweptSphereRadius; break;
858 case "contactprocessingthreshold": val = m_params[0].contactProcessingThreshold; break; 941 case "contactprocessingthreshold": val = m_params[0].contactProcessingThreshold; break;
942 case "maxPersistantmanifoldpoolSize": val = m_params[0].maxPersistantManifoldPoolSize; break;
943 case "shoulddisablecontactpooldynamicallocation": val = m_params[0].shouldDisableContactPoolDynamicAllocation; break;
944 case "shouldforceupdateallaabbs": val = m_params[0].shouldForceUpdateAllAabbs; break;
945 case "shouldrandomizesolverorder": val = m_params[0].shouldRandomizeSolverOrder; break;
946 case "shouldsplitsimulationislands": val = m_params[0].shouldSplitSimulationIslands; break;
947 case "shouldenablefrictioncaching": val = m_params[0].shouldEnableFrictionCaching; break;
948 case "numberofsolveriterations": val = m_params[0].numberOfSolverIterations; break;
859 949
860 case "terrainfriction": val = m_params[0].terrainFriction; break; 950 case "terrainfriction": val = m_params[0].terrainFriction; break;
861 case "terrainhitfraction": val = m_params[0].terrainHitFraction; break; 951 case "terrainhitfraction": val = m_params[0].terrainHitFraction; break;
@@ -866,6 +956,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
866 case "avatarrestitution": val = m_params[0].avatarRestitution; break; 956 case "avatarrestitution": val = m_params[0].avatarRestitution; break;
867 case "avatarcapsuleradius": val = m_params[0].avatarCapsuleRadius; break; 957 case "avatarcapsuleradius": val = m_params[0].avatarCapsuleRadius; break;
868 case "avatarcapsuleheight": val = m_params[0].avatarCapsuleHeight; break; 958 case "avatarcapsuleheight": val = m_params[0].avatarCapsuleHeight; break;
959 case "avatarcontactprocessingthreshold": val = m_params[0].avatarContactProcessingThreshold; break;
869 default: ret = false; break; 960 default: ret = false; break;
870 961
871 } 962 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index d12bd7d..086f0dc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -132,6 +132,15 @@ public struct ConfigurationParameters
132 public float avatarRestitution; 132 public float avatarRestitution;
133 public float avatarCapsuleRadius; 133 public float avatarCapsuleRadius;
134 public float avatarCapsuleHeight; 134 public float avatarCapsuleHeight;
135 public float avatarContactProcessingThreshold;
136
137 public float maxPersistantManifoldPoolSize;
138 public float shouldDisableContactPoolDynamicAllocation;
139 public float shouldForceUpdateAllAabbs;
140 public float shouldRandomizeSolverOrder;
141 public float shouldSplitSimulationIslands;
142 public float shouldEnableFrictionCaching;
143 public float numberOfSolverIterations;
135 144
136 public const float numericTrue = 1f; 145 public const float numericTrue = 1f;
137 public const float numericFalse = 0f; 146 public const float numericFalse = 0f;
@@ -149,16 +158,16 @@ public static extern uint Initialize(Vector3 maxPosition, IntPtr parms,
149 int maxUpdates, IntPtr updateArray); 158 int maxUpdates, IntPtr updateArray);
150 159
151[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 160[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
152public static extern bool UpdateParameter(uint worldID, uint localID,
153 [MarshalAs(UnmanagedType.LPStr)]string paramCode, float value);
154
155[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
156public static extern void SetHeightmap(uint worldID, [MarshalAs(UnmanagedType.LPArray)] float[] heightMap); 161public static extern void SetHeightmap(uint worldID, [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
157 162
158[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 163[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
159public static extern void Shutdown(uint worldID); 164public static extern void Shutdown(uint worldID);
160 165
166[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
167public static extern bool UpdateParameter(uint worldID, uint localID,
168 [MarshalAs(UnmanagedType.LPStr)]string paramCode, float value);
161 169
170// ===============================================================================
162[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 171[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
163public static extern int PhysicsStep(uint worldID, float timeStep, int maxSubSteps, float fixedTimeStep, 172public static extern int PhysicsStep(uint worldID, float timeStep, int maxSubSteps, float fixedTimeStep,
164 out int updatedEntityCount, 173 out int updatedEntityCount,
@@ -240,6 +249,7 @@ public static extern bool HasObject(uint worldID, uint id);
240[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 249[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
241public static extern bool DestroyObject(uint worldID, uint id); 250public static extern bool DestroyObject(uint worldID, uint id);
242 251
252// ===============================================================================
243[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 253[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
244public static extern SweepHit ConvexSweepTest(uint worldID, uint id, Vector3 to, float extraMargin); 254public static extern SweepHit ConvexSweepTest(uint worldID, uint id, Vector3 to, float extraMargin);
245 255
@@ -249,6 +259,7 @@ public static extern RaycastHit RayTest(uint worldID, uint id, Vector3 from, Vec
249[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 259[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
250public static extern Vector3 RecoverFromPenetration(uint worldID, uint id); 260public static extern Vector3 RecoverFromPenetration(uint worldID, uint id);
251 261
262// ===============================================================================
252[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 263[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
253public static extern void DumpBulletStatistics(); 264public static extern void DumpBulletStatistics();
254 265