Cap the number of points we generate when doing scatter to not run out of memory

This commit is contained in:
Nick 2022-07-25 21:25:36 -04:00
parent 2f4a4a7099
commit e67ddc7fe6

View File

@ -20,7 +20,12 @@ namespace NewHorizons.Builder.Props
var heightMap = config.HeightMap;
var area = 4f * Mathf.PI * radius * radius;
var points = RandomUtility.FibonacciSphere((int)(area * 10));
// To not use more than 0.5GB of RAM while doing this
// Works up to planets with 575 radius before capping
var numPoints = Math.Min((int)(area * 10), 41666666);
var points = RandomUtility.FibonacciSphere(numPoints);
Texture2D heightMapTexture = null;
if (heightMap != null)