From 9b51bb545ecf07ad1b1b8188d62d4b4a03bc3fff Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 23 Jul 2008 11:07:59 +0000 Subject: Changed it so the avatar's rotation is now sent as part of a full avatar update. This should fix the wrong rotation on existing sitting avatar when logging in bug. --- OpenSim/Framework/IClientAPI.cs | 2 +- .../Region/ClientStack/LindenUDP/LLClientView.cs | 7 +++++- .../Environment/Modules/World/NPC/NPCAvatar.cs | 2 +- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 29 +++++++++++++++++++--- .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 2 +- 5 files changed, 34 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index b1f62f1..a97ce5e 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -545,7 +545,7 @@ namespace OpenSim.Framework void SendPayPrice(LLUUID objectID, int[] payPrice); void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, - LLVector3 Pos, byte[] textureEntry, uint parentID); + LLVector3 Pos, byte[] textureEntry, uint parentID, LLQuaternion rotation); void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity, LLQuaternion rotation); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 41ac657..3fa26e4 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -2132,7 +2132,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, - uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) + uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID, LLQuaternion rotation) { ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate); // TODO: don't create new blocks if recycling an old packet @@ -2147,9 +2147,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP objupdate.ObjectData[0].ParentID = parentID; objupdate.ObjectData[0].NameValue = Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName); + LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z); byte[] pb = pos2.GetBytes(); Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); + + byte[] rot = rotation.GetBytes(); + Array.Copy(rot, 0, objupdate.ObjectData[0].ObjectData, 52, rot.Length); + objupdate.Header.Zerocoded = true; OutPacket(objupdate, ThrottleOutPacketType.Task); } diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index 72520c4..4b42f9e 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs @@ -496,7 +496,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC } public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, - uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) + uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID, LLQuaternion rotation) { } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 39718dc..2434180 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -118,7 +118,7 @@ namespace OpenSim.Region.Environment.Scenes private bool m_setAlwaysRun = false; - private Quaternion m_bodyRot; + private Quaternion m_bodyRot= Quaternion.Identity; public bool IsRestrictedToRegion = false; @@ -1266,7 +1266,8 @@ namespace OpenSim.Region.Environment.Scenes SendFullUpdateToAllClients(); // This may seem stupid, but Our Full updates don't send avatar rotation :P // So we're also sending a terse update (which has avatar rotation) - SendTerseUpdateToAllClients(); + // [Update] We do now. + //SendTerseUpdateToAllClients(); } /// @@ -1617,9 +1618,19 @@ namespace OpenSim.Region.Environment.Scenes if (m_appearance.Texture == null) return; + LLQuaternion rot; + if (m_bodyRot != null) + { + rot = new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w); + } + else + { + rot = LLQuaternion.Identity; + } + remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, LocalId, m_pos, m_appearance.Texture.ToBytes(), - m_parentID); + m_parentID, rot); m_scene.AddAgentUpdates(1); } @@ -1671,8 +1682,18 @@ namespace OpenSim.Region.Environment.Scenes // Needed for standalone m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); + LLQuaternion rot; + if (m_bodyRot != null) + { + rot = new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w); + } + else + { + rot = LLQuaternion.Identity; + } + m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, LocalId, - m_pos, m_appearance.Texture.ToBytes(), m_parentID); + m_pos, m_appearance.Texture.ToBytes(), m_parentID, rot); if (!m_isChildAgent) { diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index bc675ff..22feab6 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -413,7 +413,7 @@ namespace OpenSim.Region.Examples.SimpleModule } public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, - uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) + uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID, LLQuaternion rotation) { } -- cgit v1.1