Viewer Architecture

From Second Life Wiki
Revision as of 12:23, 13 June 2007 by Able Whitman (talk | contribs) (→‎Major Systems: reorder, add mute list)
Jump to navigation Jump to search

The Second Life client (also known as the "viewer") is a complex piece of software. It can be visualized as a streaming media client like RealPlayer, a game engine like Quake 3, or a web browser.

First you'll need to learn some terminology like "agent", "sim", and "region" in the glossary.

Learn by Example

Major Systems

  • Asset System - transport for animations, sounds, notecards, scripts, etc.
  • Avatar Appearance - appearance is constructed from a mesh, parameters to deform the mesh, and textures to describe clothing
  • Avatar Profiles
  • Culling - octree and occlusion based culling to speed rendering
  • Error Logging System - command and control of debugging output
  • Groups
  • Image System - prioritizes and decodes JPEG2000 images into OpenGL textures
    • Texture cache - used for reading and writing texture data to the local disk cache
  • Inventory - server-side storage of assets for each user
  • L$ System
  • Message System - reliable and unreliable transport over UDP
  • Movie System - QuickTime-based video on object surfaces
  • Muting Objects and Agents - How the viewer manages the muted object list
  • Rendering System - from viewer object to drawable to face to vertices to graphics card
  • Selection Manager - holds extended information for selected objects and allows editing
  • Sound System - cross platform audio based on FMOD
  • Tools - anything that takes effect when you click your mouse on the world view.
  • UI Widgets - cross platform buttons, scroll bars, etc.
  • UI Floaters - dialogs and windows built from XML files
  • VFS - cached data is held in two "virtual file systems" in large files on the client
  • Viewer Object System - objects in scene for rendering and editing
  • Web Browser - the integration of the viewer with the web.

Threads

The viewer is a single process with a few threads:

  • Main thread -- The input/output main program function (including rendering).
  • VFS thread -- Thread responsible for reading/writing to the local virtual file system.
  • LFS thread -- Thread responsible for some reading/writing to the local native file system.
  • Image thread -- Thread responsible for requesting and decoding image data
  • Error Thread -- Thread responsible for catching exceptions, calling the (currently unused?) error handler, and retiring
  • Worker Threads -- Threads designed to do cpu intensive background tasks
    • These threads may be paused during rendering so as not to reduce performance (design in-progress)

Program Flow

  1. Initialize - newview/viewer.cpp :: main()
  2. Loop - newview/viewer.cpp :: main_loop()
    • Gathers keyboard and mouse input
    • Pumps the TCP i/o
    • idle()
    • Render the frame
    • let filesystem and worker threads process
  3. Shutdown

One way to see what goes on in the main loop is to bring up the debug menus (Ctrl-Alt-D) then Client->Consoles->Fast Timers (or Ctrl-Shift-9) and expand the entries in the caption.

Sources of Input

User Guides