From 3f1dbae8e4f47056555f9ecfaa32e959293ada48 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Sep 2008 00:37:59 +0000 Subject: * minor: various doc and tidy up, logging increase to make it clearer which prim is failing a border crossing --- OpenSim/Region/Environment/Scenes/Scene.cs | 83 +++++++++++++++------- .../Region/Environment/Scenes/SceneObjectGroup.cs | 18 +++-- .../Region/Environment/Scenes/SceneObjectPart.cs | 16 ++--- 3 files changed, 80 insertions(+), 37 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index d8ce3f0..9c2dd06 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1871,13 +1871,14 @@ namespace OpenSim.Region.Environment.Scenes } /// - /// Locate New region Handle and offset the prim position for the new region - /// + /// Move the given scene object into a new region depending on which region its absolute position has moved + /// into. + /// + /// This method locates the new region handle and offsets the prim position for the new region /// - /// current position of Group - /// Scene Object Group that we're crossing - - public void CrossPrimGroupIntoNewRegion(Vector3 position, SceneObjectGroup grp) + /// the attempted out of region position of the scene object + /// the scene object that we're crossing + public void CrossPrimGroupIntoNewRegion(Vector3 attemptedPosition, SceneObjectGroup grp) { if (grp == null) return; @@ -1897,53 +1898,70 @@ namespace OpenSim.Region.Environment.Scenes } return; } - - m_log.Warn("Prim crossing: " + grp.ToString()); + int thisx = (int)RegionInfo.RegionLocX; int thisy = (int)RegionInfo.RegionLocY; ulong newRegionHandle = 0; - Vector3 pos = position; + Vector3 pos = attemptedPosition; - if (position.X > Constants.RegionSize + 0.1f) + if (attemptedPosition.X > Constants.RegionSize + 0.1f) { pos.X = ((pos.X - Constants.RegionSize)); - newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); + newRegionHandle + = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); // x + 1 } - else if (position.X < -0.1f) + else if (attemptedPosition.X < -0.1f) { pos.X = ((pos.X + Constants.RegionSize)); - newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); + newRegionHandle + = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); // x - 1 } - if (position.Y > Constants.RegionSize + 0.1f) + if (attemptedPosition.Y > Constants.RegionSize + 0.1f) { pos.Y = ((pos.Y - Constants.RegionSize)); - newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); + newRegionHandle + = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); // y + 1 } - else if (position.Y < -1f) + else if (attemptedPosition.Y < -1f) { pos.Y = ((pos.Y + Constants.RegionSize)); - newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize)); + newRegionHandle + = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize)); // y - 1 } // Offset the positions for the new region across the border + Vector3 oldGroupPosition = grp.RootPart.GroupPosition; grp.OffsetForNewRegion(pos); - CrossPrimGroupIntoNewRegion(newRegionHandle, grp); + // If we fail to cross the border, then reset the position of the scene object on that border. + if (!CrossPrimGroupIntoNewRegion(newRegionHandle, grp)) + { + grp.OffsetForNewRegion(oldGroupPosition); + } } - public void CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp) + /// + /// Move the given scene object into a new region + /// + /// + /// Scene Object Group that we're crossing + /// + /// true if the crossing itself was successful, false on failure + /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region + /// + public bool CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp) { + bool successYN = false; int primcrossingXMLmethod = 0; + if (newRegionHandle != 0) { - bool successYN = false; - successYN = m_sceneGridService.PrimCrossToNeighboringRegion( newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod); @@ -1955,14 +1973,15 @@ namespace OpenSim.Region.Environment.Scenes { DeleteSceneObject(grp); } - catch (Exception) + catch (Exception e) { - m_log.Warn("[DATABASE]: exception when trying to remove the prim that crossed the border."); + m_log.ErrorFormat( + "[INTERREGION]: Exception deleting the old object left behind on a border crossing for {0}, {1}", + grp, e); } } else { - m_log.Warn("[INTERREGION]: Prim Crossing Failed!"); if (grp.RootPart != null) { if (grp.RootPart.PhysActor != null) @@ -1970,10 +1989,26 @@ namespace OpenSim.Region.Environment.Scenes grp.RootPart.PhysActor.CrossingFailure(); } } + + m_log.ErrorFormat("[INTERREGION]: Prim crossing failed for {0}", grp); } } + else + { + m_log.Error("[INTERREGION]: region handle was unexpectedly 0 in Scene.CrossPrimGroupIntoNewRegion()"); + } + + return successYN; } + /// + /// Handle a scene object that is crossing into this region from another. + /// + /// + /// + /// + /// + /// public bool IncomingInterRegionPrimGroup(ulong regionHandle, UUID primID, string objXMLData, int XMLMethod) { m_log.Warn("{[INTERREGION]: A new prim arrived from a neighbor"); diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 1b2ea8e..f52e764 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -180,6 +180,9 @@ namespace OpenSim.Region.Environment.Scenes } } + /// + /// The absolute position of this scene object in the scene + /// public override Vector3 AbsolutePosition { get @@ -195,8 +198,9 @@ namespace OpenSim.Region.Environment.Scenes set { Vector3 val = value; + if ((val.X > 257f || val.X < -1f || val.Y > 257f || val.Y < -1f) && !m_rootPart.IsAttachment) - { + { m_scene.CrossPrimGroupIntoNewRegion(val, this); } @@ -899,7 +903,6 @@ namespace OpenSim.Region.Environment.Scenes public void ResetChildPrimPhysicsPositions() { AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works? - //HasGroupChanged = false; } public UUID GetPartsFullID(uint localID) @@ -1090,10 +1093,10 @@ namespace OpenSim.Region.Environment.Scenes { part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_physicalPrim); } - + // Hack to get the physics scene geometries in the right spot - ResetChildPrimPhysicsPositions(); - } + ResetChildPrimPhysicsPositions(); + } } else { @@ -2706,5 +2709,10 @@ namespace OpenSim.Region.Environment.Scenes part.TriggerScriptChangedEvent(val); } } + + public override string ToString() + { + return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); + } } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index eaabdd5..2b0ad12 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -108,8 +108,6 @@ namespace OpenSim.Region.Environment.Scenes [XmlIgnore] public PhysicsActor PhysActor = null; - - //Xantor 20080528 Sound stuff: // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. // Not a big problem as long as the script that sets it remains in the prim on startup. @@ -443,6 +441,9 @@ namespace OpenSim.Region.Environment.Scenes set { m_particleSystem = value; } } + /// + /// The position of the entire group that this prim belongs to. + /// public Vector3 GroupPosition { get @@ -475,18 +476,14 @@ namespace OpenSim.Region.Environment.Scenes { try { - // Root prim actually goes at Position if (_parentID == 0) { PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); - } else { - // To move the child prim in respect to the group position and rotation we have to calculate - Vector3 resultingposition = GetWorldPosition(); PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); Quaternion resultingrot = GetWorldRotation(); @@ -783,8 +780,6 @@ namespace OpenSim.Region.Environment.Scenes get { return m_parentGroup; } } - - public scriptEvents ScriptEvents { get { return AggregateScriptEvents; } @@ -3321,6 +3316,11 @@ namespace OpenSim.Region.Environment.Scenes public bool GetForceMouselook() { return m_forceMouselook; } + + public override string ToString() + { + return String.Format("{0} {1} (parent {2}))", Name, UUID, ParentGroup); + } #endregion Public Methods } -- cgit v1.1