diff options
author | Teravus Ovares | 2008-04-26 17:36:30 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-04-26 17:36:30 +0000 |
commit | 323038ceb956fef577ebd83c502cc377bcfe83f9 (patch) | |
tree | 926410e63d94006e0d66d9ab24213b9f51519342 /OpenSim | |
parent | * Committing Mantis #1061 - llRegionSay and llSetPrimitiveParams implementati... (diff) | |
download | opensim-SC-323038ceb956fef577ebd83c502cc377bcfe83f9.zip opensim-SC-323038ceb956fef577ebd83c502cc377bcfe83f9.tar.gz opensim-SC-323038ceb956fef577ebd83c502cc377bcfe83f9.tar.bz2 opensim-SC-323038ceb956fef577ebd83c502cc377bcfe83f9.tar.xz |
* Ooops, attachments now teleport/cross region borders along with your avatar. Those dastardly objects stick to you.
Diffstat (limited to 'OpenSim')
6 files changed, 141 insertions, 22 deletions
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 2aa51b8..cbe5798 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs | |||
@@ -310,13 +310,22 @@ namespace OpenSim.Region.Environment.Scenes | |||
310 | } | 310 | } |
311 | 311 | ||
312 | } | 312 | } |
313 | /// <summary> | ||
314 | /// Event Handling routine for Attach Object | ||
315 | /// </summary> | ||
316 | /// <param name="remoteClient"></param> | ||
317 | /// <param name="objectLocalID"></param> | ||
318 | /// <param name="AttachmentPt"></param> | ||
319 | /// <param name="rot"></param> | ||
313 | public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot) | 320 | public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot) |
314 | { | 321 | { |
315 | List<EntityBase> EntityList = GetEntities(); | 322 | // Calls attach with a Zero position |
316 | 323 | AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, LLVector3.Zero); | |
317 | if (AttachmentPt == 0) | 324 | } |
318 | AttachmentPt = (uint)AttachmentPoint.LeftHand; | ||
319 | 325 | ||
326 | public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos) | ||
327 | { | ||
328 | List<EntityBase> EntityList = GetEntities(); | ||
320 | foreach (EntityBase obj in EntityList) | 329 | foreach (EntityBase obj in EntityList) |
321 | { | 330 | { |
322 | if (obj is SceneObjectGroup) | 331 | if (obj is SceneObjectGroup) |
@@ -324,7 +333,20 @@ namespace OpenSim.Region.Environment.Scenes | |||
324 | if (((SceneObjectGroup)obj).LocalId == objectLocalID) | 333 | if (((SceneObjectGroup)obj).LocalId == objectLocalID) |
325 | { | 334 | { |
326 | SceneObjectGroup group = (SceneObjectGroup)obj; | 335 | SceneObjectGroup group = (SceneObjectGroup)obj; |
327 | group.AttachToAgent(remoteClient.AgentId, AttachmentPt); | 336 | if (AttachmentPt == 0) |
337 | { | ||
338 | // Check object for stored attachment point | ||
339 | AttachmentPt = (uint)group.GetAttachmentPoint(); | ||
340 | |||
341 | // if we still didn't find a suitable attachment point....... | ||
342 | if (AttachmentPt == 0) | ||
343 | { | ||
344 | AttachmentPt = (uint)AttachmentPoint.LeftHand; | ||
345 | } | ||
346 | |||
347 | } | ||
348 | |||
349 | group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos); | ||
328 | 350 | ||
329 | } | 351 | } |
330 | 352 | ||
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index ce713c5..9ca845f 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1457,6 +1457,28 @@ namespace OpenSim.Region.Environment.Scenes | |||
1457 | if (XMLMethod == 0) | 1457 | if (XMLMethod == 0) |
1458 | { | 1458 | { |
1459 | m_sceneXmlLoader.LoadGroupFromXml2String(objXMLData); | 1459 | m_sceneXmlLoader.LoadGroupFromXml2String(objXMLData); |
1460 | SceneObjectPart RootPrim = GetSceneObjectPart(primID); | ||
1461 | if (RootPrim != null) | ||
1462 | { | ||
1463 | if (RootPrim.Shape.PCode == (byte)PCode.Prim) | ||
1464 | { | ||
1465 | SceneObjectGroup grp = RootPrim.ParentGroup; | ||
1466 | if (grp != null) | ||
1467 | { | ||
1468 | if (RootPrim.Shape.State != 0) | ||
1469 | { | ||
1470 | // Attachment | ||
1471 | ScenePresence sp = GetScenePresence(grp.OwnerID); | ||
1472 | if (sp != null) | ||
1473 | { | ||
1474 | m_innerScene.AttachObject(sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition); | ||
1475 | } | ||
1476 | } | ||
1477 | } | ||
1478 | |||
1479 | |||
1480 | } | ||
1481 | } | ||
1460 | return true; | 1482 | return true; |
1461 | } | 1483 | } |
1462 | else | 1484 | else |
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index 0062e4d..27967bc 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs | |||
@@ -580,6 +580,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
580 | avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), | 580 | avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), |
581 | capsPath); | 581 | capsPath); |
582 | avatar.MakeChildAgent(); | 582 | avatar.MakeChildAgent(); |
583 | System.Threading.Thread.Sleep(5000); | ||
584 | avatar.CrossAttachmentsIntoNewRegion(regionHandle); | ||
583 | if (KillObject != null) | 585 | if (KillObject != null) |
584 | { | 586 | { |
585 | KillObject(avatar.LocalId); | 587 | KillObject(avatar.LocalId); |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index fbf0a73..7020eb8 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -628,24 +628,39 @@ namespace OpenSim.Region.Environment.Scenes | |||
628 | } | 628 | } |
629 | 629 | ||
630 | 630 | ||
631 | public void AttachToAgent(LLUUID agentID, uint attachmentpoint) | 631 | public void AttachToAgent(LLUUID agentID, uint attachmentpoint, LLVector3 AttachOffset) |
632 | { | 632 | { |
633 | ScenePresence avatar = m_scene.GetScenePresence(agentID); | 633 | ScenePresence avatar = m_scene.GetScenePresence(agentID); |
634 | if (avatar != null) | 634 | if (avatar != null) |
635 | { | 635 | { |
636 | DetachFromBackup(this); | ||
636 | m_rootPart.m_attachedAvatar = agentID; | 637 | m_rootPart.m_attachedAvatar = agentID; |
637 | m_rootPart.SetParentLocalId(avatar.LocalId); | 638 | |
638 | m_rootPart.SetAttachmentPoint(attachmentpoint); | 639 | |
639 | m_rootPart.m_IsAttachment = true; | ||
640 | if (m_rootPart.PhysActor != null) | 640 | if (m_rootPart.PhysActor != null) |
641 | { | 641 | { |
642 | m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); | 642 | m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); |
643 | m_rootPart.PhysActor = null; | 643 | m_rootPart.PhysActor = null; |
644 | AbsolutePosition = LLVector3.Zero; | 644 | AbsolutePosition = AttachOffset; |
645 | m_rootPart.m_attachedPos = AttachOffset; | ||
645 | } | 646 | } |
647 | m_rootPart.m_IsAttachment = true; | ||
648 | |||
649 | m_rootPart.SetParentLocalId(avatar.LocalId); | ||
650 | m_rootPart.SetAttachmentPoint(attachmentpoint); | ||
651 | |||
652 | avatar.AddAttachment(this); | ||
646 | m_rootPart.ScheduleFullUpdate(); | 653 | m_rootPart.ScheduleFullUpdate(); |
647 | } | 654 | } |
648 | } | 655 | } |
656 | public byte GetAttachmentPoint() | ||
657 | { | ||
658 | if (m_rootPart != null) | ||
659 | { | ||
660 | return m_rootPart.Shape.State; | ||
661 | } | ||
662 | return (byte)0; | ||
663 | } | ||
649 | 664 | ||
650 | public void DetachToGround() | 665 | public void DetachToGround() |
651 | { | 666 | { |
@@ -654,6 +669,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
654 | if (avatar != null) | 669 | if (avatar != null) |
655 | { | 670 | { |
656 | detachedpos = avatar.AbsolutePosition; | 671 | detachedpos = avatar.AbsolutePosition; |
672 | avatar.RemoveAttachment(this); | ||
657 | } | 673 | } |
658 | AbsolutePosition = detachedpos; | 674 | AbsolutePosition = detachedpos; |
659 | m_rootPart.m_attachedAvatar = LLUUID.Zero; | 675 | m_rootPart.m_attachedAvatar = LLUUID.Zero; |
@@ -661,6 +677,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
661 | m_rootPart.SetAttachmentPoint((byte)0); | 677 | m_rootPart.SetAttachmentPoint((byte)0); |
662 | m_rootPart.m_IsAttachment = false; | 678 | m_rootPart.m_IsAttachment = false; |
663 | m_rootPart.ApplyPhysics(m_rootPart.ObjectFlags, m_scene.m_physicalPrim); | 679 | m_rootPart.ApplyPhysics(m_rootPart.ObjectFlags, m_scene.m_physicalPrim); |
680 | AttachToBackup(); | ||
664 | m_rootPart.ScheduleFullUpdate(); | 681 | m_rootPart.ScheduleFullUpdate(); |
665 | } | 682 | } |
666 | /// <summary> | 683 | /// <summary> |
@@ -1395,26 +1412,36 @@ namespace OpenSim.Region.Environment.Scenes | |||
1395 | 1412 | ||
1396 | lock (m_parts) | 1413 | lock (m_parts) |
1397 | { | 1414 | { |
1415 | //if (m_rootPart.m_IsAttachment) | ||
1416 | //{ | ||
1417 | //foreach (SceneObjectPart part in m_parts.Values) | ||
1418 | //{ | ||
1419 | //part.SendScheduledUpdates(); | ||
1420 | //} | ||
1421 | //return; | ||
1422 | //} | ||
1423 | |||
1398 | if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02) | 1424 | if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02) |
1399 | { | 1425 | { |
1400 | foreach (SceneObjectPart part in m_parts.Values) | 1426 | m_rootPart.UpdateFlag = 1; |
1401 | { | ||
1402 | if (part.UpdateFlag == 0) part.UpdateFlag = 1; | ||
1403 | } | ||
1404 | |||
1405 | lastPhysGroupPos = AbsolutePosition; | 1427 | lastPhysGroupPos = AbsolutePosition; |
1406 | checkAtTargets(); | ||
1407 | } | 1428 | } |
1429 | //foreach (SceneObjectPart part in m_parts.Values) | ||
1430 | //{ | ||
1431 | //if (part.UpdateFlag == 0) part.UpdateFlag = 1; | ||
1432 | //} | ||
1433 | |||
1434 | |||
1435 | |||
1436 | checkAtTargets(); | ||
1437 | |||
1408 | 1438 | ||
1409 | if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) | 1439 | if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) |
1410 | || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) | 1440 | || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) |
1411 | || (Math.Abs(lastPhysGroupRot.Y - GroupRotation.Y) > 0.1) | 1441 | || (Math.Abs(lastPhysGroupRot.Y - GroupRotation.Y) > 0.1) |
1412 | || (Math.Abs(lastPhysGroupRot.Z - GroupRotation.Z) > 0.1)) | 1442 | || (Math.Abs(lastPhysGroupRot.Z - GroupRotation.Z) > 0.1)) |
1413 | { | 1443 | { |
1414 | foreach (SceneObjectPart part in m_parts.Values) | 1444 | m_rootPart.UpdateFlag = 1; |
1415 | { | ||
1416 | if (part.UpdateFlag == 0) part.UpdateFlag = 1; | ||
1417 | } | ||
1418 | 1445 | ||
1419 | lastPhysGroupRot = GroupRotation; | 1446 | lastPhysGroupRot = GroupRotation; |
1420 | } | 1447 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 6a12fb9..b7e72ef 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -1300,6 +1300,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
1300 | public void SetAttachmentPoint(uint AttachmentPoint) | 1300 | public void SetAttachmentPoint(uint AttachmentPoint) |
1301 | { | 1301 | { |
1302 | m_attachmentPoint = AttachmentPoint; | 1302 | m_attachmentPoint = AttachmentPoint; |
1303 | |||
1304 | // save the attachment point. | ||
1305 | //if (AttachmentPoint != 0) | ||
1306 | //{ | ||
1307 | m_shape.State = (byte)AttachmentPoint; | ||
1308 | //} | ||
1309 | |||
1303 | } | 1310 | } |
1304 | /// <summary> | 1311 | /// <summary> |
1305 | /// | 1312 | /// |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 94dbbb3..6a56204 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -117,6 +117,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
117 | 117 | ||
118 | protected AvatarAppearance m_appearance; | 118 | protected AvatarAppearance m_appearance; |
119 | 119 | ||
120 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); | ||
121 | |||
120 | //neighbouring regions we have enabled a child agent in | 122 | //neighbouring regions we have enabled a child agent in |
121 | private readonly List<ulong> m_knownChildRegions = new List<ulong>(); | 123 | private readonly List<ulong> m_knownChildRegions = new List<ulong>(); |
122 | 124 | ||
@@ -1672,8 +1674,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
1672 | // When the neighbour is informed of the border crossing, it will set up CAPS handlers for the avatar | 1674 | // When the neighbour is informed of the border crossing, it will set up CAPS handlers for the avatar |
1673 | // This means we need to remove the current caps handler here and possibly compensate later, | 1675 | // This means we need to remove the current caps handler here and possibly compensate later, |
1674 | // in case both scenes are being hosted on the same region server. Messy | 1676 | // in case both scenes are being hosted on the same region server. Messy |
1675 | m_scene.RemoveCapsHandler(UUID); | 1677 | m_scene.RemoveCapsHandler(UUID); |
1676 | 1678 | newpos = newpos + (vel); | |
1677 | bool res = | 1679 | bool res = |
1678 | m_scene.InformNeighbourOfCrossing(neighbourHandle, m_controllingClient.AgentId, newpos, | 1680 | m_scene.InformNeighbourOfCrossing(neighbourHandle, m_controllingClient.AgentId, newpos, |
1679 | m_physicsActor.Flying); | 1681 | m_physicsActor.Flying); |
@@ -1692,6 +1694,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1692 | m_controllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint, | 1694 | m_controllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint, |
1693 | capsPath); | 1695 | capsPath); |
1694 | MakeChildAgent(); | 1696 | MakeChildAgent(); |
1697 | CrossAttachmentsIntoNewRegion(neighbourHandle); | ||
1695 | m_scene.SendKillObject(m_localId); | 1698 | m_scene.SendKillObject(m_localId); |
1696 | m_scene.NotifyMyCoarseLocationChange(); | 1699 | m_scene.NotifyMyCoarseLocationChange(); |
1697 | } | 1700 | } |
@@ -1943,7 +1946,43 @@ namespace OpenSim.Region.Environment.Scenes | |||
1943 | DefaultTexture = textu.ToBytes(); | 1946 | DefaultTexture = textu.ToBytes(); |
1944 | } | 1947 | } |
1945 | } | 1948 | } |
1949 | public void AddAttachment(SceneObjectGroup gobj) | ||
1950 | { | ||
1951 | lock (m_attachments) | ||
1952 | { | ||
1953 | m_attachments.Add(gobj); | ||
1954 | } | ||
1955 | } | ||
1956 | public void RemoveAttachment(SceneObjectGroup gobj) | ||
1957 | { | ||
1958 | lock (m_attachments) | ||
1959 | { | ||
1960 | if (m_attachments.Contains(gobj)) | ||
1961 | { | ||
1962 | m_attachments.Remove(gobj); | ||
1963 | } | ||
1964 | } | ||
1965 | } | ||
1966 | public void CrossAttachmentsIntoNewRegion(ulong regionHandle) | ||
1967 | { | ||
1968 | lock (m_attachments) | ||
1969 | { | ||
1970 | foreach (SceneObjectGroup gobj in m_attachments) | ||
1971 | { | ||
1972 | // If the prim group is null then something must have happened to it! | ||
1973 | if (gobj != null) | ||
1974 | { | ||
1975 | // Set the parent localID to 0 so it transfers over properly. | ||
1976 | gobj.RootPart.SetParentLocalId(0); | ||
1977 | gobj.RootPart.m_IsAttachment = false; | ||
1978 | gobj.AbsolutePosition = gobj.RootPart.m_attachedPos; | ||
1979 | m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj); | ||
1980 | } | ||
1981 | } | ||
1982 | m_attachments.Clear(); | ||
1983 | } | ||
1946 | 1984 | ||
1985 | } | ||
1947 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) | 1986 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) |
1948 | { | 1987 | { |
1949 | m_controllingClient = client; | 1988 | m_controllingClient = client; |