From 33d32355a1712e53f402eab1aa4818712f6f5f2c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 17 Jun 2008 17:23:00 +0000 Subject: * refactor: Remove largely duplicate code from SceneXmlLoader.CreatePrimFromXml2() --- .../Modules/World/Serialiser/SceneXmlLoader.cs | 26 +--------------------- OpenSim/Region/Environment/Scenes/Scene.cs | 5 +++++ .../Region/Environment/Scenes/SceneObjectGroup.cs | 4 ++++ .../Region/Environment/Scenes/SceneObjectPart.cs | 12 ++++++---- 4 files changed, 18 insertions(+), 29 deletions(-) diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs index 69f1902..5591ddc 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs @@ -195,33 +195,9 @@ namespace OpenSim.Region.Environment.Scenes { SceneObjectGroup obj = new SceneObjectGroup(xmlData); - LLVector3 receivedVelocity = obj.RootPart.Velocity; - //System.Console.WriteLine(obj.RootPart.Velocity.ToString()); scene.AddSceneObjectFromStorage(obj); - SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); - bool UsePhysics = (((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Physics) > 0) && - scene.m_physicalPrim); - if ((rootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0) - { - rootPart.PhysActor = scene.PhysicsScene.AddPrimShape( - rootPart.Name, - rootPart.Shape, - new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, - rootPart.AbsolutePosition.Z), - new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), - new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, - rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); - - // to quote from SceneObjectPart: Basic - // Physics returns null.. joy joy joy. - if (rootPart.PhysActor != null) - { - rootPart.PhysActor.LocalID = rootPart.LocalId; - rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); - } - rootPart.Velocity = receivedVelocity; - } + obj.ApplyPhysics(scene.m_physicalPrim); obj.ScheduleGroupForFullUpdate(); } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index e274139..b39e08d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -79,7 +79,12 @@ namespace OpenSim.Region.Environment.Scenes private int m_timePhase = 24; private readonly Mutex updateLock; + + /// + /// Are we applying physics to any of the prims in this scene? + /// public bool m_physicalPrim; + public bool m_seeIntoRegionFromNeighbor; public int MaxUndoCount = 5; private int m_RestartTimerCounter; diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index f750200..877f196 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -1052,6 +1052,10 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart.ScheduleFullUpdate(); } + /// + /// Apply physics to this group + /// + /// public void ApplyPhysics(bool m_physicalPrim) { lock (m_parts) diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 42df746..85351f4 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -494,8 +494,9 @@ namespace OpenSim.Region.Environment.Scenes return m_velocity; } - set { - + + set + { m_velocity = value; if (PhysActor != null) { @@ -505,7 +506,6 @@ namespace OpenSim.Region.Environment.Scenes m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); } } - } } @@ -913,9 +913,13 @@ namespace OpenSim.Region.Environment.Scenes return newobject; } + /// + /// Apply physics to this part. + /// + /// + /// public void ApplyPhysics(uint rootObjectFlags, bool m_physicalPrim) { - bool isPhysical = (((rootObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0) && m_physicalPrim); bool isPhantom = ((rootObjectFlags & (uint) LLObject.ObjectFlags.Phantom) != 0); -- cgit v1.1