aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-01-16 00:18:59 +0000
committerJustin Clark-Casey (justincc)2013-01-16 00:20:18 +0000
commit03a8a4426fddd05418309958cbbc2966cdad75e5 (patch)
tree2cabd553d5fb898fcfd52c396ab6dd850d504c96 /OpenSim/Region/Physics
parentImplement co-operative script termination if termination comes during a scrip... (diff)
parentMerge branch 'master' of /home/opensim/var/repo/opensim (diff)
downloadopensim-SC_OLD-03a8a4426fddd05418309958cbbc2966cdad75e5.zip
opensim-SC_OLD-03a8a4426fddd05418309958cbbc2966cdad75e5.tar.gz
opensim-SC_OLD-03a8a4426fddd05418309958cbbc2966cdad75e5.tar.bz2
opensim-SC_OLD-03a8a4426fddd05418309958cbbc2966cdad75e5.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/Physics')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs15
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs58
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs7
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs6
4 files changed, 67 insertions, 19 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
index 9ff7084..ae54499 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
@@ -166,7 +166,7 @@ public override BulletWorld Initialize(Vector3 maxPosition, ConfigurationParamet
166 166
167 // If Debug logging level, enable logging from the unmanaged code 167 // If Debug logging level, enable logging from the unmanaged code
168 m_DebugLogCallbackHandle = null; 168 m_DebugLogCallbackHandle = null;
169 if (BSScene.m_log.IsDebugEnabled || PhysicsScene.PhysicsLogging.Enabled) 169 if (BSScene.m_log.IsDebugEnabled && PhysicsScene.PhysicsLogging.Enabled)
170 { 170 {
171 BSScene.m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", BSScene.LogHeader); 171 BSScene.m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", BSScene.LogHeader);
172 if (PhysicsScene.PhysicsLogging.Enabled) 172 if (PhysicsScene.PhysicsLogging.Enabled)
@@ -212,6 +212,19 @@ public override void Shutdown(BulletWorld world)
212{ 212{
213 BulletWorldUnman worldu = world as BulletWorldUnman; 213 BulletWorldUnman worldu = world as BulletWorldUnman;
214 BSAPICPP.Shutdown2(worldu.ptr); 214 BSAPICPP.Shutdown2(worldu.ptr);
215
216 if (m_paramsHandle.IsAllocated)
217 {
218 m_paramsHandle.Free();
219 }
220 if (m_collisionArrayPinnedHandle.IsAllocated)
221 {
222 m_collisionArrayPinnedHandle.Free();
223 }
224 if (m_updateArrayPinnedHandle.IsAllocated)
225 {
226 m_updateArrayPinnedHandle.Free();
227 }
215} 228}
216 229
217public override bool PushUpdate(BulletBody obj) 230public override bool PushUpdate(BulletBody obj)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index bcebaec..e434412 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -124,9 +124,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
124 static readonly float PIOverTwo = ((float)Math.PI) / 2f; 124 static readonly float PIOverTwo = ((float)Math.PI) / 2f;
125 125
126 // For debugging, flags to turn on and off individual corrections. 126 // For debugging, flags to turn on and off individual corrections.
127 private bool enableAngularVerticalAttraction = true; 127 private bool enableAngularVerticalAttraction;
128 private bool enableAngularDeflection = true; 128 private bool enableAngularDeflection;
129 private bool enableAngularBanking = true; 129 private bool enableAngularBanking;
130 130
131 public BSDynamics(BSScene myScene, BSPrim myPrim) 131 public BSDynamics(BSScene myScene, BSPrim myPrim)
132 { 132 {
@@ -141,8 +141,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
141 public void SetupVehicleDebugging() 141 public void SetupVehicleDebugging()
142 { 142 {
143 enableAngularVerticalAttraction = true; 143 enableAngularVerticalAttraction = true;
144 enableAngularDeflection = true; 144 enableAngularDeflection = false;
145 enableAngularBanking = true; 145 enableAngularBanking = false;
146 if (BSParam.VehicleDebuggingEnabled != ConfigurationParameters.numericFalse) 146 if (BSParam.VehicleDebuggingEnabled != ConfigurationParameters.numericFalse)
147 { 147 {
148 enableAngularVerticalAttraction = false; 148 enableAngularVerticalAttraction = false;
@@ -649,6 +649,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
649 private Quaternion m_knownOrientation; 649 private Quaternion m_knownOrientation;
650 private Vector3 m_knownRotationalVelocity; 650 private Vector3 m_knownRotationalVelocity;
651 private Vector3 m_knownRotationalForce; 651 private Vector3 m_knownRotationalForce;
652 private Vector3 m_knownRotationalImpulse;
652 private Vector3 m_knownForwardVelocity; // vehicle relative forward speed 653 private Vector3 m_knownForwardVelocity; // vehicle relative forward speed
653 654
654 private const int m_knownChangedPosition = 1 << 0; 655 private const int m_knownChangedPosition = 1 << 0;
@@ -658,9 +659,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
658 private const int m_knownChangedOrientation = 1 << 4; 659 private const int m_knownChangedOrientation = 1 << 4;
659 private const int m_knownChangedRotationalVelocity = 1 << 5; 660 private const int m_knownChangedRotationalVelocity = 1 << 5;
660 private const int m_knownChangedRotationalForce = 1 << 6; 661 private const int m_knownChangedRotationalForce = 1 << 6;
661 private const int m_knownChangedTerrainHeight = 1 << 7; 662 private const int m_knownChangedRotationalImpulse = 1 << 7;
662 private const int m_knownChangedWaterLevel = 1 << 8; 663 private const int m_knownChangedTerrainHeight = 1 << 8;
663 private const int m_knownChangedForwardVelocity = 1 << 9; 664 private const int m_knownChangedWaterLevel = 1 << 9;
665 private const int m_knownChangedForwardVelocity = 1 <<10;
664 666
665 private void ForgetKnownVehicleProperties() 667 private void ForgetKnownVehicleProperties()
666 { 668 {
@@ -700,6 +702,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
700 PhysicsScene.PE.SetInterpolationAngularVelocity(Prim.PhysBody, m_knownRotationalVelocity); 702 PhysicsScene.PE.SetInterpolationAngularVelocity(Prim.PhysBody, m_knownRotationalVelocity);
701 } 703 }
702 704
705 if ((m_knownChanged & m_knownChangedRotationalImpulse) != 0)
706 Prim.ApplyTorqueImpulse((Vector3)m_knownRotationalImpulse, true /*inTaintTime*/);
707
703 if ((m_knownChanged & m_knownChangedRotationalForce) != 0) 708 if ((m_knownChanged & m_knownChangedRotationalForce) != 0)
704 { 709 {
705 Prim.AddAngularForce((Vector3)m_knownRotationalForce, false /*pushForce*/, true /*inTaintTime*/); 710 Prim.AddAngularForce((Vector3)m_knownRotationalForce, false /*pushForce*/, true /*inTaintTime*/);
@@ -843,6 +848,17 @@ namespace OpenSim.Region.Physics.BulletSPlugin
843 m_knownChanged |= m_knownChangedRotationalForce; 848 m_knownChanged |= m_knownChangedRotationalForce;
844 m_knownHas |= m_knownChangedRotationalForce; 849 m_knownHas |= m_knownChangedRotationalForce;
845 } 850 }
851 private void VehicleAddRotationalImpulse(Vector3 pImpulse)
852 {
853 if ((m_knownHas & m_knownChangedRotationalImpulse) == 0)
854 {
855 m_knownRotationalImpulse = Vector3.Zero;
856 m_knownHas |= m_knownChangedRotationalImpulse;
857 }
858 m_knownRotationalImpulse += pImpulse;
859 m_knownChanged |= m_knownChangedRotationalImpulse;
860 }
861
846 // Vehicle relative forward velocity 862 // Vehicle relative forward velocity
847 private Vector3 VehicleForwardVelocity 863 private Vector3 VehicleForwardVelocity
848 { 864 {
@@ -1031,16 +1047,32 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1031 else 1047 else
1032 { 1048 {
1033 // Error is positive if below the target and negative if above. 1049 // Error is positive if below the target and negative if above.
1034 float verticalError = m_VhoverTargetHeight - VehiclePosition.Z; 1050 Vector3 hpos = VehiclePosition;
1035 float verticalCorrectionVelocity = verticalError / m_VhoverTimescale * pTimestep; 1051 float verticalError = m_VhoverTargetHeight - hpos.Z;
1052 float verticalCorrection = verticalError / m_VhoverTimescale;
1053 verticalCorrection *= m_VhoverEfficiency;
1054
1055 hpos.Z += verticalCorrection;
1056 VehiclePosition = hpos;
1057
1058 // Since we are hovering, we need to do the opposite of falling -- get rid of world Z
1059 Vector3 vel = VehicleVelocity;
1060 vel.Z = 0f;
1061 VehicleVelocity = vel;
1062
1063 /*
1064 float verticalCorrectionVelocity = verticalError / m_VhoverTimescale;
1065 Vector3 verticalCorrection = new Vector3(0f, 0f, verticalCorrectionVelocity);
1066 verticalCorrection *= m_vehicleMass;
1036 1067
1037 // TODO: implement m_VhoverEfficiency correctly 1068 // TODO: implement m_VhoverEfficiency correctly
1038 VehicleAddForceImpulse(new Vector3(0f, 0f, verticalCorrectionVelocity)); 1069 VehicleAddForceImpulse(verticalCorrection);
1070 */
1039 1071
1040 VDetailLog("{0}, MoveLinear,hover,pos={1},eff={2},hoverTS={3},height={4},target={5},err={6},corrVel={7}", 1072 VDetailLog("{0}, MoveLinear,hover,pos={1},eff={2},hoverTS={3},height={4},target={5},err={6},corr={7}",
1041 Prim.LocalID, VehiclePosition, m_VhoverEfficiency, 1073 Prim.LocalID, VehiclePosition, m_VhoverEfficiency,
1042 m_VhoverTimescale, m_VhoverHeight, m_VhoverTargetHeight, 1074 m_VhoverTimescale, m_VhoverHeight, m_VhoverTargetHeight,
1043 verticalError, verticalCorrectionVelocity); 1075 verticalError, verticalCorrection);
1044 } 1076 }
1045 1077
1046 } 1078 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 5a1b5c7..2dc89b5 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -195,8 +195,11 @@ public sealed class BSLinksetCompound : BSLinkset
195 && PhysicsScene.TerrainManager.IsWithinKnownTerrain(LinksetRoot.RawPosition)) 195 && PhysicsScene.TerrainManager.IsWithinKnownTerrain(LinksetRoot.RawPosition))
196 { 196 {
197 // TODO: replace this with are calculation of the child prim's orientation and pos. 197 // TODO: replace this with are calculation of the child prim's orientation and pos.
198 updated.LinksetInfo = null; 198 // TODO: for the moment, don't rebuild the compound shape.
199 ScheduleRebuild(updated); 199 // This is often just the car turning its wheels. When we can just reorient the one
200 // member shape of the compound shape, the overhead of rebuilding won't be a problem.
201 // updated.LinksetInfo = null;
202 // ScheduleRebuild(updated);
200 } 203 }
201 } 204 }
202 205
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index 27ff047..862dbf6 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -318,13 +318,13 @@ public static class BSParam
318 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); }, 318 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); },
319 (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ), 319 (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ),
320 new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" , 320 new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" ,
321 0f, // set to zero to disable 321 0.3f, // set to zero to disable
322 (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); }, 322 (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); },
323 (s) => { return CcdMotionThreshold; }, 323 (s) => { return CcdMotionThreshold; },
324 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); }, 324 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); },
325 (s,o,v) => { s.PE.SetCcdMotionThreshold(o.PhysBody, v); } ), 325 (s,o,v) => { s.PE.SetCcdMotionThreshold(o.PhysBody, v); } ),
326 new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" , 326 new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" ,
327 0f, 327 0.2f,
328 (s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); }, 328 (s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); },
329 (s) => { return CcdSweptSphereRadius; }, 329 (s) => { return CcdSweptSphereRadius; },
330 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); }, 330 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); },
@@ -465,7 +465,7 @@ public static class BSParam
465 (s) => { return s.UnmanagedParams[0].shouldSplitSimulationIslands; }, 465 (s) => { return s.UnmanagedParams[0].shouldSplitSimulationIslands; },
466 (s,p,l,v) => { s.UnmanagedParams[0].shouldSplitSimulationIslands = v; } ), 466 (s,p,l,v) => { s.UnmanagedParams[0].shouldSplitSimulationIslands = v; } ),
467 new ParameterDefn("ShouldEnableFrictionCaching", "Enable friction computation caching", 467 new ParameterDefn("ShouldEnableFrictionCaching", "Enable friction computation caching",
468 ConfigurationParameters.numericFalse, 468 ConfigurationParameters.numericTrue,
469 (s,cf,p,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, 469 (s,cf,p,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
470 (s) => { return s.UnmanagedParams[0].shouldEnableFrictionCaching; }, 470 (s) => { return s.UnmanagedParams[0].shouldEnableFrictionCaching; },
471 (s,p,l,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = v; } ), 471 (s,p,l,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = v; } ),