From aa8aee90a35458f1f601ca23e2298b212782d0a3 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 24 Apr 2008 11:32:41 +0000 Subject: * Adds much better support for attachments that you right click on in world. * Your friends can see your attachments now. People who appear in the sim after you've attached something can also see your attachments. * You can position & rotate your attachments now. Positions do *not* save. * You can detach attachments now the regular way. * Attachments do not cross into other regions with you..(this isn't too far off) * Updated ODE to not request terse updates on child prim. --- OpenSim/Region/Environment/Scenes/InnerScene.cs | 55 ++++++++++++++++++++-- OpenSim/Region/Environment/Scenes/Scene.cs | 1 + .../Region/Environment/Scenes/SceneObjectGroup.cs | 38 ++++++++++++++- .../Region/Environment/Scenes/SceneObjectPart.cs | 34 ++++++++++--- 4 files changed, 116 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 2b28b2a..668e50f 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -293,9 +293,46 @@ namespace OpenSim.Region.Environment.Scenes } } } + public void DetachObject(uint objectLocalID, IClientAPI remoteClient) + { + List EntityList = GetEntities(); + foreach (EntityBase obj in EntityList) + { + if (obj is SceneObjectGroup) + { + if (((SceneObjectGroup)obj).LocalId == objectLocalID) + { + SceneObjectGroup group = (SceneObjectGroup)obj; + group.DetachToGround(); + } + } + } + + } public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot) { + List EntityList = GetEntities(); + + foreach (EntityBase obj in EntityList) + { + if (obj is SceneObjectGroup) + { + if (((SceneObjectGroup)obj).LocalId == objectLocalID) + { + SceneObjectGroup group = (SceneObjectGroup)obj; + group.AttachToAgent(remoteClient.AgentId, AttachmentPt); + + } + + } + } + + } + // Use the above method. + public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, + bool deadMethod) + { Console.WriteLine("Attaching object " + objectLocalID + " to " + AttachmentPt); SceneObjectPart p = GetSceneObjectPart(objectLocalID); if (p != null) @@ -1005,15 +1042,23 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = GetGroupByPrim(localID); if (group != null) { + LLVector3 oldPos = group.AbsolutePosition; - if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos)) + if (group.RootPart.m_IsAttachment) { - group.SendGroupTerseUpdate(); - return; + group.UpdateGroupPosition(pos); } - if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + else { - group.UpdateGroupPosition(pos); + if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos)) + { + group.SendGroupTerseUpdate(); + return; + } + if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) + { + group.UpdateGroupPosition(pos); + } } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index c41a445..21c8991 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1528,6 +1528,7 @@ namespace OpenSim.Region.Environment.Scenes client.OnRezObject += RezObject; client.OnRezSingleAttachmentFromInv += RezSingleAttachment; client.OnObjectAttach += m_innerScene.AttachObject; + client.OnObjectDetach += m_innerScene.DetachObject; client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; client.OnObjectDescription += m_innerScene.PrimDescription; client.OnObjectName += m_innerScene.PrimName; diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 4f65cc7..27639ea 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -180,7 +180,7 @@ namespace OpenSim.Region.Environment.Scenes set { LLVector3 val = value; - if (val.X > 257f || val.X < -1f || val.Y > 257f || val.Y < -1f) + if ((val.X > 257f || val.X < -1f || val.Y > 257f || val.Y < -1f) && !m_rootPart.m_IsAttachment) { m_scene.CrossPrimGroupIntoNewRegion(val, this); } @@ -612,6 +612,42 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart = part; } + + public void AttachToAgent(LLUUID agentID, uint attachmentpoint) + { + ScenePresence avatar = m_scene.GetScenePresence(agentID); + if (avatar != null) + { + m_rootPart.m_attachedAvatar = agentID; + m_rootPart.SetParentLocalId(avatar.LocalId); + m_rootPart.SetAttachmentPoint(attachmentpoint); + m_rootPart.m_IsAttachment = true; + if (m_rootPart.PhysActor != null) + { + m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); + m_rootPart.PhysActor = null; + AbsolutePosition = LLVector3.Zero; + } + m_rootPart.ScheduleFullUpdate(); + } + } + + public void DetachToGround() + { + ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); + LLVector3 detachedpos = new LLVector3(127f,127f,127f); + if (avatar != null) + { + detachedpos = avatar.AbsolutePosition; + } + AbsolutePosition = detachedpos; + m_rootPart.m_attachedAvatar = LLUUID.Zero; + m_rootPart.SetParentLocalId(0); + m_rootPart.SetAttachmentPoint((byte)0); + m_rootPart.m_IsAttachment = false; + m_rootPart.ApplyPhysics(m_rootPart.ObjectFlags, m_scene.m_physicalPrim); + m_rootPart.ScheduleFullUpdate(); + } /// /// /// diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index e2cb3ac..099d0f0 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -99,6 +99,11 @@ namespace OpenSim.Region.Environment.Scenes // TODO: This needs to be persisted in next XML version update! [XmlIgnore] public int[] PayPrice = {0,0,0,0,0}; + + [XmlIgnore] public bool m_IsAttachment = false; + [XmlIgnore] public uint m_attachmentPoint = (byte)0; + [XmlIgnore] public LLUUID m_attachedAvatar = LLUUID.Zero; + public Int32 CreationDate; public uint ParentID = 0; @@ -1271,7 +1276,17 @@ namespace OpenSim.Region.Environment.Scenes } return returnresult; } + + // Use this for attachments! LocalID should be avatar's localid + public void SetParentLocalId(uint localID) + { + ParentID = localID; + } + public void SetAttachmentPoint(uint AttachmentPoint) + { + m_attachmentPoint = AttachmentPoint; + } /// /// /// @@ -2212,7 +2227,7 @@ namespace OpenSim.Region.Environment.Scenes byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, lPos, clientFlags, m_uuid, OwnerID, - m_text, color, ParentID, m_particleSystem, lRot, m_clickAction, m_TextureAnimation); + m_text, color, ParentID, m_particleSystem, lRot, m_clickAction, m_TextureAnimation, m_IsAttachment, m_attachmentPoint); } /// Terse updates @@ -2271,15 +2286,22 @@ namespace OpenSim.Region.Environment.Scenes public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) { LLQuaternion mRot = RotationOffset; - if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) + if (m_IsAttachment) { - remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State); + remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, (byte)(((byte)m_attachmentPoint) << 4)); } else { - remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Velocity, - RotationalVelocity); - //System.Console.WriteLine("LID: " + LocalID + "RVel:" + RotationalVelocity.ToString() + " TD: " + ((ushort)(m_parentGroup.Scene.TimeDilation * 500000f)).ToString() + ":" + m_parentGroup.Scene.TimeDilation.ToString()); + if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) + { + remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State); + } + else + { + remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Velocity, + RotationalVelocity); + //System.Console.WriteLine("LID: " + LocalID + "RVel:" + RotationalVelocity.ToString() + " TD: " + ((ushort)(m_parentGroup.Scene.TimeDilation * 500000f)).ToString() + ":" + m_parentGroup.Scene.TimeDilation.ToString()); + } } } -- cgit v1.1