From ed71c939fc22059b03572fe6380fcc754c89a284 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 31 Jan 2013 10:26:53 -0800 Subject: BulletSim: make sure vehicle physical properties are set when going physical by delaying setting until pre-step time. Change vehicle.Refresh() to schedule the pre-step setting. Comments and updating of TODO list. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 05ab180..8ecf2ff 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -581,9 +581,18 @@ namespace OpenSim.Region.Physics.BulletSPlugin } #endregion // Vehicle parameter setting + public void Refresh() + { + // If asking for a refresh, reset the physical parameters before the next simulation step. + PhysicsScene.PostTaintObject("BSDynamics.Refresh", Prim.LocalID, delegate() + { + SetPhysicalParameters(); + }); + } + // Some of the properties of this prim may have changed. // Do any updating needed for a vehicle - public void Refresh() + private void SetPhysicalParameters() { if (IsActive) { @@ -614,7 +623,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin // The actual vehicle gravity is set to zero in Bullet so we can do all the application of same. PhysicsScene.PE.SetGravity(Prim.PhysBody, Vector3.Zero); - VDetailLog("{0},BSDynamics.Refresh,mass={1},inert={2},grav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}", + VDetailLog("{0},BSDynamics.SetPhysicalParameters,mass={1},inert={2},vehGrav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}", Prim.LocalID, m_vehicleMass, Prim.Inertia, m_VehicleGravity, BSParam.VehicleAngularDamping, BSParam.VehicleFriction, BSParam.VehicleRestitution, BSParam.VehicleLinearFactor, BSParam.VehicleAngularFactor @@ -622,26 +631,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin } else { - PhysicsScene.PE.RemoveFromCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); + if (Prim.PhysBody.HasPhysicalBody) + PhysicsScene.PE.RemoveFromCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); } } public bool RemoveBodyDependencies(BSPhysObject prim) { - // If active, we need to add our properties back when the body is rebuilt. - return IsActive; - } - - public void RestoreBodyDependencies(BSPhysObject prim) - { - if (Prim.LocalID != prim.LocalID) - { - // The call should be on us by our prim. Error if not. - PhysicsScene.Logger.ErrorFormat("{0} RestoreBodyDependencies: called by not my prim. passedLocalID={1}, vehiclePrimLocalID={2}", - LogHeader, prim.LocalID, Prim.LocalID); - return; - } Refresh(); + return IsActive; } #region Known vehicle value functions -- cgit v1.1