From b77d354e6dcf1eb31486f0db3236780f63f23844 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 19 Feb 2012 13:21:01 +0000 Subject: [PATCH] moved vehicle from SOG to SOP --- .../Scenes/{SOGVehicle.cs => SOPVehicle.cs} | 6 +- .../Framework/Scenes/SceneObjectGroup.cs | 90 ------------------- .../Framework/Scenes/SceneObjectPart.cs | 87 +++++++++++++++--- 3 files changed, 79 insertions(+), 104 deletions(-) rename OpenSim/Region/Framework/Scenes/{SOGVehicle.cs => SOPVehicle.cs} (99%) diff --git a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs similarity index 99% rename from OpenSim/Region/Framework/Scenes/SOGVehicle.cs rename to OpenSim/Region/Framework/Scenes/SOPVehicle.cs index 5651de39eb..39786bd625 100644 --- a/OpenSim/Region/Framework/Scenes/SOGVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs @@ -36,7 +36,7 @@ using OpenSim.Region.Framework.Scenes.Serialization; namespace OpenSim.Region.Framework.Scenes { - public class SOGVehicle + public class SOPVehicle { public VehicleData vd; @@ -45,7 +45,7 @@ namespace OpenSim.Region.Framework.Scenes get { return vd.m_type; } } - public SOGVehicle() + public SOPVehicle() { vd = new VehicleData(); ProcessTypeChange(Vehicle.TYPE_NONE); // is needed? @@ -259,7 +259,7 @@ namespace OpenSim.Region.Framework.Scenes vd.m_bankingEfficiency = 0; vd.m_bankingMix = 1; vd.m_bankingTimescale = 1000; - vd.m_verticalAttractionEfficiency = 0; + vd.m_verticalAttractionEfficiency = 0; vd.m_verticalAttractionTimescale = 1000; vd.m_flags = (VehicleFlag)0; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1cce4c041d..342719921d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -115,90 +115,6 @@ namespace OpenSim.Region.Framework.Scenes private bool m_suspendUpdates; private List m_linkedAvatars = new List(); - private SOGVehicle m_vehicle = null; - - public int VehicleType - { - get - { - if (m_vehicle == null) - return (int)Vehicle.TYPE_NONE; - else - return (int)m_vehicle.Type; - } - set - { - m_vehicle = null; - if (value == (int)Vehicle.TYPE_NONE) - { - if (RootPart.PhysActor != null) - RootPart.PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; - return; - } - m_vehicle = new SOGVehicle(); - m_vehicle.ProcessTypeChange((Vehicle)value); - { - if (RootPart.PhysActor != null) - RootPart.PhysActor.VehicleType = value; - return; - } - - } - } - - public void SetVehicleFlags(int param, bool remove) - { - if (m_vehicle == null) - return; - - m_vehicle.ProcessVehicleFlags(param, remove); - - if (RootPart.PhysActor != null) - { - RootPart.PhysActor.VehicleFlags(param, remove); - } - } - - public void SetVehicleFloatParam(int param, float value) - { - if (m_vehicle == null) - return; - - m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value); - - if (RootPart.PhysActor != null) - { - RootPart.PhysActor.VehicleFloatParam(param, value); - } - } - - public void SetVehicleVectorParam(int param, Vector3 value) - { - if (m_vehicle == null) - return; - - m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value); - - if (RootPart.PhysActor != null) - { - RootPart.PhysActor.VehicleVectorParam(param, value); - } - } - - public void SetVehicleRotationParam(int param, Quaternion rotation) - { - if (m_vehicle == null) - return; - - m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); - - if (RootPart.PhysActor != null) - { - RootPart.PhysActor.VehicleRotationParam(param, rotation); - } - } - - public bool areUpdatesSuspended { get @@ -1782,8 +1698,6 @@ namespace OpenSim.Region.Framework.Scenes // ResetChildPrimPhysicsPositions(); if (m_rootPart.PhysActor != null) { - if (m_vehicle != null) - m_vehicle.SetVehicle(m_rootPart.PhysActor); m_rootPart.PhysActor.Building = false; } } @@ -1791,10 +1705,6 @@ namespace OpenSim.Region.Framework.Scenes { // Apply physics to the root prim m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false); - if (m_rootPart.PhysActor != null && m_vehicle != null) - { - m_vehicle.SetVehicle(m_rootPart.PhysActor); - } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 6438694ece..eb59ffd012 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -310,6 +310,9 @@ namespace OpenSim.Region.Framework.Scenes private UUID m_collisionSound; private float m_collisionSoundVolume; + + private SOPVehicle m_vehicle = null; + #endregion Fields // ~SceneObjectPart() @@ -1556,8 +1559,14 @@ namespace OpenSim.Region.Framework.Scenes { PhysActor.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info PhysActor.SetMaterial(Material); + + // if root part apply vehicle + if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) + m_vehicle.SetVehicle(PhysActor); + DoPhysicsPropertyUpdate(RigidBody, true); PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); + if (!building) PhysActor.Building = false; } @@ -3168,39 +3177,90 @@ namespace OpenSim.Region.Framework.Scenes } } + + public int VehicleType + { + get + { + if (m_vehicle == null) + return (int)Vehicle.TYPE_NONE; + else + return (int)m_vehicle.Type; + } + set + { + SetVehicleType(value); + } + } + public void SetVehicleType(int type) { - if (ParentGroup.IsDeleted) - return; - ParentGroup.VehicleType = type; + m_vehicle = null; + if (type == (int)Vehicle.TYPE_NONE) + { + if (_parentID ==0 && PhysActor != null) + PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; + return; + } + m_vehicle = new SOPVehicle(); + m_vehicle.ProcessTypeChange((Vehicle)type); + { + if (_parentID ==0 && PhysActor != null) + PhysActor.VehicleType = type; + return; + } } public void SetVehicleFlags(int param, bool remove) { - if (ParentGroup.IsDeleted) + if (m_vehicle == null) return; - ParentGroup.SetVehicleFlags(param, remove); + + m_vehicle.ProcessVehicleFlags(param, remove); + + if (_parentID ==0 && PhysActor != null) + { + PhysActor.VehicleFlags(param, remove); + } } public void SetVehicleFloatParam(int param, float value) { - if (ParentGroup.IsDeleted) + if (m_vehicle == null) return; - ParentGroup.SetVehicleFloatParam(param, value); + + m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value); + + if (_parentID == 0 && PhysActor != null) + { + PhysActor.VehicleFloatParam(param, value); + } } public void SetVehicleVectorParam(int param, Vector3 value) { - if (ParentGroup.IsDeleted) + if (m_vehicle == null) return; - ParentGroup.SetVehicleVectorParam(param, value); + + m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value); + + if (_parentID == 0 && PhysActor != null) + { + PhysActor.VehicleVectorParam(param, value); + } } public void SetVehicleRotationParam(int param, Quaternion rotation) { - if (ParentGroup.IsDeleted) + if (m_vehicle == null) return; - ParentGroup.SetVehicleRotationParam(param, rotation); + + m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); + + if (_parentID == 0 && PhysActor != null) + { + PhysActor.VehicleRotationParam(param, rotation); + } } /// @@ -4380,6 +4440,11 @@ namespace OpenSim.Region.Framework.Scenes m_localId); PhysActor.SetMaterial(Material); + + // if root part apply vehicle + if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) + m_vehicle.SetVehicle(PhysActor); + DoPhysicsPropertyUpdate(UsePhysics, true); if (!ParentGroup.IsDeleted)