diff options
author | Robert Adams | 2013-07-16 10:01:03 -0700 |
---|---|---|
committer | Robert Adams | 2013-07-22 10:27:21 -0700 |
commit | d0d654e2186c8b81c1150da89a549e4f7162a2b4 (patch) | |
tree | 3710604cbb3d3db2d7207ca85abcd9bb8cc87e51 /OpenSim/Region/Physics/BulletSPlugin | |
parent | BulletSim: only create vehicle prim actor when vehicles are enabled. (diff) | |
download | opensim-SC-d0d654e2186c8b81c1150da89a549e4f7162a2b4.zip opensim-SC-d0d654e2186c8b81c1150da89a549e4f7162a2b4.tar.gz opensim-SC-d0d654e2186c8b81c1150da89a549e4f7162a2b4.tar.bz2 opensim-SC-d0d654e2186c8b81c1150da89a549e4f7162a2b4.tar.xz |
BulletSim: change BSDynamics to expect to be passed a BSPrimLinkable
and start changing the logic to handle the base prim as a complex
object (ie, a linkset).
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 17 |
1 files 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 | |||
45 | private static string LogHeader = "[BULLETSIM VEHICLE]"; | 45 | private static string LogHeader = "[BULLETSIM VEHICLE]"; |
46 | 46 | ||
47 | // the prim this dynamic controller belongs to | 47 | // the prim this dynamic controller belongs to |
48 | private BSPrim ControllingPrim { get; set; } | 48 | private BSPrimLinkable ControllingPrim { get; set; } |
49 | 49 | ||
50 | private bool m_haveRegisteredForSceneEvents; | 50 | private bool m_haveRegisteredForSceneEvents; |
51 | 51 | ||
@@ -128,9 +128,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
128 | public BSDynamics(BSScene myScene, BSPrim myPrim, string actorName) | 128 | public BSDynamics(BSScene myScene, BSPrim myPrim, string actorName) |
129 | : base(myScene, myPrim, actorName) | 129 | : base(myScene, myPrim, actorName) |
130 | { | 130 | { |
131 | ControllingPrim = myPrim; | ||
132 | Type = Vehicle.TYPE_NONE; | 131 | Type = Vehicle.TYPE_NONE; |
133 | m_haveRegisteredForSceneEvents = false; | 132 | m_haveRegisteredForSceneEvents = false; |
133 | |||
134 | ControllingPrim = myPrim as BSPrimLinkable; | ||
135 | if (ControllingPrim == null) | ||
136 | { | ||
137 | // THIS CANNOT HAPPEN!! | ||
138 | } | ||
139 | VDetailLog("{0},Creation", ControllingPrim.LocalID); | ||
134 | } | 140 | } |
135 | 141 | ||
136 | // Return 'true' if this vehicle is doing vehicle things | 142 | // Return 'true' if this vehicle is doing vehicle things |
@@ -585,6 +591,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
585 | // Friction affects are handled by this vehicle code | 591 | // Friction affects are handled by this vehicle code |
586 | m_physicsScene.PE.SetFriction(ControllingPrim.PhysBody, BSParam.VehicleFriction); | 592 | m_physicsScene.PE.SetFriction(ControllingPrim.PhysBody, BSParam.VehicleFriction); |
587 | m_physicsScene.PE.SetRestitution(ControllingPrim.PhysBody, BSParam.VehicleRestitution); | 593 | m_physicsScene.PE.SetRestitution(ControllingPrim.PhysBody, BSParam.VehicleRestitution); |
594 | // ControllingPrim.Linkset.SetPhysicalFriction(BSParam.VehicleFriction); | ||
595 | // ControllingPrim.Linkset.SetPhysicalRestitution(BSParam.VehicleRestitution); | ||
588 | 596 | ||
589 | // Moderate angular movement introduced by Bullet. | 597 | // Moderate angular movement introduced by Bullet. |
590 | // TODO: possibly set AngularFactor and LinearFactor for the type of vehicle. | 598 | // TODO: possibly set AngularFactor and LinearFactor for the type of vehicle. |
@@ -595,17 +603,20 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
595 | 603 | ||
596 | // Vehicles report collision events so we know when it's on the ground | 604 | // Vehicles report collision events so we know when it's on the ground |
597 | m_physicsScene.PE.AddToCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); | 605 | m_physicsScene.PE.AddToCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); |
606 | // ControllingPrim.Linkset.SetPhysicalCollisionFlags(CollisionFlags.BS_VEHICLE_COLLISIONS); | ||
598 | 607 | ||
599 | Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(ControllingPrim.PhysShape.physShapeInfo, m_vehicleMass); | 608 | Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(ControllingPrim.PhysShape.physShapeInfo, m_vehicleMass); |
600 | ControllingPrim.Inertia = inertia * BSParam.VehicleInertiaFactor; | 609 | ControllingPrim.Inertia = inertia * BSParam.VehicleInertiaFactor; |
601 | m_physicsScene.PE.SetMassProps(ControllingPrim.PhysBody, m_vehicleMass, ControllingPrim.Inertia); | 610 | m_physicsScene.PE.SetMassProps(ControllingPrim.PhysBody, m_vehicleMass, ControllingPrim.Inertia); |
602 | m_physicsScene.PE.UpdateInertiaTensor(ControllingPrim.PhysBody); | 611 | m_physicsScene.PE.UpdateInertiaTensor(ControllingPrim.PhysBody); |
612 | // ControllingPrim.Linkset.ComputeLocalInertia(BSParam.VehicleInertiaFactor); | ||
603 | 613 | ||
604 | // Set the gravity for the vehicle depending on the buoyancy | 614 | // Set the gravity for the vehicle depending on the buoyancy |
605 | // TODO: what should be done if prim and vehicle buoyancy differ? | 615 | // TODO: what should be done if prim and vehicle buoyancy differ? |
606 | m_VehicleGravity = ControllingPrim.ComputeGravity(m_VehicleBuoyancy); | 616 | m_VehicleGravity = ControllingPrim.ComputeGravity(m_VehicleBuoyancy); |
607 | // The actual vehicle gravity is set to zero in Bullet so we can do all the application of same. | 617 | // The actual vehicle gravity is set to zero in Bullet so we can do all the application of same. |
608 | m_physicsScene.PE.SetGravity(ControllingPrim.PhysBody, Vector3.Zero); | 618 | m_physicsScene.PE.SetGravity(ControllingPrim.PhysBody, Vector3.Zero); |
619 | // ControllingPrim.Linkset.SetPhysicalGravity(Vector3.Zero); | ||
609 | 620 | ||
610 | VDetailLog("{0},BSDynamics.SetPhysicalParameters,mass={1},inert={2},vehGrav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}", | 621 | VDetailLog("{0},BSDynamics.SetPhysicalParameters,mass={1},inert={2},vehGrav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}", |
611 | ControllingPrim.LocalID, m_vehicleMass, ControllingPrim.Inertia, m_VehicleGravity, | 622 | ControllingPrim.LocalID, m_vehicleMass, ControllingPrim.Inertia, m_VehicleGravity, |
@@ -617,6 +628,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
617 | { | 628 | { |
618 | if (ControllingPrim.PhysBody.HasPhysicalBody) | 629 | if (ControllingPrim.PhysBody.HasPhysicalBody) |
619 | m_physicsScene.PE.RemoveFromCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); | 630 | m_physicsScene.PE.RemoveFromCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); |
631 | // ControllingPrim.Linkset.RemoveFromPhysicalCollisionFlags(CollisionFlags.BS_VEHICLE_COLLISIONS); | ||
620 | } | 632 | } |
621 | } | 633 | } |
622 | 634 | ||
@@ -629,6 +641,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
629 | // BSActor.Release() | 641 | // BSActor.Release() |
630 | public override void Dispose() | 642 | public override void Dispose() |
631 | { | 643 | { |
644 | VDetailLog("{0},Dispose", ControllingPrim.LocalID); | ||
632 | UnregisterForSceneEvents(); | 645 | UnregisterForSceneEvents(); |
633 | Type = Vehicle.TYPE_NONE; | 646 | Type = Vehicle.TYPE_NONE; |
634 | Enabled = false; | 647 | Enabled = false; |