From 23af1042b4656a250f63c2cfefae61b27e1ce912 Mon Sep 17 00:00:00 2001 From: Cracker1000 <39940063+cracker1000@users.noreply.github.com> Date: Thu, 5 May 2022 02:04:23 +0530 Subject: [PATCH] Make PHOT change its wavelength upon colliding with charged LITH (#841) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tamás Bálint Misius --- src/simulation/Simulation.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 52c5a4ddd..0e92e45f0 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -4351,8 +4351,18 @@ killed: continue; } - if (TYP(r)) - parts[i].ctype &= elements[TYP(r)].PhotonReflectWavelengths; + if (t == PT_PHOT) + { + auto mask = elements[TYP(r)].PhotonReflectWavelengths; + if (TYP(r) == PT_LITH) + { + int wl_bin = parts[ID(r)].ctype / 4; + if (wl_bin < 0) wl_bin = 0; + if (wl_bin > 25) wl_bin = 25; + mask = (0x1F << wl_bin); + } + parts[i].ctype &= mask; + } if (get_normal_interp(t, parts[i].x, parts[i].y, parts[i].vx, parts[i].vy, &nrx, &nry)) {