[Opensim-dev] Forcing attachments to rezz

Justin Clark-Casey jjustincc at googlemail.com
Wed Nov 24 23:43:53 UTC 2010


On 24/11/10 19:01, Neil Canham wrote:
> Hi
>    I'm writing a region module for managing appearance / outfits.  One issue I have is that attachments only appear
> after a relog.  During the client login I'm using this to attach:
>
>   m_scenes[0].RezSingleAttachment(client, item.ID, (uint)AttachmentPoint.HUDTop);
>
> in 0.6.9 - and I find I have to log out and then back in to see the attachment, I assume because the client didn't
> request the attachment it isn't looking out for it?  Is there any way that I can force the attachment to happen (I tried
> a ScenePresence SendWearables() but that seemed to not know about the attachment)

In 0.7 (I think) and later, it's possible to attach (and move) hud objects with code like

<paste>
IAttachmentsModule module = client.Scene.RequestModuleInterface<IAttachmentsModule>();
UUID sceneObjectId
     = module.RezSingleAttachmentFromInventory(client, itemId, (uint)AttachmentPoint.HUDTop);
SceneObjectGroup sog = scene.GetSceneObjectPart(sceneObjectId).ParentGroup;

// Move HUD

// A temporary messy solution to an occasional race where the attached hud sometimes ends up positioned
// on the avatar itself and does not show up as attached within inventory.
Thread.Sleep(1000);

Vector3 newPos = new Vector3(0, 0, -0.1f);
m_log.DebugFormat("[EXAMPLE]: Resetting HUD position to {0}", newPos);
module.UpdateAttachmentPosition(client, sog, newPos);
</paste>

However, the attachment code has changed a lot since 0.6.9 (for starters, it had no separate AttachmentsModule).  You 
might want to try something like

sog.HasGroupChanged = true;
sog.ScheduleGroupForFullUpdate();

to make sure the server sends an object notification to the viewer.  However, don't overuse this, since unnecessary 
multiple updates can sometimes lead to race conditions and viewer update glitches.

-- 
Justin Clark-Casey (justincc)
http://justincc.org
http://twitter.com/justincc



More information about the Opensim-dev mailing list