From 2f4a729d408acfd311c8b7bc53d2cbff9d2ddfad Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 29 Jun 2013 06:42:38 -0700 Subject: BulletSim: add inTaintTime parameter to collision cache clear function. --- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 6437b04..d17c8e7 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -706,7 +706,7 @@ public static class BSParam new ParameterDefn("ResetBroadphasePool", "Setting this is any value resets the broadphase collision pool", 0f, (s) => { return 0f; }, - (s,v) => { BSParam.ResetBroadphasePoolTainted(s, v); } ), + (s,v) => { BSParam.ResetBroadphasePoolTainted(s, v, false /* inTaintTime */); } ), new ParameterDefn("ResetConstraintSolver", "Setting this is any value resets the constraint solver", 0f, (s) => { return 0f; }, @@ -792,10 +792,10 @@ public static class BSParam // ===================================================================== // There are parameters that, when set, cause things to happen in the physics engine. // This causes the broadphase collision cache to be cleared. - private static void ResetBroadphasePoolTainted(BSScene pPhysScene, float v) + private static void ResetBroadphasePoolTainted(BSScene pPhysScene, float v, bool inTaintTime) { BSScene physScene = pPhysScene; - physScene.TaintedObject("BSParam.ResetBroadphasePoolTainted", delegate() + physScene.TaintedObject(inTaintTime, "BSParam.ResetBroadphasePoolTainted", delegate() { physScene.PE.ResetBroadphasePool(physScene.World); }); -- cgit v1.1 From 23516717e48095011c1c06d64785ef7d91754ff2 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 30 Jun 2013 13:39:58 -0700 Subject: BulletSim: a better version of llMoveToTarget that doesn't go crazy. There is still some overshoot but mostly fixes Mantis 6693. Fix bug where moveToTarget was active for non-physical objects and while selected. Fix bug where move target was not getting changed if the script changed the target during a move. --- .../Physics/BulletSPlugin/BSActorMoveToTarget.cs | 80 +++++++++++++++++++--- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 2 +- OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | 15 ++-- .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 1 + OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 19 ++++- 5 files changed, 98 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs index 75ff24e..bdf4bc0 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorMoveToTarget.cs @@ -50,7 +50,8 @@ public class BSActorMoveToTarget : BSActor // BSActor.isActive public override bool isActive { - get { return Enabled; } + // MoveToTarget only works on physical prims + get { return Enabled && m_controllingPrim.IsPhysicallyActive; } } // Release any connections and resources used by the actor. @@ -102,16 +103,28 @@ public class BSActorMoveToTarget : BSActor // We're taking over after this. m_controllingPrim.ZeroMotion(true); - m_targetMotor = new BSVMotor("BSActorMoveToTargget.Activate", - m_controllingPrim.MoveToTargetTau, // timeScale - BSMotor.Infinite, // decay time scale - 1f // efficiency + /* Someday use the PID controller + m_targetMotor = new BSPIDVMotor("BSActorMoveToTarget-" + m_controllingPrim.LocalID.ToString()); + m_targetMotor.TimeScale = m_controllingPrim.MoveToTargetTau; + m_targetMotor.Efficiency = 1f; + */ + m_targetMotor = new BSVMotor("BSActorMoveToTarget-" + m_controllingPrim.LocalID.ToString(), + m_controllingPrim.MoveToTargetTau, // timeScale + BSMotor.Infinite, // decay time scale + 1f // efficiency ); m_targetMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG so motor will output detail log messages. m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget); m_targetMotor.SetCurrent(m_controllingPrim.RawPosition); - m_physicsScene.BeforeStep += Mover; + // m_physicsScene.BeforeStep += Mover; + m_physicsScene.BeforeStep += Mover2; + } + else + { + // If already allocated, make sure the target and other paramters are current + m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget); + m_targetMotor.SetCurrent(m_controllingPrim.RawPosition); } } @@ -119,12 +132,16 @@ public class BSActorMoveToTarget : BSActor { if (m_targetMotor != null) { - m_physicsScene.BeforeStep -= Mover; + // m_physicsScene.BeforeStep -= Mover; + m_physicsScene.BeforeStep -= Mover2; m_targetMotor = null; } } - // Called just before the simulation step. Update the vertical position for hoverness. + // Origional mover that set the objects position to move to the target. + // The problem was that gravity would keep trying to push the object down so + // the overall downward velocity would increase to infinity. + // Called just before the simulation step. private void Mover(float timeStep) { // Don't do hovering while the object is selected. @@ -142,6 +159,7 @@ public class BSActorMoveToTarget : BSActor m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover,zeroMovement,movePos={1},pos={2},mass={3}", m_controllingPrim.LocalID, movePosition, m_controllingPrim.RawPosition, m_controllingPrim.Mass); m_controllingPrim.ForcePosition = m_targetMotor.TargetValue; + m_controllingPrim.ForceVelocity = OMV.Vector3.Zero; // Setting the position does not cause the physics engine to generate a property update. Force it. m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody); } @@ -151,7 +169,51 @@ public class BSActorMoveToTarget : BSActor // Setting the position does not cause the physics engine to generate a property update. Force it. m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody); } - m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover,move,fromPos={1},movePos={2}", m_controllingPrim.LocalID, origPosition, movePosition); + m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover,move,fromPos={1},movePos={2}", + m_controllingPrim.LocalID, origPosition, movePosition); + } + + // Version of mover that applies forces to move the physical object to the target. + // Also overcomes gravity so the object doesn't just drop to the ground. + // Called just before the simulation step. + private void Mover2(float timeStep) + { + // Don't do hovering while the object is selected. + if (!isActive) + return; + + OMV.Vector3 origPosition = m_controllingPrim.RawPosition; // DEBUG DEBUG (for printout below) + OMV.Vector3 addedForce = OMV.Vector3.Zero; + + // CorrectionVector is the movement vector required this step + OMV.Vector3 correctionVector = m_targetMotor.Step(timeStep, m_controllingPrim.RawPosition); + + // If we are very close to our target, turn off the movement motor. + if (m_targetMotor.ErrorIsZero()) + { + m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover3,zeroMovement,pos={1},mass={2}", + m_controllingPrim.LocalID, m_controllingPrim.RawPosition, m_controllingPrim.Mass); + m_controllingPrim.ForcePosition = m_targetMotor.TargetValue; + m_controllingPrim.ForceVelocity = OMV.Vector3.Zero; + // Setting the position does not cause the physics engine to generate a property update. Force it. + m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody); + } + else + { + // First force to move us there -- the motor return a timestep scaled value. + addedForce = correctionVector / timeStep; + // Remove the existing velocity (only the moveToTarget force counts) + addedForce -= m_controllingPrim.RawVelocity; + // Overcome gravity. + addedForce -= m_controllingPrim.Gravity; + + // Add enough force to overcome the mass of the object + addedForce *= m_controllingPrim.Mass; + + m_controllingPrim.AddForce(addedForce, false /* pushForce */, true /* inTaintTime */); + } + m_physicsScene.DetailLog("{0},BSActorMoveToTarget.Mover3,move,fromPos={1},addedForce={2}", + m_controllingPrim.LocalID, origPosition, addedForce); } } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 48f842e..5ef6992 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -626,7 +626,7 @@ public sealed class BSCharacter : BSPhysObject OMV.Vector3 addForce = force / PhysScene.LastTimeStep; AddForce(addForce, pushforce, false); } - private void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { + public override void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { if (force.IsFinite()) { OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs index ef662b5..1214703 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs @@ -144,7 +144,6 @@ public class BSVMotor : BSMotor Vector3 correction = Vector3.Zero; Vector3 error = TargetValue - CurrentValue; - LastError = error; if (!ErrorIsZero(error)) { correction = StepError(timeStep, error); @@ -179,6 +178,7 @@ public class BSVMotor : BSMotor MDetailLog("{0}, BSVMotor.Step,zero,{1},origTgt={2},origCurr={3},currTgt={4},currCurr={5}", BSScene.DetailLogZero, UseName, origCurrVal, origTarget, TargetValue, CurrentValue); } + LastError = error; return correction; } @@ -293,7 +293,6 @@ public class BSFMotor : BSMotor float correction = 0f; float error = TargetValue - CurrentValue; - LastError = error; if (!ErrorIsZero(error)) { correction = StepError(timeStep, error); @@ -328,6 +327,7 @@ public class BSFMotor : BSMotor MDetailLog("{0}, BSFMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}", BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue); } + LastError = error; return CurrentValue; } @@ -363,7 +363,7 @@ public class BSFMotor : BSMotor // ============================================================================ // ============================================================================ -// Proportional, Integral, Derivitive Motor +// Proportional, Integral, Derivitive ("PID") Motor // Good description at http://www.answers.com/topic/pid-controller . Includes processes for choosing p, i and d factors. public class BSPIDVMotor : BSVMotor { @@ -434,15 +434,14 @@ public class BSPIDVMotor : BSVMotor // A simple derivitive is the rate of change from the last error. Vector3 derivitive = (error - LastError) * timeStep; - LastError = error; // Correction = (proportionOfPresentError + accumulationOfPastError + rateOfChangeOfError) - Vector3 ret = error * timeStep * proportionFactor * FactorMix.X - + RunningIntegration * integralFactor * FactorMix.Y - + derivitive * derivFactor * FactorMix.Z + Vector3 ret = error / TimeScale * timeStep * proportionFactor * FactorMix.X + + RunningIntegration / TimeScale * integralFactor * FactorMix.Y + + derivitive / TimeScale * derivFactor * FactorMix.Z ; - MDetailLog("{0},BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}", + MDetailLog("{0}, BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}", BSScene.DetailLogZero, timeStep, error, RunningIntegration, derivitive, ret); return ret; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index a4c5e08..a0d5c42 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -210,6 +210,7 @@ public abstract class BSPhysObject : PhysicsActor AddAngularForce(force, pushforce, false); } public abstract void AddAngularForce(OMV.Vector3 force, bool pushforce, bool inTaintTime); + public abstract void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime); public abstract OMV.Vector3 ForceRotationalVelocity { get; set; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 95bdc7b..90f74df 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -450,6 +450,9 @@ public class BSPrim : BSPhysObject Gravity = ComputeGravity(Buoyancy); PhysScene.PE.SetGravity(PhysBody, Gravity); + OMV.Vector3 currentScale = PhysScene.PE.GetLocalScaling(PhysShape.physShapeInfo); // DEBUG DEBUG + DetailLog("{0},BSPrim.UpdateMassProperties,currentScale{1},shape={2}", LocalID, currentScale, PhysShape.physShapeInfo); // DEBUG DEBUG + Inertia = PhysScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass); PhysScene.PE.SetMassProps(PhysBody, physMass, Inertia); PhysScene.PE.UpdateInertiaTensor(PhysBody); @@ -1040,6 +1043,20 @@ public class BSPrim : BSPhysObject } } + public override OMV.Vector3 PIDTarget + { + set + { + base.PIDTarget = value; + BSActor actor; + if (PhysicalActors.TryGetActor(MoveToTargetActorName, out actor)) + { + // if the actor exists, tell it to refresh its values. + actor.Refresh(); + } + + } + } // Used for llSetHoverHeight and maybe vehicle height // Hover Height will override MoveTo target's Z public override bool PIDHoverActive { @@ -1063,7 +1080,7 @@ public class BSPrim : BSPhysObject // Applying a force just adds this to the total force on the object. // This added force will only last the next simulation tick. - public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { + public override void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { // for an object, doesn't matter if force is a pushforce or not if (IsPhysicallyActive) { -- cgit v1.1 From 425d2a2a972de34c1853c6049727d4c0eea38af4 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 30 Jun 2013 13:48:27 -0700 Subject: BulletSim: set linkset type to be prim specific rather than a simulator wide default. This allows individual prims to differ in the underlying linkset implementation. --- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 16 ++++------------ .../Region/Physics/BulletSPlugin/BSLinksetCompound.cs | 2 -- OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 5 ++++- 3 files changed, 8 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 76c2187..ad8e10f 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -33,14 +33,6 @@ using OMV = OpenMetaverse; namespace OpenSim.Region.Physics.BulletSPlugin { -// A BSPrim can get individual information about its linkedness attached -// to it through an instance of a subclass of LinksetInfo. -// Each type of linkset will define the information needed for its type. -public abstract class BSLinksetInfo -{ - public virtual void Clear() { } -} - public abstract class BSLinkset { // private static string LogHeader = "[BULLETSIM LINKSET]"; @@ -56,15 +48,15 @@ public abstract class BSLinkset { BSLinkset ret = null; - switch ((int)BSParam.LinksetImplementation) + switch (parent.LinksetType) { - case (int)LinksetImplementation.Constraint: + case LinksetImplementation.Constraint: ret = new BSLinksetConstraints(physScene, parent); break; - case (int)LinksetImplementation.Compound: + case LinksetImplementation.Compound: ret = new BSLinksetCompound(physScene, parent); break; - case (int)LinksetImplementation.Manual: + case LinksetImplementation.Manual: // ret = new BSLinksetManual(physScene, parent); break; default: diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 350a5d1..308cf13 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs @@ -238,7 +238,6 @@ public sealed class BSLinksetCompound : BSLinkset // there will already be a rebuild scheduled. DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild.schedulingRebuild,whichUpdated={1}", updated.LocalID, whichUpdated); - updated.LinksetInfo = null; // setting to 'null' causes relative position to be recomputed. ScheduleRebuild(updated); } } @@ -294,7 +293,6 @@ public sealed class BSLinksetCompound : BSLinkset child.LocalID, child.PhysBody.AddrString); // Cause the child's body to be rebuilt and thus restored to normal operation - child.LinksetInfo = null; child.ForceBodyShapeRebuild(false); if (!HasAnyChildren) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 235da78..87eed98 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -41,12 +41,15 @@ public class BSPrimLinkable : BSPrimDisplaced // The index of this child prim. public int LinksetChildIndex { get; set; } - public BSLinksetInfo LinksetInfo { get; set; } + public BSLinkset.LinksetImplementation LinksetType { get; set; } public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical) { + // Default linkset implementation for this prim + LinksetType = (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation; + Linkset = BSLinkset.Factory(PhysScene, this); PhysScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate() -- cgit v1.1 From 9d5ae759504f01dceac5d3f859da1e43e28797ad Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 30 Jun 2013 17:06:27 -0700 Subject: BulletSim: remove the handle to the vehicle actor and cause routines that need it to look it up. --- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 70 ++++++++++++++++------ .../Physics/BulletSPlugin/Tests/BasicVehicles.cs | 32 +++++----- 2 files changed, 70 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 90f74df..b2947c6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -70,18 +70,17 @@ public class BSPrim : BSPhysObject private int CrossingFailures { get; set; } // Keep a handle to the vehicle actor so it is easy to set parameters on same. - public BSDynamics VehicleActor; public const string VehicleActorName = "BasicVehicle"; // Parameters for the hover actor - public const string HoverActorName = "HoverActor"; + public const string HoverActorName = "BSPrim.HoverActor"; // Parameters for the axis lock actor public const String LockedAxisActorName = "BSPrim.LockedAxis"; // Parameters for the move to target actor - public const string MoveToTargetActorName = "MoveToTargetActor"; + public const string MoveToTargetActorName = "BSPrim.MoveToTargetActor"; // Parameters for the setForce and setTorque actors - public const string SetForceActorName = "SetForceActor"; - public const string SetTorqueActorName = "SetTorqueActor"; + public const string SetForceActorName = "BSPrim.SetForceActor"; + public const string SetTorqueActorName = "BSPrim.SetTorqueActor"; public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) @@ -100,9 +99,8 @@ public class BSPrim : BSPhysObject _isPhysical = pisPhysical; _isVolumeDetect = false; - // We keep a handle to the vehicle actor so we can set vehicle parameters later. - VehicleActor = new BSDynamics(PhysScene, this, VehicleActorName); - PhysicalActors.Add(VehicleActorName, VehicleActor); + // Add a dynamic vehicle to our set of actors that can move this prim. + PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName)); _mass = CalculateMass(); @@ -505,9 +503,25 @@ public class BSPrim : BSPhysObject } } + // Find and return a handle to the current vehicle actor. + // Return 'null' if there is no vehicle actor. + public BSDynamics GetVehicleActor() + { + BSDynamics ret = null; + BSActor actor; + if (PhysicalActors.TryGetActor(VehicleActorName, out actor)) + { + ret = actor as BSDynamics; + } + return ret; + } public override int VehicleType { get { - return (int)VehicleActor.Type; + int ret = (int)Vehicle.TYPE_NONE; + BSDynamics vehicleActor = GetVehicleActor(); + if (vehicleActor != null) + ret = (int)vehicleActor.Type; + return ret; } set { Vehicle type = (Vehicle)value; @@ -518,8 +532,12 @@ public class BSPrim : BSPhysObject // change all the parameters. Like a plane changing to CAR when on the // ground. In this case, don't want to zero motion. // ZeroMotion(true /* inTaintTime */); - VehicleActor.ProcessTypeChange(type); - ActivateIfPhysical(false); + BSDynamics vehicleActor = GetVehicleActor(); + if (vehicleActor != null) + { + vehicleActor.ProcessTypeChange(type); + ActivateIfPhysical(false); + } }); } } @@ -527,31 +545,47 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() { - VehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); - ActivateIfPhysical(false); + BSDynamics vehicleActor = GetVehicleActor(); + if (vehicleActor != null) + { + vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); + ActivateIfPhysical(false); + } }); } public override void VehicleVectorParam(int param, OMV.Vector3 value) { PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() { - VehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); - ActivateIfPhysical(false); + BSDynamics vehicleActor = GetVehicleActor(); + if (vehicleActor != null) + { + vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); + ActivateIfPhysical(false); + } }); } public override void VehicleRotationParam(int param, OMV.Quaternion rotation) { PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() { - VehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); - ActivateIfPhysical(false); + BSDynamics vehicleActor = GetVehicleActor(); + if (vehicleActor != null) + { + vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); + ActivateIfPhysical(false); + } }); } public override void VehicleFlags(int param, bool remove) { PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() { - VehicleActor.ProcessVehicleFlags(param, remove); + BSDynamics vehicleActor = GetVehicleActor(); + if (vehicleActor != null) + { + vehicleActor.ProcessVehicleFlags(param, remove); + } }); } diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs index b040e21..583c436 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs @@ -114,21 +114,25 @@ public class BasicVehicles : OpenSimTestCase // Instead the appropriate values are set and calls are made just the parts of the // controller we want to exercise. Stepping the physics engine then applies // the actions of that one feature. - TestVehicle.VehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency); - TestVehicle.VehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale); - TestVehicle.VehicleActor.enableAngularVerticalAttraction = true; - - TestVehicle.IsPhysical = true; - PhysicsScene.ProcessTaints(); - - // Step the simulator a bunch of times and vertical attraction should orient the vehicle up - for (int ii = 0; ii < simSteps; ii++) + BSDynamics vehicleActor = TestVehicle.GetVehicleActor(); + if (vehicleActor != null) { - TestVehicle.VehicleActor.ForgetKnownVehicleProperties(); - TestVehicle.VehicleActor.ComputeAngularVerticalAttraction(); - TestVehicle.VehicleActor.PushKnownChanged(); - - PhysicsScene.Simulate(simulationTimeStep); + vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency); + vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale); + vehicleActor.enableAngularVerticalAttraction = true; + + TestVehicle.IsPhysical = true; + PhysicsScene.ProcessTaints(); + + // Step the simulator a bunch of times and vertical attraction should orient the vehicle up + for (int ii = 0; ii < simSteps; ii++) + { + vehicleActor.ForgetKnownVehicleProperties(); + vehicleActor.ComputeAngularVerticalAttraction(); + vehicleActor.PushKnownChanged(); + + PhysicsScene.Simulate(simulationTimeStep); + } } TestVehicle.IsPhysical = false; -- cgit v1.1 From c24c99f4bab0ef2e926ebc46235ffed25fdd9add Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 30 Jun 2013 19:08:15 -0700 Subject: BulletSim: fix an occasional crash with flushing log files. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index dec6b6f..155d143 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -223,8 +223,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters // can be left in and every call doesn't have to check for null. if (m_physicsLoggingEnabled) { - PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes); - PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output error messages. + PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes, m_physicsLoggingDoFlush); + PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output its own error messages. } else { @@ -1106,8 +1106,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters public void DetailLog(string msg, params Object[] args) { PhysicsLogging.Write(msg, args); - // Add the Flush() if debugging crashes. Gets all the messages written out. - if (m_physicsLoggingDoFlush) PhysicsLogging.Flush(); } // Used to fill in the LocalID when there isn't one. It's the correct number of characters. public const string DetailLogZero = "0000000000"; -- cgit v1.1 From 8eb86c9ec91ee41699ab455fc5e788a4bff53071 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 30 Jun 2013 19:22:43 -0700 Subject: BulletSim: add the reset of the last commit for flush log file problems. Fix small typo in one log message. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 2 +- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 07e87d1..aa247dd 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1276,7 +1276,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin VehicleAddForce(appliedGravity); - VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={3}", + VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={5}", ControllingPrim.LocalID, m_VehicleGravity, ControllingPrim.IsColliding, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity); } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 155d143..1645c98 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -223,7 +223,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters // can be left in and every call doesn't have to check for null. if (m_physicsLoggingEnabled) { - PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes, m_physicsLoggingDoFlush); + PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes, m_physicsLoggingDoFlush); PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output its own error messages. } else -- cgit v1.1