From 75686e0e49308a21ca013d246544f88cd8e90cbd Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 23 Jul 2013 08:13:56 -0700 Subject: Revert "Revert "BulletSim: change BSDynamics to expect to be passed a BSPrimLinkable"" Found that the vehicle movement problem was not caused by these physics changes. This reverts commit 7b187deb19517aa7c880458894643a5448566a94. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 1540df1..82d7c44 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin private static string LogHeader = "[BULLETSIM VEHICLE]"; // the prim this dynamic controller belongs to - private BSPrim ControllingPrim { get; set; } + private BSPrimLinkable ControllingPrim { get; set; } private bool m_haveRegisteredForSceneEvents; @@ -128,9 +128,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin public BSDynamics(BSScene myScene, BSPrim myPrim, string actorName) : base(myScene, myPrim, actorName) { - ControllingPrim = myPrim; Type = Vehicle.TYPE_NONE; m_haveRegisteredForSceneEvents = false; + + ControllingPrim = myPrim as BSPrimLinkable; + if (ControllingPrim == null) + { + // THIS CANNOT HAPPEN!! + } + VDetailLog("{0},Creation", ControllingPrim.LocalID); } // Return 'true' if this vehicle is doing vehicle things @@ -585,6 +591,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Friction affects are handled by this vehicle code m_physicsScene.PE.SetFriction(ControllingPrim.PhysBody, BSParam.VehicleFriction); m_physicsScene.PE.SetRestitution(ControllingPrim.PhysBody, BSParam.VehicleRestitution); + // ControllingPrim.Linkset.SetPhysicalFriction(BSParam.VehicleFriction); + // ControllingPrim.Linkset.SetPhysicalRestitution(BSParam.VehicleRestitution); // Moderate angular movement introduced by Bullet. // TODO: possibly set AngularFactor and LinearFactor for the type of vehicle. @@ -595,17 +603,20 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Vehicles report collision events so we know when it's on the ground m_physicsScene.PE.AddToCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); + // ControllingPrim.Linkset.SetPhysicalCollisionFlags(CollisionFlags.BS_VEHICLE_COLLISIONS); Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(ControllingPrim.PhysShape.physShapeInfo, m_vehicleMass); ControllingPrim.Inertia = inertia * BSParam.VehicleInertiaFactor; m_physicsScene.PE.SetMassProps(ControllingPrim.PhysBody, m_vehicleMass, ControllingPrim.Inertia); m_physicsScene.PE.UpdateInertiaTensor(ControllingPrim.PhysBody); + // ControllingPrim.Linkset.ComputeLocalInertia(BSParam.VehicleInertiaFactor); // Set the gravity for the vehicle depending on the buoyancy // TODO: what should be done if prim and vehicle buoyancy differ? m_VehicleGravity = ControllingPrim.ComputeGravity(m_VehicleBuoyancy); // The actual vehicle gravity is set to zero in Bullet so we can do all the application of same. m_physicsScene.PE.SetGravity(ControllingPrim.PhysBody, Vector3.Zero); + // ControllingPrim.Linkset.SetPhysicalGravity(Vector3.Zero); VDetailLog("{0},BSDynamics.SetPhysicalParameters,mass={1},inert={2},vehGrav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}", ControllingPrim.LocalID, m_vehicleMass, ControllingPrim.Inertia, m_VehicleGravity, @@ -617,6 +628,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin { if (ControllingPrim.PhysBody.HasPhysicalBody) m_physicsScene.PE.RemoveFromCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); + // ControllingPrim.Linkset.RemoveFromPhysicalCollisionFlags(CollisionFlags.BS_VEHICLE_COLLISIONS); } } @@ -629,6 +641,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin // BSActor.Release() public override void Dispose() { + VDetailLog("{0},Dispose", ControllingPrim.LocalID); UnregisterForSceneEvents(); Type = Vehicle.TYPE_NONE; Enabled = false; -- cgit v1.1