aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin
diff options
context:
space:
mode:
authorRobert Adams2012-07-12 15:34:25 -0700
committerRobert Adams2012-07-20 14:02:24 -0700
commitc400918c84fc89ff0209ee05def3bb46206ba5ee (patch)
treefc28a498207e20136a87528b937ec619ab3cbe3a /OpenSim/Region/Physics/BulletSPlugin
parentBulletSim: Add detailed and voluminous debug logging that is enabled (diff)
downloadopensim-SC_OLD-c400918c84fc89ff0209ee05def3bb46206ba5ee.zip
opensim-SC_OLD-c400918c84fc89ff0209ee05def3bb46206ba5ee.tar.gz
opensim-SC_OLD-c400918c84fc89ff0209ee05def3bb46206ba5ee.tar.bz2
opensim-SC_OLD-c400918c84fc89ff0209ee05def3bb46206ba5ee.tar.xz
BulletSim: Add PID variables to physical scene. Not PIDing yet, but soon.
Cleaned up code and got rid of compile warnings.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs69
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs116
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs13
3 files changed, 97 insertions, 101 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index dc0c008..09e1f0c 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -41,7 +41,7 @@ public class BSCharacter : PhysicsActor
41 41
42 private BSScene _scene; 42 private BSScene _scene;
43 private String _avName; 43 private String _avName;
44 private bool _stopped; 44 // private bool _stopped;
45 private Vector3 _size; 45 private Vector3 _size;
46 private Vector3 _scale; 46 private Vector3 _scale;
47 private PrimitiveBaseShape _pbs; 47 private PrimitiveBaseShape _pbs;
@@ -134,9 +134,9 @@ public class BSCharacter : PhysicsActor
134 { 134 {
135 base.RequestPhysicsterseUpdate(); 135 base.RequestPhysicsterseUpdate();
136 } 136 }
137 137 // No one calls this method so I don't know what it could possibly mean
138 public override bool Stopped { 138 public override bool Stopped {
139 get { return _stopped; } 139 get { return false; }
140 } 140 }
141 public override Vector3 Size { 141 public override Vector3 Size {
142 get { return _size; } 142 get { return _size; }
@@ -391,52 +391,47 @@ public class BSCharacter : PhysicsActor
391 _mass = _density * _avatarVolume; 391 _mass = _density * _avatarVolume;
392 } 392 }
393 393
394 // Set to 'true' if the individual changed items should be checked
395 // (someday RequestPhysicsTerseUpdate() will take a bitmap of changed properties)
396 const bool SHOULD_CHECK_FOR_INDIVIDUAL_CHANGES = false;
397
398 // The physics engine says that properties have updated. Update same and inform 394 // The physics engine says that properties have updated. Update same and inform
399 // the world that things have changed. 395 // the world that things have changed.
400 public void UpdateProperties(EntityProperties entprop) 396 public void UpdateProperties(EntityProperties entprop)
401 { 397 {
398 /*
402 bool changed = false; 399 bool changed = false;
403 if (SHOULD_CHECK_FOR_INDIVIDUAL_CHANGES) { 400 // we assign to the local variables so the normal set action does not happen
404 // we assign to the local variables so the normal set action does not happen 401 if (_position != entprop.Position) {
405 if (_position != entprop.Position) {
406 _position = entprop.Position;
407 changed = true;
408 }
409 if (_orientation != entprop.Rotation) {
410 _orientation = entprop.Rotation;
411 changed = true;
412 }
413 if (_velocity != entprop.Velocity) {
414 _velocity = entprop.Velocity;
415 changed = true;
416 }
417 if (_acceleration != entprop.Acceleration) {
418 _acceleration = entprop.Acceleration;
419 changed = true;
420 }
421 if (_rotationalVelocity != entprop.RotationalVelocity) {
422 _rotationalVelocity = entprop.RotationalVelocity;
423 changed = true;
424 }
425 if (changed) {
426 // m_log.DebugFormat("{0}: UpdateProperties: id={1}, c={2}, pos={3}, rot={4}", LogHeader, LocalID, changed, _position, _orientation);
427 // Avatar movement is not done by generating this event. There is code in the heartbeat
428 // loop that updates avatars.
429 // base.RequestPhysicsterseUpdate();
430 }
431 }
432 else {
433 _position = entprop.Position; 402 _position = entprop.Position;
403 changed = true;
404 }
405 if (_orientation != entprop.Rotation) {
434 _orientation = entprop.Rotation; 406 _orientation = entprop.Rotation;
407 changed = true;
408 }
409 if (_velocity != entprop.Velocity) {
435 _velocity = entprop.Velocity; 410 _velocity = entprop.Velocity;
411 changed = true;
412 }
413 if (_acceleration != entprop.Acceleration) {
436 _acceleration = entprop.Acceleration; 414 _acceleration = entprop.Acceleration;
415 changed = true;
416 }
417 if (_rotationalVelocity != entprop.RotationalVelocity) {
437 _rotationalVelocity = entprop.RotationalVelocity; 418 _rotationalVelocity = entprop.RotationalVelocity;
419 changed = true;
420 }
421 if (changed) {
422 // m_log.DebugFormat("{0}: UpdateProperties: id={1}, c={2}, pos={3}, rot={4}", LogHeader, LocalID, changed, _position, _orientation);
423 // Avatar movement is not done by generating this event. There is code in the heartbeat
424 // loop that updates avatars.
438 // base.RequestPhysicsterseUpdate(); 425 // base.RequestPhysicsterseUpdate();
439 } 426 }
427 */
428 _position = entprop.Position;
429 _orientation = entprop.Rotation;
430 _velocity = entprop.Velocity;
431 _acceleration = entprop.Acceleration;
432 _rotationalVelocity = entprop.RotationalVelocity;
433 // Avatars don't report theirr changes the usual way. Changes are checked for in the heartbeat loop.
434 // base.RequestPhysicsterseUpdate();
440 } 435 }
441 436
442 // Called by the scene when a collision with this object is reported 437 // Called by the scene when a collision with this object is reported
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 9b28a06..23b276e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -148,7 +148,7 @@ public sealed class BSPrim : PhysicsActor
148 { 148 {
149 // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); 149 // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID);
150 // Undo any vehicle properties 150 // Undo any vehicle properties
151 _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); 151 _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE, 1f);
152 _scene.RemoveVehiclePrim(this); // just to make sure 152 _scene.RemoveVehiclePrim(this); // just to make sure
153 153
154 // undo any dependance with/on other objects 154 // undo any dependance with/on other objects
@@ -353,7 +353,7 @@ public sealed class BSPrim : PhysicsActor
353 } 353 }
354 set { 354 set {
355 Vehicle type = (Vehicle)value; 355 Vehicle type = (Vehicle)value;
356 _vehicle.ProcessTypeChange(type); 356 _vehicle.ProcessTypeChange(type, _scene.LastSimulatedTimestep);
357 _scene.TaintedObject(delegate() 357 _scene.TaintedObject(delegate()
358 { 358 {
359 if (type == Vehicle.TYPE_NONE) 359 if (type == Vehicle.TYPE_NONE)
@@ -371,11 +371,11 @@ public sealed class BSPrim : PhysicsActor
371 } 371 }
372 public override void VehicleFloatParam(int param, float value) 372 public override void VehicleFloatParam(int param, float value)
373 { 373 {
374 _vehicle.ProcessFloatVehicleParam((Vehicle)param, value); 374 _vehicle.ProcessFloatVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep);
375 } 375 }
376 public override void VehicleVectorParam(int param, OMV.Vector3 value) 376 public override void VehicleVectorParam(int param, OMV.Vector3 value)
377 { 377 {
378 _vehicle.ProcessVectorVehicleParam((Vehicle)param, value); 378 _vehicle.ProcessVectorVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep);
379 } 379 }
380 public override void VehicleRotationParam(int param, OMV.Quaternion rotation) 380 public override void VehicleRotationParam(int param, OMV.Quaternion rotation)
381 { 381 {
@@ -1262,78 +1262,66 @@ public sealed class BSPrim : PhysicsActor
1262 const float POSITION_TOLERANCE = 0.05f; 1262 const float POSITION_TOLERANCE = 0.05f;
1263 const float ACCELERATION_TOLERANCE = 0.01f; 1263 const float ACCELERATION_TOLERANCE = 0.01f;
1264 const float ROTATIONAL_VELOCITY_TOLERANCE = 0.01f; 1264 const float ROTATIONAL_VELOCITY_TOLERANCE = 0.01f;
1265 const bool SHOULD_DAMP_UPDATES = false;
1266 1265
1267 public void UpdateProperties(EntityProperties entprop) 1266 public void UpdateProperties(EntityProperties entprop)
1268 { 1267 {
1268 /*
1269 UpdatedProperties changed = 0; 1269 UpdatedProperties changed = 0;
1270 if (SHOULD_DAMP_UPDATES) 1270 // assign to the local variables so the normal set action does not happen
1271 // if (_position != entprop.Position)
1272 if (!_position.ApproxEquals(entprop.Position, POSITION_TOLERANCE))
1271 { 1273 {
1272 // assign to the local variables so the normal set action does not happen 1274 _position = entprop.Position;
1273 // if (_position != entprop.Position) 1275 changed |= UpdatedProperties.Position;
1274 if (!_position.ApproxEquals(entprop.Position, POSITION_TOLERANCE))
1275 {
1276 _position = entprop.Position;
1277 // m_log.DebugFormat("{0}: UpdateProperties: id={1}, pos = {2}", LogHeader, LocalID, _position);
1278 changed |= UpdatedProperties.Position;
1279 }
1280 // if (_orientation != entprop.Rotation)
1281 if (!_orientation.ApproxEquals(entprop.Rotation, ROTATION_TOLERANCE))
1282 {
1283 _orientation = entprop.Rotation;
1284 // m_log.DebugFormat("{0}: UpdateProperties: id={1}, rot = {2}", LogHeader, LocalID, _orientation);
1285 changed |= UpdatedProperties.Rotation;
1286 }
1287 // if (_velocity != entprop.Velocity)
1288 if (!_velocity.ApproxEquals(entprop.Velocity, VELOCITY_TOLERANCE))
1289 {
1290 _velocity = entprop.Velocity;
1291 // m_log.DebugFormat("{0}: UpdateProperties: velocity = {1}", LogHeader, _velocity);
1292 changed |= UpdatedProperties.Velocity;
1293 }
1294 // if (_acceleration != entprop.Acceleration)
1295 if (!_acceleration.ApproxEquals(entprop.Acceleration, ACCELERATION_TOLERANCE))
1296 {
1297 _acceleration = entprop.Acceleration;
1298 // m_log.DebugFormat("{0}: UpdateProperties: acceleration = {1}", LogHeader, _acceleration);
1299 changed |= UpdatedProperties.Acceleration;
1300 }
1301 // if (_rotationalVelocity != entprop.RotationalVelocity)
1302 if (!_rotationalVelocity.ApproxEquals(entprop.RotationalVelocity, ROTATIONAL_VELOCITY_TOLERANCE))
1303 {
1304 _rotationalVelocity = entprop.RotationalVelocity;
1305 // m_log.DebugFormat("{0}: UpdateProperties: rotationalVelocity = {1}", LogHeader, _rotationalVelocity);
1306 changed |= UpdatedProperties.RotationalVel;
1307 }
1308 if (changed != 0)
1309 {
1310 // m_log.DebugFormat("{0}: UpdateProperties: id={1}, c={2}, pos={3}, rot={4}", LogHeader, LocalID, changed, _position, _orientation);
1311 // Only update the position of single objects and linkset roots
1312 if (this._parentPrim == null)
1313 {
1314 // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}", LogHeader, LocalID, changed, _position, _orientation);
1315 base.RequestPhysicsterseUpdate();
1316 }
1317 }
1318 } 1276 }
1319 else 1277 // if (_orientation != entprop.Rotation)
1278 if (!_orientation.ApproxEquals(entprop.Rotation, ROTATION_TOLERANCE))
1320 { 1279 {
1321 // Don't check for damping here -- it's done in BulletSim and SceneObjectPart. 1280 _orientation = entprop.Rotation;
1322 1281 changed |= UpdatedProperties.Rotation;
1323 // Only updates only for individual prims and for the root object of a linkset. 1282 }
1283 // if (_velocity != entprop.Velocity)
1284 if (!_velocity.ApproxEquals(entprop.Velocity, VELOCITY_TOLERANCE))
1285 {
1286 _velocity = entprop.Velocity;
1287 changed |= UpdatedProperties.Velocity;
1288 }
1289 // if (_acceleration != entprop.Acceleration)
1290 if (!_acceleration.ApproxEquals(entprop.Acceleration, ACCELERATION_TOLERANCE))
1291 {
1292 _acceleration = entprop.Acceleration;
1293 changed |= UpdatedProperties.Acceleration;
1294 }
1295 // if (_rotationalVelocity != entprop.RotationalVelocity)
1296 if (!_rotationalVelocity.ApproxEquals(entprop.RotationalVelocity, ROTATIONAL_VELOCITY_TOLERANCE))
1297 {
1298 _rotationalVelocity = entprop.RotationalVelocity;
1299 changed |= UpdatedProperties.RotationalVel;
1300 }
1301 if (changed != 0)
1302 {
1303 // Only update the position of single objects and linkset roots
1324 if (this._parentPrim == null) 1304 if (this._parentPrim == null)
1325 { 1305 {
1326 // Assign to the local variables so the normal set action does not happen
1327 _position = entprop.Position;
1328 _orientation = entprop.Rotation;
1329 _velocity = entprop.Velocity;
1330 _acceleration = entprop.Acceleration;
1331 _rotationalVelocity = entprop.RotationalVelocity;
1332 // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}, vel={5}, acc={6}, rvel={7}",
1333 // LogHeader, LocalID, changed, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
1334 base.RequestPhysicsterseUpdate(); 1306 base.RequestPhysicsterseUpdate();
1335 } 1307 }
1336 } 1308 }
1309 */
1310
1311 // Don't check for damping here -- it's done in BulletSim and SceneObjectPart.
1312 // Updates only for individual prims and for the root object of a linkset.
1313 if (this._parentPrim == null)
1314 {
1315 // Assign to the local variables so the normal set action does not happen
1316 _position = entprop.Position;
1317 _orientation = entprop.Rotation;
1318 _velocity = entprop.Velocity;
1319 _acceleration = entprop.Acceleration;
1320 _rotationalVelocity = entprop.RotationalVelocity;
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);
1323 base.RequestPhysicsterseUpdate();
1324 }
1337 } 1325 }
1338 1326
1339 // I've collided with something 1327 // I've collided with something
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index eb1d798..150326e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -107,6 +107,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
107 private long m_simulationStep = 0; 107 private long m_simulationStep = 0;
108 public long SimulationStep { get { return m_simulationStep; } } 108 public long SimulationStep { get { return m_simulationStep; } }
109 109
110 public float LastSimulatedTimestep { get; private set; }
111
110 // A value of the time now so all the collision and update routines do not have to get their own 112 // A value of the time now so all the collision and update routines do not have to get their own
111 // Set to 'now' just before all the prims and actors are called for collisions and updates 113 // Set to 'now' just before all the prims and actors are called for collisions and updates
112 private int m_simulationNowTime; 114 private int m_simulationNowTime;
@@ -123,6 +125,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
123 private bool _meshSculptedPrim = true; // cause scuplted prims to get meshed 125 private bool _meshSculptedPrim = true; // cause scuplted prims to get meshed
124 private bool _forceSimplePrimMeshing = false; // if a cube or sphere, let Bullet do internal shapes 126 private bool _forceSimplePrimMeshing = false; // if a cube or sphere, let Bullet do internal shapes
125 127
128 public float PID_D { get; private set; } // derivative
129 public float PID_P { get; private set; } // proportional
130
126 public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero 131 public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero
127 public const uint GROUNDPLANE_ID = 1; 132 public const uint GROUNDPLANE_ID = 1;
128 133
@@ -222,6 +227,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
222 m_maxUpdatesPerFrame = 2048; 227 m_maxUpdatesPerFrame = 2048;
223 m_maximumObjectMass = 10000.01f; 228 m_maximumObjectMass = 10000.01f;
224 229
230 PID_D = 2200f;
231 PID_P = 900f;
232
225 parms.defaultFriction = 0.5f; 233 parms.defaultFriction = 0.5f;
226 parms.defaultDensity = 10.000006836f; // Aluminum g/cm3 234 parms.defaultDensity = 10.000006836f; // Aluminum g/cm3
227 parms.defaultRestitution = 0f; 235 parms.defaultRestitution = 0f;
@@ -278,6 +286,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
278 m_maxUpdatesPerFrame = pConfig.GetInt("MaxUpdatesPerFrame", m_maxUpdatesPerFrame); 286 m_maxUpdatesPerFrame = pConfig.GetInt("MaxUpdatesPerFrame", m_maxUpdatesPerFrame);
279 m_maximumObjectMass = pConfig.GetFloat("MaxObjectMass", m_maximumObjectMass); 287 m_maximumObjectMass = pConfig.GetFloat("MaxObjectMass", m_maximumObjectMass);
280 288
289 PID_D = pConfig.GetFloat("PIDDerivative", PID_D);
290 PID_P = pConfig.GetFloat("PIDProportional", PID_P);
291
281 parms.defaultFriction = pConfig.GetFloat("DefaultFriction", parms.defaultFriction); 292 parms.defaultFriction = pConfig.GetFloat("DefaultFriction", parms.defaultFriction);
282 parms.defaultDensity = pConfig.GetFloat("DefaultDensity", parms.defaultDensity); 293 parms.defaultDensity = pConfig.GetFloat("DefaultDensity", parms.defaultDensity);
283 parms.defaultRestitution = pConfig.GetFloat("DefaultRestitution", parms.defaultRestitution); 294 parms.defaultRestitution = pConfig.GetFloat("DefaultRestitution", parms.defaultRestitution);
@@ -415,6 +426,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
415 int collidersCount; 426 int collidersCount;
416 IntPtr collidersPtr; 427 IntPtr collidersPtr;
417 428
429 LastSimulatedTimestep = timeStep;
430
418 // prevent simulation until we've been initialized 431 // prevent simulation until we've been initialized
419 if (!m_initialized) return 10.0f; 432 if (!m_initialized) return 10.0f;
420 433