Ejemplo n.º 1
0
        public static void ReadEdges(TileData thisData, EdgesSet thisEdges)
        /// Reads apply data and converts to edges. Edges are ready to use after this stage.
        {
            HeightOutput200.ApplySetData heightDataFull = thisData.ApplyOfType <HeightOutput200.ApplySetData>();
            if (heightDataFull != null)
            {
                thisEdges.heightEdges.ReadFloats2D(heightDataFull.heights2D);
            }

            HeightOutput200.ApplySplitData heightSplitData = thisData.ApplyOfType <HeightOutput200.ApplySplitData>();
            if (heightSplitData != null)
            {
                thisEdges.heightEdges.ReadSplitFloats2D(heightSplitData.heights2DSplits);
            }

                                #if UNITY_2019_1_OR_NEWER
            HeightOutput200.ApplyTexData heightTexData = thisData.ApplyOfType <HeightOutput200.ApplyTexData>();
            if (heightTexData != null)
            {
                thisEdges.heightEdges.ReadRawFloat(heightTexData.texBytes);
            }
                                #endif


            TexturesOutput200.ApplyData texturesData = thisData.ApplyOfType <TexturesOutput200.ApplyData>();
            if (texturesData != null && texturesData.splats != null)
            {
                int numChs = texturesData.splats.GetLength(2);
                if (thisEdges.splatEdges == null || thisEdges.splatEdges.Length != numChs)
                {
                    Array.Resize(ref thisEdges.splatEdges, numChs);
                }

                for (int ch = 0; ch < numChs; ch++)
                {
                    if (thisEdges.splatEdges[ch] == null)
                    {
                        thisEdges.splatEdges[ch] = new Edges(0, 0);
                    }

                    thisEdges.splatEdges[ch].ReadSplats(texturesData.splats, ch);
                }
            }

            ReadEdgesCustom?.Invoke(thisData, thisEdges);

            thisEdges.ready = true;
        }
Ejemplo n.º 2
0
        public static void WriteEdges(TileData thisData, EdgesSet thisEdges)
        /// Writes edges back to apply data after they have been changed
        {
            HeightOutput200.ApplySetData heightDataFull = thisData.ApplyOfType <HeightOutput200.ApplySetData>();
            if (heightDataFull != null)
            {
                thisEdges.heightEdges.WriteFloats2D(heightDataFull.heights2D);
            }

            HeightOutput200.ApplySplitData heightSplitData = thisData.ApplyOfType <HeightOutput200.ApplySplitData>();
            if (heightSplitData != null)
            {
                thisEdges.heightEdges.WriteSplitFloats2D(heightSplitData.heights2DSplits);
            }

                                #if UNITY_2019_1_OR_NEWER
            HeightOutput200.ApplyTexData heightTexData = thisData.ApplyOfType <HeightOutput200.ApplyTexData>();
            if (heightTexData != null)
            {
                thisEdges.heightEdges.WriteRawFloat(heightTexData.texBytes);
            }
                                #endif


            TexturesOutput200.ApplyData texturesData = thisData.ApplyOfType <TexturesOutput200.ApplyData>();
            if (texturesData != null && texturesData.splats != null)
            {
                int numChs = texturesData.splats.GetLength(2);
                if (thisEdges.splatEdges == null || thisEdges.splatEdges.Length != numChs)
                {
                    Array.Resize(ref thisEdges.splatEdges, numChs);
                }

                for (int ch = 0; ch < numChs; ch++)
                {
                    thisEdges.splatEdges[ch].WriteSplats(texturesData.splats, ch);
                }
            }

            WriteEdgesCustom?.Invoke(thisData, thisEdges);
        }