Esempio n. 1
0
 /// <summary>
 /// Determine whether this node is dependent on another node. Used to prevent loops while editing a diagram.
 /// </summary>
 /// <returns>Whether the dependency exists.</returns>
 /// <param name="otherNode">Another node.</param>
 public bool IsDependentOn(DiagramNode otherNode)
 {
     if (this == otherNode)
     {
         return(true);
     }
     foreach (DiagramNode node in argumentNodes)
     {
         if (node.IsDependentOn(otherNode))
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 2
0
        /// <summary>
        /// Fill multiple rows of pixels. Filling will stop after the last row.
        /// </summary>
        /// <returns>
        /// Index of the next row that should be filled. When finished, this will be larger than or equal to height.
        /// </returns>
        /// <param name='pixels'>
        /// Color array representing a grid of Pixels. Its length must be at least width * height.
        /// </param>
        /// <param name='outputIndex'>
        /// Index of the output to use.
        /// </param>
        /// <param name='width'>
        /// Width.
        /// </param>
        /// <param name='height'>
        /// Height.
        /// </param>
        /// <param name='rowIndex'>
        /// Row index to start from.
        /// </param>
        /// <param name='rowCount'>
        /// Amount of rows to fill.
        /// </param>
        public int FillRows(Color[] pixels, int outputIndex, int width, int height, int rowIndex, int rowCount)
        {
            Prepare();
            if (outputs.Length == 0)
            {
                return(height);
            }
            if (outputIndex < 0 || outputIndex >= outputs.Length)
            {
                outputIndex = 0;
            }

            DiagramNode output = outputs[outputIndex].node;

            derivativeDelta = derivativeScale / (width > height ? width : height);
            float   uDelta = 1f / width, vDelta = 1f / height;
            Vector2 oldUV = uv;
            int
                oldX = pixelX,
                oldY = pixelY;

            int i = currentPixelIndex = rowIndex * width;

            for (int maxY = Mathf.Min(height, rowIndex + rowCount); rowIndex < maxY; rowIndex++)
            {
                pixelY = rowIndex;
                uv.y   = (rowIndex + 0.5f) * vDelta;
                for (int x = 0; x < width; x++)
                {
                    pixelX            = x;
                    uv.x              = (x + 0.5f) * uDelta;
                    pixels[i]         = output.ComputeColor();
                    currentPixelIndex = ++i;
                }
            }
            uv     = oldUV;
            pixelX = oldX;
            pixelY = oldY;
            return(rowIndex);
        }
Esempio n. 3
0
 internal virtual void ComputeCustom(DiagramNode node)
 {
 }