From 13778c895ae8adca907781c9d8c3a9ada30814e0 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 15 Jan 2013 01:44:34 -0800 Subject: BulletSim: by default, turn on continuious collision detection (CCD) and enable friction computation caching. Remove dangerous BulletSim settings from OpenSimDefaults.ini. --- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Physics') 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 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); }, (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ), new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" , - 0f, // set to zero to disable + 0.3f, // set to zero to disable (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); }, (s) => { return CcdMotionThreshold; }, (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); }, (s,o,v) => { s.PE.SetCcdMotionThreshold(o.PhysBody, v); } ), new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" , - 0f, + 0.2f, (s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); }, (s) => { return CcdSweptSphereRadius; }, (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); }, @@ -465,7 +465,7 @@ public static class BSParam (s) => { return s.UnmanagedParams[0].shouldSplitSimulationIslands; }, (s,p,l,v) => { s.UnmanagedParams[0].shouldSplitSimulationIslands = v; } ), new ParameterDefn("ShouldEnableFrictionCaching", "Enable friction computation caching", - ConfigurationParameters.numericFalse, + ConfigurationParameters.numericTrue, (s,cf,p,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, (s) => { return s.UnmanagedParams[0].shouldEnableFrictionCaching; }, (s,p,l,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = v; } ), -- cgit v1.1 From 0374b2a0b4a88706f5269a55bac7aa2640f82256 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 15 Jan 2013 02:21:38 -0800 Subject: BulletSim: fix logic for enabling unmanaged code debug messages. Free pinned memory when physics engine is unloaded. --- OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Physics') 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 // If Debug logging level, enable logging from the unmanaged code m_DebugLogCallbackHandle = null; - if (BSScene.m_log.IsDebugEnabled || PhysicsScene.PhysicsLogging.Enabled) + if (BSScene.m_log.IsDebugEnabled && PhysicsScene.PhysicsLogging.Enabled) { BSScene.m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", BSScene.LogHeader); if (PhysicsScene.PhysicsLogging.Enabled) @@ -212,6 +212,19 @@ public override void Shutdown(BulletWorld world) { BulletWorldUnman worldu = world as BulletWorldUnman; BSAPICPP.Shutdown2(worldu.ptr); + + if (m_paramsHandle.IsAllocated) + { + m_paramsHandle.Free(); + } + if (m_collisionArrayPinnedHandle.IsAllocated) + { + m_collisionArrayPinnedHandle.Free(); + } + if (m_updateArrayPinnedHandle.IsAllocated) + { + m_updateArrayPinnedHandle.Free(); + } } public override bool PushUpdate(BulletBody obj) -- cgit v1.1 From 181d4c6fcbf1560fcf100b5a6ec98d15ad2fe5cc Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 15 Jan 2013 02:58:14 -0800 Subject: BulletSim: temporarily disable banking and direction deflection because the computations are wrong. Add VehicleTorqueImpulse routines. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 32 ++++++++++++++++------ .../Physics/BulletSPlugin/BSLinksetCompound.cs | 7 +++-- 2 files changed, 29 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index bcebaec..f5826bc 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -124,9 +124,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin static readonly float PIOverTwo = ((float)Math.PI) / 2f; // For debugging, flags to turn on and off individual corrections. - private bool enableAngularVerticalAttraction = true; - private bool enableAngularDeflection = true; - private bool enableAngularBanking = true; + private bool enableAngularVerticalAttraction; + private bool enableAngularDeflection; + private bool enableAngularBanking; public BSDynamics(BSScene myScene, BSPrim myPrim) { @@ -141,8 +141,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin public void SetupVehicleDebugging() { enableAngularVerticalAttraction = true; - enableAngularDeflection = true; - enableAngularBanking = true; + enableAngularDeflection = false; + enableAngularBanking = false; if (BSParam.VehicleDebuggingEnabled != ConfigurationParameters.numericFalse) { enableAngularVerticalAttraction = false; @@ -649,6 +649,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin private Quaternion m_knownOrientation; private Vector3 m_knownRotationalVelocity; private Vector3 m_knownRotationalForce; + private Vector3 m_knownRotationalImpulse; private Vector3 m_knownForwardVelocity; // vehicle relative forward speed private const int m_knownChangedPosition = 1 << 0; @@ -658,9 +659,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin private const int m_knownChangedOrientation = 1 << 4; private const int m_knownChangedRotationalVelocity = 1 << 5; private const int m_knownChangedRotationalForce = 1 << 6; - private const int m_knownChangedTerrainHeight = 1 << 7; - private const int m_knownChangedWaterLevel = 1 << 8; - private const int m_knownChangedForwardVelocity = 1 << 9; + private const int m_knownChangedRotationalImpulse = 1 << 7; + private const int m_knownChangedTerrainHeight = 1 << 8; + private const int m_knownChangedWaterLevel = 1 << 9; + private const int m_knownChangedForwardVelocity = 1 <<10; private void ForgetKnownVehicleProperties() { @@ -700,6 +702,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin PhysicsScene.PE.SetInterpolationAngularVelocity(Prim.PhysBody, m_knownRotationalVelocity); } + if ((m_knownChanged & m_knownChangedRotationalImpulse) != 0) + Prim.ApplyTorqueImpulse((Vector3)m_knownRotationalImpulse, true /*inTaintTime*/); + if ((m_knownChanged & m_knownChangedRotationalForce) != 0) { Prim.AddAngularForce((Vector3)m_knownRotationalForce, false /*pushForce*/, true /*inTaintTime*/); @@ -843,6 +848,17 @@ namespace OpenSim.Region.Physics.BulletSPlugin m_knownChanged |= m_knownChangedRotationalForce; m_knownHas |= m_knownChangedRotationalForce; } + private void VehicleAddRotationalImpulse(Vector3 pImpulse) + { + if ((m_knownHas & m_knownChangedRotationalImpulse) == 0) + { + m_knownRotationalImpulse = Vector3.Zero; + m_knownHas |= m_knownChangedRotationalImpulse; + } + m_knownRotationalImpulse += pImpulse; + m_knownChanged |= m_knownChangedRotationalImpulse; + } + // Vehicle relative forward velocity private Vector3 VehicleForwardVelocity { 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 && PhysicsScene.TerrainManager.IsWithinKnownTerrain(LinksetRoot.RawPosition)) { // TODO: replace this with are calculation of the child prim's orientation and pos. - updated.LinksetInfo = null; - ScheduleRebuild(updated); + // TODO: for the moment, don't rebuild the compound shape. + // This is often just the car turning its wheels. When we can just reorient the one + // member shape of the compound shape, the overhead of rebuilding won't be a problem. + // updated.LinksetInfo = null; + // ScheduleRebuild(updated); } } -- cgit v1.1 From 021964c6e0648cf0e75b46864bef55afb7ff0a1f Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 15 Jan 2013 04:24:24 -0800 Subject: BulletSim: tweeks to improve hover. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index f5826bc..e434412 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1047,16 +1047,32 @@ namespace OpenSim.Region.Physics.BulletSPlugin else { // Error is positive if below the target and negative if above. - float verticalError = m_VhoverTargetHeight - VehiclePosition.Z; - float verticalCorrectionVelocity = verticalError / m_VhoverTimescale * pTimestep; + Vector3 hpos = VehiclePosition; + float verticalError = m_VhoverTargetHeight - hpos.Z; + float verticalCorrection = verticalError / m_VhoverTimescale; + verticalCorrection *= m_VhoverEfficiency; + + hpos.Z += verticalCorrection; + VehiclePosition = hpos; + + // Since we are hovering, we need to do the opposite of falling -- get rid of world Z + Vector3 vel = VehicleVelocity; + vel.Z = 0f; + VehicleVelocity = vel; + + /* + float verticalCorrectionVelocity = verticalError / m_VhoverTimescale; + Vector3 verticalCorrection = new Vector3(0f, 0f, verticalCorrectionVelocity); + verticalCorrection *= m_vehicleMass; // TODO: implement m_VhoverEfficiency correctly - VehicleAddForceImpulse(new Vector3(0f, 0f, verticalCorrectionVelocity)); + VehicleAddForceImpulse(verticalCorrection); + */ - VDetailLog("{0}, MoveLinear,hover,pos={1},eff={2},hoverTS={3},height={4},target={5},err={6},corrVel={7}", + VDetailLog("{0}, MoveLinear,hover,pos={1},eff={2},hoverTS={3},height={4},target={5},err={6},corr={7}", Prim.LocalID, VehiclePosition, m_VhoverEfficiency, m_VhoverTimescale, m_VhoverHeight, m_VhoverTargetHeight, - verticalError, verticalCorrectionVelocity); + verticalError, verticalCorrection); } } -- cgit v1.1