MinecraftConsoles/Minecraft.World/ImprovedNoise.h
2026-03-11 20:04:11 +03:00

29 lines
981 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "Synth.h"
class ImprovedNoise : public Synth
{
friend class PerlinNoise_SPU;
private:
int p[512]; // permutation table (size 512 for easy indexing)
double xo, yo, zo; // random offsets for each instance
public:
ImprovedNoise();
explicit ImprovedNoise(Random* random);
void init(Random* random);
double noise(double x, double y, double z) const;
static double lerp(double t, double a, double b);
static double grad(int hash, double x, double y, double z);
static double grad2(int hash, double x, double z); // 2D gradient (used in add() for ySize==1)
// Synth interface
double getValue(double x, double y) override; // 2D noise (z = 0)
double getValue(double x, double y, double z); // 3D noise
void add(doubleArray buffer, double _x, double _y, double _z,
int xSize, int ySize, int zSize,
double xs, double ys, double zs, double pow) const;
};