PositionsPinchDensity class
Пакет: com.hypixel.hytale.builtin.hytalegenerator.density
Файл: com/hypixel/hytale/builtin/hytalegenerator/density/PositionsPinchDensity.java
extends: Density
Поля (14)
| Модификаторы | Тип | Имя |
|---|---|---|
|
Vector3d |
var10 |
|
double |
var11 |
|
double |
var13 |
|
double |
var14 |
|
Vector3d |
var15 |
|
int |
var2 |
|
double |
var3 |
|
double |
var3 |
|
double |
var5 |
|
double |
var6 |
|
double |
var8 |
|
double |
var9 |
|
|
var9 |
|
|
var9 |
Методы (7)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
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(var1.length == 0) |
private |
void |
pipevoid pipe(@Nonnull Vector3d var1, @Nonnull Control var2) |
Исходный код
Показать/скрыть
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.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 PositionsPinchDensity 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 pinchCurve;
class="kw">private class="kw">final double maxDistance;
class="kw">private class="kw">final boolean distanceNormalized;
@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 rWarpVector;
@Nonnull
class="kw">private class="kw">final ReusableList<Vector3d> rWarpVectors;
@Nonnull
class="kw">private class="kw">final ReusableList<Double> rNormalizedDistances;
@Nonnull
class="kw">private class="kw">final ReusableList<Double> rWeights;
@Nonnull
class="kw">private class="kw">final Density.Context rChildContext;
@Nonnull
class="kw">private class="kw">final PositionProvider.Context rPositionsContext;
class="kw">public PositionsPinchDensity(@Nullable Density var1, @Nullable PositionProvider var2, @Nonnull Double2DoubleFunction var3, double var4, boolean var6) {
assert var4 >= 0.0;
this.input = var1;
this.positions = var2;
this.pinchCurve = var3;
this.maxDistance = var4;
this.distanceNormalized = var6;
this.rMin = new Vector3d();
this.rMax = new Vector3d();
this.rSamplePoint = new Vector3d();
this.rWarpVector = new Vector3d();
this.rWarpVectors = new ReusableList<>();
this.rNormalizedDistances = new ReusableList<>();
this.rWeights = new ReusableList<>();
this.rChildContext = new Density.Context();
this.rPositionsContext = new PositionProvider.Context();
}
class="kw">private void pipe(@Nonnull Vector3d var1, @Nonnull Control var2) {
double var3 = var1.distance(this.rSamplePoint);
if (!(var3 > this.maxDistance)) {
double var5 = var3 / this.maxDistance;
this.rWarpVector.set(var1).sub(this.rSamplePoint);
double var9;
if (this.distanceNormalized) {
var9 = this.pinchCurve.applyAsDouble(var5);
var9 *= this.maxDistance;
} else {
var9 = this.pinchCurve.applyAsDouble(var3);
}
if (!(Math.abs(this.rWarpVector.length()) < 1.0E-9)) {
this.rWarpVector.normalize(var9);
if (this.rWarpVectors.isAtHardCapacity()) {
this.rWarpVectors.expandAndSet(new Vector3d(this.rWarpVector));
} else {
this.rWarpVectors.expandAndGet().set(this.rWarpVector);
}
this.rNormalizedDistances.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.rWarpVectors.clear();
this.rNormalizedDistances.clear();
this.rPositionsContext.bounds.min.set(this.rMin);
this.rPositionsContext.bounds.max.set(this.rMax);
this.rPositionsContext.pipe = this::pipe;
this.positions.generate(this.rPositionsContext);
if (this.rWarpVectors.getSoftSize() == 0) {
class="kw">return this.input.process(var1);
}
this.rChildContext.assign(var1);
this.rChildContext.position = this.rSamplePoint;
if (this.rWarpVectors.getSoftSize() == 1) {
Vector3d var10 = this.rWarpVectors.get(0);
this.rSamplePoint.add(var10);
double var11 = this.input.process(this.rChildContext);
this.rChildContext.clearReferences();
class="kw">return var11;
}
int var2 = this.rWarpVectors.getSoftSize();
this.rWeights.clear();
double var3 = 0.0;
for (int var5 = 0; var5 < var2; var5++) {
double var6 = this.rNormalizedDistances.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);
}
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];
}
}