mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-14 12:51:20 +00:00
minor perf improvements
This commit is contained in:
@@ -1616,30 +1616,29 @@ public class FastNoiseLite implements NoiseSampler {
|
||||
return lerp(xf0, xf1, ys) * 1.4247691104677813f;
|
||||
}
|
||||
|
||||
private static long hash(long in) {
|
||||
in = (in + 0x7ed55d16) + (in << 12);
|
||||
in = (in ^ 0xc761c23c) ^ (in >> 19);
|
||||
in = (in + 0x165667b1) + (in << 5);
|
||||
in = (in + 0xd3a2646c) ^ (in << 9);
|
||||
in = (in + 0xfd7046c5) + (in << 3);
|
||||
in = (in ^ 0xb55a4f09) ^ (in >> 16);
|
||||
return in;
|
||||
long murmur64(long h) {
|
||||
h ^= h >>> 33;
|
||||
h *= 0xff51afd7ed558ccdL;
|
||||
h ^= h >>> 33;
|
||||
h *= 0xc4ceb9fe1a85ec53L;
|
||||
h ^= h >>> 33;
|
||||
return h;
|
||||
}
|
||||
|
||||
private double singleWhiteNoise(int seed, double x, double y, double z) {
|
||||
long hashX = hash(Double.doubleToRawLongBits(x) ^ seed);
|
||||
long hashZ = hash(Double.doubleToRawLongBits(y) ^ seed);
|
||||
long hashX = murmur64(Double.doubleToRawLongBits(x) ^ seed);
|
||||
long hashZ = murmur64(Double.doubleToRawLongBits(y) ^ seed);
|
||||
long hash = (((hashX ^ (hashX >>> 32)) + ((hashZ ^ (hashZ >>> 32)) << 32)) ^ seed) + Double.doubleToRawLongBits(z);
|
||||
long base = ((hash(hash)) & 0x000fffffffffffffL)
|
||||
long base = ((murmur64(hash)) & 0x000fffffffffffffL)
|
||||
+ POSITIVE_POW1; // Sign and exponent
|
||||
return (Double.longBitsToDouble(base) - 1.5) * 2;
|
||||
}
|
||||
|
||||
private double singleWhiteNoise(int seed, double x, double y) {
|
||||
long hashX = hash(Double.doubleToRawLongBits(x) ^ seed);
|
||||
long hashZ = hash(Double.doubleToRawLongBits(y) ^ seed);
|
||||
long hashX = murmur64(Double.doubleToRawLongBits(x) ^ seed);
|
||||
long hashZ = murmur64(Double.doubleToRawLongBits(y) ^ seed);
|
||||
long hash = ((hashX ^ (hashX >>> 32)) + ((hashZ ^ (hashZ >>> 32)) << 32)) ^ seed;
|
||||
long base = (hash(hash) & 0x000fffffffffffffL)
|
||||
long base = (murmur64(hash) & 0x000fffffffffffffL)
|
||||
+ POSITIVE_POW1; // Sign and exponent
|
||||
return (Double.longBitsToDouble(base) - 1.5) * 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user