aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
diff options
context:
space:
mode:
authorRobert Adams2013-01-13 22:32:31 -0800
committerRobert Adams2013-01-14 07:50:58 -0800
commit8bf0a9f85dda4b1831630b65620d5c6868196c11 (patch)
treed79799e42210133f4893d4661f0dd22124027f70 /OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
parentBulletSim: move center of gravity of linkset to its geometric center. (diff)
downloadopensim-SC_OLD-8bf0a9f85dda4b1831630b65620d5c6868196c11.zip
opensim-SC_OLD-8bf0a9f85dda4b1831630b65620d5c6868196c11.tar.gz
opensim-SC_OLD-8bf0a9f85dda4b1831630b65620d5c6868196c11.tar.bz2
opensim-SC_OLD-8bf0a9f85dda4b1831630b65620d5c6868196c11.tar.xz
BulletSim: disable center-of-mass computation for linksets until debugged. Move physical prim above ground if it is underground. Previously tried to correct by applying and up force but the prim would never go through the ground.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs35
1 files changed, 24 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index ad8024c..5a1b5c7 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -319,6 +319,7 @@ public sealed class BSLinksetCompound : BSLinkset
319 // Constraint linksets are rebuilt every time. 319 // Constraint linksets are rebuilt every time.
320 // Note that this works for rebuilding just the root after a linkset is taken apart. 320 // Note that this works for rebuilding just the root after a linkset is taken apart.
321 // Called at taint time!! 321 // Called at taint time!!
322 private bool disableCOM = true; // disable until we get this debugged
322 private void RecomputeLinksetCompound() 323 private void RecomputeLinksetCompound()
323 { 324 {
324 try 325 try
@@ -331,15 +332,26 @@ public sealed class BSLinksetCompound : BSLinkset
331 332
332 // The center of mass for the linkset is the geometric center of the group. 333 // The center of mass for the linkset is the geometric center of the group.
333 // Compute a displacement for each component so it is relative to the center-of-mass. 334 // Compute a displacement for each component so it is relative to the center-of-mass.
334 OMV.Vector3 centerOfMass = ComputeLinksetGeometricCenter(); 335 // Bullet presumes an object's origin (relative <0,0,0>) is its center-of-mass
335 OMV.Vector3 centerDisplacement = centerOfMass - LinksetRoot.RawPosition; 336 OMV.Vector3 centerOfMass;
337 OMV.Vector3 centerDisplacement = OMV.Vector3.Zero;
338 if (disableCOM) // DEBUG DEBUG
339 { // DEBUG DEBUG
340 centerOfMass = LinksetRoot.RawPosition; // DEBUG DEBUG
341 LinksetRoot.PositionDisplacement = OMV.Vector3.Zero;
342 } // DEBUG DEBUG
343 else
344 {
345 centerOfMass = ComputeLinksetGeometricCenter();
346 centerDisplacement = centerOfMass - LinksetRoot.RawPosition;
336 347
337 // Since we're displacing the center of the shape, we need to move the body in the world 348 // Since we're displacing the center of the shape, we need to move the body in the world
338 LinksetRoot.PositionDisplacement = centerDisplacement * LinksetRoot.RawOrientation; 349 LinksetRoot.PositionDisplacement = centerDisplacement;
339 350
340 PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, 0, -centerDisplacement, OMV.Quaternion.Identity, false); 351 PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, 0, -centerDisplacement, OMV.Quaternion.Identity, false);
341 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,com={1},rootPos={2},centerDisp={3}", 352 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,com={1},rootPos={2},centerDisp={3}",
342 LinksetRoot.LocalID, centerOfMass, LinksetRoot.RawPosition, centerDisplacement); 353 LinksetRoot.LocalID, centerOfMass, LinksetRoot.RawPosition, centerDisplacement);
354 }
343 355
344 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,start,rBody={1},rShape={2},numChildren={3}", 356 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,start,rBody={1},rShape={2},numChildren={3}",
345 LinksetRoot.LocalID, LinksetRoot.PhysBody, LinksetRoot.PhysShape, NumberOfChildren); 357 LinksetRoot.LocalID, LinksetRoot.PhysBody, LinksetRoot.PhysShape, NumberOfChildren);
@@ -357,14 +369,15 @@ public sealed class BSLinksetCompound : BSLinkset
357 BSLinksetCompoundInfo lci = cPrim.LinksetInfo as BSLinksetCompoundInfo; 369 BSLinksetCompoundInfo lci = cPrim.LinksetInfo as BSLinksetCompoundInfo;
358 if (lci == null) 370 if (lci == null)
359 { 371 {
360 // Each child position and rotation is given relative to the root. 372 // Each child position and rotation is given relative to the center-of-mass.
361 OMV.Quaternion invRootOrientation = OMV.Quaternion.Inverse(LinksetRoot.RawOrientation); 373 OMV.Quaternion invRootOrientation = OMV.Quaternion.Inverse(LinksetRoot.RawOrientation);
362 OMV.Vector3 displacementPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation; 374 OMV.Vector3 displacementFromRoot = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation;
375 OMV.Vector3 displacementFromCOM = displacementFromRoot - centerDisplacement;
363 OMV.Quaternion displacementRot = cPrim.RawOrientation * invRootOrientation; 376 OMV.Quaternion displacementRot = cPrim.RawOrientation * invRootOrientation;
364 377
365 // Save relative position for recomputing child's world position after moving linkset. 378 // Save relative position for recomputing child's world position after moving linkset.
366 lci = new BSLinksetCompoundInfo(memberIndex, displacementPos, displacementRot); 379 lci = new BSLinksetCompoundInfo(memberIndex, displacementFromCOM, displacementRot);
367 lci.OffsetFromCenterOfMass = displacementPos - centerDisplacement; 380 lci.OffsetFromRoot = displacementFromRoot;
368 cPrim.LinksetInfo = lci; 381 cPrim.LinksetInfo = lci;
369 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,creatingRelPos,lci={1}", cPrim.LocalID, lci); 382 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,creatingRelPos,lci={1}", cPrim.LocalID, lci);
370 } 383 }