ntg-unity
ntg-unity copied to clipboard
Out of Bounds Error with smoothing enabled
Hey, don´t be harsh with me, it´s my first issue and I hope it´s okay, I got an out of bound error when I got smoothing enabled.
IndexOutOfRangeException: Index was outside the bounds of the array. NeuralTerrainGeneration.TerrainHelper.SetTerrainHeights (UnityEngine.Terrain terrain, System.Single[] heightmap, System.Int32 width, System.Int32 height, System.Single heightMultiplier, System.Boolean scale) (at Assets/NeuralTerrainGeneration/Scripts/TerrainHelper.cs:40) NeuralTerrainGeneration.NeuralTerrainGeneratorTool.FromScratchGUI (UnityEngine.Terrain terrain) (at Assets/NeuralTerrainGeneration/Scripts/NeuralTerrainGeneratorTool.cs:282) NeuralTerrainGeneration.NeuralTerrainGeneratorTool.OnInspectorGUI (UnityEngine.Terrain terrain, UnityEditor.TerrainTools.IOnInspectorGUI editContext) (at Assets/NeuralTerrainGeneration/Scripts/NeuralTerrainGeneratorTool.cs:122) UnityEditor.TerrainInspector.OnInspectorGUI () (at <7aeb7d7a52d04045b8a1c734633fa931>:0) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass72_0.<CreateInspectorElementUsingIMGUI>b__0 () (at <7aeb7d7a52d04045b8a1c734633fa931>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
I tried to debug with rider and noticed that in the function, rider debugger didn´t pass this following logic:
float[,] newHeightmap = new float[width+1, height+1];
for(int x = 0; x < width; x++)
{
for(int y = 0; y < height; y++)
{
newHeightmap[x, y] = heightmap[x + y * width] * scaleCoefficient;
}
}
It´s line 35 on TerrainHelper.cs.
If I turn of smoothing, the Terrain gots without errors generated. For reproduction, I made a new Terrain and I tried an Demo scene, where it also happends.
Worker type I tried it with different types, also Auto and Stigma and Kernel are set to Kernel:6 Stigma:3. I also tried different numbers but every time kernel /2 for stigma.