aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorTeravus Ovares2008-04-24 11:32:41 +0000
committerTeravus Ovares2008-04-24 11:32:41 +0000
commitaa8aee90a35458f1f601ca23e2298b212782d0a3 (patch)
tree37c2645867cba040a4ad7e32d1b5ccd56d155d87 /OpenSim/Region/Environment
parent* From: Alan M Webb <awebb.vnet.ibm.com> (diff)
downloadopensim-SC-aa8aee90a35458f1f601ca23e2298b212782d0a3.zip
opensim-SC-aa8aee90a35458f1f601ca23e2298b212782d0a3.tar.gz
opensim-SC-aa8aee90a35458f1f601ca23e2298b212782d0a3.tar.bz2
opensim-SC-aa8aee90a35458f1f601ca23e2298b212782d0a3.tar.xz
* 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.
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs55
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs1
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs38
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs34
4 files changed, 116 insertions, 12 deletions
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
293 } 293 }
294 } 294 }
295 } 295 }
296 public void DetachObject(uint objectLocalID, IClientAPI remoteClient)
297 {
298 List<EntityBase> EntityList = GetEntities();
296 299
300 foreach (EntityBase obj in EntityList)
301 {
302 if (obj is SceneObjectGroup)
303 {
304 if (((SceneObjectGroup)obj).LocalId == objectLocalID)
305 {
306 SceneObjectGroup group = (SceneObjectGroup)obj;
307 group.DetachToGround();
308 }
309 }
310 }
311
312 }
297 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot) 313 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot)
298 { 314 {
315 List<EntityBase> EntityList = GetEntities();
316
317 foreach (EntityBase obj in EntityList)
318 {
319 if (obj is SceneObjectGroup)
320 {
321 if (((SceneObjectGroup)obj).LocalId == objectLocalID)
322 {
323 SceneObjectGroup group = (SceneObjectGroup)obj;
324 group.AttachToAgent(remoteClient.AgentId, AttachmentPt);
325
326 }
327
328 }
329 }
330
331 }
332 // Use the above method.
333 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot,
334 bool deadMethod)
335 {
299 Console.WriteLine("Attaching object " + objectLocalID + " to " + AttachmentPt); 336 Console.WriteLine("Attaching object " + objectLocalID + " to " + AttachmentPt);
300 SceneObjectPart p = GetSceneObjectPart(objectLocalID); 337 SceneObjectPart p = GetSceneObjectPart(objectLocalID);
301 if (p != null) 338 if (p != null)
@@ -1005,15 +1042,23 @@ namespace OpenSim.Region.Environment.Scenes
1005 SceneObjectGroup group = GetGroupByPrim(localID); 1042 SceneObjectGroup group = GetGroupByPrim(localID);
1006 if (group != null) 1043 if (group != null)
1007 { 1044 {
1045
1008 LLVector3 oldPos = group.AbsolutePosition; 1046 LLVector3 oldPos = group.AbsolutePosition;
1009 if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos)) 1047 if (group.RootPart.m_IsAttachment)
1010 { 1048 {
1011 group.SendGroupTerseUpdate(); 1049 group.UpdateGroupPosition(pos);
1012 return;
1013 } 1050 }
1014 if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) 1051 else
1015 { 1052 {
1016 group.UpdateGroupPosition(pos); 1053 if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos))
1054 {
1055 group.SendGroupTerseUpdate();
1056 return;
1057 }
1058 if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID))
1059 {
1060 group.UpdateGroupPosition(pos);
1061 }
1017 } 1062 }
1018 } 1063 }
1019 } 1064 }
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
1528 client.OnRezObject += RezObject; 1528 client.OnRezObject += RezObject;
1529 client.OnRezSingleAttachmentFromInv += RezSingleAttachment; 1529 client.OnRezSingleAttachmentFromInv += RezSingleAttachment;
1530 client.OnObjectAttach += m_innerScene.AttachObject; 1530 client.OnObjectAttach += m_innerScene.AttachObject;
1531 client.OnObjectDetach += m_innerScene.DetachObject;
1531 client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; 1532 client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest;
1532 client.OnObjectDescription += m_innerScene.PrimDescription; 1533 client.OnObjectDescription += m_innerScene.PrimDescription;
1533 client.OnObjectName += m_innerScene.PrimName; 1534 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
180 set 180 set
181 { 181 {
182 LLVector3 val = value; 182 LLVector3 val = value;
183 if (val.X > 257f || val.X < -1f || val.Y > 257f || val.Y < -1f) 183 if ((val.X > 257f || val.X < -1f || val.Y > 257f || val.Y < -1f) && !m_rootPart.m_IsAttachment)
184 { 184 {
185 m_scene.CrossPrimGroupIntoNewRegion(val, this); 185 m_scene.CrossPrimGroupIntoNewRegion(val, this);
186 } 186 }
@@ -612,6 +612,42 @@ namespace OpenSim.Region.Environment.Scenes
612 m_rootPart = part; 612 m_rootPart = part;
613 } 613 }
614 614
615
616 public void AttachToAgent(LLUUID agentID, uint attachmentpoint)
617 {
618 ScenePresence avatar = m_scene.GetScenePresence(agentID);
619 if (avatar != null)
620 {
621 m_rootPart.m_attachedAvatar = agentID;
622 m_rootPart.SetParentLocalId(avatar.LocalId);
623 m_rootPart.SetAttachmentPoint(attachmentpoint);
624 m_rootPart.m_IsAttachment = true;
625 if (m_rootPart.PhysActor != null)
626 {
627 m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor);
628 m_rootPart.PhysActor = null;
629 AbsolutePosition = LLVector3.Zero;
630 }
631 m_rootPart.ScheduleFullUpdate();
632 }
633 }
634
635 public void DetachToGround()
636 {
637 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar);
638 LLVector3 detachedpos = new LLVector3(127f,127f,127f);
639 if (avatar != null)
640 {
641 detachedpos = avatar.AbsolutePosition;
642 }
643 AbsolutePosition = detachedpos;
644 m_rootPart.m_attachedAvatar = LLUUID.Zero;
645 m_rootPart.SetParentLocalId(0);
646 m_rootPart.SetAttachmentPoint((byte)0);
647 m_rootPart.m_IsAttachment = false;
648 m_rootPart.ApplyPhysics(m_rootPart.ObjectFlags, m_scene.m_physicalPrim);
649 m_rootPart.ScheduleFullUpdate();
650 }
615 /// <summary> 651 /// <summary>
616 /// 652 ///
617 /// </summary> 653 /// </summary>
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
99 // TODO: This needs to be persisted in next XML version update! 99 // TODO: This needs to be persisted in next XML version update!
100 [XmlIgnore] public int[] PayPrice = {0,0,0,0,0}; 100 [XmlIgnore] public int[] PayPrice = {0,0,0,0,0};
101 101
102
103 [XmlIgnore] public bool m_IsAttachment = false;
104 [XmlIgnore] public uint m_attachmentPoint = (byte)0;
105 [XmlIgnore] public LLUUID m_attachedAvatar = LLUUID.Zero;
106
102 public Int32 CreationDate; 107 public Int32 CreationDate;
103 public uint ParentID = 0; 108 public uint ParentID = 0;
104 109
@@ -1271,7 +1276,17 @@ namespace OpenSim.Region.Environment.Scenes
1271 } 1276 }
1272 return returnresult; 1277 return returnresult;
1273 } 1278 }
1279
1280 // Use this for attachments! LocalID should be avatar's localid
1281 public void SetParentLocalId(uint localID)
1282 {
1283 ParentID = localID;
1284 }
1274 1285
1286 public void SetAttachmentPoint(uint AttachmentPoint)
1287 {
1288 m_attachmentPoint = AttachmentPoint;
1289 }
1275 /// <summary> 1290 /// <summary>
1276 /// 1291 ///
1277 /// </summary> 1292 /// </summary>
@@ -2212,7 +2227,7 @@ namespace OpenSim.Region.Environment.Scenes
2212 byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; 2227 byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A};
2213 remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, lPos, clientFlags, m_uuid, 2228 remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, lPos, clientFlags, m_uuid,
2214 OwnerID, 2229 OwnerID,
2215 m_text, color, ParentID, m_particleSystem, lRot, m_clickAction, m_TextureAnimation); 2230 m_text, color, ParentID, m_particleSystem, lRot, m_clickAction, m_TextureAnimation, m_IsAttachment, m_attachmentPoint);
2216 } 2231 }
2217 2232
2218 /// Terse updates 2233 /// Terse updates
@@ -2271,15 +2286,22 @@ namespace OpenSim.Region.Environment.Scenes
2271 public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) 2286 public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos)
2272 { 2287 {
2273 LLQuaternion mRot = RotationOffset; 2288 LLQuaternion mRot = RotationOffset;
2274 if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) 2289 if (m_IsAttachment)
2275 { 2290 {
2276 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State); 2291 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, (byte)(((byte)m_attachmentPoint) << 4));
2277 } 2292 }
2278 else 2293 else
2279 { 2294 {
2280 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Velocity, 2295 if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0)
2281 RotationalVelocity); 2296 {
2282 //System.Console.WriteLine("LID: " + LocalID + "RVel:" + RotationalVelocity.ToString() + " TD: " + ((ushort)(m_parentGroup.Scene.TimeDilation * 500000f)).ToString() + ":" + m_parentGroup.Scene.TimeDilation.ToString()); 2297 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State);
2298 }
2299 else
2300 {
2301 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Velocity,
2302 RotationalVelocity);
2303 //System.Console.WriteLine("LID: " + LocalID + "RVel:" + RotationalVelocity.ToString() + " TD: " + ((ushort)(m_parentGroup.Scene.TimeDilation * 500000f)).ToString() + ":" + m_parentGroup.Scene.TimeDilation.ToString());
2304 }
2283 } 2305 }
2284 } 2306 }
2285 2307