Skip to content
Snippets Groups Projects
Commit 565cdf67 authored by Chang, Ryan's avatar Chang, Ryan
Browse files

Heights

parent dcd038e8
No related branches found
No related tags found
No related merge requests found
......@@ -160,6 +160,7 @@ MonoBehaviour:
generateNewSeed: 0
refresh: 0
samples: 513
terrainHeight: 600
currentGridPosition: {x: 0, y: 0}
--- !u!4 &40297593
Transform:
......@@ -219,6 +220,7 @@ MonoBehaviour:
generateNewSeed: 0
refresh: 0
samples: 513
terrainHeight: 600
currentGridPosition: {x: 0, y: 0}
--- !u!4 &231393956
Transform:
......@@ -358,7 +360,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 437356315}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 265.31, z: 0}
m_LocalPosition: {x: 0, y: 925, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
......@@ -803,6 +805,7 @@ MonoBehaviour:
generateNewSeed: 0
refresh: 0
samples: 513
terrainHeight: 600
currentGridPosition: {x: 0, y: 0}
--- !u!4 &1129702283
Transform:
......@@ -1020,6 +1023,7 @@ MonoBehaviour:
generateNewSeed: 0
refresh: 0
samples: 513
terrainHeight: 600
currentGridPosition: {x: 0, y: 0}
--- !u!1 &1312897309
GameObject:
......@@ -1058,6 +1062,7 @@ MonoBehaviour:
generateNewSeed: 0
refresh: 0
samples: 513
terrainHeight: 600
currentGridPosition: {x: 0, y: 0}
--- !u!4 &1312897311
Transform:
......@@ -1120,7 +1125,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
octaves:
- amplitude: 1
- amplitude: 2
frequency: 0.002
type: 1
- amplitude: 0.5
......@@ -1136,6 +1141,7 @@ MonoBehaviour:
generateNewSeed: 0
refresh: 0
samples: 513
terrainHeight: 1800
currentGridPosition: {x: 0, y: 0}
--- !u!114 &1796874588
MonoBehaviour:
......
......@@ -13,15 +13,18 @@ public class TerrainGenThread
private float[,] heights;
private float heightScale = 1;
public bool Ready { get; private set; }
public TerrainGenThread(Vector2 initialCrawlPos, Vector2Int gridPos, List<Octave> octaves, int samples, TerrainData data)
public TerrainGenThread(Vector2 initialCrawlPos, Vector2Int gridPos, List<Octave> octaves, int samples, float heightScale, TerrainData data)
{
InitialCrawlPosition = initialCrawlPos;
GridPosition = gridPos;
Samples = samples;
this.octaves = octaves;
TerrainData = data;
this.heightScale = heightScale;
}
/// <summary>
......@@ -69,7 +72,7 @@ public class TerrainGenThread
addition = noise.cellular(crawlPos).x / 2.3f + 0.5f;
break;
}
heights[y, x] += addition * octave.amplitude;
heights[y, x] += addition * octave.amplitude * heightScale;
}
}
}
......
......@@ -38,6 +38,9 @@ public class TerrainGenerator : MonoBehaviour
"Larger values = more precise. Recommended value is 513.")]
public int samples = 513;
[Tooltip("How tall the terrain is. May be changed to allow for higher terrains.")]
public float terrainHeight = 600;
[Header("Autogenerated values")]
[Tooltip("Which terrain grid are we on right now?")]
public Vector2Int currentGridPosition;
......@@ -75,7 +78,9 @@ public class TerrainGenerator : MonoBehaviour
if (!previouslyLoaded.ContainsKey(gridPos) || forceRefresh)
{
TerrainData data = Instantiate(Resources.Load<TerrainData>("Template"));
TerrainGenThread genThread = new(crawlPos, gridPos, octaves, samples, data);
TerrainGenThread genThread = new(crawlPos, gridPos, octaves, samples,
data.size.y / terrainHeight, data);
data.size = new(data.size.x, terrainHeight, data.size.z);
if (thread != null)
thread.Join();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment