From 17b4818b8e9a141b54540b342542bcb2ad21b4db Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 15 Jun 2007 16:03:02 +0000 Subject: Very Preliminary border crossing added to sugilite. (Note: Sugilite doesn't have any backend ogs communication support yet so everything is Sandbox mode only ) --- .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 16 +++--- OpenSim/OpenSim.Region/Scenes/Avatar.Update.cs | 62 +++++++++++++++++++++- OpenSim/OpenSim.Region/Scenes/Avatar.cs | 39 +++++++------- OpenSim/OpenSim.Region/Scenes/Entity.cs | 35 ++++++++++++ OpenSim/OpenSim.Region/Scenes/Scene.cs | 34 ++++++++++++ OpenSim/OpenSim.RegionServer/ClientView.API.cs | 34 +++++++++++- .../ClientView.ProcessPackets.cs | 1 - OpenSim/OpenSim.RegionServer/ClientView.cs | 13 +++-- 8 files changed, 197 insertions(+), 37 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index 5636b13..341ffbb 100644 --- a/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/OpenSim.Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -120,22 +120,22 @@ namespace OpenSim.Physics.BasicPhysicsPlugin } else { - if (actor.Position.Y < -1) + if (actor.Position.Y < 0) { - actor.Position.Y = -1; + actor.Position.Y = 0; } - else if (actor.Position.Y > 257) + else if (actor.Position.Y > 256) { - actor.Position.Y = 257; + actor.Position.Y = 256; } - if (actor.Position.X < -1) + if (actor.Position.X < 0) { - actor.Position.X = -1; + actor.Position.X = 0; } - if (actor.Position.X > 257) + if (actor.Position.X > 256) { - actor.Position.X = 257; + actor.Position.X = 256; } } //} diff --git a/OpenSim/OpenSim.Region/Scenes/Avatar.Update.cs b/OpenSim/OpenSim.Region/Scenes/Avatar.Update.cs index 3f87e10..d46bf0f 100644 --- a/OpenSim/OpenSim.Region/Scenes/Avatar.Update.cs +++ b/OpenSim/OpenSim.Region/Scenes/Avatar.Update.cs @@ -32,6 +32,7 @@ using libsecondlife; using libsecondlife.Packets; using OpenSim.Physics.Manager; using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; namespace OpenSim.Region.Scenes { @@ -55,7 +56,24 @@ namespace OpenSim.Region.Scenes this.SendTerseUpdateToALLClients(); _updateCount = 0; } - } + } + + LLVector3 pos2 = this.Pos; + LLVector3 vel = this.Velocity; + + float timeStep = 0.3f; + pos2.X = pos2.X + (vel.X * timeStep); + pos2.Y = pos2.Y + (vel.Y * timeStep); + pos2.Z = pos2.Z + (vel.Z * timeStep); + if ((pos2.X < 0) || (pos2.X > 256)) + { + this.CrossToNewRegion(); + } + + if ((pos2.Y < 0) || (pos2.Y > 256)) + { + this.CrossToNewRegion(); + } } /// @@ -147,5 +165,47 @@ namespace OpenSim.Region.Scenes } + private void CrossToNewRegion() + { + + // Console.WriteLine("crossing to new region from region " + this.m_regionInfo.RegionLocX + " , "+ this.m_regionInfo.RegionLocY); + LLVector3 pos = this.Pos; + LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z); + uint neighbourx = this.m_regionInfo.RegionLocX; + uint neighboury = this.m_regionInfo.RegionLocY; + + if (pos.X < 2) + { + neighbourx -= 1; + newpos.X = 254; + } + if (pos.X > 253) + { + neighbourx += 1; + newpos.X = 1; + } + if (pos.Y < 2) + { + neighboury -= 1; + newpos.Y = 254; + } + if (pos.Y > 253) + { + neighboury += 1; + newpos.Y = 1; + } + + LLVector3 vel = this.velocity; + // Console.WriteLine("new region should be " + neighbourx + " , " + neighboury); + ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury* 256)); + RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle); + if (neighbourRegion != null) + { + // Console.WriteLine("current region port is "+ this.m_regionInfo.IPListenPort + " now crossing to new region with port " + neighbourRegion.IPListenPort); + this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos); + this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, System.Net.IPAddress.Parse(neighbourRegion.IPListenAddr), (ushort)neighbourRegion.IPListenPort); + } + } + } } diff --git a/OpenSim/OpenSim.Region/Scenes/Avatar.cs b/OpenSim/OpenSim.Region/Scenes/Avatar.cs index 17b2437..98d7564 100644 --- a/OpenSim/OpenSim.Region/Scenes/Avatar.cs +++ b/OpenSim/OpenSim.Region/Scenes/Avatar.cs @@ -102,10 +102,10 @@ namespace OpenSim.Region.Scenes ControllingClient.OnCompleteMovementToRegion += new GenericCall2(this.CompleteMovement); ControllingClient.OnCompleteMovementToRegion += new GenericCall2(this.SendInitialPosition); ControllingClient.OnAgentUpdate += new UpdateAgent(this.HandleAgentUpdate); - /* ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); + // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); - ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); - */ + //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); + } /// @@ -129,7 +129,14 @@ namespace OpenSim.Region.Scenes /// public void ChildStatusChange(bool status) { + this.childAvatar = status; + if (this.childAvatar == true) + { + this.Velocity = new LLVector3(0, 0, 0); + this.Pos = new LLVector3(128, 128, 70); + + } } /// @@ -137,22 +144,17 @@ namespace OpenSim.Region.Scenes /// public override void addForces() { + newForce = false; lock (this.forcesList) - { - newForce = false; + { if (this.forcesList.Count > 0) { for (int i = 0; i < this.forcesList.Count; i++) { NewForce force = this.forcesList[i]; - PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z); - lock (m_world.SyncRoot) - { - this._physActor.Velocity = phyVector; - } + this.updateflag = true; - this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this - // but as we are setting the velocity (rather than using real forces) at the moment it is okay. + this.Velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this this.newForce = true; } for (int i = 0; i < this.forcesList.Count; i++) @@ -165,7 +167,9 @@ namespace OpenSim.Region.Scenes public void SendTerseUpdateToClient(IClientAPI RemoteClient) { - RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.localid, new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z), new LLVector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z)); + LLVector3 pos = this.Pos; + LLVector3 vel = this.Velocity; + RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.localid, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z)); } /// @@ -185,7 +189,7 @@ namespace OpenSim.Region.Scenes /// public void CompleteMovement() { - this.ControllingClient.MoveAgentIntoRegion(m_regionInfo); + this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, Pos); } /// @@ -240,10 +244,6 @@ namespace OpenSim.Region.Scenes } else { - if (movementflag == 16) - { - movementflag = 0; - } if ((movementflag) != 0) { NewForce newVelocity = new NewForce(); @@ -252,9 +252,6 @@ namespace OpenSim.Region.Scenes newVelocity.Z = 0; this.forcesList.Add(newVelocity); movementflag = 0; - - this.movementflag = 16; - } } diff --git a/OpenSim/OpenSim.Region/Scenes/Entity.cs b/OpenSim/OpenSim.Region/Scenes/Entity.cs index d4c981a..007bdaf 100644 --- a/OpenSim/OpenSim.Region/Scenes/Entity.cs +++ b/OpenSim/OpenSim.Region/Scenes/Entity.cs @@ -93,6 +93,41 @@ namespace OpenSim.Region.Scenes } } + public virtual LLVector3 Velocity + { + get + { + if (this._physActor != null) + { + velocity.X = _physActor.Velocity.X; + velocity.Y = _physActor.Velocity.Y; + velocity.Z = _physActor.Velocity.Z; + } + + return velocity; + } + set + { + if (this._physActor != null) + { + try + { + lock (this.m_world.SyncRoot) + { + + this._physActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); + } + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + + velocity = value; + } + } + /// /// Creates a new Entity (should not occur on it's own) /// diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.cs b/OpenSim/OpenSim.Region/Scenes/Scene.cs index 98f5027..2500ee6 100644 --- a/OpenSim/OpenSim.Region/Scenes/Scene.cs +++ b/OpenSim/OpenSim.Region/Scenes/Scene.cs @@ -580,6 +580,7 @@ namespace OpenSim.Region.Scenes agent.BaseFolder = LLUUID.Zero; agent.InventoryFolder = LLUUID.Zero; agent.startpos = new LLVector3(128, 128, 70); + agent.child = true; this.commsManager.InterSims.InformNeighbourOfChildAgent(neighbours[i].RegionHandle, agent); remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, System.Net.IPAddress.Parse(neighbours[i].IPListenAddr), (ushort)neighbours[i].IPListenPort); } @@ -589,6 +590,27 @@ namespace OpenSim.Region.Scenes /// /// /// + /// + /// + public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) + { + return this.commsManager.GridServer.RequestNeighbourInfo(regionHandle); + } + + /// + /// + /// + /// + /// + /// + public void InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position) + { + this.commsManager.InterSims.ExpectAvatarCrossing(regionhandle, agentID, position); + } + + /// + /// + /// /// public override void RemoveAvatar(LLUUID agentID) { @@ -678,6 +700,7 @@ namespace OpenSim.Region.Scenes if (this.regionCommsHost != null) { this.regionCommsHost.OnExpectUser += new ExpectUserDelegate(this.NewUserConnection); + this.regionCommsHost.OnAvatarCrossingIntoRegion += new AgentCrossing(this.AgentCrossing); } } @@ -696,6 +719,17 @@ namespace OpenSim.Region.Scenes } } + public void AgentCrossing(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position) + { + if (regionHandle == this.m_regInfo.RegionHandle) + { + if (this.Avatars.ContainsKey(agentID)) + { + this.Avatars[agentID].Pos = position; + } + } + } + #endregion /// diff --git a/OpenSim/OpenSim.RegionServer/ClientView.API.cs b/OpenSim/OpenSim.RegionServer/ClientView.API.cs index 33727c4..b126004 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.API.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.API.cs @@ -166,7 +166,7 @@ namespace OpenSim /// /// /// - public void MoveAgentIntoRegion(RegionInfo regInfo) + public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos) { AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); mov.AgentData.SessionID = this.SessionID; @@ -174,7 +174,14 @@ namespace OpenSim mov.Data.RegionHandle = regInfo.RegionHandle; // TODO - dynamicalise this stuff mov.Data.Timestamp = 1172750370; - mov.Data.Position = this.startpos; + if (pos != null) + { + mov.Data.Position = pos; + } + else + { + mov.Data.Position = this.startpos; + } mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); OutPacket(mov); @@ -305,6 +312,29 @@ namespace OpenSim return agentData; } + public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, System.Net.IPAddress newRegionIP, ushort newRegionPort) + { + CrossedRegionPacket newSimPack = new CrossedRegionPacket(); + newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); + newSimPack.AgentData.AgentID = this.AgentID; + newSimPack.AgentData.SessionID = this.SessionID; + newSimPack.Info = new CrossedRegionPacket.InfoBlock(); + newSimPack.Info.Position = pos; + newSimPack.Info.LookAt = lookAt; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! + newSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock(); + newSimPack.RegionData.RegionHandle = newRegionHandle; + byte[] byteIP = newRegionIP.GetAddressBytes(); + newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; + newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; + newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; + newSimPack.RegionData.SimIP += (uint)byteIP[0]; + newSimPack.RegionData.SimPort = newRegionPort; + newSimPack.RegionData.SeedCapability = new byte[0]; + + this.OutPacket(newSimPack); + this.DowngradeClient(); + } + #region Appearance/ Wearables Methods /// diff --git a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs index f8c7cdb..4cf6ac2 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs @@ -163,7 +163,6 @@ namespace OpenSim { OnCompleteMovementToRegion(); } - // this.EnableNeighbours(); break; case PacketType.AgentUpdate: if (OnAgentUpdate != null) diff --git a/OpenSim/OpenSim.RegionServer/ClientView.cs b/OpenSim/OpenSim.RegionServer/ClientView.cs index 0943c0d..29c871e 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.cs @@ -117,17 +117,22 @@ namespace OpenSim { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:UpgradeClient() - upgrading child to full agent"); this.m_child = false; - this.startpos = m_authenticateSessionsHandler.GetPosition(CircuitCode); + //this.startpos = m_authenticateSessionsHandler.GetPosition(CircuitCode); m_authenticateSessionsHandler.UpdateAgentChildStatus(CircuitCode, false); - OnChildAgentStatus(this.m_child); + if (OnChildAgentStatus != null) + { + OnChildAgentStatus(this.m_child); + } } public void DowngradeClient() { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:UpgradeClient() - changing full agent to child"); this.m_child = true; - OnChildAgentStatus(this.m_child); - + if (OnChildAgentStatus != null) + { + OnChildAgentStatus(this.m_child); + } } public void KillClient() -- cgit v1.1