aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs66
1 files changed, 60 insertions, 6 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index 8ebb532..f953c1e 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -99,6 +99,9 @@ public abstract class BSPhysObject : PhysicsActor
99 CollisionAccumulation = 0; 99 CollisionAccumulation = 0;
100 ColliderIsMoving = false; 100 ColliderIsMoving = false;
101 CollisionScore = 0; 101 CollisionScore = 0;
102
103 // All axis free.
104 LockedAxis = LockedAxisFree;
102 } 105 }
103 106
104 // Tell the object to clean up. 107 // Tell the object to clean up.
@@ -172,7 +175,8 @@ public abstract class BSPhysObject : PhysicsActor
172 MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false); 175 MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false);
173 Friction = matAttrib.friction; 176 Friction = matAttrib.friction;
174 Restitution = matAttrib.restitution; 177 Restitution = matAttrib.restitution;
175 Density = matAttrib.density; 178 Density = matAttrib.density / BSParam.DensityScaleFactor;
179 DetailLog("{0},{1}.SetMaterial,Mat={2},frict={3},rest={4},den={5}", LocalID, TypeName, Material, Friction, Restitution, Density);
176 } 180 }
177 181
178 // Stop all physical motion. 182 // Stop all physical motion.
@@ -220,6 +224,9 @@ public abstract class BSPhysObject : PhysicsActor
220 // computed center-of-mass (like in linksets). 224 // computed center-of-mass (like in linksets).
221 public OMV.Vector3? UserSetCenterOfMass { get; set; } 225 public OMV.Vector3? UserSetCenterOfMass { get; set; }
222 226
227 public OMV.Vector3 LockedAxis { get; set; } // zero means locked. one means free.
228 public readonly OMV.Vector3 LockedAxisFree = new OMV.Vector3(1f, 1f, 1f); // All axis are free
229
223 #region Collisions 230 #region Collisions
224 231
225 // Requested number of milliseconds between collision events. Zero means disabled. 232 // Requested number of milliseconds between collision events. Zero means disabled.
@@ -416,9 +423,7 @@ public abstract class BSPhysObject : PhysicsActor
416 { 423 {
417 // Clean out any existing action 424 // Clean out any existing action
418 UnRegisterPreStepAction(op, id); 425 UnRegisterPreStepAction(op, id);
419
420 RegisteredPrestepActions[identifier] = actn; 426 RegisteredPrestepActions[identifier] = actn;
421
422 PhysicsScene.BeforeStep += actn; 427 PhysicsScene.BeforeStep += actn;
423 } 428 }
424 DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier); 429 DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier);
@@ -464,9 +469,7 @@ public abstract class BSPhysObject : PhysicsActor
464 { 469 {
465 // Clean out any existing action 470 // Clean out any existing action
466 UnRegisterPostStepAction(op, id); 471 UnRegisterPostStepAction(op, id);
467
468 RegisteredPoststepActions[identifier] = actn; 472 RegisteredPoststepActions[identifier] = actn;
469
470 PhysicsScene.AfterStep += actn; 473 PhysicsScene.AfterStep += actn;
471 } 474 }
472 DetailLog("{0},BSPhysObject.RegisterPostStepAction,id={1}", LocalID, identifier); 475 DetailLog("{0},BSPhysObject.RegisterPostStepAction,id={1}", LocalID, identifier);
@@ -503,7 +506,58 @@ public abstract class BSPhysObject : PhysicsActor
503 } 506 }
504 DetailLog("{0},BSPhysObject.UnRegisterAllPostStepActions,", LocalID); 507 DetailLog("{0},BSPhysObject.UnRegisterAllPostStepActions,", LocalID);
505 } 508 }
506 509
510 // When an update to the physical properties happens, this event is fired to let
511 // different actors to modify the update before it is passed around
512 public delegate void PreUpdatePropertyAction(ref EntityProperties entprop);
513 public event PreUpdatePropertyAction OnPreUpdateProperty;
514 protected void TriggerPreUpdatePropertyAction(ref EntityProperties entprop)
515 {
516 PreUpdatePropertyAction actions = OnPreUpdateProperty;
517 if (actions != null)
518 actions(ref entprop);
519 }
520
521 private Dictionary<string, PreUpdatePropertyAction> RegisteredPreUpdatePropertyActions = new Dictionary<string, PreUpdatePropertyAction>();
522 public void RegisterPreUpdatePropertyAction(string identifier, PreUpdatePropertyAction actn)
523 {
524 lock (RegisteredPreUpdatePropertyActions)
525 {
526 // Clean out any existing action
527 UnRegisterPreUpdatePropertyAction(identifier);
528 RegisteredPreUpdatePropertyActions[identifier] = actn;
529 OnPreUpdateProperty += actn;
530 }
531 DetailLog("{0},BSPhysObject.RegisterPreUpdatePropertyAction,id={1}", LocalID, identifier);
532 }
533 public bool UnRegisterPreUpdatePropertyAction(string identifier)
534 {
535 bool removed = false;
536 lock (RegisteredPreUpdatePropertyActions)
537 {
538 if (RegisteredPreUpdatePropertyActions.ContainsKey(identifier))
539 {
540 OnPreUpdateProperty -= RegisteredPreUpdatePropertyActions[identifier];
541 RegisteredPreUpdatePropertyActions.Remove(identifier);
542 removed = true;
543 }
544 }
545 DetailLog("{0},BSPhysObject.UnRegisterPreUpdatePropertyAction,id={1},removed={2}", LocalID, identifier, removed);
546 return removed;
547 }
548 public void UnRegisterAllPreUpdatePropertyActions()
549 {
550 lock (RegisteredPreUpdatePropertyActions)
551 {
552 foreach (KeyValuePair<string, PreUpdatePropertyAction> kvp in RegisteredPreUpdatePropertyActions)
553 {
554 OnPreUpdateProperty -= kvp.Value;
555 }
556 RegisteredPreUpdatePropertyActions.Clear();
557 }
558 DetailLog("{0},BSPhysObject.UnRegisterAllPreUpdatePropertyAction,", LocalID);
559 }
560
507 #endregion // Per Simulation Step actions 561 #endregion // Per Simulation Step actions
508 562
509 // High performance detailed logging routine used by the physical objects. 563 // High performance detailed logging routine used by the physical objects.