PositionsTwistDensity class

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

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

extends: Density

Поля (15)

МодификаторыТипИмя
Vector3d var10
Density.Context var11
double var13
double var14
Vector3d var15
int var2
double var3
double var3
var4
double var5
double var6
double var7
var7
var7
double var8

Методы (8)

МодификаторыВозвратСигнатура
public void consumervoid consumer(@Nonnull Vector3d var1, @Nonnull Control var2)
for for(int var5 = 0; var5 < var2; var5++)
for for(int var12 = 0; var12 < var2; var12++)
if if(this.distanceNormalized)
if if(this.input == null)
if if(this.positions == null)
if if(this.zeroPositionsY)
if if(var1.length == 0)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.hytalegenerator.ReusableList;
class="kw">import com.hypixel.hytale.builtin.hytalegenerator.VectorUtil;
class="kw">import com.hypixel.hytale.builtin.hytalegenerator.pipe.Control;
class="kw">import com.hypixel.hytale.builtin.hytalegenerator.positionproviders.PositionProvider;
class="kw">import it.unimi.dsi.fastutil.doubles.Double2DoubleFunction;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;

class="kw">public class PositionsTwistDensity class="kw">extends Density {
   @Nullable
   class="kw">private Density input;
   @Nullable
   class="kw">private class="kw">final PositionProvider positions;
   @Nonnull
   class="kw">private class="kw">final Double2DoubleFunction twistCurve;
   @Nonnull
   class="kw">private class="kw">final Vector3d twistAxis;
   class="kw">private class="kw">final double maxDistance;
   class="kw">private class="kw">final boolean distanceNormalized;
   class="kw">private class="kw">final boolean zeroPositionsY;
   @Nonnull
   class="kw">private class="kw">final Vector3d rMin;
   @Nonnull
   class="kw">private class="kw">final Vector3d rMax;
   @Nonnull
   class="kw">private class="kw">final Vector3d rSamplePoint;
   @Nonnull
   class="kw">private class="kw">final Vector3d rQueryPosition;
   @Nonnull
   class="kw">private class="kw">final Vector3d rWarpVector;
   @Nonnull
   class="kw">private class="kw">final ReusableList<Vector3d> rWarpVectors;
   @Nonnull
   class="kw">private class="kw">final ReusableList<Double> rWarpDistances;
   @Nonnull
   class="kw">private class="kw">final ReusableList<Double> rWeights;
   @Nonnull
   class="kw">private class="kw">final PositionProvider.Context rPositionsContext;
   @Nonnull
   class="kw">private class="kw">final Density.Context rChildContext;

   class="kw">public PositionsTwistDensity(
      @Nullable Density var1,
      @Nullable PositionProvider var2,
      @Nonnull Double2DoubleFunction var3,
      @Nonnull Vector3d var4,
      double var5,
      boolean var7,
      boolean var8
   ) {
      assert var5 >= 0.0;
      if (var4.length() < 1.0E-9) {
         var4 = new Vector3d(0.0, 1.0, 0.0);
      }

      this.input = var1;
      this.positions = var2;
      this.twistCurve = var3;
      this.twistAxis = var4;
      this.maxDistance = var5;
      this.distanceNormalized = var7;
      this.zeroPositionsY = var8;
      this.rMin = new Vector3d();
      this.rMax = new Vector3d();
      this.rSamplePoint = new Vector3d();
      this.rQueryPosition = new Vector3d();
      this.rWarpVector = new Vector3d();
      this.rWarpVectors = new ReusableList<>();
      this.rWarpDistances = new ReusableList<>();
      this.rWeights = new ReusableList<>();
      this.rPositionsContext = new PositionProvider.Context();
      this.rChildContext = new Density.Context();
   }

   class="kw">public void consumer(@Nonnull Vector3d var1, @Nonnull Control var2) {
      double var3 = var1.distance(this.rQueryPosition);
      if (!(var3 > this.maxDistance)) {
         double var5 = var3 / this.maxDistance;
         this.rWarpVector.set(this.rSamplePoint);
         double var7;
         if (this.distanceNormalized) {
            var7 = this.twistCurve.applyAsDouble(var5);
         } else {
            var7 = this.twistCurve.applyAsDouble(var3);
         }

         var7 /= 180.0;
         var7 *= Math.PI;
         this.rWarpVector.sub(var1);
         VectorUtil.rotateAroundAxis(this.rWarpVector, this.twistAxis, var7);
         this.rWarpVector.add(var1);
         this.rWarpVector.sub(this.rSamplePoint);
         if (this.rWarpVectors.isAtHardCapacity()) {
            this.rWarpVectors.expandAndSet(new Vector3d(this.rWarpVector));
         } else {
            this.rWarpVectors.expandAndGet().set(this.rWarpVector);
         }

         this.rWarpDistances.expandAndSet(var5);
      }
   }

   @Override
   class="kw">public double process(@Nonnull Density.Context var1) {
      if (this.input == null) {
         class="kw">return 0.0;
      }

      if (this.positions == null) {
         class="kw">return this.input.process(var1);
      }

      this.rMin.set(var1.position.x - this.maxDistance, var1.position.y - this.maxDistance, var1.position.z - this.maxDistance);
      this.rMax.set(var1.position.x + this.maxDistance, var1.position.y + this.maxDistance, var1.position.z + this.maxDistance);
      this.rSamplePoint.set(var1.position);
      this.rQueryPosition.set(var1.position);
      if (this.zeroPositionsY) {
         this.rQueryPosition.y = 0.0;
         this.rMin.y = -1.0;
         this.rMax.y = 1.0;
      }

      this.rWarpVectors.clear();
      this.rWarpDistances.clear();
      this.rPositionsContext.bounds.min.set(this.rMin);
      this.rPositionsContext.bounds.max.set(this.rMax);
      this.rPositionsContext.pipe = this::consumer;
      this.positions.generate(this.rPositionsContext);
      if (this.rWarpVectors.getSoftSize() == 0) {
         class="kw">return this.input.process(var1);
      }

      if (this.rWarpVectors.getSoftSize() == 1) {
         Vector3d var10 = this.rWarpVectors.get(0);
         this.rSamplePoint.add(var10);
         Density.Context var11 = new Density.Context(var1);
         var11.position = this.rSamplePoint;
         class="kw">return this.input.process(var11);
      }

      int var2 = this.rWarpVectors.getSoftSize();
      this.rWeights.clear();
      double var3 = 0.0;

      for (int var5 = 0; var5 < var2; var5++) {
         double var6 = this.rWarpDistances.get(var5);
         double var8 = 1.0 - var6;
         this.rWeights.expandAndSet(var8);
         var3 += var8;
      }

      for (int var12 = 0; var12 < var2; var12++) {
         double var14 = this.rWeights.get(var12) / var3;
         Vector3d var15 = this.rWarpVectors.get(var12);
         var15.mul(var14);
         this.rSamplePoint.add(var15);
      }

      this.rChildContext.assign(var1);
      this.rChildContext.position = this.rSamplePoint;
      double var13 = this.input.process(this.rChildContext);
      this.rChildContext.clearReferences();
      class="kw">return var13;
   }

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

      this.input = var1[0];
   }
}