Navigation Menu

Skip to content

Commit

Permalink
Display an error when a noise parameter has too many octaves (#9394)
Browse files Browse the repository at this point in the history
Display an error and throw exception when one or more octaves of
a noise has spread < 1, causing random looking broken noise.
  • Loading branch information
paramat committed Feb 12, 2020
1 parent 2d5e0ce commit c2f48ea
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/noise.cpp
Expand Up @@ -503,23 +503,32 @@ void Noise::setOctaves(int octaves)

void Noise::resizeNoiseBuf(bool is3d)
{
//maximum possible spread value factor
// Maximum possible spread value factor
float ofactor = (np.lacunarity > 1.0) ?
pow(np.lacunarity, np.octaves - 1) :
np.lacunarity;

// noise lattice point count
// Noise lattice point count
// (int)(sz * spread * ofactor) is # of lattice points crossed due to length
float num_noise_points_x = sx * ofactor / np.spread.X;
float num_noise_points_y = sy * ofactor / np.spread.Y;
float num_noise_points_z = sz * ofactor / np.spread.Z;

// protect against obviously invalid parameters
// Protect against obviously invalid parameters
if (num_noise_points_x > 1000000000.f ||
num_noise_points_y > 1000000000.f ||
num_noise_points_z > 1000000000.f)
num_noise_points_y > 1000000000.f ||
num_noise_points_z > 1000000000.f)
throw InvalidNoiseParamsException();

// Protect against an octave having a spread < 1, causing broken noise values
if (np.spread.X / ofactor < 1.0f ||
np.spread.Y / ofactor < 1.0f ||
np.spread.Z / ofactor < 1.0f) {
errorstream << "A noise parameter has too many octaves: "
<< np.octaves << " octaves" << std::endl;
throw InvalidNoiseParamsException("A noise parameter has too many octaves");
}

// + 2 for the two initial endpoints
// + 1 for potentially crossing a boundary due to offset
size_t nlx = (size_t)std::ceil(num_noise_points_x) + 3;
Expand Down

2 comments on commit c2f48ea

@crogonint
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um... I found this string mentioned in the MineTest forum, and that led me here: 'noise parameter has too many octaves'
Here's what I'm getting:

2020-10-22 19:13:53: ACTION[Server]: singleplayer places node default:torch_wall at (838,-112,-211)
2020-10-22 19:13:59: ERROR[Emerge-0]: A noise parameter has too many octaves: 6 octaves
2020-10-22 19:13:59: ERROR[Emerge-0]: An unhandled exception occurred: A noise parameter has too many octaves
2020-10-22 19:13:59: ERROR[Emerge-0]: In thread 1e:
2020-10-22 19:13:59: ERROR[Emerge-0]: /home/stefan/mt-build/build/minetest_64/minetest/src/emerge.cpp:2da: run: A fatal error occurred: A noise parameter has too many octaves


2020-10-22 19:43:14: ACTION[Server]: singleplayer places node default:torch_wall at (844,-126,-208)
2020-10-22 19:43:19: ERROR[Emerge-0]: A noise parameter has too many octaves: 6 octaves
2020-10-22 19:43:19: ERROR[Emerge-0]: An unhandled exception occurred: A noise parameter has too many octaves
2020-10-22 19:43:19: ERROR[Emerge-0]: In thread c:
2020-10-22 19:43:19: ERROR[Emerge-0]: /home/stefan/mt-build/build/minetest_64/minetest/src/emerge.cpp:2da: run: A fatal error occurred: A noise parameter has too many octaves


Repeatable. I'm jumping down a big hole, I'm running DF Caverns for the first time, and I'm trying to get down to the dwarven layer. Just as I'm getting to the bottom of the hole, this happens:
minetest

Should I open an issue somewhere, or..?

..and who the heck is stefan?? :D


2020-10-22 20:44:18: ACTION[Server]: LuaEntitySAO "nssm:stone_eater" at (818,-232,-238) (id=6769, hp=27) punched LuaEntitySAO "goblins:goblin_copper" at (819,-232,-239) (id=6253, hp=10), damage=5
2020-10-22 20:44:20: ERROR[Emerge-0]: A noise parameter has too many octaves: 6 octaves
2020-10-22 20:44:20: ERROR[Emerge-0]: An unhandled exception occurred: A noise parameter has too many octaves
2020-10-22 20:44:20: ERROR[Emerge-0]: In thread c:
2020-10-22 20:44:20: ERROR[Emerge-0]: /home/stefan/mt-build/build/minetest_64/minetest/src/emerge.cpp:2da: run: A fatal error occurred: A noise parameter has too many octaves

This time it happened riding down an underground waterfall. Am I traveling down faster than the engine can keep up?

@crogonint
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it down to one of the massive dwaven cavrerns. It appears to choke when there are too many sources of light. Sometimes when I turn my head and swing a massive cavern in to view it crashes. I dunno though, maybe it's too many entities in view or something.

Please sign in to comment.