* Ooops, attachments now teleport/cross region borders along with your avatar. Those dastardly objects stick to you.

0.6.0-stable
Teravus Ovares 2008-04-26 17:36:30 +00:00
parent 3dc60c1433
commit 323038ceb9
6 changed files with 141 additions and 22 deletions

View File

@ -310,13 +310,22 @@ namespace OpenSim.Region.Environment.Scenes
}
}
/// <summary>
/// Event Handling routine for Attach Object
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="objectLocalID"></param>
/// <param name="AttachmentPt"></param>
/// <param name="rot"></param>
public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot)
{
// Calls attach with a Zero position
AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, LLVector3.Zero);
}
public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos)
{
List<EntityBase> EntityList = GetEntities();
if (AttachmentPt == 0)
AttachmentPt = (uint)AttachmentPoint.LeftHand;
foreach (EntityBase obj in EntityList)
{
if (obj is SceneObjectGroup)
@ -324,7 +333,20 @@ namespace OpenSim.Region.Environment.Scenes
if (((SceneObjectGroup)obj).LocalId == objectLocalID)
{
SceneObjectGroup group = (SceneObjectGroup)obj;
group.AttachToAgent(remoteClient.AgentId, AttachmentPt);
if (AttachmentPt == 0)
{
// Check object for stored attachment point
AttachmentPt = (uint)group.GetAttachmentPoint();
// if we still didn't find a suitable attachment point.......
if (AttachmentPt == 0)
{
AttachmentPt = (uint)AttachmentPoint.LeftHand;
}
}
group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos);
}

View File

@ -1457,6 +1457,28 @@ namespace OpenSim.Region.Environment.Scenes
if (XMLMethod == 0)
{
m_sceneXmlLoader.LoadGroupFromXml2String(objXMLData);
SceneObjectPart RootPrim = GetSceneObjectPart(primID);
if (RootPrim != null)
{
if (RootPrim.Shape.PCode == (byte)PCode.Prim)
{
SceneObjectGroup grp = RootPrim.ParentGroup;
if (grp != null)
{
if (RootPrim.Shape.State != 0)
{
// Attachment
ScenePresence sp = GetScenePresence(grp.OwnerID);
if (sp != null)
{
m_innerScene.AttachObject(sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition);
}
}
}
}
}
return true;
}
else

View File

@ -580,6 +580,8 @@ namespace OpenSim.Region.Environment.Scenes
avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4),
capsPath);
avatar.MakeChildAgent();
System.Threading.Thread.Sleep(5000);
avatar.CrossAttachmentsIntoNewRegion(regionHandle);
if (KillObject != null)
{
KillObject(avatar.LocalId);

View File

@ -628,24 +628,39 @@ namespace OpenSim.Region.Environment.Scenes
}
public void AttachToAgent(LLUUID agentID, uint attachmentpoint)
public void AttachToAgent(LLUUID agentID, uint attachmentpoint, LLVector3 AttachOffset)
{
ScenePresence avatar = m_scene.GetScenePresence(agentID);
if (avatar != null)
{
DetachFromBackup(this);
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;
AbsolutePosition = AttachOffset;
m_rootPart.m_attachedPos = AttachOffset;
}
m_rootPart.m_IsAttachment = true;
m_rootPart.SetParentLocalId(avatar.LocalId);
m_rootPart.SetAttachmentPoint(attachmentpoint);
avatar.AddAttachment(this);
m_rootPart.ScheduleFullUpdate();
}
}
public byte GetAttachmentPoint()
{
if (m_rootPart != null)
{
return m_rootPart.Shape.State;
}
return (byte)0;
}
public void DetachToGround()
{
@ -654,6 +669,7 @@ namespace OpenSim.Region.Environment.Scenes
if (avatar != null)
{
detachedpos = avatar.AbsolutePosition;
avatar.RemoveAttachment(this);
}
AbsolutePosition = detachedpos;
m_rootPart.m_attachedAvatar = LLUUID.Zero;
@ -661,6 +677,7 @@ namespace OpenSim.Region.Environment.Scenes
m_rootPart.SetAttachmentPoint((byte)0);
m_rootPart.m_IsAttachment = false;
m_rootPart.ApplyPhysics(m_rootPart.ObjectFlags, m_scene.m_physicalPrim);
AttachToBackup();
m_rootPart.ScheduleFullUpdate();
}
/// <summary>
@ -1395,26 +1412,36 @@ namespace OpenSim.Region.Environment.Scenes
lock (m_parts)
{
//if (m_rootPart.m_IsAttachment)
//{
//foreach (SceneObjectPart part in m_parts.Values)
//{
//part.SendScheduledUpdates();
//}
//return;
//}
if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02)
{
foreach (SceneObjectPart part in m_parts.Values)
{
if (part.UpdateFlag == 0) part.UpdateFlag = 1;
}
m_rootPart.UpdateFlag = 1;
lastPhysGroupPos = AbsolutePosition;
checkAtTargets();
}
//foreach (SceneObjectPart part in m_parts.Values)
//{
//if (part.UpdateFlag == 0) part.UpdateFlag = 1;
//}
checkAtTargets();
if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1)
|| (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1)
|| (Math.Abs(lastPhysGroupRot.Y - GroupRotation.Y) > 0.1)
|| (Math.Abs(lastPhysGroupRot.Z - GroupRotation.Z) > 0.1))
{
foreach (SceneObjectPart part in m_parts.Values)
{
if (part.UpdateFlag == 0) part.UpdateFlag = 1;
}
m_rootPart.UpdateFlag = 1;
lastPhysGroupRot = GroupRotation;
}

View File

@ -1300,6 +1300,13 @@ namespace OpenSim.Region.Environment.Scenes
public void SetAttachmentPoint(uint AttachmentPoint)
{
m_attachmentPoint = AttachmentPoint;
// save the attachment point.
//if (AttachmentPoint != 0)
//{
m_shape.State = (byte)AttachmentPoint;
//}
}
/// <summary>
///

View File

@ -117,6 +117,8 @@ namespace OpenSim.Region.Environment.Scenes
protected AvatarAppearance m_appearance;
protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
//neighbouring regions we have enabled a child agent in
private readonly List<ulong> m_knownChildRegions = new List<ulong>();
@ -1672,8 +1674,8 @@ namespace OpenSim.Region.Environment.Scenes
// When the neighbour is informed of the border crossing, it will set up CAPS handlers for the avatar
// This means we need to remove the current caps handler here and possibly compensate later,
// in case both scenes are being hosted on the same region server. Messy
m_scene.RemoveCapsHandler(UUID);
m_scene.RemoveCapsHandler(UUID);
newpos = newpos + (vel);
bool res =
m_scene.InformNeighbourOfCrossing(neighbourHandle, m_controllingClient.AgentId, newpos,
m_physicsActor.Flying);
@ -1692,6 +1694,7 @@ namespace OpenSim.Region.Environment.Scenes
m_controllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint,
capsPath);
MakeChildAgent();
CrossAttachmentsIntoNewRegion(neighbourHandle);
m_scene.SendKillObject(m_localId);
m_scene.NotifyMyCoarseLocationChange();
}
@ -1943,7 +1946,43 @@ namespace OpenSim.Region.Environment.Scenes
DefaultTexture = textu.ToBytes();
}
}
public void AddAttachment(SceneObjectGroup gobj)
{
lock (m_attachments)
{
m_attachments.Add(gobj);
}
}
public void RemoveAttachment(SceneObjectGroup gobj)
{
lock (m_attachments)
{
if (m_attachments.Contains(gobj))
{
m_attachments.Remove(gobj);
}
}
}
public void CrossAttachmentsIntoNewRegion(ulong regionHandle)
{
lock (m_attachments)
{
foreach (SceneObjectGroup gobj in m_attachments)
{
// If the prim group is null then something must have happened to it!
if (gobj != null)
{
// Set the parent localID to 0 so it transfers over properly.
gobj.RootPart.SetParentLocalId(0);
gobj.RootPart.m_IsAttachment = false;
gobj.AbsolutePosition = gobj.RootPart.m_attachedPos;
m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj);
}
}
m_attachments.Clear();
}
}
public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
{
m_controllingClient = client;