OpenSimulator Internals/Walkthroughs/Avatar Derezzes Object
OpenSimulator Internals/Walkthroughs/Avatar Derezzes Object
[edit]Overview
[edit]Traces what happens in code, connectors, and database when an avatar takes an object from the world into inventory (derez), or deletes it. Uses the box-with-notecard from OpenSimulator Internals/Walkthroughs/Avatar Rezzes Box as the concrete example.
This is a concrete instance of OpenSimulator Internals/Walkthroughs/Avatar Acquires Inventory. Read that page for the full code path.
Case 1: Take (own object, no-copy)
[edit]Avatar right-clicks the box and selects Take.
1. Viewer Sends DeRezObject
[edit]- Viewer sends DeRezObject packet with action=Take, objectLocalID=box local ID.
- Scene.DeRezObjects() validates permissions (CanTakeObject).
- Calls IInventoryAccessModule.CopyToInventory(DeRezAction.Take, folderID, [boxSOG], client, false).
2. Object Serialised
[edit]BasicInventoryAccessModule.CopyBundleToInventory():
- Serialises box SOG to XML: SceneObjectSerializer.ToOriginalXmlFormat().
- XML includes: prim data, shape, permissions, position, rotation, task inventory (the notecard reference is embedded in the XML as a primitems-equivalent block).
- Creates asset: AssetService.Store() -- new UUID, AssetType.Object, data = XML bytes.
- CreateItemForObject(Take): determines folder (original FromFolderID if owner taking back own item).
- AddPermissions(): same-owner path, preserves current permissions.
- Scene.AddInventoryItem(): InventoryService.AddItem() -- writes inventoryitems row.
- Sends SendInventoryItemCreateUpdate() to client.
- DB writes
- assets -- INSERT: new object XML asset UUID
- inventoryitems -- INSERT: new item in Object folder (or original folder)
3. Object Removed from Scene
[edit]DoPostRezWhenFromItem():
- Box was no-copy: InventoryService.DeleteItems() -- removes original inventoryitems row.
Scene.DeleteSceneObject(boxSOG, false):
- RemoveScriptInstances() -- no-op (no scripts).
- Removes physics actor.
- UnlinkSceneObject() -- removes from scene graph.
- SimulationDataService.RemoveObject(boxUUID, regionID).
- DB writes
- inventoryitems -- DELETE: original no-copy item
- prims -- DELETE: box prim row
- primshapes -- DELETE: box shape row
- primitems -- DELETE: notecard task inventory row
4. DB State After
[edit]Region database:
- prims: box row gone.
- primshapes: box shape row gone.
- primitems: notecard task inventory row gone.
Robust database:
- assets: new object XML asset (contains the notecard reference inside the serialised XML).
- inventoryitems: new item pointing to the new asset UUID.
- The notecard asset itself remains in assets table -- assets are never deleted on take.
Case 2: Take Copy (copyable object)
[edit]Avatar right-clicks and selects Take Copy.
Same serialise-and-store process as above, but:
- DoPostRezWhenFromItem() does NOT delete the original inventory item (item has Copy permission).
- Scene.DeRezObjects() does NOT call DeleteSceneObject() -- object stays in world.
- DB writes
- assets -- INSERT: new object XML asset
- inventoryitems -- INSERT: new item in Object folder
Region DB unchanged. The box stays in the world.
Case 3: Delete (move to Trash)
[edit]Avatar right-clicks and selects Delete.
Calls CopyToInventory(DeRezAction.Delete):
- Destination folder: Trash (FolderType.Trash) if own object, Lost and Found if another's.
- Same serialise-and-store process.
- Scene.DeleteSceneObject() removes from scene and region DB.
- DB writes
- assets -- INSERT: serialised object XML
- inventoryitems -- INSERT: item in Trash
- prims/primshapes/primitems -- DELETE
Key DB Tables Affected
[edit]| Table | Take (no-copy) | Take Copy | Delete |
|---|---|---|---|
| assets | INSERT (new) | INSERT (new) | INSERT (new) |
| inventoryitems | INSERT new + DELETE old | INSERT new only | INSERT (Trash) |
| prims | DELETE | unchanged | DELETE |
| primshapes | DELETE | unchanged | DELETE |
| primitems | DELETE | unchanged | DELETE |
Note: asset rows are never deleted from the assets table by any of these operations. Assets accumulate. Cleanup is a separate administrative operation outside normal simulator operation.
What Happens to the Notecard Inside
[edit]The notecard was task inventory of the box (a primitems row). When the box is taken or deleted:
- The primitems row is deleted from the region DB.
- The notecard asset (text content) remains in the assets table -- it is referenced by assetID in the serialised object XML.
- When the box is later rezzed from inventory, the XML is deserialised and the notecard reappears as task inventory -- it is re-fetched from assets by assetID.
The notecard is not duplicated into the avatar's personal inventory (inventoryitems). It stays embedded in the object asset.
See Also
[edit]- OpenSimulator Internals/Walkthroughs
- OpenSimulator Internals/Walkthroughs/Avatar Acquires Inventory
- OpenSimulator Internals/Walkthroughs/Avatar Rezzes Box
- OpenSimulator Internals/Walkthroughs/Avatar Rezzes Inventory
- OpenSimulator Internals/Walkthroughs/Garbage Collection
- OpenSimulator Internals/Code Map/InventoryAccessModule
- OpenSimulator Internals/Databases