From 412d7e098c424745c0c2ae1a6526c5b5d58b3180 Mon Sep 17 00:00:00 2001 From: gareth Date: Sun, 4 Mar 2007 01:57:52 +0000 Subject: [PATCH] Fixed up bugs from patch in PREV: Slow movement of avatar FIXED Constant TerseObjectUpdates FIXED Moving out of sim FIXED --- src/world/Avatar.cs | 15 ++++++++++----- src/world/PhysicsEngine.cs | 11 ++++++----- src/world/World.cs | 25 ++++++++++++++----------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs index 68606c4ca4..fbd78b7a4b 100644 --- a/src/world/Avatar.cs +++ b/src/world/Avatar.cs @@ -13,7 +13,10 @@ namespace OpenSim.world public string firstname; public string lastname; public OpenSimClient ControllingClient; + public LLVector3 oldvel; + public LLVector3 oldpos; public uint CurrentKeyMask; + public bool walking; private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; @@ -30,18 +33,22 @@ namespace OpenSim.world base.update(); Console.WriteLine("KeyMask: " + this.CurrentKeyMask); - + + oldvel=this.velocity; + oldpos=this.position; if((this.CurrentKeyMask & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) != 0) { Vector3 tmpVelocity = this.rotation * new Vector3(1.0f,0.0f,0.0f); - tmpVelocity.Normalize(); tmpVelocity = tmpVelocity * 0.3f; + tmpVelocity.Normalize(); tmpVelocity = tmpVelocity * 0.5f; this.velocity.X = tmpVelocity.x; this.velocity.Y = tmpVelocity.y; this.velocity.Z = tmpVelocity.z; Console.WriteLine("Walking at "+ this.velocity.ToString()); + this.walking=true; } else { this.velocity.X=0; this.velocity.Y=0; this.velocity.Z=0; + this.walking=false; } } } @@ -238,10 +245,8 @@ namespace OpenSim.world public void HandleAgentUpdate(AgentUpdatePacket update) { lock(this) { - // FIXME: shouldn't update these direction - this.rotation = new Quaternion(update.AgentData.BodyRotation.W, update.AgentData.BodyRotation.X, update.AgentData.BodyRotation.Y, update.AgentData.BodyRotation.Z); - this.CurrentKeyMask = update.AgentData.ControlFlags; + this.rotation = new Quaternion(update.AgentData.BodyRotation.W, update.AgentData.BodyRotation.X, update.AgentData.BodyRotation.Y, update.AgentData.BodyRotation.Z); this.needupdate = true; } } diff --git a/src/world/PhysicsEngine.cs b/src/world/PhysicsEngine.cs index a789828afd..d9351af07c 100644 --- a/src/world/PhysicsEngine.cs +++ b/src/world/PhysicsEngine.cs @@ -20,11 +20,12 @@ namespace OpenSim.world public void DoStuff(World simworld) { foreach (libsecondlife.LLUUID UUID in simworld.Entities.Keys) { - if( true /* simworld.Entities[UUID].needupdate */) { // FIXME! - simworld.Entities[UUID].position += simworld.Entities[UUID].velocity; - Console.WriteLine("Moving "+UUID.ToString()+ " to "+ simworld.Entities[UUID].position.ToString()); - } - + if((simworld.Entities[UUID].position.X>0) & (simworld.Entities[UUID].position.X<256) & (simworld.Entities[UUID].position.Y>1) & (simworld.Entities[UUID].position.Y<256)) { + simworld.Entities[UUID].position += simworld.Entities[UUID].velocity; + simworld.Entities[UUID].position.Z = simworld.LandMap[(int)simworld.Entities[UUID].position.Y * 256 + (int)simworld.Entities[UUID].position.X]+1; + } else { + simworld.Entities[UUID].velocity = new LLVector3(0f,0f,0f); + } } } } diff --git a/src/world/World.cs b/src/world/World.cs index b261884c21..f32f9ef1fe 100644 --- a/src/world/World.cs +++ b/src/world/World.cs @@ -50,17 +50,20 @@ namespace OpenSim.world { if(Entities[UUID].needupdate) { Entities[UUID].update(); - } - if(Entities[UUID] is Avatar) { // FIXME: only send updates when avatar moves. - ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = Entities[UUID].CreateTerseBlock(); - foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { - ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME - terse.RegionData.TimeDilation = 0; - terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - terse.ObjectData[0] = terseBlock; - client.OutPacket(terse); - } + + if(Entities[UUID] is Avatar) { + Avatar avatar=(Avatar)Entities[UUID]; + if((avatar.oldpos!=avatar.position) || (avatar.oldvel!=avatar.velocity) || avatar.walking) { + ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = Entities[UUID].CreateTerseBlock(); + foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME + terse.RegionData.TimeDilation = 0; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = terseBlock; + client.OutPacket(terse); + } + }} } } }