示例#1
0
    public void editLightWithAdjacentNonTerminatingSurfaceHeightAtPatchRelativeZ(int surfaceHeight, int patchRelZ)
    {
        if (!this.spanContainsZ(patchRelZ))
        {
            return;
        }

        int  heightAt      = this.lightLevelTrapezoid.heightAt(patchRelZ).extent();
        byte lightAtBefore = this.lightLevelAt(patchRelZ);

        if (surfaceHeight < heightAt)
        {
            this.addLightLevelsWithAdjacentSurfaceHeightSpanOffset(surfaceHeight, patchRelZ - this.spanStart);
        }
        else
        {
            this.lightLevelTrapezoid.removeLightLevelsBySubtractingAdjacentSurface(patchRelZ);
        }

        //INFLUENCE...
        int deltaLight = (int)(lightAtBefore - this.lightLevelAt(patchRelZ));

        if (Mathf.Abs(deltaLight) > (int)UNIT_FALL_OFF_BYTE)
        {
            SimpleRange influenceRange = SimpleRange.SimpleRangeWithStartAndExtent(patchRelZ - INFLUENCE_RADIUS, patchRelZ + INFLUENCE_RADIUS);
            influenceRange = SimpleRange.IntersectingRange(influenceRange, new SimpleRange(0, NoisePatch.patchDimensions.z));             //wimp out (need other noisepatch windows too)
            influenceNeighborsInDirectionWithinZRange(Direction.xpos, influenceRange, INFLUENCE_RADIUS, deltaLight > 0);
            influenceNeighborsInDirectionWithinZRange(Direction.xneg, influenceRange, INFLUENCE_RADIUS, deltaLight > 0);
        }
    }
示例#2
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));
    }
示例#3
0
    public bool isContiguityAtZ(int patchRelZ, bool wantPosDir)
    {
        int nudge         = (wantPosDir ? 1 : -1);
        int adjacentIndex = patchRelZ + nudge;

        if (adjacentIndex >= zHeightRanges.Length || adjacentIndex < 0)
        {
            return(true);
        }

        SimpleRange intersection = SimpleRange.IntersectingRange(heightAt(patchRelZ), heightAt(adjacentIndex));

        return(intersection.range > 0);
    }
示例#4
0
    public void addMingleLightWithAdjacentTrapezoid(LightLevelTrapezoid other)
    {
        for (int i = this.trapezoid.span.start; i < this.trapezoid.span.extent(); ++i)
        {
            SimpleRange otherHeightRange = other.heightAt(i);
            SimpleRange heightRange      = this.heightAt(i);

            SimpleRange intersection = SimpleRange.IntersectingRange(otherHeightRange, heightRange);
            if (intersection.range > 0)
            {
                if (other.zLightLevels[i] > this.zLightLevels[i])
                {
                    this.zLightLevels[i] = (byte)Mathf.Max((int)this.zLightLevels[i], (other.zLightLevels[i] - Window.UNIT_FALL_OFF_BYTE));
                }
                else if (other.zLightLevels[i] < this.zLightLevels[i])
                {
                    other.zLightLevels[i] = (byte)Mathf.Max((int)other.zLightLevels[i], (this.zLightLevels[i] - Window.UNIT_FALL_OFF_BYTE));
                }
            }
        }
    }
示例#5
0
 private bool rangesMeetMergeRequirements(SimpleRange terminalRange, SimpleRange disRange)
 {
     return(SimpleRange.IntersectingRange(terminalRange, disRange).range >= Window.WINDOW_HEIGHTS_MINIMUN_OVERLAP);
 }