YSampledDensity class

Пакет: com.hypixel.hytale.builtin.hytalegenerator.density

Файл: com/hypixel/hytale/builtin/hytalegenerator/density/YSampledDensity.java

extends: Density

Поля (5)

МодификаторыТипИмя
double var2
double var4
double var6
double var7
double var8

Методы (6)

МодификаторыВозвратСигнатура
if if(var1.position.x != this.x || var1.position.z != this.z || this.isEmpty)
if if(var2 == this.y1)
if if(var4 == this.y0)
if if(this.isInterpolated)
private double toCellGriddouble toCellGrid(double var1)
private double toY0double toY0(double var1)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.hytalegenerator.density;

class="kw">import com.hypixel.hytale.builtin.hytalegenerator.math.Interpolation;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3d;

class="kw">public class YSampledDensity class="kw">extends Density {
   @Nonnull
   class="kw">private Density input;
   class="kw">private class="kw">final double sampleDistance;
   class="kw">private class="kw">final double sampleDistanceInverse;
   class="kw">private class="kw">final double sampleOffset;
   class="kw">private class="kw">final boolean isInterpolated;
   class="kw">private double value0;
   class="kw">private double value1;
   class="kw">private double y0;
   class="kw">private double y1;
   class="kw">private double x;
   class="kw">private double z;
   class="kw">private boolean isEmpty;
   class="kw">private class="kw">final Vector3d rChildPosition;
   class="kw">private class="kw">final Density.Context rChildContext;

   class="kw">public YSampledDensity(@Nonnull Density var1, double var2, double var4, boolean var6) {
      assert var2 > 0.0;
      this.input = var1;
      this.sampleDistance = var2;
      this.sampleDistanceInverse = 1.0 / var2;
      this.sampleOffset = var4;
      this.isInterpolated = var6;
      this.isEmpty = true;
      this.rChildPosition = new Vector3d();
      this.rChildContext = new Density.Context();
   }

   @Override
   class="kw">public double process(@Nonnull Density.Context var1) {
      if (var1.position.x != this.x || var1.position.z != this.z || this.isEmpty) {
         double var6 = this.toY0(var1.position.y);
         double var8 = var6 + this.sampleDistance;
         this.rChildContext.assign(var1);
         this.rChildContext.position = this.rChildPosition;
         this.y0 = var6;
         this.y1 = var8;
         this.rChildPosition.set(var1.position.x, this.y0, var1.position.z);
         this.value0 = this.input.process(this.rChildContext);
         this.rChildPosition.set(var1.position.x, this.y1, var1.position.z);
         this.value1 = this.input.process(this.rChildContext);
         this.isEmpty = false;
         this.x = var1.position.x;
         this.z = var1.position.z;
      } else if (var1.position.y < this.y0 || var1.position.y > this.y1) {
         double var2 = this.toY0(var1.position.y);
         double var4 = var2 + this.sampleDistance;
         this.rChildContext.assign(var1);
         this.rChildContext.position = this.rChildPosition;
         if (var2 == this.y1) {
            this.y0 = this.y1;
            this.value0 = this.value1;
         } else {
            this.y0 = var2;
            this.rChildPosition.set(var1.position.x, this.y0, var1.position.z);
            this.value0 = this.input.process(this.rChildContext);
         }

         if (var4 == this.y0) {
            this.y1 = this.y0;
            this.value1 = this.value0;
         } else {
            this.y1 = var4;
            this.rChildPosition.set(var1.position.x, this.y1, var1.position.z);
            this.value1 = this.input.process(this.rChildContext);
         }
      }

      this.rChildContext.clearReferences();
      double var7 = (var1.position.y - this.y0) * this.sampleDistanceInverse;
      if (this.isInterpolated) {
         class="kw">return Interpolation.linear(this.value0, this.value1, var7);
      } else {
         class="kw">return var7 < 0.5 ? this.value0 : this.value1;
      }
   }

   class="kw">private double toY0(double var1) {
      class="kw">return this.toCellGrid(var1) * this.sampleDistance + this.sampleOffset;
   }

   class="kw">private double toCellGrid(double var1) {
      class="kw">return Math.floor((var1 - this.sampleOffset) * this.sampleDistanceInverse);
   }

   @Override
   class="kw">public void setInputs(@Nonnull Density[] var1) {
      assert var1.length != 0;
      assert var1[0] != null;
      this.input = var1[0];
   }
}