From 3433f3814acbed69b60f177576602a6cb6a3677c Mon Sep 17 00:00:00 2001 From: Dalien Talbot Date: Sat, 8 Sep 2007 16:30:39 +0000 Subject: Partial fix for the "avatars permanently facing east" - now the rotation is set correctly, but only with the movement of the avatar. The in-place rotation updates need a little bit of more thought, and will be in a separate commit. --- OpenSim/Region/ClientStack/ClientView.API.cs | 29 ++++++++++++++-------- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 9 +++++-- .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 2 +- 3 files changed, 26 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index edc1268..c5a2284 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -929,9 +929,9 @@ namespace OpenSim.Region.ClientStack /// /// /// - public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity) + public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity, LLQuaternion rotation) { - ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity); + ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity, rotation); ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); terse.RegionData.RegionHandle = regionHandle; terse.RegionData.TimeDilation = timeDilation; @@ -1018,7 +1018,7 @@ namespace OpenSim.Region.ClientStack #region Helper Methods - protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity) + protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity, LLQuaternion rotation) { byte[] bytes = new byte[60]; int i = 0; @@ -1073,15 +1073,22 @@ namespace OpenSim.Region.ClientStack bytes[i++] = (byte)(ac % 256); bytes[i++] = (byte)((ac >> 8) % 256); + //rotation + ushort rw, rx, ry, rz; + rw = (ushort)(32768 * (rotation.W + 1)); + rx = (ushort)(32768 * (rotation.X + 1)); + ry = (ushort)(32768 * (rotation.Y + 1)); + rz = (ushort)(32768 * (rotation.Z + 1)); + //rot - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte)(rx % 256); + bytes[i++] = (byte)((rx >> 8) % 256); + bytes[i++] = (byte)(ry % 256); + bytes[i++] = (byte)((ry >> 8) % 256); + bytes[i++] = (byte)(rz % 256); + bytes[i++] = (byte)((rz >> 8) % 256); + bytes[i++] = (byte)(rw % 256); + bytes[i++] = (byte)((rw >> 8) % 256); //rotation vel bytes[i++] = (byte)(ac % 256); diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 1f8e5bb..c96d575 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -372,7 +372,7 @@ namespace OpenSim.Region.Environment.Scenes { this.bodyRot = q; update_rotation = true; - } + } foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) { if ((flags & (uint)DCF) != 0) @@ -495,7 +495,12 @@ namespace OpenSim.Region.Environment.Scenes { LLVector3 pos = this.AbsolutePosition; 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)); + LLQuaternion rot; + rot.X = this.bodyRot.x; + rot.Y = this.bodyRot.y; + rot.Z = this.bodyRot.z; + rot.W = this.bodyRot.w; + RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z), rot); } /// diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index 4b05287..7e1f5c1 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -153,7 +153,7 @@ namespace SimpleApp public virtual void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) { } public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry) { } - public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity) { } + public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity, LLQuaternion rotation) { } public virtual void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) { } -- cgit v1.1