Making attachments work again. Tons of debug more. This needs more testing and a lot of cleaning.

arthursv
Diva Canto 2009-08-16 16:17:19 -07:00
parent 6808b9109e
commit e02062051d
8 changed files with 183 additions and 66 deletions

View File

@ -215,6 +215,7 @@ namespace OpenSim.Framework
} }
} }
/// <summary> /// <summary>
/// Serializable Agent Circuit Data /// Serializable Agent Circuit Data
/// </summary> /// </summary>

View File

@ -226,6 +226,46 @@ namespace OpenSim.Framework
} }
} }
public class AttachmentData
{
public int AttachPoint;
public UUID ItemID;
public UUID AssetID;
public AttachmentData(int point, UUID item, UUID asset)
{
AttachPoint = point;
ItemID = item;
AssetID = asset;
}
public AttachmentData(OSDMap args)
{
UnpackUpdateMessage(args);
}
public OSDMap PackUpdateMessage()
{
OSDMap attachdata = new OSDMap();
attachdata["point"] = OSD.FromInteger(AttachPoint);
attachdata["item"] = OSD.FromUUID(ItemID);
attachdata["asset"] = OSD.FromUUID(AssetID);
return attachdata;
}
public void UnpackUpdateMessage(OSDMap args)
{
if (args["point"] != null)
AttachPoint = args["point"].AsInteger();
if (args["item"] != null)
ItemID = args["item"].AsUUID();
if (args["asset"] != null)
AssetID = args["asset"].AsUUID();
}
}
public class AgentData : IAgentData public class AgentData : IAgentData
{ {
private UUID m_id; private UUID m_id;
@ -272,6 +312,7 @@ namespace OpenSim.Framework
public byte[] AgentTextures; public byte[] AgentTextures;
public byte[] VisualParams; public byte[] VisualParams;
public UUID[] Wearables; public UUID[] Wearables;
public AttachmentData[] Attachments;
public string CallbackURI; public string CallbackURI;
@ -352,6 +393,13 @@ namespace OpenSim.Framework
args["wearables"] = wears; args["wearables"] = wears;
} }
if ((Attachments != null) && (Attachments.Length > 0))
{
OSDArray attachs = new OSDArray(Attachments.Length);
foreach (AttachmentData att in Attachments)
attachs.Add(att.PackUpdateMessage());
args["attachments"] = attachs;
}
if ((CallbackURI != null) && (!CallbackURI.Equals(""))) if ((CallbackURI != null) && (!CallbackURI.Equals("")))
args["callback_uri"] = OSD.FromString(CallbackURI); args["callback_uri"] = OSD.FromString(CallbackURI);
@ -492,7 +540,21 @@ namespace OpenSim.Framework
foreach (OSD o in wears) foreach (OSD o in wears)
Wearables[i++] = o.AsUUID(); Wearables[i++] = o.AsUUID();
} }
if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
{
OSDArray attachs = (OSDArray)(args["attachments"]);
Attachments = new AttachmentData[attachs.Count];
int i = 0;
foreach (OSD o in attachs)
{
if (o.Type == OSDType.Map)
{
Attachments[i++] = new AttachmentData((OSDMap)o);
}
}
}
if (args["callback_uri"] != null) if (args["callback_uri"] != null)
CallbackURI = args["callback_uri"].AsString(); CallbackURI = args["callback_uri"].AsString();
} }

View File

@ -274,9 +274,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown)) if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
folders[(AssetType)folder.Type] = folder; folders[(AssetType)folder.Type] = folder;
} }
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: System folders count for {0}: {1}", userID, folders.Count);
// Put the root folder there, as type Folder // Put the root folder there, as type Folder
folders[AssetType.Folder] = root; folders[AssetType.Folder] = root;
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: System folders count for {0}: {1}", userID, folders.Count);
return folders; return folders;
} }
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder content not found for {0}", userID); m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder content not found for {0}", userID);

View File

@ -2357,7 +2357,9 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence presence; ScenePresence presence;
if (TryGetAvatar(remoteClient.AgentId, out presence)) if (TryGetAvatar(remoteClient.AgentId, out presence))
{ {
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, att.UUID); // XXYY!!
InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID));
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>(); IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
if (ava != null) if (ava != null)
{ {

View File

@ -2042,13 +2042,22 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
m_log.DebugFormat( m_log.DebugFormat(
"[SCENE]: Adding new child agent for {0} in {1}", "[SCENE]: Adding new {0} agent for {1} in {2}",
client.Name, RegionInfo.RegionName); ((aCircuit.child == true) ? "child" : "root"), client.Name, RegionInfo.RegionName);
CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
CreateAndAddScenePresence(client); ScenePresence sp = CreateAndAddScenePresence(client);
// HERE!!! Do the initial attachments here
if (aCircuit.child == false) // first agent upon login is root agent
{
sp.IsChildAgent = false;
sp.RezAttachments();
}
} }
m_LastLogin = Environment.TickCount; m_LastLogin = Environment.TickCount;

View File

@ -557,6 +557,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup group = GetGroupByPrim(objectLocalID); SceneObjectGroup group = GetGroupByPrim(objectLocalID);
if (group != null) if (group != null)
{ {
m_log.DebugFormat("[SCENE GRAPH]: AttachObject got {0}", group.UUID);
if (m_parentScene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) if (m_parentScene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
{ {
// If the attachment point isn't the same as the one previously used // If the attachment point isn't the same as the one previously used
@ -564,6 +565,7 @@ namespace OpenSim.Region.Framework.Scenes
// and not in a weird location somewhere unknown. // and not in a weird location somewhere unknown.
if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint()) if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint())
{ {
m_log.DebugFormat("[SCENE GRAPH]: AttachObject 1 got {0}", group.UUID);
attachPos = Vector3.Zero; attachPos = Vector3.Zero;
} }
@ -572,7 +574,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
// Check object for stored attachment point // Check object for stored attachment point
AttachmentPt = (uint)group.GetAttachmentPoint(); AttachmentPt = (uint)group.GetAttachmentPoint();
} m_log.DebugFormat("[SCENE GRAPH]: AttachObject 2 got {0}", group.UUID);
}
// if we still didn't find a suitable attachment point....... // if we still didn't find a suitable attachment point.......
if (AttachmentPt == 0) if (AttachmentPt == 0)
@ -580,8 +583,12 @@ namespace OpenSim.Region.Framework.Scenes
// Stick it on left hand with Zero Offset from the attachment point. // Stick it on left hand with Zero Offset from the attachment point.
AttachmentPt = (uint)AttachmentPoint.LeftHand; AttachmentPt = (uint)AttachmentPoint.LeftHand;
attachPos = Vector3.Zero; attachPos = Vector3.Zero;
m_log.DebugFormat("[SCENE GRAPH]: AttachObject 3 got {0}", group.UUID);
} }
m_log.DebugFormat("[SCENE GRAPH]: AttachObject 4 got {0}", group.UUID);
group.SetAttachmentPoint(Convert.ToByte(AttachmentPt)); group.SetAttachmentPoint(Convert.ToByte(AttachmentPt));
group.AbsolutePosition = attachPos; group.AbsolutePosition = attachPos;
@ -590,10 +597,12 @@ namespace OpenSim.Region.Framework.Scenes
if (group.GetFromItemID() == UUID.Zero) if (group.GetFromItemID() == UUID.Zero)
{ {
m_log.DebugFormat("[SCENE GRAPH]: AttachObject 5 got {0}", group.UUID);
m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId); m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId);
} }
else else
{ {
m_log.DebugFormat("[SCENE GRAPH]: AttachObject 6 got {0}", group.GetFromItemID());
itemId = group.GetFromItemID(); itemId = group.GetFromItemID();
} }
@ -611,6 +620,8 @@ namespace OpenSim.Region.Framework.Scenes
remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false); remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false);
} }
} }
else
m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID);
} }
protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance)

View File

@ -935,6 +935,7 @@ namespace OpenSim.Region.Framework.Scenes
SetAttachmentPoint(Convert.ToByte(attachmentpoint)); SetAttachmentPoint(Convert.ToByte(attachmentpoint));
avatar.AddAttachment(this); avatar.AddAttachment(this);
m_log.DebugFormat("[SOG]: Added att {0} to avie {1}", UUID, avatar.UUID);
if (!silent) if (!silent)
{ {

View File

@ -652,9 +652,6 @@ namespace OpenSim.Region.Framework.Scenes
RegisterToEvents(); RegisterToEvents();
SetDirectionVectors(); SetDirectionVectors();
CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid);
if (userInfo != null)
userInfo.OnItemReceived += ItemReceived;
} }
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
@ -1021,7 +1018,9 @@ namespace OpenSim.Region.Framework.Scenes
} }
/// <summary> /// <summary>
/// Complete Avatar's movement into the region /// Complete Avatar's movement into the region.
/// This is called upon a very important packet sent from the client,
/// so it's client-controlled. Never call this method directly.
/// </summary> /// </summary>
public void CompleteMovement() public void CompleteMovement()
{ {
@ -1042,22 +1041,19 @@ namespace OpenSim.Region.Framework.Scenes
AbsolutePosition = pos; AbsolutePosition = pos;
} }
if (m_isChildAgent) m_isChildAgent = false;
bool m_flying = ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
MakeRootAgent(AbsolutePosition, m_flying);
if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
{ {
m_isChildAgent = false; m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
bool m_flying = ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI);
MakeRootAgent(AbsolutePosition, m_flying); m_callbackURI = null;
if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
{
m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI);
m_callbackURI = null;
}
//m_log.DebugFormat("Completed movement");
} }
//m_log.DebugFormat("Completed movement");
m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
SendInitialData(); SendInitialData();
@ -3154,6 +3150,20 @@ namespace OpenSim.Region.Framework.Scenes
m_log.Warn("[SCENE PRESENCE]: exception in CopyTo " + e.Message); m_log.Warn("[SCENE PRESENCE]: exception in CopyTo " + e.Message);
} }
//Attachments
List<int> attPoints = m_appearance.GetAttachedPoints();
if (attPoints != null)
{
m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count);
int i = 0;
AttachmentData[] attachs = new AttachmentData[attPoints.Count];
foreach (int point in attPoints)
{
attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point));
}
cAgent.Attachments = attachs;
}
// Animations // Animations
try try
{ {
@ -3219,6 +3229,19 @@ namespace OpenSim.Region.Framework.Scenes
m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message); m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message);
} }
// Attachments
try
{
if (cAgent.Attachments != null)
{
foreach (AttachmentData att in cAgent.Attachments)
{
m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID);
}
}
}
catch { }
// Animations // Animations
try try
{ {
@ -3729,37 +3752,46 @@ namespace OpenSim.Region.Framework.Scenes
return flags; return flags;
} }
private void ItemReceived(UUID itemID) /// <summary>
/// RezAttachments. This should only be called upon login on the first region
/// </summary>
public void RezAttachments()
{ {
if (IsChildAgent)
return;
if (null == m_appearance) if (null == m_appearance)
{ {
m_log.Warn("[ATTACHMENT] Appearance has not been initialized"); m_log.WarnFormat("[ATTACHMENT] Appearance has not been initialized for agent {0}", UUID);
return; return;
} }
int attachpoint = m_appearance.GetAttachpoint(itemID); List<int> attPoints = m_appearance.GetAttachedPoints();
if (attachpoint == 0) foreach (int p in attPoints)
return;
UUID asset = m_appearance.GetAttachedAsset(attachpoint);
if (UUID.Zero == asset) // We have just logged in
{ {
UUID itemID = m_appearance.GetAttachedItem(p);
UUID assetID = m_appearance.GetAttachedAsset(p);
if (UUID.Zero == assetID)
{
m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID);
continue;
}
try try
{ {
// Rez from inventory // Rez from inventory
asset = m_scene.RezSingleAttachment(ControllingClient, UUID asset = m_scene.RezSingleAttachment(ControllingClient,
itemID, (uint)attachpoint); itemID, (uint)p);
// Corner case: We are not yet a Scene Entity
// Setting attachment info in RezSingleAttachment will fail m_log.InfoFormat("[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})",
// Set it here p, itemID, assetID, asset);
//
m_appearance.SetAttachment((int)attachpoint, itemID, //SceneObjectPart att = m_scene.GetSceneObjectPart(asset);
asset); //m_log.DebugFormat("[ATTCHMENT]: Got scene object parent {0} IsAtt {1}",
m_log.InfoFormat("[ATTACHMENT] Rezzed attachment {0}, inworld asset {1}", // ((att.ParentGroup != null) ? "not null" : "null"), att.IsAttachment);
itemID.ToString(), asset); //if (att.ParentGroup != null && !att.IsAttachment)
//{
// att.FromItemID = itemID;
// m_scene.AttachObject(ControllingClient, att.ParentGroup.LocalId, 0, Quaternion.Identity, att.ParentGroup.AbsolutePosition, false);
//}
} }
catch (Exception e) catch (Exception e)
@ -3767,31 +3799,30 @@ namespace OpenSim.Region.Framework.Scenes
m_log.ErrorFormat("[ATTACHMENT] Unable to rez attachment: {0}", e.ToString()); m_log.ErrorFormat("[ATTACHMENT] Unable to rez attachment: {0}", e.ToString());
} }
return;
} }
SceneObjectPart att = m_scene.GetSceneObjectPart(asset); //SceneObjectPart att = m_scene.GetSceneObjectPart(asset);
// If this is null, then the asset has not yet appeared in world //// If this is null, then the asset has not yet appeared in world
// so we revisit this when it does //// so we revisit this when it does
// ////
if (att != null && att.UUID != asset) // Yes. It's really needed //if (att != null && att.UUID != asset) // Yes. It's really needed
{ //{
m_log.DebugFormat("[ATTACHMENT]: Attach from in world: ItemID {0}, Asset ID {1}, Attachment inworld: {2}", itemID.ToString(), asset.ToString(), att.UUID.ToString()); // m_log.DebugFormat("[ATTACHMENT]: Attach from in world: ItemID {0}, Asset ID {1}, Attachment inworld: {2}", itemID.ToString(), asset.ToString(), att.UUID.ToString());
// This will throw if crossing katty-korner // // This will throw if crossing katty-korner
// So catch it here to avoid the noid // // So catch it here to avoid the noid
// // //
try // try
{ // {
// Attach from world, if not already attached // // Attach from world, if not already attached
if (att.ParentGroup != null && !att.IsAttachment) // if (att.ParentGroup != null && !att.IsAttachment)
m_scene.AttachObject(ControllingClient, att.ParentGroup.LocalId, 0, Quaternion.Identity, att.ParentGroup.AbsolutePosition, false); // m_scene.AttachObject(ControllingClient, att.ParentGroup.LocalId, 0, Quaternion.Identity, att.ParentGroup.AbsolutePosition, false);
} // }
catch (NullReferenceException) // catch (NullReferenceException)
{ // {
} // }
} //}
} }
} }
} }