Ejemplo n.º 1
0
    public SimpleRange considerLightValuesFromOther(LightLevelTrapezoid other, bool subtract, SimpleRange withinRange, float influenceFactor)
    {
        int minInfluenceIndex = 258;
        int maxInfluenceIndex = 0;

        if (!SimpleRange.RangesIntersect(trapezoid.span, withinRange))
        {
            return(new SimpleRange(0, 0));
        }

        byte influenceFromOther = (byte)(Window.LIGHT_LEVEL_MAX * influenceFactor - Window.UNIT_FALL_OFF_BYTE);

        withinRange = SimpleRange.IntersectingRange(withinRange, new SimpleRange(0, NoisePatch.patchDimensions.z));         // safer...
        if (withinRange.isErsatzNull())
        {
            return(new SimpleRange(0, 0));
        }

        for (int i = withinRange.start; i < withinRange.extent(); ++i)
        {
            byte myCurrentLightLevel = zLightLevels[i];
            byte othersLightLevel    = other.zLightLevels[i];

//			if (myCurrentLightLevel == Window.LIGHT_LEVEL_MAX_BYTE)
//				continue;

            byte influenceAmount = 0;

            if (myCurrentLightLevel <= influenceFromOther)
            {
//				if (subtract) {
//				} else {
                influenceAmount = (byte)(other.zLightLevels[i] - Window.UNIT_FALL_OFF_BYTE);
//				}
            }
            else
            {
                //cheap0
                influenceAmount = (byte)(myCurrentLightLevel + (influenceFromOther / 2f * (subtract? -1 : 1)));
            }
            zLightLevels[i] = (byte)Mathf.Clamp(influenceAmount, 0, (int)Window.LIGHT_LEVEL_MAX_BYTE);

            minInfluenceIndex = Mathf.Min(minInfluenceIndex, i);
            maxInfluenceIndex = Mathf.Max(maxInfluenceIndex, i + 1);
        }

        if (maxInfluenceIndex == 0)
        {
            return(new SimpleRange(0, 0));
        }

        return(SimpleRange.SimpleRangeWithStartAndExtent(minInfluenceIndex, maxInfluenceIndex));
    }
Ejemplo n.º 2
0
    public bool takeInfluenceFromColumn(LightColumn other)
    {
        if (!SimpleRange.RangesIntersect(this.range, other.range))
        {
            return(false);
        }

        if (this.lightLevel < other.lightLevel - Window.UNIT_FALL_OFF_BYTE)
        {
            this.lightLevel = (byte)(other.lightLevel - Window.UNIT_FALL_OFF_BYTE);
            return(true);
        }
        return(false);
    }
Ejemplo n.º 3
0
    public List <Window> windowsFlushWithWindowZFace(Window aWindow, bool wantPosZFace, bool wantThisCoord)
    {
        List <Window> result = new List <Window>();
        int           index  = wantPosZFace ? aWindow.xCoord + 1 : aWindow.xCoord - 1;

        index = wantThisCoord ? aWindow.xCoord : index;

        if (index < 0)
        {
            // go get from next window...
            return(null);
        }
        else if (index > windows.Length - 1)
        {
            //go get from other next
            return(null);
        }
        List <Window> wins = windows[index];

        if (wins == null)
        {
            return(result);
        }

        SimpleRange thisWinSpan = aWindow.span;

        if (wantThisCoord)
        {
            thisWinSpan = new SimpleRange(thisWinSpan.start - 1, thisWinSpan.range + 1);             //want edge windows as well in this case
        }

        foreach (Window win in wins)
        {
            if (SimpleRange.RangesIntersect(aWindow.span, win.span))
            {
                if (!wantThisCoord || (wantThisCoord && !win.Equals(aWindow)))
                {
                    result.Add(win);
                }
            }
        }
        return(result);
    }
Ejemplo n.º 4
0
 private bool spanOverLaps(Window other)
 {
     return(SimpleRange.RangesIntersect(lightLevelTrapezoid.trapezoid.span, other.lightLevelTrapezoid.trapezoid.span));
 }