diff --git a/source/processes/optical/src/G4OpBoundaryProcess.cc b/source/processes/optical/src/G4OpBoundaryProcess.cc index e97c564e578ec974a46304600c889cd645c7f0ea..f03ca5060bf9525c5d7d3d7cd34c07c911515168 100644 --- a/source/processes/optical/src/G4OpBoundaryProcess.cc +++ b/source/processes/optical/src/G4OpBoundaryProcess.cc @@ -960,6 +960,19 @@ void G4OpBoundaryProcess::DielectricDielectric() G4bool Inside = false; G4bool Swap = false; + if (theFinish == polished) { + theFacetNormal = theGlobalNormal; + } + else { + theFacetNormal = GetFacetNormal(OldMomentum, theGlobalNormal); + } + + // These variables deliberately shadow at this moment, this is backport + // from Geant4 11.0 + G4double cost1 = -OldMomentum * theFacetNormal; + G4double cost2 = 0.; + G4double sint2 = 0.; + G4bool SurfaceRoughnessCriterionPass = true; if (theSurfaceRoughness != 0. && Rindex1 > Rindex2) { G4double wavelength = h_Planck*c_light/thePhotonMomentum; @@ -1303,7 +1316,7 @@ void G4OpBoundaryProcess::CalculateReflectivity() } G4double PdotN = OldMomentum * theFacetNormal; - cost1 = -PdotN; + G4double cost1 = -PdotN; if (std::abs(cost1) < 1.0 - kCarTolerance) { sint1 = std::sqrt(1. - cost1*cost1);