Fix raw32 terrain heightmap reader so it estimates terrain size from
the size of the input stream. This is required since the raw heightmap format (.r32) does not contain any size information. The estimation relies on terrain being square.0.8.0.3
parent
31cba5aa66
commit
1b41ec0a85
|
@ -25,7 +25,10 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
|
@ -116,7 +119,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
||||||
|
|
||||||
public ITerrainChannel LoadStream(Stream s)
|
public ITerrainChannel LoadStream(Stream s)
|
||||||
{
|
{
|
||||||
TerrainChannel retval = new TerrainChannel();
|
// The raw format doesn't contain any dimension information.
|
||||||
|
// Guess the square dimensions by using the length of the raw file.
|
||||||
|
double dimension = Math.Sqrt((double)(s.Length / 4));
|
||||||
|
// Regions are always multiples of 256.
|
||||||
|
int trimmedDimension = (int)dimension - ((int)dimension % (int)Constants.RegionSize);
|
||||||
|
if (trimmedDimension < Constants.RegionSize)
|
||||||
|
trimmedDimension = (int)Constants.RegionSize;
|
||||||
|
|
||||||
|
TerrainChannel retval = new TerrainChannel(trimmedDimension, trimmedDimension);
|
||||||
|
|
||||||
BinaryReader bs = new BinaryReader(s);
|
BinaryReader bs = new BinaryReader(s);
|
||||||
int y;
|
int y;
|
||||||
|
|
|
@ -217,6 +217,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// ITerrainChannel.Merge
|
// ITerrainChannel.Merge
|
||||||
public void Merge(ITerrainChannel newTerrain, Vector3 displacement, float radianRotation, Vector2 rotationDisplacement)
|
public void Merge(ITerrainChannel newTerrain, Vector3 displacement, float radianRotation, Vector2 rotationDisplacement)
|
||||||
{
|
{
|
||||||
|
m_log.DebugFormat("{0} Merge. inSize=<{1},{2}>, disp={3}, rot={4}, rotDisp={5}, outSize=<{6},{7}>", LogHeader,
|
||||||
|
newTerrain.Width, newTerrain.Height,
|
||||||
|
displacement, radianRotation, rotationDisplacement,
|
||||||
|
m_terrainData.SizeX, m_terrainData.SizeY);
|
||||||
for (int xx = 0; xx < newTerrain.Width; xx++)
|
for (int xx = 0; xx < newTerrain.Width; xx++)
|
||||||
{
|
{
|
||||||
for (int yy = 0; yy < newTerrain.Height; yy++)
|
for (int yy = 0; yy < newTerrain.Height; yy++)
|
||||||
|
|
Loading…
Reference in New Issue