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 ) --- 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 ++++++++++++++ 4 files changed, 148 insertions(+), 22 deletions(-) (limited to 'OpenSim/OpenSim.Region') 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 /// -- cgit v1.1