Overview of How Regions Work
From OpenSimulator
(New page: The following is based on a brief discussion between ter_afk and rknop on #opensim-dev. It's archived here so that hopefully others can benefit from it. == Scene: the Core of the Region ...) |
(→Scene Object Groups and Scene Object Parts) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | The following is based on a brief discussion between ter_afk and rknop on #opensim-dev. | + | The following is based on a brief discussion between ter_afk and rknop on #opensim-dev. It's archived here so that hopefully others can benefit from it. |
== Scene: the Core of the Region == | == Scene: the Core of the Region == | ||
− | OpenSim.Region.Framework.Scenes.Scene is the "heart" of OpenSimulator's functionality. | + | OpenSim.Region.Framework.Scenes.Scene is the "heart" of OpenSimulator's functionality. The method Scene.Heartbeat() starts the heartbeat going; it does this by calling the Update() method. That method is the "main loop" of the region: |
− | < | + | <source lang=csharp> |
public override void Update() | public override void Update() | ||
{ | { | ||
Line 11: | Line 11: | ||
while (!shuttingdown) | while (!shuttingdown) | ||
{ | { | ||
− | </ | + | </source> |
− | That loop is run over and over again. | + | That loop is run over and over again. At the bottom of the loop is: |
− | < | + | <source lang=csharp> |
maintc = Environment.TickCount - maintc; | maintc = Environment.TickCount - maintc; | ||
maintc = (int)(m_timespan * 1000) - maintc; | maintc = (int)(m_timespan * 1000) - maintc; | ||
Line 23: | Line 23: | ||
} | } | ||
} | } | ||
− | </ | + | </source> |
− | + | == Scene Object Groups and Scene Object Parts == | |
− | + | Each linkset in a region is represented internally by an object called a SceneObjectGroup (SOG). This holds summary information for the linkset as a whole (e.g. whether it is attached to an avatar). | |
− | + | Each SceneObjectGroup has one or more SceneObjectPart (SOP) objects. Each SOP represents an individual prim (or sculpt or mesh). Each SOP holds properties that can vary between prims (e.g. absolute position in the scene). However, for historical reasons they also hold properties that actually can only be set once per SOG and do not vary by SOP. | |
− | + | In other words, if everything else didn't take as long as one heartbeat is supposed to take, the thread goes to sleep until it's time to service the next heartbeat. This heartbeat runs about 10 times a second. | |
− | + | Other modules of all sorts can register heartbeat events that get called each pass through the main loop, and there are other events that modules can register for as well. | |
− | + | ||
− | + | For information on the serializations of SOG and SOP (as used to transfer data between regions on teleport or when saved/loaded from OARs/IARs), see [[Object Formats]]. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Latest revision as of 13:09, 29 October 2012
The following is based on a brief discussion between ter_afk and rknop on #opensim-dev. It's archived here so that hopefully others can benefit from it.
[edit] Scene: the Core of the Region
OpenSim.Region.Framework.Scenes.Scene is the "heart" of OpenSimulator's functionality. The method Scene.Heartbeat() starts the heartbeat going; it does this by calling the Update() method. That method is the "main loop" of the region:
public override void Update() { int maintc = 0; while (!shuttingdown) {
That loop is run over and over again. At the bottom of the loop is:
maintc = Environment.TickCount - maintc; maintc = (int)(m_timespan * 1000) - maintc; if ((maintc < (m_timespan * 1000)) && maintc > 0) Thread.Sleep(maintc); } }
[edit] Scene Object Groups and Scene Object Parts
Each linkset in a region is represented internally by an object called a SceneObjectGroup (SOG). This holds summary information for the linkset as a whole (e.g. whether it is attached to an avatar).
Each SceneObjectGroup has one or more SceneObjectPart (SOP) objects. Each SOP represents an individual prim (or sculpt or mesh). Each SOP holds properties that can vary between prims (e.g. absolute position in the scene). However, for historical reasons they also hold properties that actually can only be set once per SOG and do not vary by SOP.
In other words, if everything else didn't take as long as one heartbeat is supposed to take, the thread goes to sleep until it's time to service the next heartbeat. This heartbeat runs about 10 times a second.
Other modules of all sorts can register heartbeat events that get called each pass through the main loop, and there are other events that modules can register for as well.
For information on the serializations of SOG and SOP (as used to transfer data between regions on teleport or when saved/loaded from OARs/IARs), see Object Formats.