aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRobert Adams2012-10-10 13:56:16 -0700
committerRobert Adams2012-10-11 14:01:18 -0700
commit3a458e2a36253f6514720213deaa19372b06cc52 (patch)
tree7d0d849232391402e74bf83909e4256ce890abb5 /OpenSim
parentBulletSim: Change defaults for constraint CFM and ERP to make large linksets ... (diff)
downloadopensim-SC_OLD-3a458e2a36253f6514720213deaa19372b06cc52.zip
opensim-SC_OLD-3a458e2a36253f6514720213deaa19372b06cc52.tar.gz
opensim-SC_OLD-3a458e2a36253f6514720213deaa19372b06cc52.tar.bz2
opensim-SC_OLD-3a458e2a36253f6514720213deaa19372b06cc52.tar.xz
BulletSim: Use full linkset mass when computing vehicle gravity force. Add taint-time specification to new AddForce().
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs6
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs9
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs12
3 files changed, 16 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 76230a1..56342b8 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -462,7 +462,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
462 return; 462 return;
463 463
464 // Set the prim's inertia to zero. The vehicle code handles that and this 464 // Set the prim's inertia to zero. The vehicle code handles that and this
465 // removes the torque action introduced by Bullet. 465 // removes the motion and torque actions introduced by Bullet.
466 Vector3 inertia = Vector3.Zero; 466 Vector3 inertia = Vector3.Zero;
467 BulletSimAPI.SetMassProps2(Prim.BSBody.ptr, Prim.MassRaw, inertia); 467 BulletSimAPI.SetMassProps2(Prim.BSBody.ptr, Prim.MassRaw, inertia);
468 BulletSimAPI.UpdateInertiaTensor2(Prim.BSBody.ptr); 468 BulletSimAPI.UpdateInertiaTensor2(Prim.BSBody.ptr);
@@ -540,7 +540,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
540 // add Gravity and Buoyancy 540 // add Gravity and Buoyancy
541 // There is some gravity, make a gravity force vector that is applied after object velocity. 541 // There is some gravity, make a gravity force vector that is applied after object velocity.
542 // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; 542 // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g;
543 Vector3 grav = Prim.PhysicsScene.DefaultGravity * (Prim.MassRaw * (1f - m_VehicleBuoyancy)); 543 Vector3 grav = Prim.PhysicsScene.DefaultGravity * (Prim.Linkset.LinksetMass * (1f - m_VehicleBuoyancy));
544 544
545 /* 545 /*
546 * RA: Not sure why one would do this 546 * RA: Not sure why one would do this
@@ -681,7 +681,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
681 Prim.ForceVelocity = m_newVelocity; 681 Prim.ForceVelocity = m_newVelocity;
682 // apply gravity force 682 // apply gravity force
683 // Why is this set here? The physics engine already does gravity. 683 // Why is this set here? The physics engine already does gravity.
684 Prim.AddForce(grav, false); 684 Prim.AddForce(grav, false, true);
685 685
686 // Apply friction 686 // Apply friction
687 Vector3 keepFraction = Vector3.One - (Vector3.One / (m_linearFrictionTimescale / pTimestep)); 687 Vector3 keepFraction = Vector3.One - (Vector3.One / (m_linearFrictionTimescale / pTimestep));
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index b84ccdc..43b1262 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -165,13 +165,11 @@ public class BSLinkset
165 // May be called at runtime or taint-time (just pass the appropriate flag). 165 // May be called at runtime or taint-time (just pass the appropriate flag).
166 public void Refresh(BSPhysObject requestor, bool inTaintTime) 166 public void Refresh(BSPhysObject requestor, bool inTaintTime)
167 { 167 {
168 // If there are no children, there can't be any constraints to recompute 168 // If there are no children, not physical or not root, I am not the one that recomputes the constraints
169 if (!HasAnyChildren) 169 // (For the moment, static linksets do create constraints so remove the test for physical.)
170 if (!HasAnyChildren || /*!requestor.IsPhysical ||*/ !IsRoot(requestor))
170 return; 171 return;
171 172
172 // Only the root does the recomputation
173 if (IsRoot(requestor))
174 {
175 BSScene.TaintCallback refreshOperation = delegate() 173 BSScene.TaintCallback refreshOperation = delegate()
176 { 174 {
177 RecomputeLinksetConstraintVariables(); 175 RecomputeLinksetConstraintVariables();
@@ -182,7 +180,6 @@ public class BSLinkset
182 refreshOperation(); 180 refreshOperation();
183 else 181 else
184 PhysicsScene.TaintedObject("BSLinkSet.Refresh", refreshOperation); 182 PhysicsScene.TaintedObject("BSLinkSet.Refresh", refreshOperation);
185 }
186 } 183 }
187 184
188 // The object is going dynamic (physical). Do any setup necessary 185 // The object is going dynamic (physical). Do any setup necessary
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index b26f049..692713d 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -855,6 +855,9 @@ public sealed class BSPrim : BSPhysObject
855 855
856 private List<OMV.Vector3> m_accumulatedForces = new List<OMV.Vector3>(); 856 private List<OMV.Vector3> m_accumulatedForces = new List<OMV.Vector3>();
857 public override void AddForce(OMV.Vector3 force, bool pushforce) { 857 public override void AddForce(OMV.Vector3 force, bool pushforce) {
858 AddForce(force, pushforce, false);
859 }
860 public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
858 // for an object, doesn't matter if force is a pushforce or not 861 // for an object, doesn't matter if force is a pushforce or not
859 if (force.IsFinite()) 862 if (force.IsFinite())
860 { 863 {
@@ -867,11 +870,12 @@ public sealed class BSPrim : BSPhysObject
867 m_log.WarnFormat("{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID); 870 m_log.WarnFormat("{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID);
868 return; 871 return;
869 } 872 }
870 PhysicsScene.TaintedObject("BSPrim.AddForce", delegate() 873 BSScene.TaintCallback addForceOperation = delegate()
871 { 874 {
872 OMV.Vector3 fSum = OMV.Vector3.Zero; 875 OMV.Vector3 fSum = OMV.Vector3.Zero;
873 lock (m_accumulatedForces) 876 lock (m_accumulatedForces)
874 { 877 {
878 // Sum the accumulated additional forces for one big force to apply once.
875 foreach (OMV.Vector3 v in m_accumulatedForces) 879 foreach (OMV.Vector3 v in m_accumulatedForces)
876 { 880 {
877 fSum += v; 881 fSum += v;
@@ -881,7 +885,11 @@ public sealed class BSPrim : BSPhysObject
881 // DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, fSum); 885 // DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, fSum);
882 // For unknown reasons, "ApplyCentralForce" adds this force to the total force on the object. 886 // For unknown reasons, "ApplyCentralForce" adds this force to the total force on the object.
883 BulletSimAPI.ApplyCentralForce2(BSBody.ptr, fSum); 887 BulletSimAPI.ApplyCentralForce2(BSBody.ptr, fSum);
884 }); 888 };
889 if (inTaintTime)
890 addForceOperation();
891 else
892 PhysicsScene.TaintedObject("BSPrim.AddForce", addForceOperation);
885 } 893 }
886 894
887 public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { 895 public override void AddAngularForce(OMV.Vector3 force, bool pushforce) {