Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override void Update()
Run(tile);
}
}

private void Run(UnityTile tile)
{
if (_generationType == TerrainGenerationType.Height)
Expand Down Expand Up @@ -153,12 +153,19 @@ private void GenerateTerrainMesh(UnityTile tile, float heightMultiplier)
var xx = Mathd.Lerp(tile.Rect.Min.x, tile.Rect.Max.x, xrat);
var yy = Mathd.Lerp(tile.Rect.Min.y, tile.Rect.Max.y, yrat);

// Unavailable elevation data will have width less than 256
// (usually 8?), therefore we render at zero height
if (tile.HeightData.width < 256)
{
heightMultiplier = 0;
}

mesh.Vertices.Add(new Vector3(
(float)(xx - tile.Rect.Center.x),
heightMultiplier * Conversions.GetRelativeHeightFromColor(tile.HeightData.GetPixel(
(int)(xrat * 255),
(int)((1 - yrat) * 255)),
tile.RelativeScale),
(int)(xrat * 255),
(int)((1 - yrat) * 255)),
tile.RelativeScale),
(float)(yy - tile.Rect.Center.y)));
mesh.Normals.Add(Unity.Constants.Math.Vector3Up);
mesh.UV[0].Add(new Vector2(x * step, 1 - (y * step)));
Expand Down