<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://osimdev.org/wiki/index.php?action=history&amp;feed=atom&amp;title=OpenSimulator_Internals%2FWalkthroughs%2FAvatar_Rez_In_Region</id>
	<title>OpenSimulator Internals/Walkthroughs/Avatar Rez In Region - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://osimdev.org/wiki/index.php?action=history&amp;feed=atom&amp;title=OpenSimulator_Internals%2FWalkthroughs%2FAvatar_Rez_In_Region"/>
	<link rel="alternate" type="text/html" href="http://osimdev.org/wiki/index.php?title=OpenSimulator_Internals/Walkthroughs/Avatar_Rez_In_Region&amp;action=history"/>
	<updated>2026-08-04T15:36:58Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>http://osimdev.org/wiki/index.php?title=OpenSimulator_Internals/Walkthroughs/Avatar_Rez_In_Region&amp;diff=82&amp;oldid=prev</id>
		<title>Jwbshaw: first</title>
		<link rel="alternate" type="text/html" href="http://osimdev.org/wiki/index.php?title=OpenSimulator_Internals/Walkthroughs/Avatar_Rez_In_Region&amp;diff=82&amp;oldid=prev"/>
		<updated>2026-07-07T12:58:51Z</updated>

		<summary type="html">&lt;p&gt;first&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= OpenSimulator Internals/Walkthroughs/Avatar Rez In Region =&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
Traces what happens in code, connectors, and database from the moment a viewer completes login and connects to a region, through to the avatar standing in-world with appearance applied and scene state sent.&lt;br /&gt;
&lt;br /&gt;
This covers the normal login case (not HG, not region transfer). See [[OpenSimulator Internals/Walkthroughs/Avatar Transfer Between Regions]] and [[OpenSimulator Internals/Walkthroughs/Avatar Goes HG]] for those paths.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 1. Login Service Issues Seed Capability ==&lt;br /&gt;
&lt;br /&gt;
 OpenSim/Services/LLLoginService/LLLoginService.cs&lt;br /&gt;
 OpenSim/Server/Handlers/Login/LLLoginHandlers.cs&lt;br /&gt;
&lt;br /&gt;
# Viewer POSTs login credentials to ROBUST LoginService (port 8002 by default) via XMLRPC.&lt;br /&gt;
# LLLoginService authenticates via AuthenticationService, loads UserAccount, fetches appearance via AvatarService.&lt;br /&gt;
# LoginService calls PresenceService.LoginAgent() -- writes presence row: UserID, RegionID, SessionID, SecureSessionID, Online=1.&lt;br /&gt;
# LoginService calls GridUserService.SetLastPosition() -- updates griduser: LastRegionID, LastPosition, Login timestamp.&lt;br /&gt;
# LoginService selects destination region via GridService -- reads from regions table.&lt;br /&gt;
# LoginService calls the destination region&amp;#039;s NewUserConnection capability -- passes AgentCircuitData (agent UUID, session UUID, circuit code, appearance, teleport flags). This pre-populates AgentCircuitManager in the region before the viewer connects.&lt;br /&gt;
# LoginService returns login response to viewer: SimIP, SimPort, RegionX/Y, SeedCapability URL, circuit code, session UUIDs.&lt;br /&gt;
&lt;br /&gt;
; DB writes:&lt;br /&gt;
* presence -- INSERT or UPDATE: UserID, RegionID, SessionID, SecureSessionID, Online=1&lt;br /&gt;
* griduser -- UPDATE: LastRegionID, LastPosition, Login timestamp&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 2. Viewer Establishes UDP Circuit ==&lt;br /&gt;
&lt;br /&gt;
 OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs&lt;br /&gt;
&lt;br /&gt;
# Viewer sends UseCircuitCode packet to region UDP port.&lt;br /&gt;
# LLUDPServer.HandleUseCircuitCode() validates circuit code against AgentCircuitManager (pre-populated in step 1).&lt;br /&gt;
# On match: LLUDPClient created. LLClientView constructed and associated with the circuit.&lt;br /&gt;
# ScenePresence constructed:&lt;br /&gt;
#* IsChildAgent = true initially (set in constructor)&lt;br /&gt;
#* Constructor fetches UserAccount for god level and user flags&lt;br /&gt;
#* Constructor calls RegisterToClientEvents() -- wires OnCompleteMovementToRegion → CompleteMovement, OnAgentUpdate → HandleAgentUpdate, OnRegionHandShakeReply → RegionHandShakeReply, and others&lt;br /&gt;
#* Appearance set from AgentCircuitData appearance passed by LoginService&lt;br /&gt;
#* AdjustKnownSeeds() called -- initialises known neighbour region cap seeds&lt;br /&gt;
&lt;br /&gt;
; No DB writes at this step.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 3. Viewer Sends CompleteMovementToRegion ==&lt;br /&gt;
&lt;br /&gt;
 OpenSim/Region/Framework/Scenes/ScenePresence.cs -- CompleteMovement()&lt;br /&gt;
&lt;br /&gt;
The viewer fires CompleteMovementToRegion after receiving the circuit acknowledgement. This triggers ScenePresence.CompleteMovement() on the region side.&lt;br /&gt;
&lt;br /&gt;
# For login (IsRealLogin true): does NOT wait for UpdateAgent -- skips WaitForUpdateAgent(). For teleports and crossings: waits up to 10 seconds for the source region&amp;#039;s UpdateAgent call to arrive before proceeding.&lt;br /&gt;
# Checks flying state from AgentControlFlags.&lt;br /&gt;
# Calls MakeRootAgent() (see step 4).&lt;br /&gt;
# If not a cross-update: fetches group title via IGroupsModule.&lt;br /&gt;
# Rotates avatar to look direction.&lt;br /&gt;
# Initialises parcel tracking (m_currentParcelUUID, m_currentParcelHide).&lt;br /&gt;
# Sets m_inTransit = false.&lt;br /&gt;
# Sends RegionHandshake to viewer (ControllingClient.SendRegionHandshake()) if not a crossing.&lt;br /&gt;
# Calls ControllingClient.MoveAgentIntoRegion() -- sends the viewer its position and look.&lt;br /&gt;
# Validates baked texture cache via AvatarFactory. Queues appearance save if invalid.&lt;br /&gt;
# Sends initial avatar data to all presences (SendInitialAvatarDataToAllAgents()).&lt;br /&gt;
# Sends this avatar&amp;#039;s appearance to self (SendAppearanceToAgent(this)).&lt;br /&gt;
# Sends current animation pack to self.&lt;br /&gt;
# Sends appearance and animations to all other presences (parcel visibility respected).&lt;br /&gt;
# Rezzes attachments: for real login, calls Scene.AttachmentsModule.RezAttachments(this).&lt;br /&gt;
# For login (not cross-update): calls IFriendsModule.SendFriendsOnlineIfNeeded().&lt;br /&gt;
# Hooks RegionHeartbeatEnd event for per-frame health regen and movement animation updates.&lt;br /&gt;
&lt;br /&gt;
; No DB writes at this step (appearance save is queued async if needed).&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 4. MakeRootAgent() ==&lt;br /&gt;
&lt;br /&gt;
 OpenSim/Region/Framework/Scenes/ScenePresence.cs -- MakeRootAgent()&lt;br /&gt;
&lt;br /&gt;
Called from CompleteMovement(). This is the critical path; delay here delays the crossing.&lt;br /&gt;
&lt;br /&gt;
# Acquires m_completeMovementLock. Returns false immediately if already root agent (IsChildAgent == false).&lt;br /&gt;
# Handles pending sit: if ParentUUID is set, resolves the sit target prim and re-seats the avatar.&lt;br /&gt;
# Sets IsChildAgent = false.&lt;br /&gt;
# Updates RegionHandle to this region.&lt;br /&gt;
# Fires EventManager.TriggerSetRootAgentScene().&lt;br /&gt;
# Position adjustment (if not sitting):&lt;br /&gt;
#* Checks and adjusts landing point (telehub, parcel landing point, ban lines) via CheckAndAdjustLandingPoint_OS() or _SL().&lt;br /&gt;
#* Clamps position to region bounds.&lt;br /&gt;
#* Raises position to ground height + avatar half-height.&lt;br /&gt;
#* If ViaLogin or ViaLocation flags set: raycasts downward from PhysSearchHeight (300m) to find surface, adjusts Z to avoid being inside objects.&lt;br /&gt;
#* Sets AbsolutePosition.&lt;br /&gt;
#* Calls AddToPhysicalScene(isFlying) -- creates PhysicsActor, enters physics simulation.&lt;br /&gt;
# Calls m_scene.SwapRootAgentCount(false, IsNPC) -- increments root agent count.&lt;br /&gt;
# Resets MovementFlags to 0.&lt;br /&gt;
# Updates circuit child status: AuthenticateHandler.UpdateAgentChildStatus(circuitCode, false).&lt;br /&gt;
# Fires EventManager.TriggerOnMakeRootAgent(this) -- modules hook here.&lt;br /&gt;
&lt;br /&gt;
; No DB writes at this step.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 5. RegionHandshake / SendInitialData ==&lt;br /&gt;
&lt;br /&gt;
 OpenSim/Region/Framework/Scenes/ScenePresence.cs -- RegionHandShakeReply(), SendInitialData()&lt;br /&gt;
&lt;br /&gt;
# Viewer sends RegionHandshakeReply in response to the handshake sent in step 3.&lt;br /&gt;
# RegionHandShakeReply() sets m_gotRegionHandShake = true and NeedInitialData = 2.&lt;br /&gt;
# On subsequent heartbeat frames, Update() checks NeedInitialData &amp;gt; 0 and calls SendInitialData().&lt;br /&gt;
# SendInitialData() waits for viewer caps seeds to be sent (ViewerFlags.SentSeeds), then waits a few more frames for the viewer to process them (NeedInitialData incremented to 6 before proceeding).&lt;br /&gt;
# When ready, fires async via Util.FireAndForget:&lt;br /&gt;
#* Releases source region if callback URI present (v1 or v0.7 HG path).&lt;br /&gt;
#* Closes old child agents via IEntityTransferModule.CloseOldChildAgents().&lt;br /&gt;
#* Sends terrain layer data (Scene.SendLayerData()) if not a teleport.&lt;br /&gt;
#* Sends parcel info (LandChannel.sendClientInitialLandInfo()).&lt;br /&gt;
#* Sends full updates for all other root presences&amp;#039; avatars (SendOtherAgentsAvatarFullToMe()).&lt;br /&gt;
#* Sends ObjectUpdate packets for all scene objects within draw distance -- either full updates or cache probes depending on viewer cache state.&lt;br /&gt;
#* Creates child agents in neighbouring regions via IEntityTransferModule.EnableChildAgents(this).&lt;br /&gt;
#* Enables child update processing (m_childUpdatesBusy = false).&lt;br /&gt;
&lt;br /&gt;
; No DB writes at this step.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 6. Attachments Rezzed ==&lt;br /&gt;
&lt;br /&gt;
 OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs -- RezAttachments()&lt;br /&gt;
&lt;br /&gt;
Called from CompleteMovement() for real logins (IsRealLogin true). For teleports/crossings, attachments are carried in AgentData and scripts restarted via RestartAttachmentScripts() instead.&lt;br /&gt;
&lt;br /&gt;
# For each attachment in appearance data: fetches inventory item from InventoryService.&lt;br /&gt;
# Fetches asset from AssetService.&lt;br /&gt;
# Rezzes SceneObjectGroup in world at attachment point.&lt;br /&gt;
# Note: method name typo IncomingAttechments() exists at Scene.cs line 2976 and AttachmentsModule.cs line 384 (Mantis pending).&lt;br /&gt;
&lt;br /&gt;
; DB reads:&lt;br /&gt;
* inventoryitems -- SELECT by item UUID for each attachment&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 7. Presence and GridUser Updated ==&lt;br /&gt;
&lt;br /&gt;
 OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs&lt;br /&gt;
 OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs&lt;br /&gt;
&lt;br /&gt;
After MakeRootAgent and CompleteMovement complete, the region confirms the avatar&amp;#039;s position:&lt;br /&gt;
&lt;br /&gt;
# PresenceService.ReportAgent() -- updates presence table, confirms RegionID.&lt;br /&gt;
# GridUserService.SetLastPosition() -- updates griduser with confirmed in-region position and look.&lt;br /&gt;
&lt;br /&gt;
; DB writes:&lt;br /&gt;
* presence -- UPDATE: RegionID confirmed for this session&lt;br /&gt;
* griduser -- UPDATE: LastPosition, LastLookAt, LastRegionID&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Summary: DB Tables Touched ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Table !! Operation !! Step&lt;br /&gt;
|-&lt;br /&gt;
| presence || INSERT/UPDATE || LoginService (step 1)&lt;br /&gt;
|-&lt;br /&gt;
| griduser || UPDATE || LoginService (step 1), post-rez (step 7)&lt;br /&gt;
|-&lt;br /&gt;
| regions || SELECT || LoginService destination lookup (step 1)&lt;br /&gt;
|-&lt;br /&gt;
| avatarappearance || SELECT || LoginService via AvatarService (step 1)&lt;br /&gt;
|-&lt;br /&gt;
| avatarattachments || SELECT || LoginService via AvatarService (step 1)&lt;br /&gt;
|-&lt;br /&gt;
| inventoryitems || SELECT || AttachmentsModule.RezAttachments() (step 6)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: avatarappearance and avatarattachments are read by LoginService, not by the region directly -- the appearance data travels to the region inside AgentCircuitData.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Key Flags ==&lt;br /&gt;
&lt;br /&gt;
* TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID -- set for normal login. Controls landing point behavior, telehub routing, and whether WaitForUpdateAgent() is skipped.&lt;br /&gt;
* TeleportFlags.ViaHGLogin -- HG login path; triggers different appearance handling and skips baked texture validation.&lt;br /&gt;
* IsRealLogin() -- returns true only for ViaLogin without ViaHGLogin. Determines whether attachments are freshly rezzed vs carried from source region.&lt;br /&gt;
* m_gotCrossUpdate -- false for login, true for region crossings. Controls whether SendLayerData and child agent setup are deferred.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[OpenSimulator Internals/Walkthroughs]]&lt;br /&gt;
* [[OpenSimulator Internals/Code Map/ROBUST/LoginService]]&lt;br /&gt;
* [[OpenSimulator Internals/Code Map/ROBUST/PresenceService]]&lt;br /&gt;
* [[OpenSimulator Internals/Code Map/ROBUST/AvatarService]]&lt;br /&gt;
* [[OpenSimulator Internals/Code Map/Scene]]&lt;br /&gt;
* [[OpenSimulator Internals/Code Map/LLClientView]]&lt;br /&gt;
* [[OpenSimulator Internals/Connector Architecture/Presence Connector]]&lt;br /&gt;
* [[OpenSimulator Internals/Connector Architecture/Avatar Connector]]&lt;br /&gt;
* [[OpenSimulator Internals/Walkthroughs/Avatar Transfer Between Regions]]&lt;br /&gt;
* [[OpenSimulator Internals/Walkthroughs/Avatar Goes HG]]&lt;/div&gt;</summary>
		<author><name>Jwbshaw</name></author>
	</entry>
</feed>