Jump to content

OpenSimulator Internals/Walkthroughs/Avatar Rezzes Inventory

From Open Simulator Technical Help

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()
  1. Viewer sends RezObject packet with itemID, ray start/end, and rez flags.
  2. Scene.RezObject() calls IInventoryAccessModule.RezObject().

2. Item and Asset Fetched

[edit]
BasicInventoryAccessModule -- RezObject()
  1. Calls InventoryService.GetItem(agentID, itemID) -- reads inventoryitems table.
  2. Validates item exists and is owned by agent.
  3. Calls AssetService.Get(assetID) -- fetches object XML asset.
  4. 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
  1. Calls Scene.GetObjectsToRez() -- deserialises XML into List<SceneObjectGroup> and position offsets.
    • Single object: SceneObjectSerializer.FromOriginalXmlFormat().
    • Coalesced: CoalescedSceneObjectsSerializer.FromXml().
  2. Calls Scene.GetNewRezLocation() -- raycasts from RayStart to RayEnd against physics scene to find surface position.
  3. Checks CanRezObject permission at target position.
  4. If no-copy item fails perm check: sends SendBulkUpdateInventory to restore item to client display.

4. Ownership and Permissions Applied

[edit]
BasicInventoryAccessModule -- DoPreRezWhenFromItem()
  1. Sets rootPart.Name and Description from inventory item (single object only).
  2. Applies ObjectSlamSale if flagged.
  3. Sets FromFolderID on SOG.
  4. 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.
  5. If same owner: sets FromUserInventoryItemID if item is copyable (links rezzed object back to inventory item for "save changes" support).
  6. Calls TrimPermissions() and InvalidateDeepEffectivePerms().

5. Object Added to Scene

[edit]
BasicInventoryAccessModule -- RezObject() continued
  1. group.ResetIDs() -- assigns new UUIDs to all parts.
  2. Clears attachment data (ClearPartAttachmentData()).
  3. Sets IsSelected if RezSelected flag.
  4. Sets AbsolutePosition from ray result.
  5. Calls Scene.AddNewSceneObject(group, true, false) -- adds to scene graph, schedules persistence.
  6. Calls CreateScriptInstances(0, true, DefaultScriptEngine, 1) -- starts scripts with on_rez state source.
  7. Calls ResumeScripts().
  8. 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()
  1. If item.CurrentPermissions has no Copy bit: calls InventoryService.DeleteItems(owner, [itemID]).
  2. 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.


See Also

[edit]