public void SmoothAroundIngredients() { float t = Time.realtimeSinceStartup; //print("SmoothAroundIngredients"); for (int i = 0; i < (int)ingredientsCorners.Count - 3; i += 4) { //print((0+i)+","+(1+i)+","+(2+i)+","+(3+i)); if (ingredientsCorners[0 + i].y > betaHeightsForTest[(int)ingredientsCorners[0 + i].x, (int)ingredientsCorners[0 + i].z]) { //ZSideHighSmoothing(ingredientsCorners[0+i],ingredientsCorners[1+i]); //XSideHighSmoothing(ingredientsCorners[2+i],ingredientsCorners[3+i]); //print("HIGH"); var pair = HighGroundSmoother.SquareSmootherForHighGround(new Vector3[] { ingredientsCorners[0 + i], ingredientsCorners[3 + i], ingredientsCorners[1 + i], ingredientsCorners[2 + i] }, ref betaHeights, elevation, width, height); //terrain.terrainData.SetHeights(0,0,betaHeights); //return; } else { OtherSideSmoothing(ingredientsCorners[0 + i], ingredientsCorners[1 + i]); //x direction SideSmoothing(ingredientsCorners[2 + i], ingredientsCorners[3 + i]); //z direction //print("LOW"); } } int Tw = terrain.terrainData.heightmapWidth; int Th = terrain.terrainData.heightmapHeight; //smooth function from old famus terraintoolkit : https://github.com/unitycoder/unityterraintoolkit/blob/f29819161e1cb00dc77c302908cf378f5fe9fcf7/Assets/TerrainToolkit/Scripts/TerrainToolkit.cs betaHeights = smooth(betaHeights, new Vector2(Tw, Th), Neighbourhood.Moore); terrain.terrainData.SetHeights(0, 0, betaHeights); float finalTime = Time.realtimeSinceStartup - t; print("Time : " + finalTime.ToString()); }
public void SmoothAroundIngredients() { float t = Time.time; //print("SmoothAroundIngredients"); for (int i = 0; i < (int)ingredientsCorners.Count - 3; i += 4) { //print((0+i)+","+(1+i)+","+(2+i)+","+(3+i)); if (ingredientsCorners[0 + i].y > betaHeightsForTest[(int)ingredientsCorners[0 + i].x, (int)ingredientsCorners[0 + i].z]) { //ZSideHighSmoothing(ingredientsCorners[0+i],ingredientsCorners[1+i]); //XSideHighSmoothing(ingredientsCorners[2+i],ingredientsCorners[3+i]); print("HIGH"); var pair = HighGroundSmoother.SquareSmootherForHighGround(new Vector3[] { ingredientsCorners[0 + i], ingredientsCorners[3 + i], ingredientsCorners[1 + i], ingredientsCorners[2 + i] }, ref betaHeights, elevation, width, height); //terrain.terrainData.SetHeights(0,0,betaHeights); //return; } else { OtherSideSmoothing(ingredientsCorners[0 + i], ingredientsCorners[1 + i]); //x direction SideSmoothing(ingredientsCorners[2 + i], ingredientsCorners[3 + i]); //z direction print("LOW"); } } terrain.terrainData.SetHeights(0, 0, betaHeights); float finalTime = Time.time - t; print("Time : " + finalTime.ToString()); }