aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
diff options
context:
space:
mode:
authorRobert Adams2013-04-30 11:42:11 -0700
committerRobert Adams2013-04-30 11:42:11 -0700
commit7cdb07b386ffe88749fcc6cabadd9851f254699d (patch)
tree92b4a1851c00b1a3352e4e853adda013a98aa181 /OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
parentBulletSim: Add non-static BSShape.GetReference for getting another reference (diff)
downloadopensim-SC_OLD-7cdb07b386ffe88749fcc6cabadd9851f254699d.zip
opensim-SC_OLD-7cdb07b386ffe88749fcc6cabadd9851f254699d.tar.gz
opensim-SC_OLD-7cdb07b386ffe88749fcc6cabadd9851f254699d.tar.bz2
opensim-SC_OLD-7cdb07b386ffe88749fcc6cabadd9851f254699d.tar.xz
BulletSim: improvements to LinksetCompound and PrimDisplaced. Not all working yet.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs37
1 files changed, 27 insertions, 10 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index e967dfc..e3ce7fb 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -395,7 +395,8 @@ public sealed class BSLinksetCompound : BSLinkset
395 // Constraint linksets are rebuilt every time. 395 // Constraint linksets are rebuilt every time.
396 // Note that this works for rebuilding just the root after a linkset is taken apart. 396 // Note that this works for rebuilding just the root after a linkset is taken apart.
397 // Called at taint time!! 397 // Called at taint time!!
398 private bool disableCOM = true; // DEBUG DEBUG: disable until we get this debugged 398 private bool UseBulletSimRootOffsetHack = false;
399 private bool disableCOM = true; // For basic linkset debugging, turn off the center-of-mass setting
399 private void RecomputeLinksetCompound() 400 private void RecomputeLinksetCompound()
400 { 401 {
401 if (!LinksetRoot.IsPhysicallyActive) 402 if (!LinksetRoot.IsPhysicallyActive)
@@ -428,11 +429,19 @@ public sealed class BSLinksetCompound : BSLinkset
428 429
429 // 'centerDisplacement' is the value to subtract from children to give physical offset position 430 // 'centerDisplacement' is the value to subtract from children to give physical offset position
430 OMV.Vector3 centerDisplacement = (centerOfMassW - LinksetRoot.RawPosition) * invRootOrientation; 431 OMV.Vector3 centerDisplacement = (centerOfMassW - LinksetRoot.RawPosition) * invRootOrientation;
431 LinksetRoot.SetEffectiveCenterOfMassW(centerDisplacement); 432 if (UseBulletSimRootOffsetHack || disableCOM)
432 433 {
433 // TODO: add phantom root shape to be the center-of-mass 434 centerDisplacement = OMV.Vector3.Zero;
435 LinksetRoot.ClearDisplacement();
436 }
437 else
438 {
439 LinksetRoot.SetEffectiveCenterOfMassDisplacement(centerDisplacement);
440 }
441 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,rootPos={1},com={2},comDisp={3}",
442 LinksetRoot.LocalID, LinksetRoot.RawPosition, centerOfMassW, centerDisplacement);
434 443
435 // Add a shape for each of the other children in the linkset 444 // Add the shapes of all the components of the linkset
436 int memberIndex = 1; 445 int memberIndex = 1;
437 ForEachMember(delegate(BSPrimLinkable cPrim) 446 ForEachMember(delegate(BSPrimLinkable cPrim)
438 { 447 {
@@ -449,8 +458,8 @@ public sealed class BSLinksetCompound : BSLinkset
449 OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement; 458 OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement;
450 OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; 459 OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation;
451 m_physicsScene.PE.AddChildShapeToCompoundShape(LinksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot); 460 m_physicsScene.PE.AddChildShapeToCompoundShape(LinksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot);
452 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1},rShape={2},cShape={3},offPos={4},offRot={5}", 461 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1}cShape={2},offPos={3},offRot={4}",
453 LinksetRoot.LocalID, memberIndex, LinksetRoot.PhysShape, cPrim.PhysShape, offsetPos, offsetRot); 462 LinksetRoot.LocalID, memberIndex, cPrim.PhysShape, offsetPos, offsetRot);
454 463
455 memberIndex++; 464 memberIndex++;
456 465
@@ -463,13 +472,21 @@ public sealed class BSLinksetCompound : BSLinkset
463 m_physicsScene.PE.RemoveObjectFromWorld(m_physicsScene.World, LinksetRoot.PhysBody); 472 m_physicsScene.PE.RemoveObjectFromWorld(m_physicsScene.World, LinksetRoot.PhysBody);
464 m_physicsScene.PE.SetCollisionShape(m_physicsScene.World, LinksetRoot.PhysBody, LinksetShape.physShapeInfo); 473 m_physicsScene.PE.SetCollisionShape(m_physicsScene.World, LinksetRoot.PhysBody, LinksetShape.physShapeInfo);
465 m_physicsScene.PE.AddObjectToWorld(m_physicsScene.World, LinksetRoot.PhysBody); 474 m_physicsScene.PE.AddObjectToWorld(m_physicsScene.World, LinksetRoot.PhysBody);
475 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addBody,body={1},shape={2}",
476 LinksetRoot.LocalID, LinksetRoot.PhysBody, LinksetShape);
466 477
467 // With all of the linkset packed into the root prim, it has the mass of everyone. 478 // With all of the linkset packed into the root prim, it has the mass of everyone.
468 LinksetMass = ComputeLinksetMass(); 479 LinksetMass = ComputeLinksetMass();
469 LinksetRoot.UpdatePhysicalMassProperties(LinksetMass, true); 480 LinksetRoot.UpdatePhysicalMassProperties(LinksetMass, true);
470 481
471 // Enable the physical position updator to return the position and rotation of the root shape 482 if (UseBulletSimRootOffsetHack)
472 m_physicsScene.PE.AddToCollisionFlags(LinksetRoot.PhysBody, CollisionFlags.BS_RETURN_ROOT_COMPOUND_SHAPE); 483 {
484 // Enable the physical position updator to return the position and rotation of the root shape.
485 // This enables a feature in the C++ code to return the world coordinates of the first shape in the
486 // compound shape. This eleviates the need to offset the returned physical position by the
487 // center-of-mass offset.
488 m_physicsScene.PE.AddToCollisionFlags(LinksetRoot.PhysBody, CollisionFlags.BS_RETURN_ROOT_COMPOUND_SHAPE);
489 }
473 } 490 }
474 finally 491 finally
475 { 492 {
@@ -477,7 +494,7 @@ public sealed class BSLinksetCompound : BSLinkset
477 } 494 }
478 495
479 // See that the Aabb surrounds the new shape 496 // See that the Aabb surrounds the new shape
480 m_physicsScene.PE.RecalculateCompoundShapeLocalAabb(LinksetRoot.PhysShape.physShapeInfo); 497 m_physicsScene.PE.RecalculateCompoundShapeLocalAabb(LinksetShape.physShapeInfo);
481 } 498 }
482} 499}
483} \ No newline at end of file 500} \ No newline at end of file