OpenSimulator Internals/Walkthroughs/Avatar Rezzes Box
OpenSimulator Internals/Walkthroughs/Avatar Rezzes Box
[edit]Overview
[edit]Traces what happens in code, connectors, and database when an avatar rezzes a simple object (a box) from inventory into the world, then puts a notecard inside it. Uses live data from the osimdev T1 region database to illustrate the actual DB state.
This is a concrete instance of OpenSimulator Internals/Walkthroughs/Avatar Rezzes Inventory. Read that page for the full code path. This page focuses on the DB state before and after.
Setup: What Was in the Database Before
[edit]Before the box was rezzed, osimdev T1 contained 7 objects (471 prims). After rezzing the box and adding a notecard:
From live query (WHERE UUID = SceneGroupID to get root prim names):
SceneGroupID prim_count root_name a4cbde76-... 193 CASA 3 (large house) da990c49-... 181 Brown House ed13b4e9-... 54 4 chair set ef6cc0c0-... 36 Athena Bento BoM Mesh Body 6.5 d78b8ebf-... 5 Brown House Sculpts 1285d009-... 1 Sofa_1_N150911kompleet 746c1d97-... 1 Object (cube) 789a253a-... 1 Box
Note: the original query used MIN(Name) GROUP BY SceneGroupID which returned child prim names ("171800", "171801" etc.) for the Athena HUD instead of the root prim name. The correct query uses WHERE UUID = SceneGroupID. See WTF file.
1. Rezzing the Box
[edit]Avatar drags "Box" from inventory to the world.
Scene.RezObject() → BasicInventoryAccessModule.RezObject():
- InventoryService.GetItem() -- fetches the box's inventory record from inventoryitems table.
- AssetService.Get(assetID) -- fetches the serialised object XML from assets table.
- Scene.GetObjectsToRez() -- deserialises XML into SceneObjectGroup (1 prim).
- GetNewRezLocation() -- raycasts to ground surface for position.
- DoPreRezWhenFromItem() -- sets name/description, links FromUserInventoryItemID if copyable.
- Scene.AddNewSceneObject() -- adds to scene graph.
- SimulationDataService.StoreObject() called immediately on add -- writes prim to DB.
- CreateScriptInstances() -- no scripts in a plain box, so no-op.
- Schedules full update to all clients.
- DB reads
- inventoryitems -- SELECT: box item record
- assets -- SELECT: object XML asset
- DB writes (immediate on AddNewSceneObject)
- prims -- INSERT: 1 row (UUID, SceneGroupID = same UUID for root, Name="Box", GroupPositionX/Y/Z, etc.)
- primshapes -- INSERT: 1 row (shape data: PCode=9 box, ProfileShape=0, etc.)
- DB writes (on next backup cycle, ~18s later)
- prims -- UPDATE: position/state confirmed
- primitems -- INSERT: empty (no task inventory yet)
2. Putting the Notecard in the Box
[edit]Avatar opens the box contents and drags a notecard from inventory into it.
This is a task inventory operation, not a world rez:
- Viewer sends UpdateTaskInventory packet.
- Scene.UpdateTaskInventory() validates permissions.
- Copies inventory item to object's task inventory (SceneObjectPart.Inventory).
- Sets HasGroupChanged = true on the SOG.
- On next backup cycle: SimulationDataService.StoreObject() writes primitems row.
- DB writes (on next backup cycle)
- primitems -- INSERT: 1 row (primID = box UUID, name="Notecard", assetID = notecard asset UUID, invType=7, assetType=7, etc.)
3. DB State After
[edit]prims table: 1 new row for the box root prim. primshapes table: 1 new row. primitems table: 1 new row for the notecard inside the box.
The notecard asset itself (the text content) lives in the assets table -- it was already there from when the notecard was written. The primitems row references it by assetID.
4. What the DB Rows Look Like
[edit]prims row (key fields):
- UUID -- unique prim UUID
- SceneGroupID -- same as UUID for root prim; child prims have root's UUID here
- RegionUUID -- T1 region UUID
- Name -- "Box"
- GroupPositionX/Y/Z -- world position
- OwnerID -- avatar UUID
- CreatorID -- avatar UUID
- BaseMask, OwnerMask, EveryoneMask, GroupMask, NextOwnerMask -- permissions
- ScriptAccessPin -- 0 (no scripts)
- RotationX/Y/Z/W -- orientation quaternion
primshapes row (key fields):
- UUID -- same as prim UUID
- PCode -- 9 (primitive)
- ProfileShape -- 0 (square/box)
- HollowShape -- 0
- ScaleX/Y/Z -- 0.5, 0.5, 0.5 (default half-metre cube)
- PathBegin/PathEnd -- 0/1 (full path)
- ProfileBegin/ProfileEnd -- 0/1 (full profile)
primitems row (key fields, after notecard added):
- itemID -- unique UUID for this task inventory entry
- primID -- box prim UUID
- assetID -- notecard asset UUID
- name -- notecard name
- description -- notecard description
- invType -- 7 (notecard)
- assetType -- 7 (notecard)
- creatorID -- avatar UUID
- ownerID -- avatar UUID
- BaseMask/CurrentMask/etc. -- permissions