Repository navigation
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a214dbc956
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if hasfield(T, :n) | ||
| return (Base.typename(T).wrapper)(s, obj.n, c_tuple) | ||
| else | ||
| return (Base.typename(T).wrapper)(s, c_tuple) |
There was a problem hiding this comment.
Add constructible coated wrappers
When with_coatings is called on the existing optics advertised in the examples, this fallback calls the original type constructor with an extra coatings tuple, e.g. Lens(s, obj.n, c_tuple) or Mirror(s, c_tuple). Those structs in this commit still only have shape,n or shape fields and no matching constructors, so the public coating API throws a MethodError before any coated component can be created.
Useful? React with 👍 / 👎.
|
|
||
| Default fallback implementation checking if an object has refractive properties. Returns `false`. | ||
| """ | ||
| is_refractive(::AbstractObject) = false |
There was a problem hiding this comment.
Mark refractive optics as refractive
For standalone coatings or coincident coated boundaries adjacent to a Lens/Prism, this new predicate is the only applicable method because no is_refractive(::AbstractRefractiveOptic) override is added. The boundary resolver therefore treats refractive substrates as ambient media, chooses the system index instead of the glass index, and returns no substrate hint, so coated or standalone interfaces next to lenses trace as air-to-air boundaries.
Useful? React with 👍 / 👎.
|
|
||
| Refer to e.g. [`DiscreteRefractiveIndex`](@ref), [`SellmeierEquation`](@ref), [`AbsorbingMedium`](@ref), and [`GainMedium`](@ref). | ||
| """ | ||
| const RefractiveIndex = Union{Function, DiscreteRefractiveIndex, SellmeierEquation, AbsorbingMedium, GainMedium} |
There was a problem hiding this comment.
Remove Float64-only refractive index returns
Adding AbsorbingMedium and GainMedium to RefractiveIndex makes Lens/Prism accept media whose call returns n + imκ, but the existing refractive_index(::AbstractRefractiveOptic{<:Any,<:RefractiveIndex}, λ)::Float64 method still forces that complex value into Float64. Any nonzero absorption or gain therefore throws before the new attenuation code can run; the refractive optic accessor needs to return Number/the actual complex value.
Useful? React with 👍 / 👎.
| end | ||
| end | ||
|
|
||
| Ray{T}(pos, dir, int, λ, n) where {T} = Ray{T}(pos, dir, int, λ, n, one(T)) |
There was a problem hiding this comment.
Preserve ray weights across legacy interactions
This compatibility overload keeps old Ray{T}(pos, dir, int, λ, n) call sites compiling by silently resetting the new power weight to 1. Existing interactions such as ordinary lenses and mirrors still use that signature, so a ray that was split or attenuated by the new coating physics regains full power at the next uncoated optic, making optical_power and power_cutoff incorrect; those call sites need to pass through weight(ray).
Useful? React with 👍 / 👎.
| end | ||
|
|
||
| function bounding_sphere(s::CylinderSDF{T}) where T | ||
| return (Point3{T}(0), sqrt(s.radius^2 + (s.height / 2)^2)) |
There was a problem hiding this comment.
Use the full cylinder half-extent in culling
CylinderSDF.sdf treats height as the y half-extent via abs(y) - cylinder.height, but the new bounding sphere only includes height / 2. For tall cylinders, off-axis rays aimed at an end cap can be fast-forwarded past the real cap hit into the volume, after which _raymarch_outside may never report the intersection; the sphere radius should use sqrt(radius^2 + height^2) to enclose the actual SDF.
Useful? React with 👍 / 👎.
| if is_reflected | ||
| return SPBasis(-rs, 0, 0, rp) | ||
| else | ||
| return SPBasis(ts, 0, 0, tp) |
There was a problem hiding this comment.
Convert Fresnel field coefficients to power
For Uncoated boundaries with n1 != n2, these are field Fresnel transmission coefficients, but coating_transmittance later treats abs2(ts/tp) as transmitted power without the admittance factor n2*cos(θt)/(n1*cos(θi)). At normal incidence from air to glass this reports 0.64 instead of the physical 0.96, so unpolarized Ray weights through bare or thin-film transmissive boundaries are corrupted.
Useful? React with 👍 / 👎.
…ix surface_tag fallback and numeric_gradient step
a214dbc to
888cac1
Compare
888cac1 to
6c67176
Compare
…SDF surface_tags to :top/:bottom, and make Aqua test conditional
…ons and polarization raytracing
6c67176 to
7edcf60
Compare
…and preserve Gaussian beamlet ray weights
… architecture into boundary-physics
Part 2 of 3: Physical Boundary Interactions & Wave Propagation
This PR introduces the physical boundary interaction engine:
BoundaryPhysics.jlimplementing Snell's law, Fresnel coefficients, and Total Internal Reflection (TIR).Splittingbehavior) generating transmitted and reflected child rays.