diff options
author | Robert Adams | 2013-02-12 15:45:44 -0800 |
---|---|---|
committer | Robert Adams | 2013-02-12 15:52:10 -0800 |
commit | 0194a3d890b95c8a29fcdf130c378e3a8a629c77 (patch) | |
tree | df1d9993266ab8460809fb8c901e7f08d7b3bdba /OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |
parent | BulletSim: More work on center-of-mass. Remove linksetinfo and rely on simula... (diff) | |
download | opensim-SC_OLD-0194a3d890b95c8a29fcdf130c378e3a8a629c77.zip opensim-SC_OLD-0194a3d890b95c8a29fcdf130c378e3a8a629c77.tar.gz opensim-SC_OLD-0194a3d890b95c8a29fcdf130c378e3a8a629c77.tar.bz2 opensim-SC_OLD-0194a3d890b95c8a29fcdf130c378e3a8a629c77.tar.xz |
BulletSim: fix density since the simulator/viewer track density in a
funny unit that is 100 times real density (default 1000).
Fix avatar drifting slowly when stationary flying.
Fix for physical prims getting corrected for being under terrain when it was
just its geometric center that was below terrain.
Add PreUpdatePropertyAction allowing plugable modifiction of phys
parameters returned from Bullet.
Fix an exception setting GravityMultiplier on initialization.
Update DLLs and SOs for good measure (no functional change).
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 66 |
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. |