diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 44937df..ad09a61 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -356,13 +356,32 @@ public sealed class BSPrim : BSPhysObject | |||
356 | { | 356 | { |
357 | get | 357 | get |
358 | { | 358 | { |
359 | // return Linkset.LinksetMass; | 359 | return Linkset.LinksetMass; |
360 | return _mass; | 360 | // return _mass; |
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | ||
364 | // used when we only want this prim's mass and not the linkset thing | 364 | // used when we only want this prim's mass and not the linkset thing |
365 | public override float MassRaw { get { return _mass; } } | 365 | public override float MassRaw { |
366 | get { return _mass; } | ||
367 | } | ||
368 | // Set the physical mass to the passed mass. | ||
369 | // Note that this does not change _mass! | ||
370 | public override void UpdatePhysicalMassProperties(float physMass) | ||
371 | { | ||
372 | if (IsStatic) | ||
373 | { | ||
374 | BulletSimAPI.SetMassProps2(BSBody.ptr, 0f, OMV.Vector3.Zero); | ||
375 | BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); | ||
376 | } | ||
377 | else | ||
378 | { | ||
379 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, physMass); | ||
380 | BulletSimAPI.SetMassProps2(BSBody.ptr, physMass, localInertia); | ||
381 | BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); | ||
382 | DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2}", LocalID, physMass, localInertia); | ||
383 | } | ||
384 | } | ||
366 | 385 | ||
367 | // Is this used? | 386 | // Is this used? |
368 | public override OMV.Vector3 CenterOfMass | 387 | public override OMV.Vector3 CenterOfMass |
@@ -613,7 +632,7 @@ public sealed class BSPrim : BSPhysObject | |||
613 | // Recompute any linkset parameters. | 632 | // Recompute any linkset parameters. |
614 | // When going from non-physical to physical, this re-enables the constraints that | 633 | // When going from non-physical to physical, this re-enables the constraints that |
615 | // had been automatically disabled when the mass was set to zero. | 634 | // had been automatically disabled when the mass was set to zero. |
616 | Linkset.Refresh(this, true); | 635 | Linkset.Refresh(this); |
617 | 636 | ||
618 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,exit,static={1},solid={2},mass={3},collide={4},cf={5:X},body={6},shape={7}", | 637 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,exit,static={1},solid={2},mass={3},collide={4},cf={5:X},body={6},shape={7}", |
619 | LocalID, IsStatic, IsSolid, _mass, SubscribedEvents(), CurrentCollisionFlags, BSBody, BSShape); | 638 | LocalID, IsStatic, IsSolid, _mass, SubscribedEvents(), CurrentCollisionFlags, BSBody, BSShape); |
@@ -635,9 +654,7 @@ public sealed class BSPrim : BSPhysObject | |||
635 | // Center of mass is at the center of the object | 654 | // Center of mass is at the center of the object |
636 | BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.BSBody.ptr, _position, _orientation); | 655 | BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.BSBody.ptr, _position, _orientation); |
637 | // Mass is zero which disables a bunch of physics stuff in Bullet | 656 | // Mass is zero which disables a bunch of physics stuff in Bullet |
638 | BulletSimAPI.SetMassProps2(BSBody.ptr, 0f, OMV.Vector3.Zero); | 657 | UpdatePhysicalMassProperties(0f); |
639 | // There is no inertia in a static object | ||
640 | BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); | ||
641 | // Set collision detection parameters | 658 | // Set collision detection parameters |
642 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) | 659 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) |
643 | { | 660 | { |
@@ -671,9 +688,7 @@ public sealed class BSPrim : BSPhysObject | |||
671 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 688 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); |
672 | 689 | ||
673 | // A dynamic object has mass | 690 | // A dynamic object has mass |
674 | OMV.Vector3 inertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, Mass); | 691 | UpdatePhysicalMassProperties(MassRaw); |
675 | BulletSimAPI.SetMassProps2(BSBody.ptr, _mass, inertia); | ||
676 | BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); | ||
677 | 692 | ||
678 | // Set collision detection parameters | 693 | // Set collision detection parameters |
679 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) | 694 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) |
@@ -1247,9 +1262,7 @@ public sealed class BSPrim : BSPhysObject | |||
1247 | 1262 | ||
1248 | returnMass = _density * volume; | 1263 | returnMass = _density * volume; |
1249 | 1264 | ||
1250 | /* | 1265 | /* Comment out code that computes the mass of the linkset. That is done in the Linkset class. |
1251 | * This change means each object keeps its own mass and the Mass property | ||
1252 | * will return the sum if we're part of a linkset. | ||
1253 | if (IsRootOfLinkset) | 1266 | if (IsRootOfLinkset) |
1254 | { | 1267 | { |
1255 | foreach (BSPrim prim in _childrenPrims) | 1268 | foreach (BSPrim prim in _childrenPrims) |