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 | |
parent | BulletSim: More work on center-of-mass. Remove linksetinfo and rely on simula... (diff) | |
download | opensim-SC-0194a3d890b95c8a29fcdf130c378e3a8a629c77.zip opensim-SC-0194a3d890b95c8a29fcdf130c378e3a8a629c77.tar.gz opensim-SC-0194a3d890b95c8a29fcdf130c378e3a8a629c77.tar.bz2 opensim-SC-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')
7 files changed, 150 insertions, 25 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 04fb05b..8dca7c6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -83,7 +83,7 @@ public sealed class BSCharacter : BSPhysObject | |||
83 | _velocity = OMV.Vector3.Zero; | 83 | _velocity = OMV.Vector3.Zero; |
84 | _buoyancy = ComputeBuoyancyFromFlying(isFlying); | 84 | _buoyancy = ComputeBuoyancyFromFlying(isFlying); |
85 | Friction = BSParam.AvatarStandingFriction; | 85 | Friction = BSParam.AvatarStandingFriction; |
86 | Density = BSParam.AvatarDensity; | 86 | Density = BSParam.AvatarDensity / BSParam.DensityScaleFactor; |
87 | 87 | ||
88 | // Old versions of ScenePresence passed only the height. If width and/or depth are zero, | 88 | // Old versions of ScenePresence passed only the height. If width and/or depth are zero, |
89 | // replace with the default values. | 89 | // replace with the default values. |
@@ -231,6 +231,15 @@ public sealed class BSCharacter : BSPhysObject | |||
231 | PhysicsScene.PE.SetFriction(PhysBody, Friction); | 231 | PhysicsScene.PE.SetFriction(PhysBody, Friction); |
232 | } | 232 | } |
233 | } | 233 | } |
234 | else | ||
235 | { | ||
236 | if (Flying) | ||
237 | { | ||
238 | // Flying and not collising and velocity nearly zero. | ||
239 | ZeroMotion(true /* inTaintTime */); | ||
240 | } | ||
241 | } | ||
242 | |||
234 | DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1},colliding={2}", LocalID, _velocityMotor.TargetValue, IsColliding); | 243 | DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1},colliding={2}", LocalID, _velocityMotor.TargetValue, IsColliding); |
235 | } | 244 | } |
236 | else | 245 | else |
@@ -869,7 +878,7 @@ public sealed class BSCharacter : BSPhysObject | |||
869 | * Math.Min(Size.X, Size.Y) / 2 | 878 | * Math.Min(Size.X, Size.Y) / 2 |
870 | * Size.Y / 2f // plus the volume of the capsule end caps | 879 | * Size.Y / 2f // plus the volume of the capsule end caps |
871 | ); | 880 | ); |
872 | _mass = Density * _avatarVolume; | 881 | _mass = Density * BSParam.DensityScaleFactor * _avatarVolume; |
873 | } | 882 | } |
874 | 883 | ||
875 | // The physics engine says that properties have updated. Update same and inform | 884 | // The physics engine says that properties have updated. Update same and inform |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 1f66b56..4ce58c7 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | |||
@@ -399,7 +399,7 @@ public sealed class BSLinksetCompound : BSLinkset | |||
399 | // Constraint linksets are rebuilt every time. | 399 | // Constraint linksets are rebuilt every time. |
400 | // Note that this works for rebuilding just the root after a linkset is taken apart. | 400 | // Note that this works for rebuilding just the root after a linkset is taken apart. |
401 | // Called at taint time!! | 401 | // Called at taint time!! |
402 | private bool disableCOM = false; // DEBUG DEBUG: disable until we get this debugged | 402 | private bool disableCOM = true; // DEBUG DEBUG: disable until we get this debugged |
403 | private void RecomputeLinksetCompound() | 403 | private void RecomputeLinksetCompound() |
404 | { | 404 | { |
405 | try | 405 | try |
@@ -430,10 +430,10 @@ public sealed class BSLinksetCompound : BSLinkset | |||
430 | LinksetRoot.ForcePosition = LinksetRoot.RawPosition; | 430 | LinksetRoot.ForcePosition = LinksetRoot.RawPosition; |
431 | 431 | ||
432 | // Update the local transform for the root child shape so it is offset from the <0,0,0> which is COM | 432 | // Update the local transform for the root child shape so it is offset from the <0,0,0> which is COM |
433 | PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, 0, | 433 | PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, 0 /* childIndex */, |
434 | -centerDisplacement, | 434 | -centerDisplacement, |
435 | LinksetRoot.RawOrientation, | 435 | OMV.Quaternion.Identity, // LinksetRoot.RawOrientation, |
436 | false /* shouldRecalculateLocalAabb */); | 436 | false /* shouldRecalculateLocalAabb (is done later after linkset built) */); |
437 | 437 | ||
438 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,com={1},rootPos={2},centerDisp={3}", | 438 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,com={1},rootPos={2},centerDisp={3}", |
439 | LinksetRoot.LocalID, centerOfMassW, LinksetRoot.RawPosition, centerDisplacement); | 439 | LinksetRoot.LocalID, centerOfMassW, LinksetRoot.RawPosition, centerDisplacement); |
@@ -463,7 +463,6 @@ public sealed class BSLinksetCompound : BSLinkset | |||
463 | // Use call to CreateGeomNonSpecial(). | 463 | // Use call to CreateGeomNonSpecial(). |
464 | BulletShape saveShape = cPrim.PhysShape; | 464 | BulletShape saveShape = cPrim.PhysShape; |
465 | cPrim.PhysShape.Clear(); // Don't let the create free the child's shape | 465 | cPrim.PhysShape.Clear(); // Don't let the create free the child's shape |
466 | // PhysicsScene.Shapes.CreateGeomNonSpecial(true, cPrim, null); | ||
467 | PhysicsScene.Shapes.CreateGeomMeshOrHull(cPrim, null); | 466 | PhysicsScene.Shapes.CreateGeomMeshOrHull(cPrim, null); |
468 | BulletShape newShape = cPrim.PhysShape; | 467 | BulletShape newShape = cPrim.PhysShape; |
469 | cPrim.PhysShape = saveShape; | 468 | cPrim.PhysShape = saveShape; |
@@ -471,6 +470,8 @@ public sealed class BSLinksetCompound : BSLinkset | |||
471 | OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement; | 470 | OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement; |
472 | OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; | 471 | OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; |
473 | PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, newShape, offsetPos, offsetRot); | 472 | PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, newShape, offsetPos, offsetRot); |
473 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addNative,indx={1},rShape={2},cShape={3},offPos={4},offRot={5}", | ||
474 | LinksetRoot.LocalID, memberIndex, LinksetRoot.PhysShape, newShape, offsetPos, offsetRot); | ||
474 | } | 475 | } |
475 | else | 476 | else |
476 | { | 477 | { |
@@ -484,7 +485,10 @@ public sealed class BSLinksetCompound : BSLinkset | |||
484 | } | 485 | } |
485 | OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement; | 486 | OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement; |
486 | OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; | 487 | OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; |
487 | PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, cPrim.PhysShape, offsetPos, offsetRot); | 488 | PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, cPrim.PhysShape, offsetPos, offsetRot); |
489 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addNonNative,indx={1},rShape={2},cShape={3},offPos={4},offRot={5}", | ||
490 | LinksetRoot.LocalID, memberIndex, LinksetRoot.PhysShape, cPrim.PhysShape, offsetPos, offsetRot); | ||
491 | |||
488 | } | 492 | } |
489 | memberIndex++; | 493 | memberIndex++; |
490 | } | 494 | } |
@@ -503,6 +507,7 @@ public sealed class BSLinksetCompound : BSLinkset | |||
503 | Rebuilding = false; | 507 | Rebuilding = false; |
504 | } | 508 | } |
505 | 509 | ||
510 | // See that the Aabb surrounds the new shape | ||
506 | PhysicsScene.PE.RecalculateCompoundShapeLocalAabb(LinksetRoot.PhysShape); | 511 | PhysicsScene.PE.RecalculateCompoundShapeLocalAabb(LinksetRoot.PhysShape); |
507 | } | 512 | } |
508 | } | 513 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 3e0b4bc..329169f 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | |||
@@ -49,6 +49,7 @@ public static class BSParam | |||
49 | public static float MaxLinearVelocity { get; private set; } | 49 | public static float MaxLinearVelocity { get; private set; } |
50 | public static float MaxAngularVelocity { get; private set; } | 50 | public static float MaxAngularVelocity { get; private set; } |
51 | public static float MaxAddForceMagnitude { get; private set; } | 51 | public static float MaxAddForceMagnitude { get; private set; } |
52 | public static float DensityScaleFactor { get; private set; } | ||
52 | 53 | ||
53 | public static float LinearDamping { get; private set; } | 54 | public static float LinearDamping { get; private set; } |
54 | public static float AngularDamping { get; private set; } | 55 | public static float AngularDamping { get; private set; } |
@@ -281,29 +282,35 @@ public static class BSParam | |||
281 | new ParameterDefn("MinObjectMass", "Minimum object mass (0.0001)", | 282 | new ParameterDefn("MinObjectMass", "Minimum object mass (0.0001)", |
282 | 0.0001f, | 283 | 0.0001f, |
283 | (s,cf,p,v) => { MinimumObjectMass = cf.GetFloat(p, v); }, | 284 | (s,cf,p,v) => { MinimumObjectMass = cf.GetFloat(p, v); }, |
284 | (s) => { return (float)MinimumObjectMass; }, | 285 | (s) => { return MinimumObjectMass; }, |
285 | (s,p,l,v) => { MinimumObjectMass = v; } ), | 286 | (s,p,l,v) => { MinimumObjectMass = v; } ), |
286 | new ParameterDefn("MaxObjectMass", "Maximum object mass (10000.01)", | 287 | new ParameterDefn("MaxObjectMass", "Maximum object mass (10000.01)", |
287 | 10000.01f, | 288 | 10000.01f, |
288 | (s,cf,p,v) => { MaximumObjectMass = cf.GetFloat(p, v); }, | 289 | (s,cf,p,v) => { MaximumObjectMass = cf.GetFloat(p, v); }, |
289 | (s) => { return (float)MaximumObjectMass; }, | 290 | (s) => { return MaximumObjectMass; }, |
290 | (s,p,l,v) => { MaximumObjectMass = v; } ), | 291 | (s,p,l,v) => { MaximumObjectMass = v; } ), |
291 | new ParameterDefn("MaxLinearVelocity", "Maximum velocity magnitude that can be assigned to an object", | 292 | new ParameterDefn("MaxLinearVelocity", "Maximum velocity magnitude that can be assigned to an object", |
292 | 1000.0f, | 293 | 1000.0f, |
293 | (s,cf,p,v) => { MaxLinearVelocity = cf.GetFloat(p, v); }, | 294 | (s,cf,p,v) => { MaxLinearVelocity = cf.GetFloat(p, v); }, |
294 | (s) => { return (float)MaxLinearVelocity; }, | 295 | (s) => { return MaxLinearVelocity; }, |
295 | (s,p,l,v) => { MaxLinearVelocity = v; } ), | 296 | (s,p,l,v) => { MaxLinearVelocity = v; } ), |
296 | new ParameterDefn("MaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to an object", | 297 | new ParameterDefn("MaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to an object", |
297 | 1000.0f, | 298 | 1000.0f, |
298 | (s,cf,p,v) => { MaxAngularVelocity = cf.GetFloat(p, v); }, | 299 | (s,cf,p,v) => { MaxAngularVelocity = cf.GetFloat(p, v); }, |
299 | (s) => { return (float)MaxAngularVelocity; }, | 300 | (s) => { return MaxAngularVelocity; }, |
300 | (s,p,l,v) => { MaxAngularVelocity = v; } ), | 301 | (s,p,l,v) => { MaxAngularVelocity = v; } ), |
301 | // LL documentation says thie number should be 20f for llApplyImpulse and 200f for llRezObject | 302 | // LL documentation says thie number should be 20f for llApplyImpulse and 200f for llRezObject |
302 | new ParameterDefn("MaxAddForceMagnitude", "Maximum force that can be applied by llApplyImpulse (SL says 20f)", | 303 | new ParameterDefn("MaxAddForceMagnitude", "Maximum force that can be applied by llApplyImpulse (SL says 20f)", |
303 | 20000.0f, | 304 | 20000.0f, |
304 | (s,cf,p,v) => { MaxAddForceMagnitude = cf.GetFloat(p, v); }, | 305 | (s,cf,p,v) => { MaxAddForceMagnitude = cf.GetFloat(p, v); }, |
305 | (s) => { return (float)MaxAddForceMagnitude; }, | 306 | (s) => { return MaxAddForceMagnitude; }, |
306 | (s,p,l,v) => { MaxAddForceMagnitude = v; } ), | 307 | (s,p,l,v) => { MaxAddForceMagnitude = v; } ), |
308 | // Density is passed around as 100kg/m3. This scales that to 1kg/m3. | ||
309 | new ParameterDefn("DensityScaleFactor", "Conversion for simulator/viewer density (100kg/m3) to physical density (1kg/m3)", | ||
310 | 0.01f, | ||
311 | (s,cf,p,v) => { DensityScaleFactor = cf.GetFloat(p, v); }, | ||
312 | (s) => { return DensityScaleFactor; }, | ||
313 | (s,p,l,v) => { DensityScaleFactor = v; } ), | ||
307 | 314 | ||
308 | new ParameterDefn("PID_D", "Derivitive factor for motion smoothing", | 315 | new ParameterDefn("PID_D", "Derivitive factor for motion smoothing", |
309 | 2200f, | 316 | 2200f, |
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. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index a76f8b9..0323b0d 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -242,6 +242,45 @@ public class BSPrim : BSPhysObject | |||
242 | public override void LockAngularMotion(OMV.Vector3 axis) | 242 | public override void LockAngularMotion(OMV.Vector3 axis) |
243 | { | 243 | { |
244 | DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis); | 244 | DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis); |
245 | |||
246 | OMV.Vector3 locking = new OMV.Vector3(1f, 1f, 1f); | ||
247 | if (axis.X != 1) locking.X = 0f; | ||
248 | if (axis.Y != 1) locking.Y = 0f; | ||
249 | if (axis.Z != 1) locking.Z = 0f; | ||
250 | LockedAxis = locking; | ||
251 | |||
252 | /* Not implemented yet | ||
253 | if (LockedAxis != LockedAxisFree) | ||
254 | { | ||
255 | // Something is locked so start the thingy that keeps that axis from changing | ||
256 | RegisterPreUpdatePropertyAction("BSPrim.LockAngularMotion", delegate(ref EntityProperties entprop) | ||
257 | { | ||
258 | if (LockedAxis != LockedAxisFree) | ||
259 | { | ||
260 | if (IsPhysicallyActive) | ||
261 | { | ||
262 | // Bullet can lock axis but it only works for global axis. | ||
263 | // Check if this prim is aligned on global axis and use Bullet's | ||
264 | // system if so. | ||
265 | |||
266 | ForceOrientation = entprop.Rotation; | ||
267 | ForceRotationalVelocity = entprop.RotationalVelocity; | ||
268 | } | ||
269 | } | ||
270 | else | ||
271 | { | ||
272 | UnRegisterPreUpdatePropertyAction("BSPrim.LockAngularMotion"); | ||
273 | } | ||
274 | |||
275 | }); | ||
276 | } | ||
277 | else | ||
278 | { | ||
279 | // Everything seems unlocked | ||
280 | UnRegisterPreUpdatePropertyAction("BSPrim.LockAngularMotion"); | ||
281 | } | ||
282 | */ | ||
283 | |||
245 | return; | 284 | return; |
246 | } | 285 | } |
247 | 286 | ||
@@ -311,7 +350,8 @@ public class BSPrim : BSPhysObject | |||
311 | 350 | ||
312 | float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); | 351 | float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); |
313 | OMV.Vector3 upForce = OMV.Vector3.Zero; | 352 | OMV.Vector3 upForce = OMV.Vector3.Zero; |
314 | if (RawPosition.Z < terrainHeight) | 353 | float approxSize = Math.Max(Size.X, Math.Max(Size.Y, Size.Z)); |
354 | if ((RawPosition.Z + approxSize / 2f) < terrainHeight) | ||
315 | { | 355 | { |
316 | DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, RawPosition, terrainHeight); | 356 | DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, RawPosition, terrainHeight); |
317 | float targetHeight = terrainHeight + (Size.Z / 2f); | 357 | float targetHeight = terrainHeight + (Size.Z / 2f); |
@@ -576,6 +616,8 @@ public class BSPrim : BSPhysObject | |||
576 | } | 616 | } |
577 | } | 617 | } |
578 | } | 618 | } |
619 | // The simulator/viewer keep density as 100kg/m3. | ||
620 | // Remember to use BSParam.DensityScaleFactor to create the physical density. | ||
579 | public override float Density | 621 | public override float Density |
580 | { | 622 | { |
581 | get { return base.Density; } | 623 | get { return base.Density; } |
@@ -1569,7 +1611,8 @@ public class BSPrim : BSPhysObject | |||
1569 | profileEnd = 1.0f - (float)BaseShape.ProfileEnd * 2.0e-5f; | 1611 | profileEnd = 1.0f - (float)BaseShape.ProfileEnd * 2.0e-5f; |
1570 | volume *= (profileEnd - profileBegin); | 1612 | volume *= (profileEnd - profileBegin); |
1571 | 1613 | ||
1572 | returnMass = Density * volume; | 1614 | returnMass = Density * BSParam.DensityScaleFactor * volume; |
1615 | DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3}", LocalID, Density, volume, returnMass); | ||
1573 | 1616 | ||
1574 | returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass); | 1617 | returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass); |
1575 | 1618 | ||
@@ -1607,6 +1650,8 @@ public class BSPrim : BSPhysObject | |||
1607 | // the world that things have changed. | 1650 | // the world that things have changed. |
1608 | public override void UpdateProperties(EntityProperties entprop) | 1651 | public override void UpdateProperties(EntityProperties entprop) |
1609 | { | 1652 | { |
1653 | TriggerPreUpdatePropertyAction(ref entprop); | ||
1654 | |||
1610 | // A temporary kludge to suppress the rotational effects introduced on vehicles by Bullet | 1655 | // A temporary kludge to suppress the rotational effects introduced on vehicles by Bullet |
1611 | // TODO: handle physics introduced by Bullet with computed vehicle physics. | 1656 | // TODO: handle physics introduced by Bullet with computed vehicle physics. |
1612 | if (VehicleController.IsActive) | 1657 | if (VehicleController.IsActive) |
@@ -1619,7 +1664,11 @@ public class BSPrim : BSPhysObject | |||
1619 | // Assign directly to the local variables so the normal set actions do not happen | 1664 | // Assign directly to the local variables so the normal set actions do not happen |
1620 | _position = entprop.Position; | 1665 | _position = entprop.Position; |
1621 | _orientation = entprop.Rotation; | 1666 | _orientation = entprop.Rotation; |
1622 | _velocity = entprop.Velocity; | 1667 | // _velocity = entprop.Velocity; |
1668 | // DEBUG DEBUG DEBUG -- smooth velocity changes a bit. The simulator seems to be | ||
1669 | // very sensitive to velocity changes. | ||
1670 | if (!entprop.Velocity.ApproxEquals(_velocity, 0.1f)) | ||
1671 | _velocity = entprop.Velocity; | ||
1623 | _acceleration = entprop.Acceleration; | 1672 | _acceleration = entprop.Acceleration; |
1624 | _rotationalVelocity = entprop.RotationalVelocity; | 1673 | _rotationalVelocity = entprop.RotationalVelocity; |
1625 | 1674 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs index b9f2cca..f1c3b5c 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs | |||
@@ -144,7 +144,7 @@ public class BSPrimDisplaced : BSPrim | |||
144 | // Correct for any rotation around the center-of-mass | 144 | // Correct for any rotation around the center-of-mass |
145 | // TODO!!! | 145 | // TODO!!! |
146 | entprop.Position = entprop.Position + (PositionDisplacement * entprop.Rotation); | 146 | entprop.Position = entprop.Position + (PositionDisplacement * entprop.Rotation); |
147 | entprop.Rotation = something; | 147 | // entprop.Rotation = something; |
148 | } | 148 | } |
149 | 149 | ||
150 | base.UpdateProperties(entprop); | 150 | base.UpdateProperties(entprop); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 96f9762..d65d407 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs | |||
@@ -135,7 +135,8 @@ public class BSPrimLinkable : BSPrimDisplaced | |||
135 | // When going from non-physical to physical, this re-enables the constraints that | 135 | // When going from non-physical to physical, this re-enables the constraints that |
136 | // had been automatically disabled when the mass was set to zero. | 136 | // had been automatically disabled when the mass was set to zero. |
137 | // For compound based linksets, this enables and disables interactions of the children. | 137 | // For compound based linksets, this enables and disables interactions of the children. |
138 | Linkset.Refresh(this); | 138 | if (Linkset != null) // null can happen during initialization |
139 | Linkset.Refresh(this); | ||
139 | } | 140 | } |
140 | 141 | ||
141 | protected override void MakeDynamic(bool makeStatic) | 142 | protected override void MakeDynamic(bool makeStatic) |