<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://opensimulator.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://opensimulator.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Reibling</id>
		<title>OpenSimulator - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://opensimulator.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Reibling"/>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/wiki/Special:Contributions/Reibling"/>
		<updated>2026-05-06T10:13:58Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.19.9</generator>

	<entry>
		<id>http://opensimulator.org/wiki/Upgrading</id>
		<title>Upgrading</title>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/wiki/Upgrading"/>
				<updated>2015-04-20T16:05:24Z</updated>
		
		<summary type="html">&lt;p&gt;Reibling: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Quicklinks}}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Updating your version of OpenSimulator =&lt;br /&gt;
&lt;br /&gt;
Upgrading your version of OpenSimulator involves 2 major steps&lt;br /&gt;
&lt;br /&gt;
1.  Updating your existing data for the new version of OpenSimulator.&lt;br /&gt;
2.  Updating the config files for the new version of OpenSimulator.&lt;br /&gt;
&lt;br /&gt;
== Updating your existing data ==&lt;br /&gt;
&lt;br /&gt;
The first step is very easy.  OpenSimulator has a data migration system which will automatically update your old database schema and data for use with the new version of OpenSimulator.  This will be valid for many past versions of OpenSimulator (currently all the way back to OpenSimulator 0.6.9 and quite possibly before).&lt;br /&gt;
&lt;br /&gt;
Naturally, we very strongly recommend that you make a backup of your old database first, but the upgrade process almost always occurs without a hitch.  However, one could always suffer a power cut or other major computer failure during the ugprade.&lt;br /&gt;
&lt;br /&gt;
If you're using SQLite, then you will also need to copy over the database files since these are in the OpenSimulator bin directory.  These will be all the files ending with .db (e.g. Asset.db, inventory.db).&lt;br /&gt;
&lt;br /&gt;
Performing this upgrade means configuring your new OpenSimulator version to access your existing database.  This brings us onto the next step.&lt;br /&gt;
&lt;br /&gt;
== Updating your config files ==&lt;br /&gt;
&lt;br /&gt;
This step is a little more involved.  We don't recommend that you simply copy over your existing config files to the new OpenSimulator installation.  Although this will often work, sometimes it's quite possible to miss new configuration settings which end up causing subtle and unexplained problems.&lt;br /&gt;
&lt;br /&gt;
Instead, we strongly recommend that you look through the new config files and copy over the settings that apply to both the new and old config.&lt;br /&gt;
&lt;br /&gt;
This applies to both the main configuration files (e.g. OpenSim.ini and config-include/*.ini) and any region configuration files.&lt;br /&gt;
&lt;br /&gt;
SEE Discussion at [[Talk:Upgrading]] for examples of How-To Back Up &amp;amp; Restore your system PRIOR to ANY Migration or Upgrade!&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
 '''METHOD 1: If Using SQLite in StandAlone Mode'''&lt;br /&gt;
 &lt;br /&gt;
 1. Build the latest version from source (or download the binaries)&lt;br /&gt;
 &lt;br /&gt;
 2. Put this new installation in a new folder&lt;br /&gt;
 &lt;br /&gt;
 3. Copy the following files from the old \bin to the new \bin&lt;br /&gt;
    - All *.db files&lt;br /&gt;
    - The opensim.ini file&lt;br /&gt;
&lt;br /&gt;
 4. Look through the following configuration files and copy over your changed settings.&lt;br /&gt;
    - The opensim.ini file&lt;br /&gt;
    - The bin/config-include INI files&lt;br /&gt;
    - The bin/Regions XML files&lt;br /&gt;
    - The bin/estate_settings.xml (if it has been amended)&lt;br /&gt;
 &lt;br /&gt;
 5. Launch the new opensim.exe&lt;br /&gt;
&lt;br /&gt;
 '''METHOD 2: If Using MySQL in StandAlone Mode'''&lt;br /&gt;
 &lt;br /&gt;
 1. Build the latest version from source (or download the binaries)&lt;br /&gt;
 &lt;br /&gt;
 2. Put this new installation in a new folder&lt;br /&gt;
&lt;br /&gt;
 3. Look through the following configuration files and copy over your changed settings.&lt;br /&gt;
    - The opensim.ini file&lt;br /&gt;
    - The bin/Regions XML files&lt;br /&gt;
    - The bin/config-include INI files&lt;br /&gt;
    - The bin/estate_settings.xml (if it has been amended)&lt;br /&gt;
 &lt;br /&gt;
 4. Launch the new opensim.exe&lt;br /&gt;
&lt;br /&gt;
TODO: Need to write example/instructions for migrating ROBUST.  This is actually a lot simpler - one just needs to copy over settings in Robust.ini as appropriate.&lt;br /&gt;
&lt;br /&gt;
= Changing the database used by OpenSimulator =&lt;br /&gt;
&lt;br /&gt;
Since SQLite is our default database, there often comes a time when people outgrow it and want to move on to another database backend (usually MySQL). There is a script on the forge at [http://forge.opensimulator.org/gf/project/sqlite2mysql/] which should be able to do the conversion. If it's out of date then just give the author/s a nudge (or patch it!)&lt;br /&gt;
&lt;br /&gt;
An alternative method is to change to each region (change-region) before backing up their contents to a separate OpenSimulator Region Archive (OAR) for each region. Then change the database backend and then reload the OARs in each region separately. The disadvantage of this is that it's a little laborious if you have many regions.&lt;br /&gt;
&lt;br /&gt;
You can use the &amp;quot;command-script&amp;quot; feature of OpenSim.exe to semi-automate this. E.g., create a file in your &amp;quot;bin&amp;quot; directory, called something like &amp;quot;dobackup&amp;quot;, which contains the necessary commands, for example:&lt;br /&gt;
&lt;br /&gt;
 change-region My Island 1&lt;br /&gt;
 save-oar MI1&lt;br /&gt;
 change-region My Island 2&lt;br /&gt;
 save-oar MI2&lt;br /&gt;
 change-region Another Region&lt;br /&gt;
 save-oar AR&lt;br /&gt;
 change-region root&lt;br /&gt;
&lt;br /&gt;
This can be run from OpenSim.exe by typing &amp;quot;command-script&amp;quot; followed by the name you gave the script (eg &amp;quot;dobackup&amp;quot;). Note that this will overwrite the previous backup of the same name.&lt;br /&gt;
&lt;br /&gt;
Note that using a save and reload via the OAR mechanism would not normally migrate your avatar inventories (you would need to rez everything out to the region, convert the data base, and then derez them again to your inventory).&lt;/div&gt;</summary>
		<author><name>Reibling</name></author>	</entry>

	<entry>
		<id>http://opensimulator.org/wiki/Upgrading</id>
		<title>Upgrading</title>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/wiki/Upgrading"/>
				<updated>2015-04-20T16:03:59Z</updated>
		
		<summary type="html">&lt;p&gt;Reibling: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Quicklinks}}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Updating your version of OpenSimulator =&lt;br /&gt;
&lt;br /&gt;
Upgrading your version of OpenSimulator involves 2 major steps&lt;br /&gt;
&lt;br /&gt;
1.  Updating your existing data for the new version of OpenSimulator.&lt;br /&gt;
2.  Updating the config files for the new version of OpenSimulator.&lt;br /&gt;
&lt;br /&gt;
== Updating your existing data ==&lt;br /&gt;
&lt;br /&gt;
The first step is very easy.  OpenSimulator has a data migration system which will automatically update your old database schema and data for use with the new version of OpenSimulator.  This will be valid for many past versions of OpenSimulator (currently all the way back to OpenSimulator 0.6.9 and quite possibly before).&lt;br /&gt;
&lt;br /&gt;
Naturally, we very strongly recommend that you make a backup of your old database first, but the upgrade process almost always occurs without a hitch.  However, one could always suffer a power cut or other major computer failure during the ugprade.&lt;br /&gt;
&lt;br /&gt;
If you're using SQLite, then you will also need to copy over the database files since these are in the OpenSimulator bin directory.  These will be all the files ending with .db (e.g. Asset.db, inventory.db).&lt;br /&gt;
&lt;br /&gt;
Performing this upgrade means configuring your new OpenSimulator version to access your existing database.  This brings us onto the next step.&lt;br /&gt;
&lt;br /&gt;
== Updating your config files ==&lt;br /&gt;
&lt;br /&gt;
This step is a little more involved.  We don't recommend that you simply copy over your existing config files to the new OpenSimulator installation.  Although this will often work, sometimes it's quite possible to miss new configuration settings which end up causing subtle and unexplained problems.&lt;br /&gt;
&lt;br /&gt;
Instead, we strongly recommend that you look through the new config files and copy over the settings that apply to both the new and old config.&lt;br /&gt;
&lt;br /&gt;
This applies to both the main configuration files (e.g. OpenSim.ini and config-include/*.ini) and any region configuration files.&lt;br /&gt;
&lt;br /&gt;
SEE Discussion at [[Talk:Upgrading]] for examples of How-To Back Up &amp;amp; Restore your system PRIOR to ANY Migration or Upgrade!&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
 '''METHOD 1: If Using SQLite in StandAlone Mode'''&lt;br /&gt;
 &lt;br /&gt;
 1. Build the latest version from source (or download the binaries)&lt;br /&gt;
 &lt;br /&gt;
 2. Put this new installation in a new folder&lt;br /&gt;
 &lt;br /&gt;
 3. Copy the following files from the old \bin to the new \bin&lt;br /&gt;
    - All *.db files&lt;br /&gt;
    - The opensim.ini file&lt;br /&gt;
&lt;br /&gt;
 4. Look through the following configuration files and copy over your changed settings.&lt;br /&gt;
    - The opensim.ini file&lt;br /&gt;
    - The bin/config-include INI files&lt;br /&gt;
    - The bin/Regions XML files&lt;br /&gt;
    - The bin/estate_settings.xml (if it has been amended)&lt;br /&gt;
 &lt;br /&gt;
 5. Launch the new opensim.exe&lt;br /&gt;
&lt;br /&gt;
 '''METHOD 2: If Using MySQL in StandAlone Mode'''&lt;br /&gt;
 &lt;br /&gt;
 1. Build the latest version from source (or download the binaries)&lt;br /&gt;
 &lt;br /&gt;
 2. Put this new installation in a new folder&lt;br /&gt;
&lt;br /&gt;
 3. Look through the following configuration files and copy over your changed settings.&lt;br /&gt;
    - The opensim.ini file&lt;br /&gt;
    - The bin/regions XML files&lt;br /&gt;
    - The bin/config-include INI files&lt;br /&gt;
    - The bin/estate_settings.xml (if it has been amended)&lt;br /&gt;
 &lt;br /&gt;
 4. Launch the new opensim.exe&lt;br /&gt;
&lt;br /&gt;
TODO: Need to write example/instructions for migrating ROBUST.  This is actually a lot simpler - one just needs to copy over settings in Robust.ini as appropriate.&lt;br /&gt;
&lt;br /&gt;
= Changing the database used by OpenSimulator =&lt;br /&gt;
&lt;br /&gt;
Since SQLite is our default database, there often comes a time when people outgrow it and want to move on to another database backend (usually MySQL). There is a script on the forge at [http://forge.opensimulator.org/gf/project/sqlite2mysql/] which should be able to do the conversion. If it's out of date then just give the author/s a nudge (or patch it!)&lt;br /&gt;
&lt;br /&gt;
An alternative method is to change to each region (change-region) before backing up their contents to a separate OpenSimulator Region Archive (OAR) for each region. Then change the database backend and then reload the OARs in each region separately. The disadvantage of this is that it's a little laborious if you have many regions.&lt;br /&gt;
&lt;br /&gt;
You can use the &amp;quot;command-script&amp;quot; feature of OpenSim.exe to semi-automate this. E.g., create a file in your &amp;quot;bin&amp;quot; directory, called something like &amp;quot;dobackup&amp;quot;, which contains the necessary commands, for example:&lt;br /&gt;
&lt;br /&gt;
 change-region My Island 1&lt;br /&gt;
 save-oar MI1&lt;br /&gt;
 change-region My Island 2&lt;br /&gt;
 save-oar MI2&lt;br /&gt;
 change-region Another Region&lt;br /&gt;
 save-oar AR&lt;br /&gt;
 change-region root&lt;br /&gt;
&lt;br /&gt;
This can be run from OpenSim.exe by typing &amp;quot;command-script&amp;quot; followed by the name you gave the script (eg &amp;quot;dobackup&amp;quot;). Note that this will overwrite the previous backup of the same name.&lt;br /&gt;
&lt;br /&gt;
Note that using a save and reload via the OAR mechanism would not normally migrate your avatar inventories (you would need to rez everything out to the region, convert the data base, and then derez them again to your inventory).&lt;/div&gt;</summary>
		<author><name>Reibling</name></author>	</entry>

	<entry>
		<id>http://opensimulator.org/wiki/Varregion</id>
		<title>Varregion</title>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/wiki/Varregion"/>
				<updated>2014-03-07T19:14:08Z</updated>
		
		<summary type="html">&lt;p&gt;Reibling: /* Tips on Migrating Existing Sims to VarRegions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Varregion'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&amp;quot;Varregion&amp;quot; is a feature of OpenSimulator that enables region sizes larger than 256x256. The region is just larger so it acts like a regular region but with borders farther apart.&lt;br /&gt;
&lt;br /&gt;
The implementation uses the [http://aurora-sim.org Aurora] large region protocol extensions so the existing [http://firestormviewer.org Firestorm] and [http://singularityviewer.org Singularity] Aurora support will now work for OpenSimulator.&lt;br /&gt;
&lt;br /&gt;
This is different from the older [[Megaregions]] large region feature which does not require extra viewer support (above that already implemented by Linden Lab) but which relies on a number of fragile hacks to make a viewer work in a way that Linden Lab never supported.  Megaregions also contain a number of extant simulator-side bugs.&lt;br /&gt;
&lt;br /&gt;
A growing list of protocol changes to implement &amp;quot;varregion&amp;quot; is at [[varregion/Protocol|Varregion Protocol]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
Some restrictions apply:&lt;br /&gt;
* The dimensions must be a multiple of 256 and less than or equal to 8192.&lt;br /&gt;
* The dimensions must be square (as of 20131104)&lt;br /&gt;
* Adjacent regions must be the same size. For instance, you can have multiple 512x512 regions adjacent (and see into the other region and border cross). There seems to be a viewer problem where, if regions of different size are within view distance, crashes can happen. Consider having regions of only the same size 'in view'. Remember that the region coordinates are specified in 256m region count so a group of four 512x512 regions would be specified at 8000/8000, 8000/8002, 8002/8000, and 8002/8002, for instance.&lt;br /&gt;
* You must use BulletSim (as of 20131104, ODE has not been modified for varregions)&lt;br /&gt;
** You must use BulletSim's height map terrain implementation. As of 20140128, BulletSim has been modified to force heightmap terrain implementation if region size is greater than 256 on any side. The setting can be forced by adding to your INI files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[BulletSim]&lt;br /&gt;
    TerrainImplementation = 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
The size is be specified in the &amp;lt;tt&amp;gt;Region.ini&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    [MyRegionName]&lt;br /&gt;
    RegionUUID = 95ec77ec-58c5-4ce2-9ff3-b6d1900d78a2&lt;br /&gt;
    Location = 1000,1000&lt;br /&gt;
    SizeX = 1024&lt;br /&gt;
    SizeY = 1024&lt;br /&gt;
    InternalAddress = 0.0.0.0&lt;br /&gt;
    InternalPort = 9200&lt;br /&gt;
    AllowAlternatePorts = False&lt;br /&gt;
    ExternalHostName = SYSTEMIP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If size is not specified, it will, of course, default to the legacy size of 256.&lt;br /&gt;
&lt;br /&gt;
If the given dimensions do not fit the restrictions, acceptable values are computed and warning and error messages are output into the log.&lt;br /&gt;
&lt;br /&gt;
If converting from a mega-region, remember to set &amp;quot;&amp;lt;tt&amp;gt;CombineContiguousRegions = false&amp;lt;/tt&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
for llRezObject to work beyond 256m set &amp;quot;ScriptDistanceLimitFactor = 52.0&amp;quot; (for 512mx512m) in the [Xengine] section of OpenSim.ini.&lt;br /&gt;
&lt;br /&gt;
The terrain heightmap is stored in the database as an array of 'shorts' (two bytes) so, if you have a very large region you might need to set the database maximum size to a larger value. For instance, a 2816x2816 region (11x11 legacy regions) turns into a 56 megabyte heightmap and, for MySQL, you would need to set &amp;lt;tt&amp;gt;max_allowed_packet&amp;lt;/tt&amp;gt; to something like 64M.&lt;br /&gt;
&lt;br /&gt;
==Loading Terrain==&lt;br /&gt;
The usual terrain console commands work with varregions. If you have set up a larger region, you can load BMP/RAW/PNG heightmap files of the dimensions of the region and fill the whole region. For instance, a 1024x1024 region terrain would be completely initialized by &amp;quot;terrain load 1024.bmp&amp;quot; if '1024.bmp is a 1024x1024 bitmap.&lt;br /&gt;
&lt;br /&gt;
==Varregions and OAR Files==&lt;br /&gt;
The objects and terrain are stored in an OAR file as if it was one region. That is, if you save a 1024x1024 region in an OAR file, you can later restore the objects and terrain into a 1024x1024 sized region. If you load an OAR file from a smaller region into a larger region, the unspecified terrain space will default to 25m.&lt;br /&gt;
&lt;br /&gt;
To make conversion to varregions easier, 'load oar' now has a '--displacement &amp;quot;&amp;lt;x,y,z&amp;gt;&amp;quot;' parameter. This displaces all of the objects and the terrain from the oar file when loading them into the new region.  For instance, say you have four&lt;br /&gt;
OAR files from four adjacent 256x256 regions (oar00.oar, oar01.oar, oar10.oar, and oar11.oar). You create a new 512x512 varregion named 'bigregion'. The following commands place the four regions of objects, terrains and parcels&lt;br /&gt;
into the new larger region:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
change region bigregion&lt;br /&gt;
load oar oar00.oar&lt;br /&gt;
load oar oar01.oar --displacement &amp;quot;&amp;lt;0,256,0&amp;gt;&amp;quot; --merge --forceterrain --forceparcel&lt;br /&gt;
load oar oar10.oar --displacement &amp;quot;&amp;lt;256,0,0&amp;gt;&amp;quot; --merge --forceterrain --forceparcel&lt;br /&gt;
load oar oar11.oar --displacement &amp;quot;&amp;lt;256,256,0&amp;gt;&amp;quot; --merge --forceterrain --forceparcel&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the new &amp;quot;--forceterrain&amp;quot; and &amp;quot;--forceparcel&amp;quot; parameters. &amp;quot;--merge&amp;quot;, used by itself, is for merging together the objects from multiple OARs. Merging also suppresses the loading of terrain and parcel data which is just what you want when merging objects. But, if loading multiple OARs to create a new, larger region, the terrain and parcel information  must be loaded. Thus the new parameters.&lt;br /&gt;
&lt;br /&gt;
==Things Known to be Broken==&lt;br /&gt;
* There is some problem with teleporting in an out of larger region. It works for some configurations and not others.&lt;br /&gt;
* While adjacent regions are usually viewable, sometimes they are not. They appear when you cross over into the region.&lt;br /&gt;
&lt;br /&gt;
==Implementation Discussion==&lt;br /&gt;
Since this will be a major change to OpenSimulator that touches a&lt;br /&gt;
lot of different parts, subsequent posts, will discuss the changes I'm making.&lt;br /&gt;
&lt;br /&gt;
===TerrainData===&lt;br /&gt;
One major problem is passing the terrain data from the region to the&lt;br /&gt;
protocol stack. The existing implementation passed an array of floats&lt;br /&gt;
that were presumed to be a 256x256 array of region terrain heights.&lt;br /&gt;
The&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainChannel&amp;lt;/tt&amp;gt;&lt;br /&gt;
class is an attempt to hide the terrain implementation&lt;br /&gt;
from&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainModule&amp;lt;/tt&amp;gt;&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainChannel&amp;lt;/tt&amp;gt;&lt;br /&gt;
can't be passed into the protocol&lt;br /&gt;
stack (LLClientView) because&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainChannel&amp;lt;/tt&amp;gt;&lt;br /&gt;
is defined as part of&lt;br /&gt;
&amp;lt;tt&amp;gt;OpenSim.Region.Framework&amp;lt;/tt&amp;gt;&lt;br /&gt;
which is not visible to the protocol code.&lt;br /&gt;
&lt;br /&gt;
My solution is to create the&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt;&lt;br /&gt;
class in&lt;br /&gt;
&amp;lt;tt&amp;gt;OpenSim.Framework.&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt;&lt;br /&gt;
just wraps the data structure for the terrain and additionally has&lt;br /&gt;
the attributes giving X and Y size.&lt;br /&gt;
&lt;br /&gt;
I didn't want to change the signature of IClientAPI since so many external modules&lt;br /&gt;
rely on it.&lt;br /&gt;
It should be changed to pass &amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt; rather than a &amp;lt;tt&amp;gt;float[]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I decided to not change IClientAPI but rather have &amp;lt;tt&amp;gt;LLClientView&amp;lt;/tt&amp;gt; ignore&lt;br /&gt;
the passed array and instead reach back into the associated scene and fetch the&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt; instance.&lt;br /&gt;
&lt;br /&gt;
There is one subclass of &amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;HeightmapTerrainData&amp;lt;/tt&amp;gt; which keeps the terrain as a compressed heightmap. The height of each point is stored as a &amp;lt;tt&amp;gt;short&amp;lt;/tt&amp;gt; which is &amp;lt;tt&amp;gt;height * compressionFactor&amp;lt;/tt&amp;gt; where &amp;lt;tt&amp;gt;compressionFactor&amp;lt;/tt&amp;gt; is usually &amp;quot;100&amp;quot;. This creates a compact storage of the terrain heights with two decimal points of resolution.&lt;br /&gt;
&lt;br /&gt;
The LLLP (&amp;quot;Linden Lab Legacy Protocol&amp;quot;) sends terrain height data in&lt;br /&gt;
compressed &amp;quot;patches&amp;quot; of 16x16 areas of the terrain&lt;br /&gt;
height. This is a protocol feature that is implemented in &amp;lt;tt&amp;gt;TerrainChannel&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I feel that underlying protocol optimizations shouldn't appear up the&lt;br /&gt;
stack so, in creating &amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt;, I tried to hide terrain patches.&lt;br /&gt;
I mean, someday terrain will be generalized meshes. Right?&lt;br /&gt;
&lt;br /&gt;
===Terrain in the Database===&lt;br /&gt;
Previously, terrain height maps were saved in the database as a blob of 256x256 doubles. To have different region sizes, that format had to change. There is an existing database field &amp;lt;tt&amp;gt;revision&amp;lt;/tt&amp;gt; that stored the time the terrain was saved. This revision information wasn't used for anything so this field was co-opted to contain a revision code for the height field blob.&lt;br /&gt;
&lt;br /&gt;
There are three forms for the height map blob: legacy, compressed2D and regular2D. &amp;quot;legacy&amp;quot; is, of course, the previous 256x256 collections of doubles. &amp;quot;regular2D&amp;quot; contains the X, Y dimensions and enough floats for that area's heights. &amp;quot;compressed2D&amp;quot; contains the X,Y and compressionFactor followed by enough shorts for the height map.&lt;br /&gt;
&lt;br /&gt;
The database readers and writers default to the legacy format and, if the region happens to have the dimensions 256x256, it is stored using the legacy format. This is an attempt to keep downward compatibility.&lt;br /&gt;
&lt;br /&gt;
All of the database modules (MySQL, SQLite, MSSQL and PSQL) have been modified to store terrain this new way.&lt;br /&gt;
&lt;br /&gt;
===Sensing Border Crossing===&lt;br /&gt;
Most of the ‘move to new region’ code is based on checking boundaries. There is much code related to computing if an object or avatar has crossed a region boundary and then computing the address of the next region from same. Introducing variable sized regions messes a lot of this computation up. That is, the code doing the arithmetic usually assumes it knows the address of the next region based on a known region size and them can compute the location of the next region based on that. With varregions those assumptions no longer hold. Varregion implementation means that the computation of region base locations and border locations moves to the GridService who is the entity who really knows the size of all the regions and what is adjacent to what.&lt;br /&gt;
&lt;br /&gt;
The realization that location to region computation is really a GridService operation lead me to totally rip apart the grid boundary checking code and replace it with two functions: &amp;lt;tt&amp;gt;Scene.PositionIsInCurrentRegion(Vector3 pos)&amp;lt;/tt&amp;gt; and then &amp;lt;tt&amp;gt;EntityTransferModule.GetRegionContainingWorldLocation(double X, double Y)&amp;lt;/tt&amp;gt;. The former function tests to see if the object/avatar has moved out of the current region and the latter gets the region moved into. (Side note: &amp;lt;tt&amp;gt;GetRegionContainingWorldLocation&amp;lt;/tt&amp;gt; should really be a function on &amp;lt;tt&amp;gt;IGridService&amp;lt;/tt&amp;gt; but that exercise is left for future hacking).&lt;br /&gt;
&lt;br /&gt;
These changes leave all the 'border' code in limbo -- the generation of the border lists is still there but it is not being used. This should eventually be cleaned up. Also, the computation of neighbor regions is scattered around with routines on &amp;lt;tt&amp;gt;IGridService&amp;lt;/tt&amp;gt;, in &amp;lt;tt&amp;gt;EntityTransferModule&amp;lt;/tt&amp;gt; and a bunch of bookkeeping in &amp;lt;tt&amp;gt;Scene&amp;lt;/tt&amp;gt;. This too should be cleaned up.&lt;br /&gt;
&lt;br /&gt;
==Implementation Notes==&lt;br /&gt;
&lt;br /&gt;
As of January 27, 2014, varregion is a feature of the 'master' repository branch.&lt;br /&gt;
&lt;br /&gt;
===Stuff to Work On===&lt;br /&gt;
What follows are notes I am making as things that might need work are found in OpenSimulator.&lt;br /&gt;
&lt;br /&gt;
* Consolidate neighbor region computation code (Scene, EntityTransferModule and IGridService all have 'get neighbor' code)&lt;br /&gt;
* Clean up/eliminate border list creation and use code&lt;br /&gt;
* Region handles are world coords and also the base of the region&lt;br /&gt;
** verify that everyone who converts coords to handle (Util.RegionWorldLocToHandle) is supplying the base of the region. (mostly done)&lt;br /&gt;
* ITerrainLoader implementations (mostly done)&lt;br /&gt;
**	How to handle tiles.&lt;br /&gt;
**	How to handle large regions sizes.&lt;br /&gt;
**	Terrain/FileLoaders/*.cs all return an ITerrainChannel&lt;br /&gt;
**	Need to fix all the file reader/writers&lt;br /&gt;
**	FileLoaders/LLRAW.cs has several &amp;quot;256&amp;quot;s rather than constant references&lt;br /&gt;
* Teleporting: should be able to teleport to anywhere in a large region&lt;br /&gt;
** &amp;quot;MyRegion/550/687/40&amp;quot;&lt;br /&gt;
* HG code needs to allow addresses anywhere into large regions&lt;br /&gt;
* When GridService return adjacent regions, make sure it does the right thing for large regions&lt;br /&gt;
* Consider moving terrain XML serialization into TerrainData&lt;br /&gt;
* Consider removing all instances of TerrainChannel.GetFloatsSerialized()&lt;br /&gt;
**	Replace with passing around TerrainData&lt;br /&gt;
* Code in EntityTransferModule that checks distance to decide if to make new connection&lt;br /&gt;
**	search for references to 'Constants.RegionSize'&lt;br /&gt;
**	Consider removing the distance code and replacing with call to grid service&lt;br /&gt;
* WorldMapModule.cs does a lot of arithmetic depending on constants that are really Contants.RegionSize&lt;br /&gt;
* Util.IsOutsideView uses Constants.RegionSize. Is use in ScenePresence a problem?&lt;br /&gt;
**	Used in ScenePresence.AdjustKnownSeeds()&lt;br /&gt;
**	Is this another instance like EntityTransferModule that needs to goto the grid service?&lt;br /&gt;
* Move all the short[] heightmap representation stuff into TerrainData.cs (partially done)&lt;br /&gt;
**	Is it possible to move all the patch stuff out of TerrainModule/TerrainChannel?&lt;br /&gt;
**	Clean up the use of m_revert. It looks like it is not saved after terrain is modified.&lt;br /&gt;
* Need to look through RegionCombinerModule.cs and see what safety checks are needed&lt;br /&gt;
**	Maybe just prevent combination if not legacy region size&lt;br /&gt;
* In LSL_Api.cs, llEdgeOfWorld() does some neighbor computation. Check for ok'ness.&lt;br /&gt;
* LandManagementModule.SendParcelOverlay sends land sale/ownership info for 4x4m areas&lt;br /&gt;
**  Looks like it expects to send exactly one 1024 byte block (for the 256x256 legacy region&lt;br /&gt;
**  Check viewer code for what will happen for larger regions&lt;br /&gt;
* The code for cloud and wind needs to be enhanced for larger regions&lt;br /&gt;
**	New overlay types added&lt;br /&gt;
* LLClientView.SendMapBlockSplit() needs to have region size to send with the map info&lt;br /&gt;
* Region/Framework/Scenes/Tests/BorderTests.cs might need work if non-standard regions are tested&lt;br /&gt;
* Verify terrain tests still work (for 256m regions)&lt;br /&gt;
* Region coords are sometimes 'int' and sometimes 'uint' with conversions EVERYWHERE&lt;br /&gt;
** pass over everything and convert region coordinates it 'uint's&lt;br /&gt;
** consider creating structures for world and region coordinates so there can be compile time checking&lt;br /&gt;
&lt;br /&gt;
====Viewer====&lt;br /&gt;
* LLSurface is wired to expect adjacent regions of same size&lt;br /&gt;
* Terrain surface image is sized with a 'static&amp;quot;: &amp;quot;    static S32  sTextureSize;               // Size of the surface texture&amp;quot;&lt;br /&gt;
* From FreeNode:#SingularityViewer 20131125:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;Aleric&amp;gt; radams1, SianaGearz, frnic : I couldn't help myself doing a profile anyway..  The reason the viewer is slow is because it's busy &amp;quot;drawing&amp;quot; the terrain. &amp;quot;drawing&amp;quot; between quotes because my guess is that it is trying to draw ALL terrain and then clip that afterwards to the frustrum... &lt;br /&gt;
&amp;lt;Aleric&amp;gt; So, this could be greatly improved by disregarding terrain way way earlier when it is beyond the drawing range anyway.&lt;br /&gt;
&amp;lt;SianaGearz&amp;gt; OK&lt;br /&gt;
&amp;lt;Aleric&amp;gt; I disabled all rendering, even added a 'return' in terrain render&lt;br /&gt;
&amp;lt;Aleric&amp;gt; but.. no improvement of FPS!&lt;br /&gt;
&amp;lt;frnic&amp;gt; oops&lt;br /&gt;
&amp;lt;Aleric&amp;gt; LLSurfacePatch::updateVisibility() is still eating a lot of cpu.&lt;br /&gt;
&amp;lt;Aleric&amp;gt; LLSurface::updatePatchVisibilities does 97% of the calls to LLSurfacePatch::updateVisibility&lt;br /&gt;
&amp;lt;Aleric&amp;gt; which then spends most of it's time calling LLCamera::AABBInFrustumNoFarClip&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Singularity commit for varregion: https://github.com/singularity-viewer/SingularityViewer/commit/ad8ea07a&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
* Terrain/parcel operations&lt;br /&gt;
** Default 256 standalone region&lt;br /&gt;
*** Clean database. Start single standalone region. Verify 'pimple' region. Verify one parcel. Flatten region.&lt;br /&gt;
*** Create parcels adjacent to each edge and standalone in middle. Change names of each parcel and verify. Restart simulator and verify parcels exist and work correctly.&lt;br /&gt;
*** Save five parcel region as OAR. Clear database. Restart region. Load oar. Verify 5 parcels of correct location, name and features.&lt;br /&gt;
** Adjacent 256 standalone regions &lt;br /&gt;
** 768x768 standalone region&lt;br /&gt;
** Changing land from 256 to 768&lt;br /&gt;
* Teleporting&lt;br /&gt;
* Adjacency&lt;br /&gt;
* Hypergrid&lt;br /&gt;
&lt;br /&gt;
==Tips on Migrating Existing Sims to VarRegions==&lt;br /&gt;
* When you start the sim, you have to have either no regions nearby, or identical sized regions. otherwise, it locks your movement to the size of the smallest region&lt;br /&gt;
* When you load your oars, it's like Aurora sim.  You need to load them by displacement first, load each one in place to get the terrains.&lt;br /&gt;
* When you merge, you lose the terrain.&lt;br /&gt;
* The second round, you reload each oar, this time with merge to load the objects.&lt;br /&gt;
* If you don't use merge, you lose all the objects with each oar load.&lt;br /&gt;
* When you load your oars, in format &amp;quot;&amp;lt;0,0,0&amp;gt;&amp;quot; the first number is east/west, or x, the second number is north/south, or y, and the third number is up or down, or z.&lt;br /&gt;
* The location must be in increments of 256.&lt;br /&gt;
* Using ROBUST for xbakes takes a significant load off the server; textures load quickly&lt;/div&gt;</summary>
		<author><name>Reibling</name></author>	</entry>

	<entry>
		<id>http://opensimulator.org/wiki/Varregion</id>
		<title>Varregion</title>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/wiki/Varregion"/>
				<updated>2014-03-07T18:56:18Z</updated>
		
		<summary type="html">&lt;p&gt;Reibling: /* Tips on Migrating Existing Sims to VarRegions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Varregion'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&amp;quot;Varregion&amp;quot; is a feature of OpenSimulator that enables region sizes larger than 256x256. The region is just larger so it acts like a regular region but with borders farther apart.&lt;br /&gt;
&lt;br /&gt;
The implementation uses the [http://aurora-sim.org Aurora] large region protocol extensions so the existing [http://firestormviewer.org Firestorm] and [http://singularityviewer.org Singularity] Aurora support will now work for OpenSimulator.&lt;br /&gt;
&lt;br /&gt;
This is different from the older [[Megaregions]] large region feature which does not require extra viewer support (above that already implemented by Linden Lab) but which relies on a number of fragile hacks to make a viewer work in a way that Linden Lab never supported.  Megaregions also contain a number of extant simulator-side bugs.&lt;br /&gt;
&lt;br /&gt;
A growing list of protocol changes to implement &amp;quot;varregion&amp;quot; is at [[varregion/Protocol|Varregion Protocol]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
Some restrictions apply:&lt;br /&gt;
* The dimensions must be a multiple of 256 and less than or equal to 8192.&lt;br /&gt;
* The dimensions must be square (as of 20131104)&lt;br /&gt;
* Adjacent regions must be the same size. For instance, you can have multiple 512x512 regions adjacent (and see into the other region and border cross). There seems to be a viewer problem where, if regions of different size are within view distance, crashes can happen. Consider having regions of only the same size 'in view'. Remember that the region coordinates are specified in 256m region count so a group of four 512x512 regions would be specified at 8000/8000, 8000/8002, 8002/8000, and 8002/8002, for instance.&lt;br /&gt;
* You must use BulletSim (as of 20131104, ODE has not been modified for varregions)&lt;br /&gt;
** You must use BulletSim's height map terrain implementation. As of 20140128, BulletSim has been modified to force heightmap terrain implementation if region size is greater than 256 on any side. The setting can be forced by adding to your INI files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[BulletSim]&lt;br /&gt;
    TerrainImplementation = 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
The size is be specified in the &amp;lt;tt&amp;gt;Region.ini&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    [MyRegionName]&lt;br /&gt;
    RegionUUID = 95ec77ec-58c5-4ce2-9ff3-b6d1900d78a2&lt;br /&gt;
    Location = 1000,1000&lt;br /&gt;
    SizeX = 1024&lt;br /&gt;
    SizeY = 1024&lt;br /&gt;
    InternalAddress = 0.0.0.0&lt;br /&gt;
    InternalPort = 9200&lt;br /&gt;
    AllowAlternatePorts = False&lt;br /&gt;
    ExternalHostName = SYSTEMIP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If size is not specified, it will, of course, default to the legacy size of 256.&lt;br /&gt;
&lt;br /&gt;
If the given dimensions do not fit the restrictions, acceptable values are computed and warning and error messages are output into the log.&lt;br /&gt;
&lt;br /&gt;
If converting from a mega-region, remember to set &amp;quot;&amp;lt;tt&amp;gt;CombineContiguousRegions = false&amp;lt;/tt&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
for llRezObject to work beyond 256m set &amp;quot;ScriptDistanceLimitFactor = 52.0&amp;quot; (for 512mx512m) in the [Xengine] section of OpenSim.ini.&lt;br /&gt;
&lt;br /&gt;
The terrain heightmap is stored in the database as an array of 'shorts' (two bytes) so, if you have a very large region you might need to set the database maximum size to a larger value. For instance, a 2816x2816 region (11x11 legacy regions) turns into a 56 megabyte heightmap and, for MySQL, you would need to set &amp;lt;tt&amp;gt;max_allowed_packet&amp;lt;/tt&amp;gt; to something like 64M.&lt;br /&gt;
&lt;br /&gt;
==Loading Terrain==&lt;br /&gt;
The usual terrain console commands work with varregions. If you have set up a larger region, you can load BMP/RAW/PNG heightmap files of the dimensions of the region and fill the whole region. For instance, a 1024x1024 region terrain would be completely initialized by &amp;quot;terrain load 1024.bmp&amp;quot; if '1024.bmp is a 1024x1024 bitmap.&lt;br /&gt;
&lt;br /&gt;
==Varregions and OAR Files==&lt;br /&gt;
The objects and terrain are stored in an OAR file as if it was one region. That is, if you save a 1024x1024 region in an OAR file, you can later restore the objects and terrain into a 1024x1024 sized region. If you load an OAR file from a smaller region into a larger region, the unspecified terrain space will default to 25m.&lt;br /&gt;
&lt;br /&gt;
To make conversion to varregions easier, 'load oar' now has a '--displacement &amp;quot;&amp;lt;x,y,z&amp;gt;&amp;quot;' parameter. This displaces all of the objects and the terrain from the oar file when loading them into the new region.  For instance, say you have four&lt;br /&gt;
OAR files from four adjacent 256x256 regions (oar00.oar, oar01.oar, oar10.oar, and oar11.oar). You create a new 512x512 varregion named 'bigregion'. The following commands place the four regions of objects, terrains and parcels&lt;br /&gt;
into the new larger region:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
change region bigregion&lt;br /&gt;
load oar oar00.oar&lt;br /&gt;
load oar oar01.oar --displacement &amp;quot;&amp;lt;0,256,0&amp;gt;&amp;quot; --merge --forceterrain --forceparcel&lt;br /&gt;
load oar oar10.oar --displacement &amp;quot;&amp;lt;256,0,0&amp;gt;&amp;quot; --merge --forceterrain --forceparcel&lt;br /&gt;
load oar oar11.oar --displacement &amp;quot;&amp;lt;256,256,0&amp;gt;&amp;quot; --merge --forceterrain --forceparcel&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the new &amp;quot;--forceterrain&amp;quot; and &amp;quot;--forceparcel&amp;quot; parameters. &amp;quot;--merge&amp;quot;, used by itself, is for merging together the objects from multiple OARs. Merging also suppresses the loading of terrain and parcel data which is just what you want when merging objects. But, if loading multiple OARs to create a new, larger region, the terrain and parcel information  must be loaded. Thus the new parameters.&lt;br /&gt;
&lt;br /&gt;
==Things Known to be Broken==&lt;br /&gt;
* There is some problem with teleporting in an out of larger region. It works for some configurations and not others.&lt;br /&gt;
* While adjacent regions are usually viewable, sometimes they are not. They appear when you cross over into the region.&lt;br /&gt;
&lt;br /&gt;
==Implementation Discussion==&lt;br /&gt;
Since this will be a major change to OpenSimulator that touches a&lt;br /&gt;
lot of different parts, subsequent posts, will discuss the changes I'm making.&lt;br /&gt;
&lt;br /&gt;
===TerrainData===&lt;br /&gt;
One major problem is passing the terrain data from the region to the&lt;br /&gt;
protocol stack. The existing implementation passed an array of floats&lt;br /&gt;
that were presumed to be a 256x256 array of region terrain heights.&lt;br /&gt;
The&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainChannel&amp;lt;/tt&amp;gt;&lt;br /&gt;
class is an attempt to hide the terrain implementation&lt;br /&gt;
from&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainModule&amp;lt;/tt&amp;gt;&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainChannel&amp;lt;/tt&amp;gt;&lt;br /&gt;
can't be passed into the protocol&lt;br /&gt;
stack (LLClientView) because&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainChannel&amp;lt;/tt&amp;gt;&lt;br /&gt;
is defined as part of&lt;br /&gt;
&amp;lt;tt&amp;gt;OpenSim.Region.Framework&amp;lt;/tt&amp;gt;&lt;br /&gt;
which is not visible to the protocol code.&lt;br /&gt;
&lt;br /&gt;
My solution is to create the&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt;&lt;br /&gt;
class in&lt;br /&gt;
&amp;lt;tt&amp;gt;OpenSim.Framework.&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt;&lt;br /&gt;
just wraps the data structure for the terrain and additionally has&lt;br /&gt;
the attributes giving X and Y size.&lt;br /&gt;
&lt;br /&gt;
I didn't want to change the signature of IClientAPI since so many external modules&lt;br /&gt;
rely on it.&lt;br /&gt;
It should be changed to pass &amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt; rather than a &amp;lt;tt&amp;gt;float[]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I decided to not change IClientAPI but rather have &amp;lt;tt&amp;gt;LLClientView&amp;lt;/tt&amp;gt; ignore&lt;br /&gt;
the passed array and instead reach back into the associated scene and fetch the&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt; instance.&lt;br /&gt;
&lt;br /&gt;
There is one subclass of &amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;HeightmapTerrainData&amp;lt;/tt&amp;gt; which keeps the terrain as a compressed heightmap. The height of each point is stored as a &amp;lt;tt&amp;gt;short&amp;lt;/tt&amp;gt; which is &amp;lt;tt&amp;gt;height * compressionFactor&amp;lt;/tt&amp;gt; where &amp;lt;tt&amp;gt;compressionFactor&amp;lt;/tt&amp;gt; is usually &amp;quot;100&amp;quot;. This creates a compact storage of the terrain heights with two decimal points of resolution.&lt;br /&gt;
&lt;br /&gt;
The LLLP (&amp;quot;Linden Lab Legacy Protocol&amp;quot;) sends terrain height data in&lt;br /&gt;
compressed &amp;quot;patches&amp;quot; of 16x16 areas of the terrain&lt;br /&gt;
height. This is a protocol feature that is implemented in &amp;lt;tt&amp;gt;TerrainChannel&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I feel that underlying protocol optimizations shouldn't appear up the&lt;br /&gt;
stack so, in creating &amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt;, I tried to hide terrain patches.&lt;br /&gt;
I mean, someday terrain will be generalized meshes. Right?&lt;br /&gt;
&lt;br /&gt;
===Terrain in the Database===&lt;br /&gt;
Previously, terrain height maps were saved in the database as a blob of 256x256 doubles. To have different region sizes, that format had to change. There is an existing database field &amp;lt;tt&amp;gt;revision&amp;lt;/tt&amp;gt; that stored the time the terrain was saved. This revision information wasn't used for anything so this field was co-opted to contain a revision code for the height field blob.&lt;br /&gt;
&lt;br /&gt;
There are three forms for the height map blob: legacy, compressed2D and regular2D. &amp;quot;legacy&amp;quot; is, of course, the previous 256x256 collections of doubles. &amp;quot;regular2D&amp;quot; contains the X, Y dimensions and enough floats for that area's heights. &amp;quot;compressed2D&amp;quot; contains the X,Y and compressionFactor followed by enough shorts for the height map.&lt;br /&gt;
&lt;br /&gt;
The database readers and writers default to the legacy format and, if the region happens to have the dimensions 256x256, it is stored using the legacy format. This is an attempt to keep downward compatibility.&lt;br /&gt;
&lt;br /&gt;
All of the database modules (MySQL, SQLite, MSSQL and PSQL) have been modified to store terrain this new way.&lt;br /&gt;
&lt;br /&gt;
===Sensing Border Crossing===&lt;br /&gt;
Most of the ‘move to new region’ code is based on checking boundaries. There is much code related to computing if an object or avatar has crossed a region boundary and then computing the address of the next region from same. Introducing variable sized regions messes a lot of this computation up. That is, the code doing the arithmetic usually assumes it knows the address of the next region based on a known region size and them can compute the location of the next region based on that. With varregions those assumptions no longer hold. Varregion implementation means that the computation of region base locations and border locations moves to the GridService who is the entity who really knows the size of all the regions and what is adjacent to what.&lt;br /&gt;
&lt;br /&gt;
The realization that location to region computation is really a GridService operation lead me to totally rip apart the grid boundary checking code and replace it with two functions: &amp;lt;tt&amp;gt;Scene.PositionIsInCurrentRegion(Vector3 pos)&amp;lt;/tt&amp;gt; and then &amp;lt;tt&amp;gt;EntityTransferModule.GetRegionContainingWorldLocation(double X, double Y)&amp;lt;/tt&amp;gt;. The former function tests to see if the object/avatar has moved out of the current region and the latter gets the region moved into. (Side note: &amp;lt;tt&amp;gt;GetRegionContainingWorldLocation&amp;lt;/tt&amp;gt; should really be a function on &amp;lt;tt&amp;gt;IGridService&amp;lt;/tt&amp;gt; but that exercise is left for future hacking).&lt;br /&gt;
&lt;br /&gt;
These changes leave all the 'border' code in limbo -- the generation of the border lists is still there but it is not being used. This should eventually be cleaned up. Also, the computation of neighbor regions is scattered around with routines on &amp;lt;tt&amp;gt;IGridService&amp;lt;/tt&amp;gt;, in &amp;lt;tt&amp;gt;EntityTransferModule&amp;lt;/tt&amp;gt; and a bunch of bookkeeping in &amp;lt;tt&amp;gt;Scene&amp;lt;/tt&amp;gt;. This too should be cleaned up.&lt;br /&gt;
&lt;br /&gt;
==Implementation Notes==&lt;br /&gt;
&lt;br /&gt;
As of January 27, 2014, varregion is a feature of the 'master' repository branch.&lt;br /&gt;
&lt;br /&gt;
===Stuff to Work On===&lt;br /&gt;
What follows are notes I am making as things that might need work are found in OpenSimulator.&lt;br /&gt;
&lt;br /&gt;
* Consolidate neighbor region computation code (Scene, EntityTransferModule and IGridService all have 'get neighbor' code)&lt;br /&gt;
* Clean up/eliminate border list creation and use code&lt;br /&gt;
* Region handles are world coords and also the base of the region&lt;br /&gt;
** verify that everyone who converts coords to handle (Util.RegionWorldLocToHandle) is supplying the base of the region. (mostly done)&lt;br /&gt;
* ITerrainLoader implementations (mostly done)&lt;br /&gt;
**	How to handle tiles.&lt;br /&gt;
**	How to handle large regions sizes.&lt;br /&gt;
**	Terrain/FileLoaders/*.cs all return an ITerrainChannel&lt;br /&gt;
**	Need to fix all the file reader/writers&lt;br /&gt;
**	FileLoaders/LLRAW.cs has several &amp;quot;256&amp;quot;s rather than constant references&lt;br /&gt;
* Teleporting: should be able to teleport to anywhere in a large region&lt;br /&gt;
** &amp;quot;MyRegion/550/687/40&amp;quot;&lt;br /&gt;
* HG code needs to allow addresses anywhere into large regions&lt;br /&gt;
* When GridService return adjacent regions, make sure it does the right thing for large regions&lt;br /&gt;
* Consider moving terrain XML serialization into TerrainData&lt;br /&gt;
* Consider removing all instances of TerrainChannel.GetFloatsSerialized()&lt;br /&gt;
**	Replace with passing around TerrainData&lt;br /&gt;
* Code in EntityTransferModule that checks distance to decide if to make new connection&lt;br /&gt;
**	search for references to 'Constants.RegionSize'&lt;br /&gt;
**	Consider removing the distance code and replacing with call to grid service&lt;br /&gt;
* WorldMapModule.cs does a lot of arithmetic depending on constants that are really Contants.RegionSize&lt;br /&gt;
* Util.IsOutsideView uses Constants.RegionSize. Is use in ScenePresence a problem?&lt;br /&gt;
**	Used in ScenePresence.AdjustKnownSeeds()&lt;br /&gt;
**	Is this another instance like EntityTransferModule that needs to goto the grid service?&lt;br /&gt;
* Move all the short[] heightmap representation stuff into TerrainData.cs (partially done)&lt;br /&gt;
**	Is it possible to move all the patch stuff out of TerrainModule/TerrainChannel?&lt;br /&gt;
**	Clean up the use of m_revert. It looks like it is not saved after terrain is modified.&lt;br /&gt;
* Need to look through RegionCombinerModule.cs and see what safety checks are needed&lt;br /&gt;
**	Maybe just prevent combination if not legacy region size&lt;br /&gt;
* In LSL_Api.cs, llEdgeOfWorld() does some neighbor computation. Check for ok'ness.&lt;br /&gt;
* LandManagementModule.SendParcelOverlay sends land sale/ownership info for 4x4m areas&lt;br /&gt;
**  Looks like it expects to send exactly one 1024 byte block (for the 256x256 legacy region&lt;br /&gt;
**  Check viewer code for what will happen for larger regions&lt;br /&gt;
* The code for cloud and wind needs to be enhanced for larger regions&lt;br /&gt;
**	New overlay types added&lt;br /&gt;
* LLClientView.SendMapBlockSplit() needs to have region size to send with the map info&lt;br /&gt;
* Region/Framework/Scenes/Tests/BorderTests.cs might need work if non-standard regions are tested&lt;br /&gt;
* Verify terrain tests still work (for 256m regions)&lt;br /&gt;
* Region coords are sometimes 'int' and sometimes 'uint' with conversions EVERYWHERE&lt;br /&gt;
** pass over everything and convert region coordinates it 'uint's&lt;br /&gt;
** consider creating structures for world and region coordinates so there can be compile time checking&lt;br /&gt;
&lt;br /&gt;
====Viewer====&lt;br /&gt;
* LLSurface is wired to expect adjacent regions of same size&lt;br /&gt;
* Terrain surface image is sized with a 'static&amp;quot;: &amp;quot;    static S32  sTextureSize;               // Size of the surface texture&amp;quot;&lt;br /&gt;
* From FreeNode:#SingularityViewer 20131125:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;Aleric&amp;gt; radams1, SianaGearz, frnic : I couldn't help myself doing a profile anyway..  The reason the viewer is slow is because it's busy &amp;quot;drawing&amp;quot; the terrain. &amp;quot;drawing&amp;quot; between quotes because my guess is that it is trying to draw ALL terrain and then clip that afterwards to the frustrum... &lt;br /&gt;
&amp;lt;Aleric&amp;gt; So, this could be greatly improved by disregarding terrain way way earlier when it is beyond the drawing range anyway.&lt;br /&gt;
&amp;lt;SianaGearz&amp;gt; OK&lt;br /&gt;
&amp;lt;Aleric&amp;gt; I disabled all rendering, even added a 'return' in terrain render&lt;br /&gt;
&amp;lt;Aleric&amp;gt; but.. no improvement of FPS!&lt;br /&gt;
&amp;lt;frnic&amp;gt; oops&lt;br /&gt;
&amp;lt;Aleric&amp;gt; LLSurfacePatch::updateVisibility() is still eating a lot of cpu.&lt;br /&gt;
&amp;lt;Aleric&amp;gt; LLSurface::updatePatchVisibilities does 97% of the calls to LLSurfacePatch::updateVisibility&lt;br /&gt;
&amp;lt;Aleric&amp;gt; which then spends most of it's time calling LLCamera::AABBInFrustumNoFarClip&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Singularity commit for varregion: https://github.com/singularity-viewer/SingularityViewer/commit/ad8ea07a&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
* Terrain/parcel operations&lt;br /&gt;
** Default 256 standalone region&lt;br /&gt;
*** Clean database. Start single standalone region. Verify 'pimple' region. Verify one parcel. Flatten region.&lt;br /&gt;
*** Create parcels adjacent to each edge and standalone in middle. Change names of each parcel and verify. Restart simulator and verify parcels exist and work correctly.&lt;br /&gt;
*** Save five parcel region as OAR. Clear database. Restart region. Load oar. Verify 5 parcels of correct location, name and features.&lt;br /&gt;
** Adjacent 256 standalone regions &lt;br /&gt;
** 768x768 standalone region&lt;br /&gt;
** Changing land from 256 to 768&lt;br /&gt;
* Teleporting&lt;br /&gt;
* Adjacency&lt;br /&gt;
* Hypergrid&lt;br /&gt;
&lt;br /&gt;
==Tips on Migrating Existing Sims to VarRegions==&lt;br /&gt;
* When you start the sim, you have to have either no regions nearby, or identical sized regions. otherwise, it locks your movement to the size of the smallest region&lt;br /&gt;
* When you load your oars, it's like Aurora sim.  You need to load them by displacement first, load each one in place to get the terrains.&lt;br /&gt;
* When you merge, you lose the terrain.&lt;br /&gt;
* The second round, you reload each oar, this time with merge to load the objects.&lt;br /&gt;
* If you don't use merge, you lose all the objects with each oar load.&lt;br /&gt;
* When you load your oars, in format &amp;quot;&amp;lt;0,0,0&amp;gt;&amp;quot;  the first number is east/west, or x.&lt;br /&gt;
* The second number is north/south, or y&lt;br /&gt;
* The third number is up or down, or z.&lt;br /&gt;
* The location must be in increments of 256.&lt;br /&gt;
* Using ROBUST for xbakes takes a significant load off the server; textures load quickly&lt;/div&gt;</summary>
		<author><name>Reibling</name></author>	</entry>

	<entry>
		<id>http://opensimulator.org/wiki/Varregion</id>
		<title>Varregion</title>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/wiki/Varregion"/>
				<updated>2014-03-07T18:53:00Z</updated>
		
		<summary type="html">&lt;p&gt;Reibling: /* Varregions and OAR Files */ Change order of parameters - examples resulted in error expecting oar file name parameter in a different location&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Varregion'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&amp;quot;Varregion&amp;quot; is a feature of OpenSimulator that enables region sizes larger than 256x256. The region is just larger so it acts like a regular region but with borders farther apart.&lt;br /&gt;
&lt;br /&gt;
The implementation uses the [http://aurora-sim.org Aurora] large region protocol extensions so the existing [http://firestormviewer.org Firestorm] and [http://singularityviewer.org Singularity] Aurora support will now work for OpenSimulator.&lt;br /&gt;
&lt;br /&gt;
This is different from the older [[Megaregions]] large region feature which does not require extra viewer support (above that already implemented by Linden Lab) but which relies on a number of fragile hacks to make a viewer work in a way that Linden Lab never supported.  Megaregions also contain a number of extant simulator-side bugs.&lt;br /&gt;
&lt;br /&gt;
A growing list of protocol changes to implement &amp;quot;varregion&amp;quot; is at [[varregion/Protocol|Varregion Protocol]].&lt;br /&gt;
&lt;br /&gt;
==Restrictions==&lt;br /&gt;
Some restrictions apply:&lt;br /&gt;
* The dimensions must be a multiple of 256 and less than or equal to 8192.&lt;br /&gt;
* The dimensions must be square (as of 20131104)&lt;br /&gt;
* Adjacent regions must be the same size. For instance, you can have multiple 512x512 regions adjacent (and see into the other region and border cross). There seems to be a viewer problem where, if regions of different size are within view distance, crashes can happen. Consider having regions of only the same size 'in view'. Remember that the region coordinates are specified in 256m region count so a group of four 512x512 regions would be specified at 8000/8000, 8000/8002, 8002/8000, and 8002/8002, for instance.&lt;br /&gt;
* You must use BulletSim (as of 20131104, ODE has not been modified for varregions)&lt;br /&gt;
** You must use BulletSim's height map terrain implementation. As of 20140128, BulletSim has been modified to force heightmap terrain implementation if region size is greater than 256 on any side. The setting can be forced by adding to your INI files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[BulletSim]&lt;br /&gt;
    TerrainImplementation = 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
The size is be specified in the &amp;lt;tt&amp;gt;Region.ini&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    [MyRegionName]&lt;br /&gt;
    RegionUUID = 95ec77ec-58c5-4ce2-9ff3-b6d1900d78a2&lt;br /&gt;
    Location = 1000,1000&lt;br /&gt;
    SizeX = 1024&lt;br /&gt;
    SizeY = 1024&lt;br /&gt;
    InternalAddress = 0.0.0.0&lt;br /&gt;
    InternalPort = 9200&lt;br /&gt;
    AllowAlternatePorts = False&lt;br /&gt;
    ExternalHostName = SYSTEMIP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If size is not specified, it will, of course, default to the legacy size of 256.&lt;br /&gt;
&lt;br /&gt;
If the given dimensions do not fit the restrictions, acceptable values are computed and warning and error messages are output into the log.&lt;br /&gt;
&lt;br /&gt;
If converting from a mega-region, remember to set &amp;quot;&amp;lt;tt&amp;gt;CombineContiguousRegions = false&amp;lt;/tt&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
for llRezObject to work beyond 256m set &amp;quot;ScriptDistanceLimitFactor = 52.0&amp;quot; (for 512mx512m) in the [Xengine] section of OpenSim.ini.&lt;br /&gt;
&lt;br /&gt;
The terrain heightmap is stored in the database as an array of 'shorts' (two bytes) so, if you have a very large region you might need to set the database maximum size to a larger value. For instance, a 2816x2816 region (11x11 legacy regions) turns into a 56 megabyte heightmap and, for MySQL, you would need to set &amp;lt;tt&amp;gt;max_allowed_packet&amp;lt;/tt&amp;gt; to something like 64M.&lt;br /&gt;
&lt;br /&gt;
==Loading Terrain==&lt;br /&gt;
The usual terrain console commands work with varregions. If you have set up a larger region, you can load BMP/RAW/PNG heightmap files of the dimensions of the region and fill the whole region. For instance, a 1024x1024 region terrain would be completely initialized by &amp;quot;terrain load 1024.bmp&amp;quot; if '1024.bmp is a 1024x1024 bitmap.&lt;br /&gt;
&lt;br /&gt;
==Varregions and OAR Files==&lt;br /&gt;
The objects and terrain are stored in an OAR file as if it was one region. That is, if you save a 1024x1024 region in an OAR file, you can later restore the objects and terrain into a 1024x1024 sized region. If you load an OAR file from a smaller region into a larger region, the unspecified terrain space will default to 25m.&lt;br /&gt;
&lt;br /&gt;
To make conversion to varregions easier, 'load oar' now has a '--displacement &amp;quot;&amp;lt;x,y,z&amp;gt;&amp;quot;' parameter. This displaces all of the objects and the terrain from the oar file when loading them into the new region.  For instance, say you have four&lt;br /&gt;
OAR files from four adjacent 256x256 regions (oar00.oar, oar01.oar, oar10.oar, and oar11.oar). You create a new 512x512 varregion named 'bigregion'. The following commands place the four regions of objects, terrains and parcels&lt;br /&gt;
into the new larger region:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
change region bigregion&lt;br /&gt;
load oar oar00.oar&lt;br /&gt;
load oar oar01.oar --displacement &amp;quot;&amp;lt;0,256,0&amp;gt;&amp;quot; --merge --forceterrain --forceparcel&lt;br /&gt;
load oar oar10.oar --displacement &amp;quot;&amp;lt;256,0,0&amp;gt;&amp;quot; --merge --forceterrain --forceparcel&lt;br /&gt;
load oar oar11.oar --displacement &amp;quot;&amp;lt;256,256,0&amp;gt;&amp;quot; --merge --forceterrain --forceparcel&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the new &amp;quot;--forceterrain&amp;quot; and &amp;quot;--forceparcel&amp;quot; parameters. &amp;quot;--merge&amp;quot;, used by itself, is for merging together the objects from multiple OARs. Merging also suppresses the loading of terrain and parcel data which is just what you want when merging objects. But, if loading multiple OARs to create a new, larger region, the terrain and parcel information  must be loaded. Thus the new parameters.&lt;br /&gt;
&lt;br /&gt;
==Things Known to be Broken==&lt;br /&gt;
* There is some problem with teleporting in an out of larger region. It works for some configurations and not others.&lt;br /&gt;
* While adjacent regions are usually viewable, sometimes they are not. They appear when you cross over into the region.&lt;br /&gt;
&lt;br /&gt;
==Implementation Discussion==&lt;br /&gt;
Since this will be a major change to OpenSimulator that touches a&lt;br /&gt;
lot of different parts, subsequent posts, will discuss the changes I'm making.&lt;br /&gt;
&lt;br /&gt;
===TerrainData===&lt;br /&gt;
One major problem is passing the terrain data from the region to the&lt;br /&gt;
protocol stack. The existing implementation passed an array of floats&lt;br /&gt;
that were presumed to be a 256x256 array of region terrain heights.&lt;br /&gt;
The&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainChannel&amp;lt;/tt&amp;gt;&lt;br /&gt;
class is an attempt to hide the terrain implementation&lt;br /&gt;
from&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainModule&amp;lt;/tt&amp;gt;&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainChannel&amp;lt;/tt&amp;gt;&lt;br /&gt;
can't be passed into the protocol&lt;br /&gt;
stack (LLClientView) because&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainChannel&amp;lt;/tt&amp;gt;&lt;br /&gt;
is defined as part of&lt;br /&gt;
&amp;lt;tt&amp;gt;OpenSim.Region.Framework&amp;lt;/tt&amp;gt;&lt;br /&gt;
which is not visible to the protocol code.&lt;br /&gt;
&lt;br /&gt;
My solution is to create the&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt;&lt;br /&gt;
class in&lt;br /&gt;
&amp;lt;tt&amp;gt;OpenSim.Framework.&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt;&lt;br /&gt;
just wraps the data structure for the terrain and additionally has&lt;br /&gt;
the attributes giving X and Y size.&lt;br /&gt;
&lt;br /&gt;
I didn't want to change the signature of IClientAPI since so many external modules&lt;br /&gt;
rely on it.&lt;br /&gt;
It should be changed to pass &amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt; rather than a &amp;lt;tt&amp;gt;float[]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I decided to not change IClientAPI but rather have &amp;lt;tt&amp;gt;LLClientView&amp;lt;/tt&amp;gt; ignore&lt;br /&gt;
the passed array and instead reach back into the associated scene and fetch the&lt;br /&gt;
&amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt; instance.&lt;br /&gt;
&lt;br /&gt;
There is one subclass of &amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;HeightmapTerrainData&amp;lt;/tt&amp;gt; which keeps the terrain as a compressed heightmap. The height of each point is stored as a &amp;lt;tt&amp;gt;short&amp;lt;/tt&amp;gt; which is &amp;lt;tt&amp;gt;height * compressionFactor&amp;lt;/tt&amp;gt; where &amp;lt;tt&amp;gt;compressionFactor&amp;lt;/tt&amp;gt; is usually &amp;quot;100&amp;quot;. This creates a compact storage of the terrain heights with two decimal points of resolution.&lt;br /&gt;
&lt;br /&gt;
The LLLP (&amp;quot;Linden Lab Legacy Protocol&amp;quot;) sends terrain height data in&lt;br /&gt;
compressed &amp;quot;patches&amp;quot; of 16x16 areas of the terrain&lt;br /&gt;
height. This is a protocol feature that is implemented in &amp;lt;tt&amp;gt;TerrainChannel&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I feel that underlying protocol optimizations shouldn't appear up the&lt;br /&gt;
stack so, in creating &amp;lt;tt&amp;gt;TerrainData&amp;lt;/tt&amp;gt;, I tried to hide terrain patches.&lt;br /&gt;
I mean, someday terrain will be generalized meshes. Right?&lt;br /&gt;
&lt;br /&gt;
===Terrain in the Database===&lt;br /&gt;
Previously, terrain height maps were saved in the database as a blob of 256x256 doubles. To have different region sizes, that format had to change. There is an existing database field &amp;lt;tt&amp;gt;revision&amp;lt;/tt&amp;gt; that stored the time the terrain was saved. This revision information wasn't used for anything so this field was co-opted to contain a revision code for the height field blob.&lt;br /&gt;
&lt;br /&gt;
There are three forms for the height map blob: legacy, compressed2D and regular2D. &amp;quot;legacy&amp;quot; is, of course, the previous 256x256 collections of doubles. &amp;quot;regular2D&amp;quot; contains the X, Y dimensions and enough floats for that area's heights. &amp;quot;compressed2D&amp;quot; contains the X,Y and compressionFactor followed by enough shorts for the height map.&lt;br /&gt;
&lt;br /&gt;
The database readers and writers default to the legacy format and, if the region happens to have the dimensions 256x256, it is stored using the legacy format. This is an attempt to keep downward compatibility.&lt;br /&gt;
&lt;br /&gt;
All of the database modules (MySQL, SQLite, MSSQL and PSQL) have been modified to store terrain this new way.&lt;br /&gt;
&lt;br /&gt;
===Sensing Border Crossing===&lt;br /&gt;
Most of the ‘move to new region’ code is based on checking boundaries. There is much code related to computing if an object or avatar has crossed a region boundary and then computing the address of the next region from same. Introducing variable sized regions messes a lot of this computation up. That is, the code doing the arithmetic usually assumes it knows the address of the next region based on a known region size and them can compute the location of the next region based on that. With varregions those assumptions no longer hold. Varregion implementation means that the computation of region base locations and border locations moves to the GridService who is the entity who really knows the size of all the regions and what is adjacent to what.&lt;br /&gt;
&lt;br /&gt;
The realization that location to region computation is really a GridService operation lead me to totally rip apart the grid boundary checking code and replace it with two functions: &amp;lt;tt&amp;gt;Scene.PositionIsInCurrentRegion(Vector3 pos)&amp;lt;/tt&amp;gt; and then &amp;lt;tt&amp;gt;EntityTransferModule.GetRegionContainingWorldLocation(double X, double Y)&amp;lt;/tt&amp;gt;. The former function tests to see if the object/avatar has moved out of the current region and the latter gets the region moved into. (Side note: &amp;lt;tt&amp;gt;GetRegionContainingWorldLocation&amp;lt;/tt&amp;gt; should really be a function on &amp;lt;tt&amp;gt;IGridService&amp;lt;/tt&amp;gt; but that exercise is left for future hacking).&lt;br /&gt;
&lt;br /&gt;
These changes leave all the 'border' code in limbo -- the generation of the border lists is still there but it is not being used. This should eventually be cleaned up. Also, the computation of neighbor regions is scattered around with routines on &amp;lt;tt&amp;gt;IGridService&amp;lt;/tt&amp;gt;, in &amp;lt;tt&amp;gt;EntityTransferModule&amp;lt;/tt&amp;gt; and a bunch of bookkeeping in &amp;lt;tt&amp;gt;Scene&amp;lt;/tt&amp;gt;. This too should be cleaned up.&lt;br /&gt;
&lt;br /&gt;
==Implementation Notes==&lt;br /&gt;
&lt;br /&gt;
As of January 27, 2014, varregion is a feature of the 'master' repository branch.&lt;br /&gt;
&lt;br /&gt;
===Stuff to Work On===&lt;br /&gt;
What follows are notes I am making as things that might need work are found in OpenSimulator.&lt;br /&gt;
&lt;br /&gt;
* Consolidate neighbor region computation code (Scene, EntityTransferModule and IGridService all have 'get neighbor' code)&lt;br /&gt;
* Clean up/eliminate border list creation and use code&lt;br /&gt;
* Region handles are world coords and also the base of the region&lt;br /&gt;
** verify that everyone who converts coords to handle (Util.RegionWorldLocToHandle) is supplying the base of the region. (mostly done)&lt;br /&gt;
* ITerrainLoader implementations (mostly done)&lt;br /&gt;
**	How to handle tiles.&lt;br /&gt;
**	How to handle large regions sizes.&lt;br /&gt;
**	Terrain/FileLoaders/*.cs all return an ITerrainChannel&lt;br /&gt;
**	Need to fix all the file reader/writers&lt;br /&gt;
**	FileLoaders/LLRAW.cs has several &amp;quot;256&amp;quot;s rather than constant references&lt;br /&gt;
* Teleporting: should be able to teleport to anywhere in a large region&lt;br /&gt;
** &amp;quot;MyRegion/550/687/40&amp;quot;&lt;br /&gt;
* HG code needs to allow addresses anywhere into large regions&lt;br /&gt;
* When GridService return adjacent regions, make sure it does the right thing for large regions&lt;br /&gt;
* Consider moving terrain XML serialization into TerrainData&lt;br /&gt;
* Consider removing all instances of TerrainChannel.GetFloatsSerialized()&lt;br /&gt;
**	Replace with passing around TerrainData&lt;br /&gt;
* Code in EntityTransferModule that checks distance to decide if to make new connection&lt;br /&gt;
**	search for references to 'Constants.RegionSize'&lt;br /&gt;
**	Consider removing the distance code and replacing with call to grid service&lt;br /&gt;
* WorldMapModule.cs does a lot of arithmetic depending on constants that are really Contants.RegionSize&lt;br /&gt;
* Util.IsOutsideView uses Constants.RegionSize. Is use in ScenePresence a problem?&lt;br /&gt;
**	Used in ScenePresence.AdjustKnownSeeds()&lt;br /&gt;
**	Is this another instance like EntityTransferModule that needs to goto the grid service?&lt;br /&gt;
* Move all the short[] heightmap representation stuff into TerrainData.cs (partially done)&lt;br /&gt;
**	Is it possible to move all the patch stuff out of TerrainModule/TerrainChannel?&lt;br /&gt;
**	Clean up the use of m_revert. It looks like it is not saved after terrain is modified.&lt;br /&gt;
* Need to look through RegionCombinerModule.cs and see what safety checks are needed&lt;br /&gt;
**	Maybe just prevent combination if not legacy region size&lt;br /&gt;
* In LSL_Api.cs, llEdgeOfWorld() does some neighbor computation. Check for ok'ness.&lt;br /&gt;
* LandManagementModule.SendParcelOverlay sends land sale/ownership info for 4x4m areas&lt;br /&gt;
**  Looks like it expects to send exactly one 1024 byte block (for the 256x256 legacy region&lt;br /&gt;
**  Check viewer code for what will happen for larger regions&lt;br /&gt;
* The code for cloud and wind needs to be enhanced for larger regions&lt;br /&gt;
**	New overlay types added&lt;br /&gt;
* LLClientView.SendMapBlockSplit() needs to have region size to send with the map info&lt;br /&gt;
* Region/Framework/Scenes/Tests/BorderTests.cs might need work if non-standard regions are tested&lt;br /&gt;
* Verify terrain tests still work (for 256m regions)&lt;br /&gt;
* Region coords are sometimes 'int' and sometimes 'uint' with conversions EVERYWHERE&lt;br /&gt;
** pass over everything and convert region coordinates it 'uint's&lt;br /&gt;
** consider creating structures for world and region coordinates so there can be compile time checking&lt;br /&gt;
&lt;br /&gt;
====Viewer====&lt;br /&gt;
* LLSurface is wired to expect adjacent regions of same size&lt;br /&gt;
* Terrain surface image is sized with a 'static&amp;quot;: &amp;quot;    static S32  sTextureSize;               // Size of the surface texture&amp;quot;&lt;br /&gt;
* From FreeNode:#SingularityViewer 20131125:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;Aleric&amp;gt; radams1, SianaGearz, frnic : I couldn't help myself doing a profile anyway..  The reason the viewer is slow is because it's busy &amp;quot;drawing&amp;quot; the terrain. &amp;quot;drawing&amp;quot; between quotes because my guess is that it is trying to draw ALL terrain and then clip that afterwards to the frustrum... &lt;br /&gt;
&amp;lt;Aleric&amp;gt; So, this could be greatly improved by disregarding terrain way way earlier when it is beyond the drawing range anyway.&lt;br /&gt;
&amp;lt;SianaGearz&amp;gt; OK&lt;br /&gt;
&amp;lt;Aleric&amp;gt; I disabled all rendering, even added a 'return' in terrain render&lt;br /&gt;
&amp;lt;Aleric&amp;gt; but.. no improvement of FPS!&lt;br /&gt;
&amp;lt;frnic&amp;gt; oops&lt;br /&gt;
&amp;lt;Aleric&amp;gt; LLSurfacePatch::updateVisibility() is still eating a lot of cpu.&lt;br /&gt;
&amp;lt;Aleric&amp;gt; LLSurface::updatePatchVisibilities does 97% of the calls to LLSurfacePatch::updateVisibility&lt;br /&gt;
&amp;lt;Aleric&amp;gt; which then spends most of it's time calling LLCamera::AABBInFrustumNoFarClip&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Singularity commit for varregion: https://github.com/singularity-viewer/SingularityViewer/commit/ad8ea07a&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
* Terrain/parcel operations&lt;br /&gt;
** Default 256 standalone region&lt;br /&gt;
*** Clean database. Start single standalone region. Verify 'pimple' region. Verify one parcel. Flatten region.&lt;br /&gt;
*** Create parcels adjacent to each edge and standalone in middle. Change names of each parcel and verify. Restart simulator and verify parcels exist and work correctly.&lt;br /&gt;
*** Save five parcel region as OAR. Clear database. Restart region. Load oar. Verify 5 parcels of correct location, name and features.&lt;br /&gt;
** Adjacent 256 standalone regions &lt;br /&gt;
** 768x768 standalone region&lt;br /&gt;
** Changing land from 256 to 768&lt;br /&gt;
* Teleporting&lt;br /&gt;
* Adjacency&lt;br /&gt;
* Hypergrid&lt;br /&gt;
&lt;br /&gt;
==Tips on Migrating Existing Sims to VarRegions==&lt;br /&gt;
* When you start the sim, you have to have either no regions nearby, or identical sized regions. otherwise, it locks your movement to the size of the smallest region&lt;br /&gt;
* When you load your oars, it's like Aurora sim.  You need to load them by displacement first, load each one in place to get the terrains.&lt;br /&gt;
* When you merge, you lose the terrain.&lt;br /&gt;
* The second round, you reload each oar, this time with merge to load the objects.&lt;br /&gt;
* If you don't use merge, you lose all the objects with each oar load.&lt;br /&gt;
* When you load your oars, in format &amp;quot;&amp;lt;0,0,0&amp;gt;&amp;quot;  the first number is east/west, or x.&lt;br /&gt;
* The second number is north/south, or y&lt;br /&gt;
* The third number is up or down, or z.&lt;br /&gt;
* The location must be in increments of 256.&lt;/div&gt;</summary>
		<author><name>Reibling</name></author>	</entry>

	</feed>