diff --git a/src/main/java/eu/jonahbauer/raytracing/render/spectral/SampledWavelengths.java b/src/main/java/eu/jonahbauer/raytracing/render/spectral/SampledWavelengths.java index 01df5cf..18374d0 100644 --- a/src/main/java/eu/jonahbauer/raytracing/render/spectral/SampledWavelengths.java +++ b/src/main/java/eu/jonahbauer/raytracing/render/spectral/SampledWavelengths.java @@ -58,12 +58,12 @@ public final class SampledWavelengths { * Terminates the secondary wavelengths. This method should be called after a wavelength-dependent operation like * refraction that makes it incorrect to track multiple wavelengths together. */ - public @NotNull SampledWavelengths collapse() { - if (pdf.length < 2 || pdf[1] == 0) return this; - var newPdf = Arrays.copyOf(pdf, pdf.length); - Arrays.fill(newPdf, 1, newPdf.length, 0d); - newPdf[0] /= newPdf.length; - return new SampledWavelengths(lambdas, newPdf); + public double collapse() { + if (pdf.length >= 2 || pdf[1] != 0) { + Arrays.fill(pdf, 1, pdf.length, 0d); + pdf[0] /= pdf.length; + } + return lambdas[0]; } /*