Example #1
0
        private static void WeldDraftToMain(TerrainTile reference, TerrainTile welded, Coord weldDir)
        /// Lowers edges on welding to main tile
        {
            if (welded.draft.edges.heightEdges.IsEmpty)
            {
                welded.draft.edges.heightEdges.ReadFloats2D(welded.draft.terrain.terrainData.GetHeights(0, 0, welded.draft.terrain.terrainData.heightmapResolution, welded.draft.terrain.terrainData.heightmapResolution));
            }
            //for an unknown reason ready chunks in scene do not have their edges (generated or saved). Leads to "Empty weld array" error. Forcing to read from terrain.

            EdgesSet refEdges  = reference.main.edges;
            EdgesSet weldEdges = welded.draft.edges;

            //loading saved edges big array
            float[] refArr = refEdges.heightEdges.GetArr(weldDir);

            //duplicating neig saved edges short array
            float[] weldArr     = weldEdges.heightEdges.GetArr(-weldDir);
            float[] weldArrCopy = new float[weldArr.Length];
            //Array.Copy(weldArr, weldArrCopy, weldArr.Length); //will be re-filled anyways

            //welding and apply to terrain
            Weld.WeldArrays(refArr, weldArrCopy, lowerOnMismatch: true);

            Weld.ApplyToTerrain(welded.draft.terrain.terrainData, weldArrCopy, -weldDir);
        }
Example #2
0
        private static void WeldDraftToMain(TerrainTile reference, TerrainTile welded, Coord weldDir)
        /// Lowers edges on welding to main tile
        {
            EdgesSet refEdges  = reference.main.edges;
            EdgesSet weldEdges = welded.draft.edges;

            //loading saved edges big array
            float[] refArr = refEdges.heightEdges.GetArr(weldDir);

            //duplicating neig saved edges short array
            float[] weldArr     = weldEdges.heightEdges.GetArr(-weldDir);
            float[] weldArrCopy = new float[weldArr.Length];
            //Array.Copy(weldArr, weldArrCopy, weldArr.Length); //will be re-filled anyways

            //welding and apply to terrain
            Weld.WeldArrays(refArr, weldArrCopy, lowerOnMismatch: true);

            Weld.ApplyToTerrain(welded.draft.terrain.terrainData, weldArrCopy, -weldDir);
        }