From a1538b4f7c93a4540934f0e147bcc76e1ad47d85 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 10 Jan 2022 13:00:06 +0100 Subject: [PATCH] pnmimage: Add offset parameters to PNMImage::perlin_noise_fill() --- panda/src/pnmimage/pnmImage.cxx | 5 +++-- panda/src/pnmimage/pnmImage.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index a39ef5c61e..428344b33f 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -1980,13 +1980,14 @@ quantize(size_t max_colors) { * PerlinNoise2 class in mathutil. */ void PNMImage:: -perlin_noise_fill(float sx, float sy, int table_size, unsigned long seed) { +perlin_noise_fill(float sx, float sy, int table_size, unsigned long seed, + float ox, float oy) { float x, y; float noise; PerlinNoise2 perlin (sx * _x_size, sy * _y_size, table_size, seed); for (x = 0; x < _x_size; ++x) { for (y = 0; y < _y_size; ++y) { - noise = perlin.noise(x, y); + noise = perlin.noise(x + ox, y + oy); set_xel(x, y, 0.5 * (noise + 1.0)); } } diff --git a/panda/src/pnmimage/pnmImage.h b/panda/src/pnmimage/pnmImage.h index da1e2d0553..5e2599f325 100644 --- a/panda/src/pnmimage/pnmImage.h +++ b/panda/src/pnmimage/pnmImage.h @@ -258,7 +258,8 @@ PUBLISHED: void make_histogram(Histogram &hist); void quantize(size_t max_colors); BLOCKING void perlin_noise_fill(float sx, float sy, int table_size = 256, - unsigned long seed = 0); + unsigned long seed = 0, + float ox = 0, float oy = 0); void perlin_noise_fill(StackedPerlinNoise2 &perlin); void remix_channels(const LMatrix4 &conv);