BlendNoiseProperty class
Пакет: com.hypixel.hytale.procedurallib.property
Файл: com/hypixel/hytale/procedurallib/property/BlendNoiseProperty.java
implements: NoiseProperty
Поля (9)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
NoiseProperty |
alpha |
|
double |
var11 |
|
double |
var11 |
|
double |
var13 |
|
double |
var13 |
|
double |
var15 |
|
double |
var6 |
|
double |
var8 |
|
double |
var9 |
Методы (13)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
IllegalStateExceptionthrow new IllegalStateException("Thresholds must be in ascending order") |
|
|
for for(int var4 = 1; var4 < var3.length; var4++) |
|
|
for for(int var8 = 1; var8 < this.noises.length; var8++) |
|
|
for for(int var10 = 1; var10 < this.noises.length; var10++) |
|
|
if if(var3[var4] <= var3[var4 - 1]) |
|
|
if if(this.noises.length == 0) |
|
|
if if(var6 <= this.thresholds[0]) |
|
|
if if(var6 >= this.thresholds[this.thresholds.length - 1]) |
|
|
if if(var6 <= this.thresholds[var8]) |
|
|
if if(this.noises.length == 0) |
|
|
if if(var8 <= this.thresholds[0]) |
|
|
if if(var8 >= this.thresholds[this.thresholds.length - 1]) |
|
|
if if(var8 <= this.thresholds[var10]) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.procedurallib.property;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">public class BlendNoiseProperty class="kw">implements NoiseProperty {
class="kw">private class="kw">final NoiseProperty alpha;
class="kw">private class="kw">final NoiseProperty[] noises;
class="kw">private class="kw">final double[] thresholds;
class="kw">private class="kw">final class="kw">transient double[] normalize;
class="kw">public BlendNoiseProperty(NoiseProperty var1, NoiseProperty[] var2, double[] var3) {
this.alpha = var1;
this.noises = var2;
this.thresholds = var3;
this.normalize = new double[var3.length];
for (int var4 = 1; var4 < var3.length; var4++) {
if (var3[var4] <= var3[var4 - 1]) {
throw new IllegalStateException("Thresholds must be in ascending order");
}
this.normalize[var4] = 1.0 / (var3[var4] - var3[var4 - 1]);
}
}
@Override
class="kw">public double get(int var1, double var2, double var4) {
if (this.noises.length == 0) {
class="kw">return 0.0;
}
double var6 = this.alpha.get(var1, var2, var4);
if (var6 <= this.thresholds[0]) {
class="kw">return this.noises[0].get(var1, var2, var4);
}
if (var6 >= this.thresholds[this.thresholds.length - 1]) {
class="kw">return this.noises[this.noises.length - 1].get(var1, var2, var4);
}
for (int var8 = 1; var8 < this.noises.length; var8++) {
if (var6 <= this.thresholds[var8]) {
double var9 = (var6 - this.thresholds[var8 - 1]) * this.normalize[var8];
double var11 = this.noises[var8 - 1].get(var1, var2, var4);
double var13 = this.noises[var8].get(var1, var2, var4);
class="kw">return MathUtil.lerp(var11, var13, var9);
}
}
class="kw">return 0.0;
}
@Override
class="kw">public double get(int var1, double var2, double var4, double var6) {
if (this.noises.length == 0) {
class="kw">return 0.0;
}
double var8 = this.alpha.get(var1, var2, var4, var6);
if (var8 <= this.thresholds[0]) {
class="kw">return this.noises[0].get(var1, var2, var4, var6);
}
if (var8 >= this.thresholds[this.thresholds.length - 1]) {
class="kw">return this.noises[this.noises.length - 1].get(var1, var2, var4, var6);
}
for (int var10 = 1; var10 < this.noises.length; var10++) {
if (var8 <= this.thresholds[var10]) {
double var11 = (var8 - this.thresholds[var10 - 1]) * this.normalize[var10];
double var13 = this.noises[var10 - 1].get(var1, var2, var4, var6);
double var15 = this.noises[var10 + 0].get(var1, var2, var4, var6);
class="kw">return MathUtil.lerp(var13, var15, var11);
}
}
class="kw">return 0.0;
}
}