aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs14
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs103
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSMotors.cs15
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs3
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs3
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs11
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs109
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs40
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs1
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt75
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs26
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs10
13 files changed, 242 insertions, 170 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index aa247dd..c27d3f0 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -774,7 +774,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
774 774
775 // Since the computation of terrain height can be a little involved, this routine 775 // Since the computation of terrain height can be a little involved, this routine
776 // is used to fetch the height only once for each vehicle simulation step. 776 // is used to fetch the height only once for each vehicle simulation step.
777 Vector3 lastRememberedHeightPos; 777 Vector3 lastRememberedHeightPos = new Vector3(-1, -1, -1);
778 private float GetTerrainHeight(Vector3 pos) 778 private float GetTerrainHeight(Vector3 pos)
779 { 779 {
780 if ((m_knownHas & m_knownChangedTerrainHeight) == 0 || pos != lastRememberedHeightPos) 780 if ((m_knownHas & m_knownChangedTerrainHeight) == 0 || pos != lastRememberedHeightPos)
@@ -788,14 +788,16 @@ namespace OpenSim.Region.Physics.BulletSPlugin
788 788
789 // Since the computation of water level can be a little involved, this routine 789 // Since the computation of water level can be a little involved, this routine
790 // is used ot fetch the level only once for each vehicle simulation step. 790 // is used ot fetch the level only once for each vehicle simulation step.
791 Vector3 lastRememberedWaterHeightPos = new Vector3(-1, -1, -1);
791 private float GetWaterLevel(Vector3 pos) 792 private float GetWaterLevel(Vector3 pos)
792 { 793 {
793 if ((m_knownHas & m_knownChangedWaterLevel) == 0) 794 if ((m_knownHas & m_knownChangedWaterLevel) == 0 || pos != lastRememberedWaterHeightPos)
794 { 795 {
796 lastRememberedWaterHeightPos = pos;
795 m_knownWaterLevel = ControllingPrim.PhysScene.TerrainManager.GetWaterLevelAtXYZ(pos); 797 m_knownWaterLevel = ControllingPrim.PhysScene.TerrainManager.GetWaterLevelAtXYZ(pos);
796 m_knownHas |= m_knownChangedWaterLevel; 798 m_knownHas |= m_knownChangedWaterLevel;
797 } 799 }
798 return (float)m_knownWaterLevel; 800 return m_knownWaterLevel;
799 } 801 }
800 802
801 private Vector3 VehiclePosition 803 private Vector3 VehiclePosition
@@ -991,11 +993,17 @@ namespace OpenSim.Region.Physics.BulletSPlugin
991 { 993 {
992 Vector3 vel = VehicleVelocity; 994 Vector3 vel = VehicleVelocity;
993 if ((m_flags & (VehicleFlag.NO_X)) != 0) 995 if ((m_flags & (VehicleFlag.NO_X)) != 0)
996 {
994 vel.X = 0; 997 vel.X = 0;
998 }
995 if ((m_flags & (VehicleFlag.NO_Y)) != 0) 999 if ((m_flags & (VehicleFlag.NO_Y)) != 0)
1000 {
996 vel.Y = 0; 1001 vel.Y = 0;
1002 }
997 if ((m_flags & (VehicleFlag.NO_Z)) != 0) 1003 if ((m_flags & (VehicleFlag.NO_Z)) != 0)
1004 {
998 vel.Z = 0; 1005 vel.Z = 0;
1006 }
999 VehicleVelocity = vel; 1007 VehicleVelocity = vel;
1000 } 1008 }
1001 1009
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 308cf13..1d94142 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -35,62 +35,6 @@ using OMV = OpenMetaverse;
35namespace OpenSim.Region.Physics.BulletSPlugin 35namespace OpenSim.Region.Physics.BulletSPlugin
36{ 36{
37 37
38 /*
39// When a child is linked, the relationship position of the child to the parent
40// is remembered so the child's world position can be recomputed when it is
41// removed from the linkset.
42sealed class BSLinksetCompoundInfo : BSLinksetInfo
43{
44 public int Index;
45 public OMV.Vector3 OffsetFromRoot;
46 public OMV.Vector3 OffsetFromCenterOfMass;
47 public OMV.Quaternion OffsetRot;
48 public BSLinksetCompoundInfo(int indx, OMV.Vector3 p, OMV.Quaternion r)
49 {
50 Index = indx;
51 OffsetFromRoot = p;
52 OffsetFromCenterOfMass = p;
53 OffsetRot = r;
54 }
55 // 'centerDisplacement' is the distance from the root the the center-of-mass (Bullet 'zero' of the shape)
56 public BSLinksetCompoundInfo(int indx, BSPrimLinkable root, BSPrimLinkable child, OMV.Vector3 centerDisplacement)
57 {
58 // Each child position and rotation is given relative to the center-of-mass.
59 OMV.Quaternion invRootOrientation = OMV.Quaternion.Inverse(root.RawOrientation);
60 OMV.Vector3 displacementFromRoot = (child.RawPosition - root.RawPosition) * invRootOrientation;
61 OMV.Vector3 displacementFromCOM = displacementFromRoot - centerDisplacement;
62 OMV.Quaternion displacementRot = child.RawOrientation * invRootOrientation;
63
64 // Save relative position for recomputing child's world position after moving linkset.
65 Index = indx;
66 OffsetFromRoot = displacementFromRoot;
67 OffsetFromCenterOfMass = displacementFromCOM;
68 OffsetRot = displacementRot;
69 }
70 public override void Clear()
71 {
72 Index = 0;
73 OffsetFromRoot = OMV.Vector3.Zero;
74 OffsetFromCenterOfMass = OMV.Vector3.Zero;
75 OffsetRot = OMV.Quaternion.Identity;
76 }
77 public override string ToString()
78 {
79 StringBuilder buff = new StringBuilder();
80 buff.Append("<i=");
81 buff.Append(Index.ToString());
82 buff.Append(",p=");
83 buff.Append(OffsetFromRoot.ToString());
84 buff.Append(",m=");
85 buff.Append(OffsetFromCenterOfMass.ToString());
86 buff.Append(",r=");
87 buff.Append(OffsetRot.ToString());
88 buff.Append(">");
89 return buff.ToString();
90 }
91};
92 */
93
94public sealed class BSLinksetCompound : BSLinkset 38public sealed class BSLinksetCompound : BSLinkset
95{ 39{
96 private static string LogHeader = "[BULLETSIM LINKSET COMPOUND]"; 40 private static string LogHeader = "[BULLETSIM LINKSET COMPOUND]";
@@ -151,7 +95,9 @@ public sealed class BSLinksetCompound : BSLinkset
151 public override bool MakeStatic(BSPrimLinkable child) 95 public override bool MakeStatic(BSPrimLinkable child)
152 { 96 {
153 bool ret = false; 97 bool ret = false;
98
154 DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); 99 DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child));
100 child.ClearDisplacement();
155 if (IsRoot(child)) 101 if (IsRoot(child))
156 { 102 {
157 // Schedule a rebuild to verify that the root shape is set to the real shape. 103 // Schedule a rebuild to verify that the root shape is set to the real shape.
@@ -315,7 +261,6 @@ public sealed class BSLinksetCompound : BSLinkset
315 // Note that this works for rebuilding just the root after a linkset is taken apart. 261 // Note that this works for rebuilding just the root after a linkset is taken apart.
316 // Called at taint time!! 262 // Called at taint time!!
317 private bool UseBulletSimRootOffsetHack = false; // Attempt to have Bullet track the coords of root compound shape 263 private bool UseBulletSimRootOffsetHack = false; // Attempt to have Bullet track the coords of root compound shape
318 private bool disableCOM = true; // For basic linkset debugging, turn off the center-of-mass setting
319 private void RecomputeLinksetCompound() 264 private void RecomputeLinksetCompound()
320 { 265 {
321 try 266 try
@@ -326,55 +271,70 @@ public sealed class BSLinksetCompound : BSLinkset
326 // to what they should be as if the root was not in a linkset. 271 // to what they should be as if the root was not in a linkset.
327 // Not that bad since we only get into this routine if there are children in the linkset and 272 // Not that bad since we only get into this routine if there are children in the linkset and
328 // something has been updated/changed. 273 // something has been updated/changed.
274 // Have to do the rebuild before checking for physical because this might be a linkset
275 // being destructed and going non-physical.
329 LinksetRoot.ForceBodyShapeRebuild(true); 276 LinksetRoot.ForceBodyShapeRebuild(true);
330 277
331 // There is no reason to build all this physical stuff for a non-physical linkset. 278 // There is no reason to build all this physical stuff for a non-physical linkset.
332 if (!LinksetRoot.IsPhysicallyActive) 279 if (!LinksetRoot.IsPhysicallyActive)
333 { 280 {
334 // Clean up any old linkset shape and make sure the root shape is set to the root object.
335 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); 281 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID);
336
337 return; // Note the 'finally' clause at the botton which will get executed. 282 return; // Note the 'finally' clause at the botton which will get executed.
338 } 283 }
339 284
340 // Get a new compound shape to build the linkset shape in. 285 // Get a new compound shape to build the linkset shape in.
341 BSShape linksetShape = BSShapeCompound.GetReference(m_physicsScene); 286 BSShape linksetShape = BSShapeCompound.GetReference(m_physicsScene);
342 287
343 // The center of mass for the linkset is the geometric center of the group.
344 // Compute a displacement for each component so it is relative to the center-of-mass. 288 // Compute a displacement for each component so it is relative to the center-of-mass.
345 // Bullet presumes an object's origin (relative <0,0,0>) is its center-of-mass 289 // Bullet presumes an object's origin (relative <0,0,0>) is its center-of-mass
346 OMV.Vector3 centerOfMassW = ComputeLinksetCenterOfMass(); 290 OMV.Vector3 centerOfMassW = ComputeLinksetCenterOfMass();
347 291
348 OMV.Quaternion invRootOrientation = OMV.Quaternion.Normalize(OMV.Quaternion.Inverse(LinksetRoot.RawOrientation)); 292 OMV.Quaternion invRootOrientation = OMV.Quaternion.Normalize(OMV.Quaternion.Inverse(LinksetRoot.RawOrientation));
293 OMV.Vector3 origRootPosition = LinksetRoot.RawPosition;
349 294
350 // 'centerDisplacement' is the value to subtract from children to give physical offset position 295 // 'centerDisplacementV' is the vehicle relative distance from the simulator root position to the center-of-mass
351 OMV.Vector3 centerDisplacementV = (centerOfMassW - LinksetRoot.RawPosition) * invRootOrientation; 296 OMV.Vector3 centerDisplacementV = (centerOfMassW - LinksetRoot.RawPosition) * invRootOrientation;
352 if (UseBulletSimRootOffsetHack || disableCOM) 297 if (UseBulletSimRootOffsetHack || !BSParam.LinksetOffsetCenterOfMass)
353 { 298 {
299 // Zero everything if center-of-mass displacement is not being done.
354 centerDisplacementV = OMV.Vector3.Zero; 300 centerDisplacementV = OMV.Vector3.Zero;
355 LinksetRoot.ClearDisplacement(); 301 LinksetRoot.ClearDisplacement();
356 } 302 }
357 else 303 else
358 { 304 {
359 LinksetRoot.SetEffectiveCenterOfMassDisplacement(centerDisplacementV); 305 // The actual center-of-mass could have been set by the user.
306 centerDisplacementV = LinksetRoot.SetEffectiveCenterOfMassDisplacement(centerDisplacementV);
360 } 307 }
308
361 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,rootPos={1},com={2},comDisp={3}", 309 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,rootPos={1},com={2},comDisp={3}",
362 LinksetRoot.LocalID, LinksetRoot.RawPosition, centerOfMassW, centerDisplacementV); 310 LinksetRoot.LocalID, origRootPosition, centerOfMassW, centerDisplacementV);
363 311
364 // Add the shapes of all the components of the linkset 312 // Add the shapes of all the components of the linkset
365 int memberIndex = 1; 313 int memberIndex = 1;
366 ForEachMember(delegate(BSPrimLinkable cPrim) 314 ForEachMember(delegate(BSPrimLinkable cPrim)
367 { 315 {
368 // Root shape is always index zero. 316 if (IsRoot(cPrim))
369 cPrim.LinksetChildIndex = IsRoot(cPrim) ? 0 : memberIndex; 317 {
318 // Root shape is always index zero.
319 cPrim.LinksetChildIndex = 0;
320 }
321 else
322 {
323 cPrim.LinksetChildIndex = memberIndex;
324 memberIndex++;
325 }
370 326
371 // Get a reference to the shape of the child and add that shape to the linkset compound shape 327 // Get a reference to the shape of the child for adding of that shape to the linkset compound shape
372 BSShape childShape = cPrim.PhysShape.GetReference(m_physicsScene, cPrim); 328 BSShape childShape = cPrim.PhysShape.GetReference(m_physicsScene, cPrim);
373 OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacementV; 329
330 // Offset the child shape from the center-of-mass and rotate it to vehicle relative.
331 OMV.Vector3 offsetPos = (cPrim.RawPosition - origRootPosition) * invRootOrientation - centerDisplacementV;
374 OMV.Quaternion offsetRot = OMV.Quaternion.Normalize(cPrim.RawOrientation) * invRootOrientation; 332 OMV.Quaternion offsetRot = OMV.Quaternion.Normalize(cPrim.RawOrientation) * invRootOrientation;
333
334 // Add the child shape to the compound shape being built
375 m_physicsScene.PE.AddChildShapeToCompoundShape(linksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot); 335 m_physicsScene.PE.AddChildShapeToCompoundShape(linksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot);
376 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1},cShape={2},offPos={3},offRot={4}", 336 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1},cShape={2},offPos={3},offRot={4}",
377 LinksetRoot.LocalID, memberIndex, childShape, offsetPos, offsetRot); 337 LinksetRoot.LocalID, cPrim.LinksetChildIndex, childShape, offsetPos, offsetRot);
378 338
379 // Since we are borrowing the shape of the child, disable the origional child body 339 // Since we are borrowing the shape of the child, disable the origional child body
380 if (!IsRoot(cPrim)) 340 if (!IsRoot(cPrim))
@@ -386,8 +346,6 @@ public sealed class BSLinksetCompound : BSLinkset
386 cPrim.PhysBody.collisionType = CollisionType.LinksetChild; 346 cPrim.PhysBody.collisionType = CollisionType.LinksetChild;
387 } 347 }
388 348
389 memberIndex++;
390
391 return false; // 'false' says to move onto the next child in the list 349 return false; // 'false' says to move onto the next child in the list
392 }); 350 });
393 351
@@ -409,8 +367,9 @@ public sealed class BSLinksetCompound : BSLinkset
409 { 367 {
410 // Enable the physical position updator to return the position and rotation of the root shape. 368 // Enable the physical position updator to return the position and rotation of the root shape.
411 // This enables a feature in the C++ code to return the world coordinates of the first shape in the 369 // This enables a feature in the C++ code to return the world coordinates of the first shape in the
412 // compound shape. This eleviates the need to offset the returned physical position by the 370 // compound shape. This aleviates the need to offset the returned physical position by the
413 // center-of-mass offset. 371 // center-of-mass offset.
372 // TODO: either debug this feature or remove it.
414 m_physicsScene.PE.AddToCollisionFlags(LinksetRoot.PhysBody, CollisionFlags.BS_RETURN_ROOT_COMPOUND_SHAPE); 373 m_physicsScene.PE.AddToCollisionFlags(LinksetRoot.PhysBody, CollisionFlags.BS_RETURN_ROOT_COMPOUND_SHAPE);
415 } 374 }
416 } 375 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
index 1214703..7693195 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
@@ -188,6 +188,8 @@ public class BSVMotor : BSMotor
188 CurrentValue = current; 188 CurrentValue = current;
189 return Step(timeStep); 189 return Step(timeStep);
190 } 190 }
191 // Given and error, computer a correction for this step.
192 // Simple scaling of the error by the timestep.
191 public virtual Vector3 StepError(float timeStep, Vector3 error) 193 public virtual Vector3 StepError(float timeStep, Vector3 error)
192 { 194 {
193 if (!Enabled) return Vector3.Zero; 195 if (!Enabled) return Vector3.Zero;
@@ -221,7 +223,7 @@ public class BSVMotor : BSMotor
221 CurrentValue, TargetValue); 223 CurrentValue, TargetValue);
222 224
223 LastError = BSMotor.InfiniteVector; 225 LastError = BSMotor.InfiniteVector;
224 while (maxOutput-- > 0 && !LastError.ApproxEquals(Vector3.Zero, ErrorZeroThreshold)) 226 while (maxOutput-- > 0 && !ErrorIsZero())
225 { 227 {
226 Vector3 lastStep = Step(timeStep); 228 Vector3 lastStep = Step(timeStep);
227 MDetailLog("{0},BSVMotor.Test,{1},cur={2},tgt={3},lastError={4},lastStep={5}", 229 MDetailLog("{0},BSVMotor.Test,{1},cur={2},tgt={3},lastError={4},lastStep={5}",
@@ -375,7 +377,6 @@ public class BSPIDVMotor : BSVMotor
375 // The factors are vectors for the three dimensions. This is the proportional of each 377 // The factors are vectors for the three dimensions. This is the proportional of each
376 // that is applied. This could be multiplied through the actual factors but it 378 // that is applied. This could be multiplied through the actual factors but it
377 // is sometimes easier to manipulate the factors and their mix separately. 379 // is sometimes easier to manipulate the factors and their mix separately.
378 // to
379 public Vector3 FactorMix; 380 public Vector3 FactorMix;
380 381
381 // Arbritrary factor range. 382 // Arbritrary factor range.
@@ -413,14 +414,14 @@ public class BSPIDVMotor : BSVMotor
413 // If efficiency is high (1f), use a factor value that moves the error value to zero with little overshoot. 414 // If efficiency is high (1f), use a factor value that moves the error value to zero with little overshoot.
414 // If efficiency is low (0f), use a factor value that overcorrects. 415 // If efficiency is low (0f), use a factor value that overcorrects.
415 // TODO: might want to vary contribution of different factor depending on efficiency. 416 // TODO: might want to vary contribution of different factor depending on efficiency.
416 float factor = ((1f - this.Efficiency) * EfficiencyHigh + EfficiencyLow) / 3f; 417 // float factor = ((1f - this.Efficiency) * EfficiencyHigh + EfficiencyLow) / 3f;
417 // float factor = (1f - this.Efficiency) * EfficiencyHigh + EfficiencyLow; 418 float factor = (1f - this.Efficiency) * EfficiencyHigh + EfficiencyLow;
418 419
419 proportionFactor = new Vector3(factor, factor, factor); 420 proportionFactor = new Vector3(factor, factor, factor);
420 integralFactor = new Vector3(factor, factor, factor); 421 integralFactor = new Vector3(factor, factor, factor);
421 derivFactor = new Vector3(factor, factor, factor); 422 derivFactor = new Vector3(factor, factor, factor);
422 423
423 MDetailLog("{0},BSPIDVMotor.setEfficiency,eff={1},factor={2}", BSScene.DetailLogZero, Efficiency, factor); 424 MDetailLog("{0}, BSPIDVMotor.setEfficiency,eff={1},factor={2}", BSScene.DetailLogZero, Efficiency, factor);
424 } 425 }
425 } 426 }
426 427
@@ -441,8 +442,8 @@ public class BSPIDVMotor : BSVMotor
441 + derivitive / TimeScale * derivFactor * FactorMix.Z 442 + derivitive / TimeScale * derivFactor * FactorMix.Z
442 ; 443 ;
443 444
444 MDetailLog("{0}, BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}", 445 MDetailLog("{0}, BSPIDVMotor.step,ts={1},err={2},lerr={3},runnInt={4},deriv={5},ret={6}",
445 BSScene.DetailLogZero, timeStep, error, RunningIntegration, derivitive, ret); 446 BSScene.DetailLogZero, timeStep, error, LastError, RunningIntegration, derivitive, ret);
446 447
447 return ret; 448 return ret;
448 } 449 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index d17c8e7..0f84bf7 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -176,6 +176,7 @@ public static class BSParam
176 176
177 // Linkset implementation parameters 177 // Linkset implementation parameters
178 public static float LinksetImplementation { get; private set; } 178 public static float LinksetImplementation { get; private set; }
179 public static bool LinksetOffsetCenterOfMass { get; private set; }
179 public static bool LinkConstraintUseFrameOffset { get; private set; } 180 public static bool LinkConstraintUseFrameOffset { get; private set; }
180 public static bool LinkConstraintEnableTransMotor { get; private set; } 181 public static bool LinkConstraintEnableTransMotor { get; private set; }
181 public static float LinkConstraintTransMotorMaxVel { get; private set; } 182 public static float LinkConstraintTransMotorMaxVel { get; private set; }
@@ -684,6 +685,8 @@ public static class BSParam
684 685
685 new ParameterDefn<float>("LinksetImplementation", "Type of linkset implementation (0=Constraint, 1=Compound, 2=Manual)", 686 new ParameterDefn<float>("LinksetImplementation", "Type of linkset implementation (0=Constraint, 1=Compound, 2=Manual)",
686 (float)BSLinkset.LinksetImplementation.Compound ), 687 (float)BSLinkset.LinksetImplementation.Compound ),
688 new ParameterDefn<bool>("LinksetOffsetCenterOfMass", "If 'true', compute linkset center-of-mass and offset linkset position to account for same",
689 false ),
687 new ParameterDefn<bool>("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.", 690 new ParameterDefn<bool>("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.",
688 false ), 691 false ),
689 new ParameterDefn<bool>("LinkConstraintEnableTransMotor", "Whether to enable translational motor on linkset constraints", 692 new ParameterDefn<bool>("LinkConstraintEnableTransMotor", "Whether to enable translational motor on linkset constraints",
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index a0d5c42..738e2d0 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -90,6 +90,8 @@ public abstract class BSPhysObject : PhysicsActor
90 PhysBody = new BulletBody(localID); 90 PhysBody = new BulletBody(localID);
91 PhysShape = new BSShapeNull(); 91 PhysShape = new BSShapeNull();
92 92
93 UserSetCenterOfMassDisplacement = null;
94
93 PrimAssetState = PrimAssetCondition.Unknown; 95 PrimAssetState = PrimAssetCondition.Unknown;
94 96
95 // Default material type. Also sets Friction, Restitution and Density. 97 // Default material type. Also sets Friction, Restitution and Density.
@@ -180,6 +182,7 @@ public abstract class BSPhysObject : PhysicsActor
180 Material = (MaterialAttributes.Material)material; 182 Material = (MaterialAttributes.Material)material;
181 183
182 // Setting the material sets the material attributes also. 184 // Setting the material sets the material attributes also.
185 // TODO: decide if this is necessary -- the simulator does this.
183 MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false); 186 MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false);
184 Friction = matAttrib.friction; 187 Friction = matAttrib.friction;
185 Restitution = matAttrib.restitution; 188 Restitution = matAttrib.restitution;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index b2947c6..ce4c3da 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -802,6 +802,7 @@ public class BSPrim : BSPhysObject
802 // isSolid: other objects bounce off of this object 802 // isSolid: other objects bounce off of this object
803 // isVolumeDetect: other objects pass through but can generate collisions 803 // isVolumeDetect: other objects pass through but can generate collisions
804 // collisionEvents: whether this object returns collision events 804 // collisionEvents: whether this object returns collision events
805 // NOTE: overloaded by BSPrimLinkable to also update linkset physical parameters.
805 public virtual void UpdatePhysicalParameters() 806 public virtual void UpdatePhysicalParameters()
806 { 807 {
807 if (!PhysBody.HasPhysicalBody) 808 if (!PhysBody.HasPhysicalBody)
@@ -1125,7 +1126,9 @@ public class BSPrim : BSPhysObject
1125 OMV.Vector3 addForce = force; 1126 OMV.Vector3 addForce = force;
1126 PhysScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() 1127 PhysScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate()
1127 { 1128 {
1128 // Bullet adds this central force to the total force for this tick 1129 // Bullet adds this central force to the total force for this tick.
1130 // Deep down in Bullet:
1131 // linearVelocity += totalForce / mass * timeStep;
1129 DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce); 1132 DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce);
1130 if (PhysBody.HasPhysicalBody) 1133 if (PhysBody.HasPhysicalBody)
1131 { 1134 {
@@ -1493,6 +1496,8 @@ public class BSPrim : BSPhysObject
1493 1496
1494 returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass); 1497 returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass);
1495 // DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3}", LocalID, Density, volume, returnMass); 1498 // DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3}", LocalID, Density, volume, returnMass);
1499 DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3},pathB={4},pathE={5},profB={6},profE={7},siz={8}",
1500 LocalID, Density, volume, returnMass, pathBegin, pathEnd, profileBegin, profileEnd, _size);
1496 1501
1497 return returnMass; 1502 return returnMass;
1498 }// end CalculateMass 1503 }// end CalculateMass
@@ -1528,6 +1533,8 @@ public class BSPrim : BSPhysObject
1528 1533
1529 // The physics engine says that properties have updated. Update same and inform 1534 // The physics engine says that properties have updated. Update same and inform
1530 // the world that things have changed. 1535 // the world that things have changed.
1536 // NOTE: BSPrim.UpdateProperties is overloaded by BSPrimLinkable which modifies updates from root and children prims.
1537 // NOTE: BSPrim.UpdateProperties is overloaded by BSPrimDisplaced which handles mapping physical position to simulator position.
1531 public override void UpdateProperties(EntityProperties entprop) 1538 public override void UpdateProperties(EntityProperties entprop)
1532 { 1539 {
1533 // Let anyone (like the actors) modify the updated properties before they are pushed into the object and the simulator. 1540 // Let anyone (like the actors) modify the updated properties before they are pushed into the object and the simulator.
@@ -1563,8 +1570,6 @@ public class BSPrim : BSPhysObject
1563 LastEntityProperties = CurrentEntityProperties; 1570 LastEntityProperties = CurrentEntityProperties;
1564 CurrentEntityProperties = entprop; 1571 CurrentEntityProperties = entprop;
1565 1572
1566 // Note that BSPrim can be overloaded by BSPrimLinkable which controls updates from root and children prims.
1567
1568 PhysScene.PostUpdate(this); 1573 PhysScene.PostUpdate(this);
1569 } 1574 }
1570} 1575}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs
index f5ee671..35d5a08 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs
@@ -44,14 +44,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin
44{ 44{
45public class BSPrimDisplaced : BSPrim 45public class BSPrimDisplaced : BSPrim
46{ 46{
47 // The purpose of this module is to do any mapping between what the simulator thinks 47 // The purpose of this subclass is to do any mapping between what the simulator thinks
48 // the prim position and orientation is and what the physical position/orientation. 48 // the prim position and orientation is and what the physical position/orientation.
49 // This difference happens because Bullet assumes the center-of-mass is the <0,0,0> 49 // This difference happens because Bullet assumes the center-of-mass is the <0,0,0>
50 // of the prim/linkset. The simulator tracks the location of the prim/linkset by 50 // of the prim/linkset. The simulator, on the other hand, tracks the location of
51 // the location of the root prim. So, if center-of-mass is anywhere but the origin 51 // the prim/linkset by the location of the root prim. So, if center-of-mass is anywhere
52 // of the root prim, the physical origin is displaced from the simulator origin. 52 // but the origin of the root prim, the physical origin is displaced from the simulator origin.
53 // 53 //
54 // This routine works by capturing the Force* setting of position/orientation/... and 54 // This routine works by capturing ForcePosition and
55 // adjusting the simulator values (being set) into the physical values. 55 // adjusting the simulator values (being set) into the physical values.
56 // The conversion is also done in the opposite direction (physical origin -> simulator origin). 56 // The conversion is also done in the opposite direction (physical origin -> simulator origin).
57 // 57 //
@@ -59,8 +59,8 @@ public class BSPrimDisplaced : BSPrim
59 // are converted into simulator origin values before being passed to the base 59 // are converted into simulator origin values before being passed to the base
60 // class. 60 // class.
61 61
62 // PositionDisplacement is the vehicle relative distance from the root prim position to the center-of-mass.
62 public virtual OMV.Vector3 PositionDisplacement { get; set; } 63 public virtual OMV.Vector3 PositionDisplacement { get; set; }
63 public virtual OMV.Quaternion OrientationDisplacement { get; set; }
64 64
65 public BSPrimDisplaced(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, 65 public BSPrimDisplaced(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
66 OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) 66 OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
@@ -69,50 +69,81 @@ public class BSPrimDisplaced : BSPrim
69 ClearDisplacement(); 69 ClearDisplacement();
70 } 70 }
71 71
72 // Clears any center-of-mass displacement introduced by linksets, etc.
73 // Does not clear the displacement set by the user.
72 public void ClearDisplacement() 74 public void ClearDisplacement()
73 { 75 {
74 PositionDisplacement = OMV.Vector3.Zero; 76 if (UserSetCenterOfMassDisplacement.HasValue)
75 OrientationDisplacement = OMV.Quaternion.Identity; 77 PositionDisplacement = (OMV.Vector3)UserSetCenterOfMassDisplacement;
78 else
79 PositionDisplacement = OMV.Vector3.Zero;
76 } 80 }
77 81
78 // Set this sets and computes the displacement from the passed prim to the center-of-mass. 82 // 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. 83 // 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). 84 // The displacement is in local coordinates (relative to root prim in linkset oriented coordinates).
81 public virtual void SetEffectiveCenterOfMassDisplacement(Vector3 centerOfMassDisplacement) 85 // Returns the relative offset from the root position to the center-of-mass.
86 // Called at taint time.
87 public virtual Vector3 SetEffectiveCenterOfMassDisplacement(Vector3 centerOfMassDisplacement)
82 { 88 {
89 PhysScene.AssertInTaintTime("BSPrimDisplaced.SetEffectiveCenterOfMassDisplacement");
83 Vector3 comDisp; 90 Vector3 comDisp;
84 if (UserSetCenterOfMassDisplacement.HasValue) 91 if (UserSetCenterOfMassDisplacement.HasValue)
85 comDisp = (OMV.Vector3)UserSetCenterOfMassDisplacement; 92 comDisp = (OMV.Vector3)UserSetCenterOfMassDisplacement;
86 else 93 else
87 comDisp = centerOfMassDisplacement; 94 comDisp = centerOfMassDisplacement;
88 95
96 // Eliminate any jitter caused be very slight differences in masses and positions
97 if (comDisp.ApproxEquals(Vector3.Zero, 0.01f) )
98 comDisp = Vector3.Zero;
99
89 DetailLog("{0},BSPrimDisplaced.SetEffectiveCenterOfMassDisplacement,userSet={1},comDisp={2}", 100 DetailLog("{0},BSPrimDisplaced.SetEffectiveCenterOfMassDisplacement,userSet={1},comDisp={2}",
90 LocalID, UserSetCenterOfMassDisplacement.HasValue, comDisp); 101 LocalID, UserSetCenterOfMassDisplacement.HasValue, comDisp);
91 if (comDisp == Vector3.Zero) 102 if ( !comDisp.ApproxEquals(PositionDisplacement, 0.01f) )
92 { 103 {
93 // If there is no diplacement. Things get reset. 104 // Displacement setting is changing.
94 PositionDisplacement = OMV.Vector3.Zero; 105 // The relationship between the physical object and simulated object must be aligned.
95 OrientationDisplacement = OMV.Quaternion.Identity;
96 }
97 else
98 {
99 // Remember the displacement from root as well as the origional rotation of the
100 // new center-of-mass.
101 PositionDisplacement = comDisp; 106 PositionDisplacement = comDisp;
102 OrientationDisplacement = OMV.Quaternion.Identity; 107 this.ForcePosition = RawPosition;
103 } 108 }
109
110 return PositionDisplacement;
104 } 111 }
105 112
113 // 'ForcePosition' is the one way to set the physical position of the body in the physics engine.
114 // Displace the simulator idea of position (center of root prim) to the physical position.
106 public override Vector3 ForcePosition 115 public override Vector3 ForcePosition
107 { 116 {
108 get { return base.ForcePosition; } 117 get {
118 OMV.Vector3 physPosition = base.ForcePosition;
119 if (PositionDisplacement != OMV.Vector3.Zero)
120 {
121 // If there is some displacement, return the physical position (center-of-mass)
122 // location minus the displacement to give the center of the root prim.
123 OMV.Vector3 displacement = PositionDisplacement * ForceOrientation;
124 DetailLog("{0},BSPrimDisplaced.ForcePosition,get,physPos={1},disp={2},simPos={3}",
125 LocalID, physPosition, displacement, physPosition - displacement);
126 physPosition -= displacement;
127 }
128 return physPosition;
129 }
109 set 130 set
110 { 131 {
111 if (PositionDisplacement != OMV.Vector3.Zero) 132 if (PositionDisplacement != OMV.Vector3.Zero)
112 { 133 {
113 OMV.Vector3 displacedPos = value - (PositionDisplacement * RawOrientation); 134 // This value is the simulator's idea of where the prim is: the center of the root prim
114 DetailLog("{0},BSPrimDisplaced.ForcePosition,val={1},disp={2},newPos={3}", LocalID, value, PositionDisplacement, displacedPos); 135 RawPosition = value;
115 base.ForcePosition = displacedPos; 136
137 // Move the passed root prim postion to the center-of-mass position and set in the physics engine.
138 OMV.Vector3 displacement = PositionDisplacement * RawOrientation;
139 OMV.Vector3 displacedPos = RawPosition + displacement;
140 DetailLog("{0},BSPrimDisplaced.ForcePosition,set,simPos={1},disp={2},physPos={3}",
141 LocalID, RawPosition, displacement, displacedPos);
142 if (PhysBody.HasPhysicalBody)
143 {
144 PhysScene.PE.SetTranslation(PhysBody, displacedPos, RawOrientation);
145 ActivateIfPhysical(false);
146 }
116 } 147 }
117 else 148 else
118 { 149 {
@@ -121,25 +152,12 @@ public class BSPrimDisplaced : BSPrim
121 } 152 }
122 } 153 }
123 154
124 public override Quaternion ForceOrientation 155 // These are also overridden by BSPrimLinkable if the prim can be part of a linkset
125 {
126 get { return base.ForceOrientation; }
127 set
128 {
129 // TODO:
130 base.ForceOrientation = value;
131 }
132 }
133
134 // TODO: decide if this is the right place for these variables.
135 // Somehow incorporate the optional settability by the user.
136 // Is this used?
137 public override OMV.Vector3 CenterOfMass 156 public override OMV.Vector3 CenterOfMass
138 { 157 {
139 get { return RawPosition; } 158 get { return RawPosition; }
140 } 159 }
141 160
142 // Is this used?
143 public override OMV.Vector3 GeometricCenter 161 public override OMV.Vector3 GeometricCenter
144 { 162 {
145 get { return RawPosition; } 163 get { return RawPosition; }
@@ -148,15 +166,18 @@ public class BSPrimDisplaced : BSPrim
148 public override void UpdateProperties(EntityProperties entprop) 166 public override void UpdateProperties(EntityProperties entprop)
149 { 167 {
150 // Undo any center-of-mass displacement that might have been done. 168 // Undo any center-of-mass displacement that might have been done.
151 if (PositionDisplacement != OMV.Vector3.Zero || OrientationDisplacement != OMV.Quaternion.Identity) 169 if (PositionDisplacement != OMV.Vector3.Zero)
152 { 170 {
153 // Correct for any rotation around the center-of-mass 171 // The origional shape was offset from 'zero' by PositionDisplacement.
154 // TODO!!! 172 // These physical location must be back converted to be centered around the displaced
155 173 // root shape.
156 OMV.Vector3 displacedPos = entprop.Position + (PositionDisplacement * entprop.Rotation); 174
157 DetailLog("{0},BSPrimDisplaced.ForcePosition,physPos={1},disp={2},newPos={3}", LocalID, entprop.Position, PositionDisplacement, displacedPos); 175 // Move the returned center-of-mass location to the root prim location.
176 OMV.Vector3 displacement = PositionDisplacement * entprop.Rotation;
177 OMV.Vector3 displacedPos = entprop.Position - displacement;
178 DetailLog("{0},BSPrimDisplaced.UpdateProperties,physPos={1},disp={2},simPos={3}",
179 LocalID, entprop.Position, displacement, displacedPos);
158 entprop.Position = displacedPos; 180 entprop.Position = displacedPos;
159 // entprop.Rotation = something;
160 } 181 }
161 182
162 base.UpdateProperties(entprop); 183 base.UpdateProperties(entprop);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
index 87eed98..1fbcfcc 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
@@ -37,6 +37,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
37{ 37{
38public class BSPrimLinkable : BSPrimDisplaced 38public class BSPrimLinkable : BSPrimDisplaced
39{ 39{
40 // The purpose of this subclass is to add linkset functionality to the prim. This overrides
41 // operations necessary for keeping the linkset created and, additionally, this
42 // calls the linkset implementation for its creation and management.
43
44 // This adds the overrides for link() and delink() so the prim is linkable.
45
40 public BSLinkset Linkset { get; set; } 46 public BSLinkset Linkset { get; set; }
41 // The index of this child prim. 47 // The index of this child prim.
42 public int LinksetChildIndex { get; set; } 48 public int LinksetChildIndex { get; set; }
@@ -69,8 +75,8 @@ public class BSPrimLinkable : BSPrimDisplaced
69 BSPrimLinkable parent = obj as BSPrimLinkable; 75 BSPrimLinkable parent = obj as BSPrimLinkable;
70 if (parent != null) 76 if (parent != null)
71 { 77 {
72 BSPhysObject parentBefore = Linkset.LinksetRoot; 78 BSPhysObject parentBefore = Linkset.LinksetRoot; // DEBUG
73 int childrenBefore = Linkset.NumberOfChildren; 79 int childrenBefore = Linkset.NumberOfChildren; // DEBUG
74 80
75 Linkset = parent.Linkset.AddMeToLinkset(this); 81 Linkset = parent.Linkset.AddMeToLinkset(this);
76 82
@@ -85,8 +91,8 @@ public class BSPrimLinkable : BSPrimDisplaced
85 // TODO: decide if this parent checking needs to happen at taint time 91 // TODO: decide if this parent checking needs to happen at taint time
86 // Race condition here: if link() and delink() in same simulation tick, the delink will not happen 92 // Race condition here: if link() and delink() in same simulation tick, the delink will not happen
87 93
88 BSPhysObject parentBefore = Linkset.LinksetRoot; 94 BSPhysObject parentBefore = Linkset.LinksetRoot; // DEBUG
89 int childrenBefore = Linkset.NumberOfChildren; 95 int childrenBefore = Linkset.NumberOfChildren; // DEBUG
90 96
91 Linkset = Linkset.RemoveMeFromLinkset(this); 97 Linkset = Linkset.RemoveMeFromLinkset(this);
92 98
@@ -128,6 +134,17 @@ public class BSPrimLinkable : BSPrimDisplaced
128 get { return Linkset.LinksetMass; } 134 get { return Linkset.LinksetMass; }
129 } 135 }
130 136
137 public override OMV.Vector3 CenterOfMass
138 {
139 get { return Linkset.CenterOfMass; }
140 }
141
142 public override OMV.Vector3 GeometricCenter
143 {
144 get { return Linkset.GeometricCenter; }
145 }
146
147 // Refresh the linkset structure and parameters when the prim's physical parameters are changed.
131 public override void UpdatePhysicalParameters() 148 public override void UpdatePhysicalParameters()
132 { 149 {
133 base.UpdatePhysicalParameters(); 150 base.UpdatePhysicalParameters();
@@ -139,13 +156,17 @@ public class BSPrimLinkable : BSPrimDisplaced
139 Linkset.Refresh(this); 156 Linkset.Refresh(this);
140 } 157 }
141 158
159 // When the prim is made dynamic or static, the linkset needs to change.
142 protected override void MakeDynamic(bool makeStatic) 160 protected override void MakeDynamic(bool makeStatic)
143 { 161 {
144 base.MakeDynamic(makeStatic); 162 base.MakeDynamic(makeStatic);
145 if (makeStatic) 163 if (Linkset != null) // null can happen during initialization
146 Linkset.MakeStatic(this); 164 {
147 else 165 if (makeStatic)
148 Linkset.MakeDynamic(this); 166 Linkset.MakeStatic(this);
167 else
168 Linkset.MakeDynamic(this);
169 }
149 } 170 }
150 171
151 // Body is being taken apart. Remove physical dependencies and schedule a rebuild. 172 // Body is being taken apart. Remove physical dependencies and schedule a rebuild.
@@ -155,6 +176,8 @@ public class BSPrimLinkable : BSPrimDisplaced
155 base.RemoveDependencies(); 176 base.RemoveDependencies();
156 } 177 }
157 178
179 // Called after a simulation step for the changes in physical object properties.
180 // Do any filtering/modification needed for linksets.
158 public override void UpdateProperties(EntityProperties entprop) 181 public override void UpdateProperties(EntityProperties entprop)
159 { 182 {
160 if (Linkset.IsRoot(this)) 183 if (Linkset.IsRoot(this))
@@ -176,6 +199,7 @@ public class BSPrimLinkable : BSPrimDisplaced
176 Linkset.UpdateProperties(UpdatedProperties.EntPropUpdates, this); 199 Linkset.UpdateProperties(UpdatedProperties.EntPropUpdates, this);
177 } 200 }
178 201
202 // Called after a simulation step to post a collision with this object.
179 public override bool Collide(uint collidingWith, BSPhysObject collidee, 203 public override bool Collide(uint collidingWith, BSPhysObject collidee,
180 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) 204 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
181 { 205 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 1645c98..e56a6f6 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -785,7 +785,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
785 { 785 {
786 // The simulation of the time interval took less than realtime. 786 // The simulation of the time interval took less than realtime.
787 // Do a sleep for the rest of realtime. 787 // Do a sleep for the rest of realtime.
788 DetailLog("{0},BulletSPluginPhysicsThread,sleeping={1}", BSScene.DetailLogZero, simulationTimeVsRealtimeDifferenceMS);
789 Thread.Sleep(simulationTimeVsRealtimeDifferenceMS); 788 Thread.Sleep(simulationTimeVsRealtimeDifferenceMS);
790 } 789 }
791 else 790 else
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
index 4357ef1..0453376 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
@@ -3,25 +3,21 @@ CURRENT PROBLEMS TO FIX AND/OR LOOK AT
3Vehicle buoyancy. Computed correctly? Possibly creating very large effective mass. 3Vehicle buoyancy. Computed correctly? Possibly creating very large effective mass.
4 Interaction of llSetBuoyancy and vehicle buoyancy. Should be additive? 4 Interaction of llSetBuoyancy and vehicle buoyancy. Should be additive?
5 Negative buoyancy computed correctly 5 Negative buoyancy computed correctly
6Center-of-gravity
6Computation of mesh mass. How done? How should it be done? 7Computation of mesh mass. How done? How should it be done?
7Script changing rotation of child prim while vehicle moving (eg turning wheel) causes
8 the wheel to appear to jump back. Looks like sending position from previous update.
9Enable vehicle border crossings (at least as poorly as ODE) 8Enable vehicle border crossings (at least as poorly as ODE)
10 Terrain skirts 9 Terrain skirts
11 Avatar created in previous region and not new region when crossing border 10 Avatar created in previous region and not new region when crossing border
12 Vehicle recreated in new sim at small Z value (offset from root value?) (DONE) 11 Vehicle recreated in new sim at small Z value (offset from root value?) (DONE)
12User settable terrain mesh
13 Allow specifying as convex or concave and use different getHeight functions depending
14Boats, when turning nose down into the water
15 Acts like rotation around Z is also effecting rotation around X and Y
13Deleting a linkset while standing on the root will leave the physical shape of the root behind. 16Deleting a linkset while standing on the root will leave the physical shape of the root behind.
14 Not sure if it is because standing on it. Done with large prim linksets. 17 Not sure if it is because standing on it. Done with large prim linksets.
15Linkset child rotations. 18Linkset child rotations.
16 Nebadon spiral tube has middle sections which are rotated wrong. 19 Nebadon spiral tube has middle sections which are rotated wrong.
17 Select linked spiral tube. Delink and note where the middle section ends up. 20 Select linked spiral tube. Delink and note where the middle section ends up.
18Refarb compound linkset creation to create a pseudo-root for center-of-mass
19 Let children change their shape to physical indendently and just add shapes to compound
20Vehicle angular vertical attraction
21vehicle angular banking
22Center-of-gravity
23Vehicle angular deflection
24 Preferred orientation angular correction fix
25Teravus llMoveToTarget script debug 21Teravus llMoveToTarget script debug
26 Mixing of hover, buoyancy/gravity, moveToTarget, into one force 22 Mixing of hover, buoyancy/gravity, moveToTarget, into one force
27 Setting hover height to zero disables hover even if hover flags are on (from SL wiki) 23 Setting hover height to zero disables hover even if hover flags are on (from SL wiki)
@@ -33,10 +29,16 @@ Vehicle script tuning/debugging
33 Avanti speed script 29 Avanti speed script
34 Weapon shooter script 30 Weapon shooter script
35Move material definitions (friction, ...) into simulator. 31Move material definitions (friction, ...) into simulator.
32osGetPhysicsEngineVerion() and create a version code for the C++ DLL
36One sided meshes? Should terrain be built into a closed shape? 33One sided meshes? Should terrain be built into a closed shape?
37 When meshes get partially wedged into the terrain, they cannot push themselves out. 34 When meshes get partially wedged into the terrain, they cannot push themselves out.
38 It is possible that Bullet processes collisions whether entering or leaving a mesh. 35 It is possible that Bullet processes collisions whether entering or leaving a mesh.
39 Ref: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4869 36 Ref: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4869
37Small physical objects do not interact correctly
38 Create chain of .5x.5x.1 torui and make all but top physical so to hang.
39 The chain will fall apart and pairs will dance around on ground
40 Chains of 1x1x.2 will stay connected but will dance.
41 Chains above 2x2x.4 are more stable and get stablier as torui get larger.
40 42
41VEHICLES TODO LIST: 43VEHICLES TODO LIST:
42================================================= 44=================================================
@@ -45,14 +47,12 @@ LINEAR_MOTOR_DIRECTION values should be clamped to reasonable numbers.
45 Same for other velocity settings. 47 Same for other velocity settings.
46UBit improvements to remove rubber-banding of avatars sitting on vehicle child prims: 48UBit improvements to remove rubber-banding of avatars sitting on vehicle child prims:
47 https://github.com/UbitUmarov/Ubit-opensim 49 https://github.com/UbitUmarov/Ubit-opensim
48Vehicles (Move smoothly)
49Some vehicles should not be able to turn if no speed or off ground. 50Some vehicles should not be able to turn if no speed or off ground.
50Cannot edit/move a vehicle being ridden: it jumps back to the origional position. 51Cannot edit/move a vehicle being ridden: it jumps back to the origional position.
51Neb car jiggling left and right 52Neb car jiggling left and right
52 Happens on terrain and any other mesh object. Flat cubes are much smoother. 53 Happens on terrain and any other mesh object. Flat cubes are much smoother.
53 This has been reduced but not eliminated. 54 This has been reduced but not eliminated.
54Implement referenceFrame for all the motion routines. 55Implement referenceFrame for all the motion routines.
55For limitMotorUp, use raycast down to find if vehicle is in the air.
56Verify llGetVel() is returning a smooth and good value for vehicle movement. 56Verify llGetVel() is returning a smooth and good value for vehicle movement.
57llGetVel() should return the root's velocity if requested in a child prim. 57llGetVel() should return the root's velocity if requested in a child prim.
58Implement function efficiency for lineaar and angular motion. 58Implement function efficiency for lineaar and angular motion.
@@ -93,29 +93,15 @@ Revisit CollisionMargin. Builders notice the 0.04 spacing between prims.
93Duplicating a physical prim causes old prim to jump away 93Duplicating a physical prim causes old prim to jump away
94 Dup a phys prim and the original become unselected and thus interacts w/ selected prim. 94 Dup a phys prim and the original become unselected and thus interacts w/ selected prim.
95Scenes with hundred of thousands of static objects take a lot of physics CPU time. 95Scenes with hundred of thousands of static objects take a lot of physics CPU time.
96BSPrim.Force should set a continious force on the prim. The force should be
97 applied each tick. Some limits?
98Gun sending shooter flying. 96Gun sending shooter flying.
99Collision margin (gap between physical objects lying on each other) 97Collision margin (gap between physical objects lying on each other)
100Boundry checking (crashes related to crossing boundry) 98Boundry checking (crashes related to crossing boundry)
101 Add check for border edge position for avatars and objects. 99 Add check for border edge position for avatars and objects.
102 Verify the events are created for border crossings. 100 Verify the events are created for border crossings.
103Avatar rotation (check out changes to ScenePresence for physical rotation)
104Avatar running (what does phys engine need to do?)
105Small physical objects do not interact correctly
106 Create chain of .5x.5x.1 torui and make all but top physical so to hang.
107 The chain will fall apart and pairs will dance around on ground
108 Chains of 1x1x.2 will stay connected but will dance.
109 Chains above 2x2x.4 are more stable and get stablier as torui get larger.
110Add PID motor for avatar movement (slow to stop, ...)
111setForce should set a constant force. Different than AddImpulse.
112Implement raycast.
113Implement ShapeCollection.Dispose() 101Implement ShapeCollection.Dispose()
114Implement water as a plain so raycasting and collisions can happen with same. 102Implement water as a plain or mesh so raycasting and collisions can happen with same.
115Add collision penetration return 103Add collision penetration return
116 Add field passed back by BulletSim.dll and fill with info in ManifoldConstact.GetDistance() 104 Add field passed back by BulletSim.dll and fill with info in ManifoldConstact.GetDistance()
117Add osGetPhysicsEngineName() so scripters can tell whether BulletSim or ODE
118 Also osGetPhysicsEngineVerion() maybe.
119Linkset.Position and Linkset.Orientation requre rewrite to properly return 105Linkset.Position and Linkset.Orientation requre rewrite to properly return
120 child position. LinksetConstraint acts like it's at taint time!! 106 child position. LinksetConstraint acts like it's at taint time!!
121Implement LockAngularMotion -- implements llSetStatus(ROTATE_AXIS_*, T/F) 107Implement LockAngularMotion -- implements llSetStatus(ROTATE_AXIS_*, T/F)
@@ -127,9 +113,6 @@ Selecting and deselecting physical objects causes CPU processing time to jump
127Re-implement buoyancy as a separate force on the object rather than diddling gravity. 113Re-implement buoyancy as a separate force on the object rather than diddling gravity.
128 Register a pre-step event to add the force. 114 Register a pre-step event to add the force.
129More efficient memory usage when passing hull information from BSPrim to BulletSim 115More efficient memory usage when passing hull information from BSPrim to BulletSim
130Avatar movement motor check for zero or small movement. Somehow suppress small movements
131 when avatar has stopped and is just standing. Simple test for near zero has
132 the problem of preventing starting up (increase from zero) especially when falling.
133Physical and phantom will drop through the terrain 116Physical and phantom will drop through the terrain
134 117
135 118
@@ -172,7 +155,6 @@ Do we need to do convex hulls all the time? Can complex meshes be left meshes?
172 There is some problem with meshes and collisions 155 There is some problem with meshes and collisions
173 Hulls are not as detailed as meshes. Hulled vehicles insides are different shape. 156 Hulls are not as detailed as meshes. Hulled vehicles insides are different shape.
174Debounce avatar contact so legs don't keep folding up when standing. 157Debounce avatar contact so legs don't keep folding up when standing.
175Implement LSL physics controls. Like STATUS_ROTATE_X.
176Add border extensions to terrain to help region crossings and objects leaving region. 158Add border extensions to terrain to help region crossings and objects leaving region.
177Use a different capsule shape for avatar when sitting 159Use a different capsule shape for avatar when sitting
178 LL uses a pyrimidal shape scaled by the avatar's bounding box 160 LL uses a pyrimidal shape scaled by the avatar's bounding box
@@ -205,8 +187,6 @@ Keep avatar scaling correct. http://pennycow.blogspot.fr/2011/07/matter-of-scale
205 187
206INTERNAL IMPROVEMENT/CLEANUP 188INTERNAL IMPROVEMENT/CLEANUP
207================================================= 189=================================================
208Can the 'inTaintTime' flag be cleaned up and used? For instance, a call to
209 BSScene.TaintedObject() could immediately execute the callback if already in taint time.
210Create the physical wrapper classes (BulletBody, BulletShape) by methods on 190Create the physical wrapper classes (BulletBody, BulletShape) by methods on
211 BSAPITemplate and make their actual implementation Bullet engine specific. 191 BSAPITemplate and make their actual implementation Bullet engine specific.
212 For the short term, just call the existing functions in ShapeCollection. 192 For the short term, just call the existing functions in ShapeCollection.
@@ -365,4 +345,35 @@ After getting off a vehicle, the root prim is phantom (can be walked through)
365Explore btGImpactMeshShape as alternative to convex hulls for simplified physical objects. 345Explore btGImpactMeshShape as alternative to convex hulls for simplified physical objects.
366 Regular triangle meshes don't do physical collisions. 346 Regular triangle meshes don't do physical collisions.
367 (DONE: discovered GImpact is VERY CPU intensive) 347 (DONE: discovered GImpact is VERY CPU intensive)
348Script changing rotation of child prim while vehicle moving (eg turning wheel) causes
349 the wheel to appear to jump back. Looks like sending position from previous update.
350 (DONE: redo of compound linksets fixed problem)
351Refarb compound linkset creation to create a pseudo-root for center-of-mass
352 Let children change their shape to physical indendently and just add shapes to compound
353 (DONE: redo of compound linkset fixed problem)
354Vehicle angular vertical attraction (DONE: vegaslon code)
355vehicle angular banking (DONE: vegaslon code)
356Vehicle angular deflection (DONE: vegaslon code)
357 Preferred orientation angular correction fix
358Vehicles (Move smoothly)
359For limitMotorUp, use raycast down to find if vehicle is in the air.
360 (WILL NOT BE DONE: gravity does the job well enough)
361BSPrim.Force should set a continious force on the prim. The force should be
362 applied each tick. Some limits?
363 (DONE: added physical actors. Implemented SetForce, SetTorque, ...)
364Implement LSL physics controls. Like STATUS_ROTATE_X. (DONE)
365Add osGetPhysicsEngineName() so scripters can tell whether BulletSim or ODE
366Avatar rotation (check out changes to ScenePresence for physical rotation) (DONE)
367Avatar running (what does phys engine need to do?) (DONE: multiplies run factor by walking force)
368setForce should set a constant force. Different than AddImpulse. (DONE)
369Add PID motor for avatar movement (slow to stop, ...) (WNBD: current works ok)
370Avatar movement motor check for zero or small movement. Somehow suppress small movements
371 when avatar has stopped and is just standing. Simple test for near zero has
372 the problem of preventing starting up (increase from zero) especially when falling.
373 (DONE: avatar movement actor knows if standing on stationary object and zeros motion)
374Can the 'inTaintTime' flag be cleaned up and used? For instance, a call to
375 BSScene.TaintedObject() could immediately execute the callback if already in taint time.
376 (DONE)
377
378
368 379
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index c0b8373..34e2b4d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2382,6 +2382,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2382 return force; 2382 return force;
2383 } 2383 }
2384 2384
2385 public void llSetVelocity(LSL_Vector velocity, int local)
2386 {
2387 m_host.AddScriptLPS(1);
2388
2389 if (!m_host.ParentGroup.IsDeleted)
2390 {
2391 if (local != 0)
2392 velocity *= llGetRot();
2393
2394 m_host.ParentGroup.RootPart.Velocity = velocity;
2395 }
2396 }
2397
2398 public void llSetAngularVelocity(LSL_Vector angularVelocity, int local)
2399 {
2400 m_host.AddScriptLPS(1);
2401
2402 if (!m_host.ParentGroup.IsDeleted)
2403 {
2404 if (local != 0)
2405 angularVelocity *= llGetRot();
2406
2407 m_host.ParentGroup.RootPart.AngularVelocity = angularVelocity;
2408 }
2409 }
2410
2385 public LSL_Integer llTarget(LSL_Vector position, double range) 2411 public LSL_Integer llTarget(LSL_Vector position, double range)
2386 { 2412 {
2387 m_host.AddScriptLPS(1); 2413 m_host.AddScriptLPS(1);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index ff13ee6..340edb3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -342,6 +342,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
342 void llSetDamage(double damage); 342 void llSetDamage(double damage);
343 void llSetForce(LSL_Vector force, int local); 343 void llSetForce(LSL_Vector force, int local);
344 void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local); 344 void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local);
345 void llSetVelocity(LSL_Vector velocity, int local);
346 void llSetAngularVelocity(LSL_Vector angularVelocity, int local);
345 void llSetHoverHeight(double height, int water, double tau); 347 void llSetHoverHeight(double height, int water, double tau);
346 void llSetInventoryPermMask(string item, int mask, int value); 348 void llSetInventoryPermMask(string item, int mask, int value);
347 void llSetLinkAlpha(int linknumber, double alpha, int face); 349 void llSetLinkAlpha(int linknumber, double alpha, int face);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 87cc342..7cd17e7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -1548,6 +1548,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1548 m_LSL_Functions.llSetForceAndTorque(force, torque, local); 1548 m_LSL_Functions.llSetForceAndTorque(force, torque, local);
1549 } 1549 }
1550 1550
1551 public void llSetVelocity(LSL_Vector force, int local)
1552 {
1553 m_LSL_Functions.llSetVelocity(force, local);
1554 }
1555
1556 public void llSetAngularVelocity(LSL_Vector force, int local)
1557 {
1558 m_LSL_Functions.llSetAngularVelocity(force, local);
1559 }
1560
1551 public void llSetHoverHeight(double height, int water, double tau) 1561 public void llSetHoverHeight(double height, int water, double tau)
1552 { 1562 {
1553 m_LSL_Functions.llSetHoverHeight(height, water, tau); 1563 m_LSL_Functions.llSetHoverHeight(height, water, tau);