From a56664cf5910876b8ab7ca175bdb88918ec15280 Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Mon, 11 Feb 2008 01:43:54 +0000
Subject: * um, Prim crossings? Experimental. * Backup your database just in
case.
---
OpenSim/Framework/RegionCommsListener.cs | 2 +-
.../Region/Communications/OGS1/OGS1GridServices.cs | 51 ++++++---
OpenSim/Region/Environment/Scenes/Scene.cs | 114 +++++++++++++--------
.../Scenes/SceneCommunicationService.cs | 19 +++-
.../Region/Environment/Scenes/SceneObjectGroup.cs | 23 ++---
.../Region/Environment/Scenes/SceneXmlLoader.cs | 27 +++++
OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 1 +
7 files changed, 157 insertions(+), 80 deletions(-)
diff --git a/OpenSim/Framework/RegionCommsListener.cs b/OpenSim/Framework/RegionCommsListener.cs
index c12c3df..41577c6 100644
--- a/OpenSim/Framework/RegionCommsListener.cs
+++ b/OpenSim/Framework/RegionCommsListener.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Framework
public virtual bool TriggerExpectPrim(ulong regionHandle, LLUUID primID, string objData)
{
- if (OnExpectUser != null)
+ if (OnExpectPrim != null)
{
OnExpectPrim(regionHandle, primID, objData);
return true;
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
index 29f5472..f8ab9ef 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
@@ -865,40 +865,36 @@ namespace OpenSim.Region.Communications.OGS1
catch (RemotingException e)
{
NoteDeadRegion(regionHandle);
- m_log.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName +
- " " + regInfo.RegionLocX + "," + regInfo.RegionLocY);
+ m_log.Warn("Remoting Error: Unable to connect to adjacent region: " + regionHandle);
m_log.Debug(e.ToString());
return false;
}
catch (SocketException e)
{
NoteDeadRegion(regionHandle);
- m_log.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " +
- regInfo.RegionLocX + "," + regInfo.RegionLocY);
+ m_log.Warn("Remoting Error: Unable to connect to adjacent region: " + regionHandle);
m_log.Debug(e.ToString());
return false;
}
catch (InvalidCredentialException e)
{
NoteDeadRegion(regionHandle);
- m_log.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName +
- " " + regInfo.RegionLocX + "," + regInfo.RegionLocY);
+ m_log.Warn("Invalid Credential Exception: Invalid Credentials : " + regionHandle);
m_log.Debug(e.ToString());
return false;
}
catch (AuthenticationException e)
{
NoteDeadRegion(regionHandle);
- m_log.Warn("Authentication exception: Unable to connect to adjacent region: " +
- regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY);
+ m_log.Warn("Authentication exception: Unable to connect to adjacent region: " + regionHandle);
+
m_log.Debug(e.ToString());
return false;
}
catch (Exception e)
{
NoteDeadRegion(regionHandle);
- m_log.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName +
- " " + regInfo.RegionLocX + "," + regInfo.RegionLocY);
+ m_log.Warn("Unknown exception: Unable to connect to adjacent region: " + regionHandle);
m_log.Debug(e.ToString());
return false;
}
@@ -1005,14 +1001,37 @@ namespace OpenSim.Region.Communications.OGS1
catch (RemotingException e)
{
NoteDeadRegion(regionHandle);
- m_log.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName +
- " " + regInfo.RegionLocX + "," + regInfo.RegionLocY);
+ m_log.Warn("Remoting Error: Unable to connect to adjacent region: " + regionHandle);
m_log.Debug(e.ToString());
return false;
}
- catch
+ catch (SocketException e)
{
NoteDeadRegion(regionHandle);
+ m_log.Warn("Remoting Error: Unable to connect to adjacent region: " + regionHandle);
+ m_log.Debug(e.ToString());
+ return false;
+ }
+ catch (InvalidCredentialException e)
+ {
+ NoteDeadRegion(regionHandle);
+ m_log.Warn("Invalid Credential Exception: Invalid Credentials : " + regionHandle);
+ m_log.Debug(e.ToString());
+ return false;
+ }
+ catch (AuthenticationException e)
+ {
+ NoteDeadRegion(regionHandle);
+ m_log.Warn("Authentication exception: Unable to connect to adjacent region: " + regionHandle);
+
+ m_log.Debug(e.ToString());
+ return false;
+ }
+ catch (Exception e)
+ {
+ NoteDeadRegion(regionHandle);
+ m_log.Warn("Unknown exception: Unable to connect to adjacent region: " + regionHandle);
+ m_log.Debug(e.ToString());
return false;
}
}
@@ -1205,15 +1224,17 @@ namespace OpenSim.Region.Communications.OGS1
// Is this necessary?
try
{
- //return m_localBackend.TriggerExpectPrim(regionHandle,primID, objData);
+ m_localBackend.TriggerExpectPrim(regionHandle, primID, objData);
+ return true;
//m_localBackend.
- return false;
+
}
catch (RemotingException e)
{
m_log.Error("Remoting Error: Unable to connect to adjacent region.\n" + e.ToString());
return false;
}
+ return false;
}
///
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 015ba12..999de9c 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1089,50 +1089,7 @@ namespace OpenSim.Region.Environment.Scenes
if (target != null)
{
pos = target.AbsolutePosition;
-
- //m_log.Info("[RAYTRACE]: " + pos.ToString());
- //EntityIntersection rayTracing = null;
- //ScenePresence presence = ((ScenePresence)GetScenePresence(ownerID));
- //if (presence != null)
- //{
- //Vector3 CameraPosition = presence.CameraPosition;
- //Vector3 rayEnd = new Vector3(pos.X, pos.Y, pos.Z);
-
- //float rayMag = m_innerScene.Vector3Distance(CameraPosition, rayEnd);
- //LLVector3 rayDirectionLL = Util.GetNormal(pos);
-
- //Vector3 rayDirection = new Vector3(rayDirectionLL.X, rayDirectionLL.Y, rayDirectionLL.Z);
-
- //Ray rezRay = new Ray(CameraPosition, rayDirection);
-
- //Vector3 RezDirectionFromCamera = rezRay.Direction;
-
- //rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay);
- //}
-
- //if ((rayTracing != null) && (rayTracing.HitTF))
- //{
- // We raytraced and found a prim in the way of the ground.. so
- // We will rez the object somewhere close to the prim. Better math needed. This is a Stub
- //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z);
- //Vector3 Newpos = rayTracing.ipoint;
- //Vector3 NewScale =
- //new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z);
-
- //Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation;
- //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z);
-
- //LLQuaternion primLocalRot = rayTracing.obj.RotationOffset;
- //Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z);
-
- //Quaternion NewRot = LocalRot * ParentRot;
-
- //Vector3 RezPoint = Newpos;
-
- //m_log.Info("[REZINFO]: Possible Rez Point:" + RezPoint.ToString());
- //pos = new LLVector3(RezPoint.x, RezPoint.y, RezPoint.z);
- //}
-
+ // TODO: Raytrace here
return pos;
}
else
@@ -1253,6 +1210,73 @@ namespace OpenSim.Region.Environment.Scenes
m_sceneXmlLoader.SavePrimsToXml2(fileName);
}
+ public void CrossPrimGroupIntoNewRegion(LLVector3 position, SceneObjectGroup grp)
+ {
+ m_log.Warn("Prim crossing: " + grp.UUID.ToString());
+ int thisx = (int)RegionInfo.RegionLocX;
+ int thisy = (int)RegionInfo.RegionLocY;
+ ulong newRegionHandle = 0;
+ LLVector3 pos = grp.AbsolutePosition;
+
+ if (position.X > 255.6f)
+ {
+ pos.X = ((pos.X - 256) + 10);
+
+ newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * 256), (uint)(thisy * 256));
+
+ // x + 1
+ }
+ else if (position.X < 0.4f)
+ {
+ pos.X = ((pos.X + 256) - 10);
+ newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * 256), (uint)(thisy * 256));
+ // x - 1
+ }
+
+ if (position.Y > 255.6f)
+ {
+ pos.Y = ((pos.Y - 256) + 10);
+ newRegionHandle = Util.UIntsToLong((uint)(thisx * 256), (uint)((thisy + 1) * 256));
+ // y + 1
+ }
+ else if (position.Y < 0.4f)
+ {
+ pos.Y = ((pos.Y + 256) - 10);
+ newRegionHandle = Util.UIntsToLong((uint)(thisx * 256), (uint)((thisy - 1) * 256));
+ // y - 1
+ }
+
+ // Offset the positions for the new region across the border
+ grp.OffsetForNewRegion(pos);
+
+ if (newRegionHandle != 0)
+ {
+ bool successYN = false;
+ successYN = m_sceneGridService.PrimCrossToNeighboringRegion(newRegionHandle, grp.UUID, m_sceneXmlLoader.SavePrimGroupToXML2String(grp));
+ if (successYN)
+ {
+ // We remove the object here
+ try
+ {
+ DeleteSceneObjectGroup(grp);
+ }
+ catch (System.Exception)
+ {
+ m_log.Warn("[DATABASE]: exception when trying to remove the prim that crossed the border.");
+ }
+ }
+ else
+ {
+ m_log.Warn("[INTERREGION]: Prim Crossing Failed!");
+ }
+ }
+ }
+ public void IncomingInterRegionPrimGroup(ulong regionHandle, LLUUID primID, string objXMLData)
+ {
+ m_log.Warn("{[INTERREGION]: OMG! A new prim arrived from a neighbor!.. Kyill eeehht! before it corrupts my entire database! AHHH! I feel so dirty now! yuck! ack! arg!");
+ m_sceneXmlLoader.LoadGroupFromXml2String(objXMLData);
+
+ }
#endregion
#region Add/Remove Avatar Methods
@@ -1527,6 +1551,7 @@ namespace OpenSim.Region.Environment.Scenes
m_sceneGridService.OnCloseAgentConnection += CloseConnection;
m_sceneGridService.OnRegionUp += OtherRegionUp;
m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
+ m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
@@ -1540,6 +1565,7 @@ namespace OpenSim.Region.Environment.Scenes
///
public void UnRegisterReginWithComms()
{
+ m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
m_sceneGridService.OnRegionUp -= OtherRegionUp;
m_sceneGridService.OnExpectUser -= NewUserConnection;
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
index a89b52c..482701b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
@@ -49,6 +49,7 @@ namespace OpenSim.Region.Environment.Scenes
public event AgentCrossing OnAvatarCrossingIntoRegion;
public event ExpectUserDelegate OnExpectUser;
+ public event ExpectPrimDelegate OnExpectPrim;
public event CloseAgentConnection OnCloseAgentConnection;
public event PrimCrossing OnPrimCrossingIntoRegion;
public event RegionUp OnRegionUp;
@@ -82,10 +83,9 @@ namespace OpenSim.Region.Environment.Scenes
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
regionCommsHost.debugRegionName = _debugRegionName;
-
+ regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
regionCommsHost.OnExpectUser += NewUserConnection;
regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
- regionCommsHost.OnPrimCrossingIntoRegion += PrimCrossing;
regionCommsHost.OnCloseAgentConnection += CloseConnection;
regionCommsHost.OnRegionUp += newRegionUp;
regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
@@ -104,8 +104,8 @@ namespace OpenSim.Region.Environment.Scenes
regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
regionCommsHost.OnRegionUp -= newRegionUp;
regionCommsHost.OnExpectUser -= NewUserConnection;
+ regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
- regionCommsHost.OnPrimCrossingIntoRegion -= PrimCrossing;
regionCommsHost.OnCloseAgentConnection -= CloseConnection;
m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
regionCommsHost = null;
@@ -156,6 +156,15 @@ namespace OpenSim.Region.Environment.Scenes
}
}
+ protected void IncomingPrimCrossing(ulong regionHandle, LLUUID primID, String objXMLData)
+ {
+ if (OnExpectPrim != null)
+ {
+ OnExpectPrim(regionHandle, primID, objXMLData);
+ }
+
+ }
+
protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical)
{
if (OnPrimCrossingIntoRegion != null)
@@ -535,9 +544,9 @@ namespace OpenSim.Region.Environment.Scenes
return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying);
}
- public bool PrimCrossToNeighboringRegion(ulong regionhandle, LLUUID primID, LLVector3 position, bool isPhysical)
+ public bool PrimCrossToNeighboringRegion(ulong regionhandle, LLUUID primID, string objData)
{
- return m_commsProvider.InterRegion.ExpectPrimCrossing(regionhandle, primID, position, isPhysical);
+ return m_commsProvider.InterRegion.InformRegionOfPrimCrossing(regionhandle, primID, objData);
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 2917056..05b9014 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -126,23 +126,11 @@ namespace OpenSim.Region.Environment.Scenes
set
{
LLVector3 val = value;
- if (val.X > 255.6f)
+ if (val.X > 255.6f || val.X < 0.4f || val.Y > 255.6f || val.Y < 0.4f)
{
- val.X = 255.6f;
- }
- else if (val.X < 0.4f)
- {
- val.X = 0.4f;
- }
-
- if (val.Y > 255.6f)
- {
- val.Y = 255.6f;
- }
- else if (val.Y < 0.4f)
- {
- val.Y = 0.4f;
+ m_scene.CrossPrimGroupIntoNewRegion(val, this);
}
+
lock (m_parts)
{
@@ -1378,6 +1366,11 @@ namespace OpenSim.Region.Environment.Scenes
ScheduleGroupForTerseUpdate();
}
+ public void OffsetForNewRegion(LLVector3 offset)
+ {
+ m_rootPart.GroupPosition = offset;
+ }
+
#endregion
#region Rotation
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
index 3b4deaf..6d911f1 100644
--- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
@@ -123,6 +123,33 @@ namespace OpenSim.Region.Environment.Scenes
file.Close();
}
+ public string SavePrimGroupToXML2String(SceneObjectGroup grp)
+ {
+ string returnstring = "";
+ returnstring += "\n";
+ returnstring += grp.ToXmlString2();
+ returnstring += "\n";
+ return returnstring;
+
+ }
+
+ public void LoadGroupFromXml2String(string xmlString)
+ {
+ XmlDocument doc = new XmlDocument();
+ XmlNode rootNode;
+
+ XmlTextReader reader = new XmlTextReader(new StringReader(xmlString));
+ reader.WhitespaceHandling = WhitespaceHandling.None;
+ doc.Load(reader);
+ reader.Close();
+ rootNode = doc.FirstChild;
+ foreach (XmlNode aPrimNode in rootNode.ChildNodes)
+ {
+ CreatePrimFromXml(aPrimNode.OuterXml);
+ }
+
+ }
+
public void LoadPrimsFromXml2(string fileName)
{
XmlDocument doc = new XmlDocument();
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index d171947..adb53d2 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -84,6 +84,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public OdePrim(String primName, OdeScene parent_scene, IntPtr targetSpace, PhysicsVector pos, PhysicsVector size,
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical)
{
+ System.Threading.Thread.Sleep(20);
_velocity = new PhysicsVector();
_position = pos;
m_taintposition = pos;
--
cgit v1.1