aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs37
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs3
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs22
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapes.cs2
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt3
5 files changed, 50 insertions, 17 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
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index 28d4bd7..7eba851 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -259,7 +259,8 @@ public abstract class BSPhysObject : PhysicsActor
259 259
260 // The user can optionally set the center of mass. The user's setting will override any 260 // The user can optionally set the center of mass. The user's setting will override any
261 // computed center-of-mass (like in linksets). 261 // computed center-of-mass (like in linksets).
262 public OMV.Vector3? UserSetCenterOfMass { get; set; } 262 // Note this is a displacement from the root's coordinates. Zero means use the root prim as center-of-mass.
263 public OMV.Vector3? UserSetCenterOfMassDisplacement { get; set; }
263 264
264 public OMV.Vector3 LockedAxis { get; set; } // zero means locked. one means free. 265 public OMV.Vector3 LockedAxis { get; set; } // zero means locked. one means free.
265 public readonly OMV.Vector3 LockedAxisFree = new OMV.Vector3(1f, 1f, 1f); // All axis are free 266 public readonly OMV.Vector3 LockedAxisFree = new OMV.Vector3(1f, 1f, 1f); // All axis are free
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs
index f1c3b5c..f5ee671 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs
@@ -78,14 +78,16 @@ public class BSPrimDisplaced : BSPrim
78 // Set this sets and computes the displacement from the passed prim to the center-of-mass. 78 // Set this sets and computes the displacement from the passed prim to the center-of-mass.
79 // A user set value for center-of-mass overrides whatever might be passed in here. 79 // A user set value for center-of-mass overrides whatever might be passed in here.
80 // The displacement is in local coordinates (relative to root prim in linkset oriented coordinates). 80 // The displacement is in local coordinates (relative to root prim in linkset oriented coordinates).
81 public virtual void SetEffectiveCenterOfMassW(Vector3 centerOfMassDisplacement) 81 public virtual void SetEffectiveCenterOfMassDisplacement(Vector3 centerOfMassDisplacement)
82 { 82 {
83 Vector3 comDisp; 83 Vector3 comDisp;
84 if (UserSetCenterOfMass.HasValue) 84 if (UserSetCenterOfMassDisplacement.HasValue)
85 comDisp = (OMV.Vector3)UserSetCenterOfMass; 85 comDisp = (OMV.Vector3)UserSetCenterOfMassDisplacement;
86 else 86 else
87 comDisp = centerOfMassDisplacement; 87 comDisp = centerOfMassDisplacement;
88 88
89 DetailLog("{0},BSPrimDisplaced.SetEffectiveCenterOfMassDisplacement,userSet={1},comDisp={2}",
90 LocalID, UserSetCenterOfMassDisplacement.HasValue, comDisp);
89 if (comDisp == Vector3.Zero) 91 if (comDisp == Vector3.Zero)
90 { 92 {
91 // If there is no diplacement. Things get reset. 93 // If there is no diplacement. Things get reset.
@@ -107,9 +109,15 @@ public class BSPrimDisplaced : BSPrim
107 set 109 set
108 { 110 {
109 if (PositionDisplacement != OMV.Vector3.Zero) 111 if (PositionDisplacement != OMV.Vector3.Zero)
110 base.ForcePosition = value - (PositionDisplacement * RawOrientation); 112 {
113 OMV.Vector3 displacedPos = value - (PositionDisplacement * RawOrientation);
114 DetailLog("{0},BSPrimDisplaced.ForcePosition,val={1},disp={2},newPos={3}", LocalID, value, PositionDisplacement, displacedPos);
115 base.ForcePosition = displacedPos;
116 }
111 else 117 else
118 {
112 base.ForcePosition = value; 119 base.ForcePosition = value;
120 }
113 } 121 }
114 } 122 }
115 123
@@ -118,6 +126,7 @@ public class BSPrimDisplaced : BSPrim
118 get { return base.ForceOrientation; } 126 get { return base.ForceOrientation; }
119 set 127 set
120 { 128 {
129 // TODO:
121 base.ForceOrientation = value; 130 base.ForceOrientation = value;
122 } 131 }
123 } 132 }
@@ -143,7 +152,10 @@ public class BSPrimDisplaced : BSPrim
143 { 152 {
144 // Correct for any rotation around the center-of-mass 153 // Correct for any rotation around the center-of-mass
145 // TODO!!! 154 // TODO!!!
146 entprop.Position = entprop.Position + (PositionDisplacement * entprop.Rotation); 155
156 OMV.Vector3 displacedPos = entprop.Position + (PositionDisplacement * entprop.Rotation);
157 DetailLog("{0},BSPrimDisplaced.ForcePosition,physPos={1},disp={2},newPos={3}", LocalID, entprop.Position, PositionDisplacement, displacedPos);
158 entprop.Position = displacedPos;
147 // entprop.Rotation = something; 159 // entprop.Rotation = something;
148 } 160 }
149 161
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
index f0c9fd5..3faa484 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
@@ -117,7 +117,7 @@ public abstract class BSShape
117 StringBuilder buff = new StringBuilder(); 117 StringBuilder buff = new StringBuilder();
118 buff.Append("<t="); 118 buff.Append("<t=");
119 buff.Append(ShapeType.ToString()); 119 buff.Append(ShapeType.ToString());
120 buff.Append("<p="); 120 buff.Append(",p=");
121 buff.Append(AddrString); 121 buff.Append(AddrString);
122 buff.Append(",c="); 122 buff.Append(",c=");
123 buff.Append(referenceCount.ToString()); 123 buff.Append(referenceCount.ToString());
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
index 559a73f..5792ae6 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
@@ -52,6 +52,9 @@ One sided meshes? Should terrain be built into a closed shape?
52 52
53VEHICLES TODO LIST: 53VEHICLES TODO LIST:
54================================================= 54=================================================
55LINEAR_MOTOR_DIRECTION values should be clamped to reasonable numbers.
56 What are the limits in SL?
57 Same for other velocity settings.
55UBit improvements to remove rubber-banding of avatars sitting on vehicle child prims: 58UBit improvements to remove rubber-banding of avatars sitting on vehicle child prims:
56 https://github.com/UbitUmarov/Ubit-opensim 59 https://github.com/UbitUmarov/Ubit-opensim
57Border crossing with linked vehicle causes crash 60Border crossing with linked vehicle causes crash