tayloraswift / swift-noise

Generate and compose commonly-used procedural noises and distributions, in pure Swift
https://swiftinit.org/docs/swift-noise/noise
Apache License 2.0
116 stars 11 forks source link

Strange crash with Fatal error: Array index is out of range #3

Open wilg opened 2 years ago

wilg commented 2 years ago

I get a crash somewhat randomly when generating in a loop of tens of thousands of pixels.

Here's an example of some of the settings when it crashed. It doesn't seem to crash particularly reproducibly.

let noise = GradientNoise2D(amplitude: 1, frequency: 0.5, seed: 332)
noise.evaluate(-25.3217883662071, 43.793)

I (amazingly) cannot figure out how to copy the stack trace out of Xcode but it crashes on this line:

https://github.com/kelvin13/noise/blob/965fc23d7e95fb21a9065ef1566ee2bbd2b86e4b/sources/noise/gradient.swift#L540

with

2022-02-04 12:49:07.312857-0800 Run[53616:517701] Swift/Array.swift:405: Fatal error: Array index is out of range