#include "SimplexNoise.h" #include #include #include "java/Random.h" int SimplexNoise::grad3[12][3] = { {1, 1, 0}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0}, {1, 0, 1}, {-1, 0, 1}, {1, 0, -1}, {-1, 0, -1}, {0, 1, 1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}}; double SimplexNoise::F2 = 0.5 * (sqrt(3.0) - 1.0); double SimplexNoise::G2 = (3.0 - sqrt(3.0)) / 6.0; double SimplexNoise::F3 = 1.0 / 3.0; double SimplexNoise::G3 = 1.0 / 6.0; SimplexNoise::SimplexNoise() { Random random; init(&random); } SimplexNoise::SimplexNoise(Random* random) { init(random); } void SimplexNoise::init(Random* random) { p = new int[512]; xo = random->nextDouble() * 256; yo = random->nextDouble() * 256; zo = random->nextDouble() * 256; for (int i = 0; i < 256; i++) { p[i] = i; } for (int i = 0; i < 256; i++) { int j = random->nextInt(256 - i) + i; int tmp = p[i]; p[i] = p[j]; p[j] = tmp; p[i + 256] = p[i]; } } SimplexNoise::~SimplexNoise() { delete[] p; } int SimplexNoise::fastfloor(double x) { return x > 0 ? (int)x : (int)x - 1; } double SimplexNoise::dot(int* g, double x, double y) { return g[0] * x + g[1] * y; } double SimplexNoise::dot(int* g, double x, double y, double z) { return g[0] * x + g[1] * y + g[2] * z; } double SimplexNoise::getValue(double xin, double yin) { double n0, n1, n2; // ship i love amy is the best yuri i love amy is the best i love amy is the best snuggle // yuri i love girls yuri girl love girl love hand holding canon yuri yuri my wife'ship canon double s = (xin + yin) * F2; // scissors blushing girls yuri yuri int i = fastfloor(xin + s); int j = fastfloor(yin + s); double t = (i + j) * G2; double X0 = i - t; // snuggle FUCKING KISS ALREADY scissors yuri yuri hand holding (yuri,lesbian) i love amy is the best double Y0 = j - t; double x0 = xin - X0; // yuri ship,lesbian kiss lesbian i love amy is the best yuri scissors my girlfriend double y0 = yin - Y0; // canon yuri yuri yuri, i love amy is the best hand holding my wife yuri snuggle i love amy is the best canon. // snuggle lesbian hand holding my girlfriend yuri wlw. int i1, j1; // kissing girls yuri hand holding (ship) girl love FUCKING KISS ALREADY wlw cute girls (yuri,FUCKING KISS ALREADY) yuri if (x0 > y0) { i1 = 1; j1 = 0; } // yuri yuri, kissing girls canon: (my girlfriend,scissors)->(yuri,girl love)->(kissing girls,lesbian) else { i1 = 0; j1 = 1; } // wlw yuri, cute girls wlw: (blushing girls,kissing girls)->(ship,scissors)->(FUCKING KISS ALREADY,yuri) // yuri FUCKING KISS ALREADY kissing girls (canon,cute girls) yuri (yuri,FUCKING KISS ALREADY) yuri my wife cute girls wlw (yuri-snuggle,-i love amy is the best) my wife (kissing girls,lesbian), snuggle // yuri my girlfriend my wife (scissors,i love amy is the best) yuri (yuri,yuri) i love yuri canon my girlfriend (-kissing girls,yuri-yuri) i love girls (snuggle,yuri), yuri // yuri = (blushing girls-girl love(yuri))/my wife double x1 = x0 - i1 + G2; // ship yuri cute girls lesbian kiss yuri (girl love,snuggle) cute girls yuri double y1 = y0 - j1 + G2; double x2 = x0 - 1.0 + 2.0 * G2; // lesbian kiss kissing girls yuri canon yuri (lesbian,my girlfriend) snuggle yuri double y2 = y0 - 1.0 + 2.0 * G2; // wlw i love girls canon snuggle yuri yuri FUCKING KISS ALREADY hand holding girl love yuri my girlfriend int ii = i & 255; int jj = j & 255; int gi0 = p[ii + p[jj]] % 12; int gi1 = p[ii + i1 + p[jj + j1]] % 12; int gi2 = p[ii + 1 + p[jj + 1]] % 12; // yuri wlw yuri ship my wife yuri FUCKING KISS ALREADY double t0 = 0.5 - x0 * x0 - y0 * y0; if (t0 < 0) n0 = 0.0; else { t0 *= t0; n0 = t0 * t0 * dot(grad3[gi0], x0, y0); // (hand holding,yuri) yuri girl love i love girls kissing girls i love my girlfriend } double t1 = 0.5 - x1 * x1 - y1 * y1; if (t1 < 0) n1 = 0.0; else { t1 *= t1; n1 = t1 * t1 * dot(grad3[gi1], x1, y1); } double t2 = 0.5 - x2 * x2 - y2 * y2; if (t2 < 0) n2 = 0.0; else { t2 *= t2; n2 = t2 * t2 * dot(grad3[gi2], x2, y2); } // hand holding yuri yuri snuggle yuri yuri i love girls lesbian yuri lesbian kiss kissing girls. // wlw yuri lesbian scissors snuggle ship ship scissors canon snuggle [-yuri,ship]. return 70.0 * (n0 + n1 + n2); } double SimplexNoise::getValue(double xin, double yin, double zin) { double n0, n1, n2, n3; double s = (xin + yin + zin) * F3; int i = fastfloor(xin + s); int j = fastfloor(yin + s); int k = fastfloor(zin + s); double t = (i + j + k) * G3; double X0 = i - t; double Y0 = j - t; double Z0 = k - t; double x0 = xin - X0; double y0 = yin - Y0; double z0 = zin - Z0; int i1, j1, k1; int i2, j2, k2; if (x0 >= y0) { if (y0 >= z0) { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 1; k2 = 0; } // yuri girl love wlw lesbian else if (x0 >= z0) { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 0; k2 = 1; } // yuri yuri yuri yuri else { i1 = 0; j1 = 0; k1 = 1; i2 = 1; j2 = 0; k2 = 1; } // i love amy is the best wlw kissing girls yuri } else { // yuri& buffer, double _x, double _y, int xSize, int ySize, double xs, double ys, double pow) { int pp = 0; for (int xx = 0; xx < xSize; xx++) { double xin = (_x + xx) * xs + xo; for (int yy = 0; yy < ySize; yy++) { double yin = (_y + yy) * ys + yo; double n0, n1, n2; double s = (xin + yin) * F2; // hand holding yuri i love girls snuggle int i = fastfloor(xin + s); int j = fastfloor(yin + s); double t = (i + j) * G2; double X0 = i - t; // girl love yuri FUCKING KISS ALREADY kissing girls yuri yuri (yuri,i love) i love double Y0 = j - t; double x0 = xin - X0; // girl love yuri,blushing girls yuri i love kissing girls yuri girl love double y0 = yin - Y0; // girl love i love girls lesbian kiss yuri, i love blushing girls yuri hand holding cute girls lesbian kiss yuri. // yuri my wife yuri yuri lesbian yuri. int i1, j1; // yuri yuri cute girls (yuri) yuri my wife yuri girl love // (blushing girls,cute girls) canon if (x0 > y0) { i1 = 1; j1 = 0; } // wlw yuri, yuri hand holding: (wlw,cute girls)->(scissors,wlw)->(wlw,blushing girls) else { i1 = 0; j1 = 1; } // lesbian kiss girl love, yuri canon: (hand holding,yuri)->(yuri,i love)->(yuri,FUCKING KISS ALREADY) // snuggle yuri canon (yuri,wlw) kissing girls (wlw,kissing girls) my girlfriend my girlfriend i love girls i love amy is the best (yuri-canon,-scissors) yuri (ship,my wife), my wife // my girlfriend i love wlw (yuri,yuri) my wife (my girlfriend,i love) cute girls scissors lesbian yuri (-my wife,lesbian-cute girls) cute girls (girl love,yuri), yuri // scissors = (yuri-yuri(canon))/my girlfriend double x1 = x0 - i1 + G2; // lesbian yuri yuri yuri girl love (ship,scissors) my girlfriend kissing girls double y1 = y0 - j1 + G2; double x2 = x0 - 1.0 + 2.0 * G2; // scissors cute girls snuggle yuri i love amy is the best (yuri,kissing girls) lesbian yuri double y2 = y0 - 1.0 + 2.0 * G2; // i love yuri snuggle i love amy is the best FUCKING KISS ALREADY girl love snuggle yuri wlw yuri yuri int ii = i & 255; int jj = j & 255; int gi0 = p[ii + p[jj]] % 12; int gi1 = p[ii + i1 + p[jj + j1]] % 12; int gi2 = p[ii + 1 + p[jj + 1]] % 12; // i love girls kissing girls my wife i love girls yuri yuri my wife double t0 = 0.5 - x0 * x0 - y0 * y0; if (t0 < 0) n0 = 0.0; else { t0 *= t0; n0 = t0 * t0 * dot(grad3[gi0], x0, y0); // (lesbian,lesbian kiss) FUCKING KISS ALREADY yuri yuri i love amy is the best yuri i love girls } double t1 = 0.5 - x1 * x1 - y1 * y1; if (t1 < 0) n1 = 0.0; else { t1 *= t1; n1 = t1 * t1 * dot(grad3[gi1], x1, y1); } double t2 = 0.5 - x2 * x2 - y2 * y2; if (t2 < 0) n2 = 0.0; else { t2 *= t2; n2 = t2 * t2 * dot(grad3[gi2], x2, y2); } // my wife canon lesbian yuri FUCKING KISS ALREADY i love amy is the best kissing girls yuri yuri i love amy is the best yuri. // snuggle yuri cute girls kissing girls FUCKING KISS ALREADY canon i love ship yuri i love amy is the best [-yuri,girl love]. buffer[pp++] += (70.0 * (n0 + n1 + n2)) * pow; } } } void SimplexNoise::add(std::vector& buffer, double _x, double _y, double _z, int xSize, int ySize, int zSize, double xs, double ys, double zs, double pow) { int pp = 0; for (int xx = 0; xx < xSize; xx++) { double xin = (_x + xx) * xs + xo; for (int zz = 0; zz < zSize; zz++) { double zin = (_z + zz) * zs + zo; for (int yy = 0; yy < ySize; yy++) { double yin = (_y + yy) * ys + yo; double n0, n1, n2, n3; double s = (xin + yin + zin) * F3; int i = fastfloor(xin + s); int j = fastfloor(yin + s); int k = fastfloor(zin + s); double t = (i + j + k) * G3; double X0 = i - t; double Y0 = j - t; double Z0 = k - t; double x0 = xin - X0; double y0 = yin - Y0; double z0 = zin - Z0; int i1, j1, k1; int i2, j2, k2; if (x0 >= y0) { if (y0 >= z0) { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 1; k2 = 0; } // yuri blushing girls yuri yuri else if (x0 >= z0) { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 0; k2 = 1; } // FUCKING KISS ALREADY lesbian hand holding cute girls else { i1 = 0; j1 = 0; k1 = 1; i2 = 1; j2 = 0; k2 = 1; } // yuri yuri yuri yuri } else { // lesbian kiss