From e7439efc74a1cc0daedc51eb25ae66cd03db70b5 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Thu, 24 Dec 2009 19:19:44 -0500 Subject: Recover out-of-region objects during db load. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 24 ++++++++++++++++++++++++ OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b0fb8b3..998d598 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -222,6 +222,30 @@ namespace OpenSim.Region.Framework.Scenes protected internal bool AddRestoredSceneObject( SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) { + // KF: Check for out-of-region, move inside and make static. + Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, + sceneObject.RootPart.GroupPosition.Y, + sceneObject.RootPart.GroupPosition.Z); + if (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || + npos.X > Constants.RegionSize || + npos.Y > Constants.RegionSize) + { + if (npos.X < 0.0) npos.X = 1.0f; + if (npos.Y < 0.0) npos.Y = 1.0f; + if (npos.Z < 0.0) npos.Z = 0.0f; + if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f; + if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f; + + foreach (SceneObjectPart part in sceneObject.Children.Values) + { + part.GroupPosition = npos; + } + sceneObject.RootPart.Velocity = Vector3.Zero; + sceneObject.RootPart.AngularVelocity = Vector3.Zero; + sceneObject.RootPart.Acceleration = Vector3.Zero; + sceneObject.RootPart.Velocity = Vector3.Zero; + } + if (!alreadyPersisted) { sceneObject.ForceInventoryPersistence(); diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs index 983431d..0179240 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs @@ -215,6 +215,7 @@ namespace OpenSim.Region.Physics.OdePlugin parent_scene.GetTerrainHeightAtXY(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f)) + 0.5f); m_log.Warn("[PHYSICS]: Got nonFinite Object create Position"); } + _position = pos; m_taintposition = pos; PID_D = parent_scene.bodyPIDD; @@ -254,7 +255,8 @@ namespace OpenSim.Region.Physics.OdePlugin _parent_scene = parent_scene; m_targetSpace = (IntPtr)0; - if (pos.Z < 0) +// if (pos.Z < 0) + if (pos.Z < parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y)) m_isphysical = false; else { -- cgit v1.1