Skip to content

Commit 941d000

Browse files
committed
Noise: Update Noise::resizeNoiseBuf to account for lacunarity not equal to 2
1 parent 29b413b commit 941d000

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/noise.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -400,15 +400,15 @@ void Noise::resizeNoiseBuf(bool is3d)
400400
float ofactor;
401401

402402
//maximum possible spread value factor
403-
ofactor = (float)(1 << (np->octaves - 1));
403+
ofactor = pow(np->lacunarity, np->octaves - 1);
404404

405405
//noise lattice point count
406406
//(int)(sz * spread * ofactor) is # of lattice points crossed due to length
407407
// + 2 for the two initial endpoints
408408
// + 1 for potentially crossing a boundary due to offset
409-
nlx = (int)(sx * ofactor / np->spread.X) + 3;
410-
nly = (int)(sy * ofactor / np->spread.Y) + 3;
411-
nlz = is3d ? (int)(sz * ofactor / np->spread.Z) + 3 : 1;
409+
nlx = (int)ceil(sx * ofactor / np->spread.X) + 3;
410+
nly = (int)ceil(sy * ofactor / np->spread.Y) + 3;
411+
nlz = is3d ? (int)ceil(sz * ofactor / np->spread.Z) + 3 : 1;
412412

413413
delete[] noise_buf;
414414
try {

0 commit comments

Comments
 (0)