예제 #1
0
        /// <summary>
        /// Sets <see cref="CubismMaskTile"/>.
        /// </summary>
        /// <param name="value">Value to set.</param>
        /// <returns>Instance.</returns>
        internal CubismMaskRenderer SetMaskTile(CubismMaskTile value)
        {
            MaskProperties.SetVector(CubismShaderVariables.MaskTile, value);


            return(this);
        }
예제 #2
0
        /// <summary>
        /// Sets the mask tile to write to and read from.
        /// </summary>
        /// <param name="value">Value to set.</param>
        /// <returns>Instance.</returns>
        public CubismMaskMaskedJunction SetMaskTile(CubismMaskTile value)
        {
            MaskTile = value;


            return(this);
        }
예제 #3
0
        /// <summary>
        /// Converts from <see cref="CubismMaskTile"/> to index.
        /// </summary>
        /// <param name="tile">Tile to convert.</param>
        /// <returns>Tile index.</returns>
        private int ToIndex(CubismMaskTile tile)
        {
            var tileCounts  = (int)Mathf.Pow(4, Subdivisions - 1);
            var tilesPerRow = (int)Mathf.Pow(2, Subdivisions - 1);


            return((int)((tile.Channel * tileCounts) + (tile.Column * tilesPerRow) + tile.Row));
        }
예제 #4
0
        /// <summary>
        /// Acquires tiles.
        /// </summary>
        /// <param name="count">Number of tiles to acquire.</param>
        /// <returns>Acquired tiles on success; <see langword="null"/> otherwise.</returns>
        public CubismMaskTile[] AcquireTiles(int count)
        {
            var result = new CubismMaskTile[count];


            // Populate container.
            for (var i = 0; i < count; ++i)
            {
                var allocationSuccessful = false;


                for (var j = 0; j < Slots.Length; ++j)
                {
                    // Skip occupied slots.
                    if (Slots[j])
                    {
                        continue;
                    }


                    // Generate tile.
                    result[i] = ToTile(j);


                    // Flag slot as occupied.
                    Slots[j] = true;


                    // Flag allocation as successful.
                    allocationSuccessful = true;


                    break;
                }


                // Return as soon as one allocation fails.
                if (!allocationSuccessful)
                {
                    return(null);
                }
            }


            // Return on success.
            return(result);
        }