public void copyHeightAndLightValuesFromTo(ref LightLevelTrapezoid other, int zStartCopy, int zCopyExtent) { for (int i = zStartCopy; i < zCopyExtent; ++i) { other.zHeightRanges[i] = this.zHeightRanges[i]; other.zLightLevels[i] = this.zLightLevels[i]; } }
private void copyHeightAndLightFromOther(LightLevelTrapezoid other) { for (int i = other.trapezoid.span.start; i < other.trapezoid.span.extent(); ++i) { this.zHeightRanges[i] = other.zHeightRanges[i]; this.zLightLevels[i] = other.zLightLevels[i]; } }
private void constructorSetupWindow(WindowMap _windowMap, SimpleRange startDisRange, int startX, int startZ) { this.m_windowMap = _windowMap; Trapezoid atrapezoid = new Trapezoid(startDisRange, startZ); this.lightLevelTrapezoid = new LightLevelTrapezoid(TrapLight.MediumLightQuad(), atrapezoid); // this.heights.Add(startDisRange); this.xLevel = startX; }
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)); }
// public void addDiscontinuityRangeBeyondEndAtZExtent(SimpleRange newDisRange, int newZExtent) public void incorporateStartFlushWithExtentOther(LightLevelTrapezoid other) { AssertUtil.Assert(this.trapezoid.span.extent() == other.trapezoid.span.start, "adding ranges from other but not getting other.start == this.extent: " + "other start: " + other.trapezoid.span.start + "\nthis extent: " + this.trapezoid.span.extent()); SimpleRange otherSpan = other.trapezoid.span; int newZExtent = otherSpan.extent(); copyHeightAndLightFromOther(other); // this.zHeightRanges[newZExtent] = newDisRange; this.trapezoid.endRange = other.trapezoid.endRange; // CONSIDER: whether we need trapezoid end height dims at all at this point // SimpleRange.Average(this.trapezoid.endRange, newDisRange); this.trapezoid.span.range = newZExtent - this.trapezoid.span.start; assertSpanDebug("adding ranges from other"); }
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)); } } } }