OpenSimulator Internals/Walkthroughs/Avatar Rezzes Inventory
Appearance
OpenSimulator Internals/Walkthroughs/Avatar Rezzes Inventory
[edit]Overview
[edit]Traces what happens in code, connectors, and database when an avatar rezzes an object from inventory into the world.
1. Client Sends RezObject
[edit]OpenSim/Region/Framework/Scenes/Scene.cs -- RezObject()
- Viewer sends RezObject packet with itemID, ray start/end, and rez flags.
- Scene.RezObject() calls IInventoryAccessModule.RezObject().
2. Item and Asset Fetched
[edit]BasicInventoryAccessModule -- RezObject()
- Calls InventoryService.GetItem(agentID, itemID) -- reads inventoryitems table.
- Validates item exists and is owned by agent.
- Calls AssetService.Get(assetID) -- fetches object XML asset.
- If asset null or empty: sends alert to client, returns null.
For HG foreign users (HGInventoryAccessModule):
- If IsForeignUser: calls m_assMapper.Get(item.AssetID, agentID, foreignAssetServer) before asset fetch -- pulls asset from foreign grid if not cached locally.
- DB reads
- inventoryitems -- SELECT by item UUID
- assets -- SELECT by asset UUID
3. Deserialise and Position
[edit]BasicInventoryAccessModule -- RezObject() continued
- Calls Scene.GetObjectsToRez() -- deserialises XML into List<SceneObjectGroup> and position offsets.
- Single object: SceneObjectSerializer.FromOriginalXmlFormat().
- Coalesced: CoalescedSceneObjectsSerializer.FromXml().
- Calls Scene.GetNewRezLocation() -- raycasts from RayStart to RayEnd against physics scene to find surface position.
- Checks CanRezObject permission at target position.
- If no-copy item fails perm check: sends SendBulkUpdateInventory to restore item to client display.
4. Ownership and Permissions Applied
[edit]BasicInventoryAccessModule -- DoPreRezWhenFromItem()
- Sets rootPart.Name and Description from inventory item (single object only).
- Applies ObjectSlamSale if flagged.
- Sets FromFolderID on SOG.
- If ownership change (new owner or Slam flag):
- Changes OwnerID on all parts, sets LastOwnerID, calls Inventory.ChangeInventoryOwner().
- Calls ApplyNextOwnerPermissions() -- applies NextOwnerMask to BasePermissions.
- Applies any ObjectOverwrite flags from item.
- If same owner: sets FromUserInventoryItemID if item is copyable (links rezzed object back to inventory item for "save changes" support).
- Calls TrimPermissions() and InvalidateDeepEffectivePerms().
5. Object Added to Scene
[edit]BasicInventoryAccessModule -- RezObject() continued
- group.ResetIDs() -- assigns new UUIDs to all parts.
- Clears attachment data (ClearPartAttachmentData()).
- Sets IsSelected if RezSelected flag.
- Sets AbsolutePosition from ray result.
- Calls Scene.AddNewSceneObject(group, true, false) -- adds to scene graph, schedules persistence.
- Calls CreateScriptInstances(0, true, DefaultScriptEngine, 1) -- starts scripts with on_rez state source.
- Calls ResumeScripts().
- Schedules full update to clients.
- DB writes
- prims -- INSERT: new prim rows for each part
- primshapes -- INSERT: shape data for each part
- primitems -- INSERT: task inventory for each part
6. No-Copy Item Removed from Inventory
[edit]BasicInventoryAccessModule -- DoPostRezWhenFromItem()
- If item.CurrentPermissions has no Copy bit: calls InventoryService.DeleteItems(owner, [itemID]).
- Item is consumed on rez.
- DB writes (no-copy only)
- inventoryitems -- DELETE: item removed
7. HG Asset Push (HG users only)
[edit]Not applicable on standard rez. HG asset push (ExportAsset) is triggered on CopyToInventory, not on rez.
Summary: DB Tables Touched
[edit]| Table | Operation | Notes |
|---|---|---|
| inventoryitems | SELECT | Fetch item record |
| assets | SELECT | Fetch object XML |
| prims | INSERT | New object in region |
| primshapes | INSERT | Shape data |
| primitems | INSERT | Task inventory per part |
| inventoryitems | DELETE | No-copy items only |
Edge Cases
[edit]Attachment rez (from RezAttachments or RezSingleAttachmentFromInventory): uses same RezObject() path but attachment=true. AddNewSceneObject() is called without script start (scripts start later in AttachToAgent). See OpenSimulator Internals/Walkthroughs/Avatar Rez In Region.
Coalesced object: multiple SOGs deserialised from one asset, each positioned using the stored offsets from CoalescedSceneObjectsSerializer. Each gets its own DB rows.