Skip to content

feat(geometry): improve ray-marching, SDF evaluation and intersection… - #60

Open
TacHawkes wants to merge 51 commits into
masterfrom
feature/intersection-handling
Open

TacHawkes wants to merge 51 commits into
masterfrom
feature/intersection-handling

Conversation

@TacHawkes

Copy link
Copy Markdown
Collaborator

Part 1 of 3: Core Geometry & Intersection Infrastructure

This PR provides geometric foundation improvements:

  • Ray-marching step & threshold optimizations in SDFs (AbstractSDF, UnionSDF, primitive SDFs).
  • Outward normal computation & bounding sphere / bounding box queries.
  • Coincident boundary intersection infrastructure.

This was referenced Aug 19, 2026
@codecov

codecov Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.36671% with 425 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.69%. Comparing base (4eb0229) to head (230971b).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
ext/RenderAstigmaticGaussian.jl 0.00% 44 Missing ⚠️
ext/RenderBeam.jl 0.00% 41 Missing ⚠️
src/AbstractTypes/AbstractShapeTrait.jl 72.18% 37 Missing ⚠️
src/System.jl 84.44% 35 Missing ⚠️
src/SDFs/UnionSDF.jl 56.94% 31 Missing ⚠️
src/SDFs/AbstractSDF.jl 76.36% 26 Missing ⚠️
src/OpticalComponents/Detectors/Detector.jl 51.16% 21 Missing ⚠️
src/SDFs/PrimitiveSDF.jl 76.66% 21 Missing ⚠️
src/Beam.jl 72.46% 19 Missing ⚠️
src/AbstractTypes/AbstractSegment.jl 61.53% 15 Missing ⚠️
... and 27 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #60      +/-   ##
==========================================
- Coverage   73.46%   71.69%   -1.78%     
==========================================
  Files          61       72      +11     
  Lines        3885     4557     +672     
==========================================
+ Hits         2854     3267     +413     
- Misses       1031     1290     +259     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da01ad5047

ℹ️ 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".

Comment thread src/SDFs/PrimitiveSDF.jl Resolved
Comment thread src/SDFs/PrimitiveSDF.jl Resolved
Comment thread src/SDFs/AbstractSDF.jl Resolved
@StackEnjoyer

Copy link
Copy Markdown
Owner

My comments/changes so far:

Remove retracing

Retracing has been a cumbersome feature so far. Only slight performance improvements (if any) and an unproportional amount of maintanance required. It is therefore time to say goodbye this feature. This will obviously imply a breaking change note for the overall (Coating)-patch.

Immutable AbstractIntersection

With retracing gone, there is no more need for Intersections to be updatable in subsequent tracing loops. The new AbstractIntersection type subtypes levels of intersection types useful to represent:

  • ShapeIntersection: ray-shape intersection information
  • ObjectIntersection: akin to the Intersection-type before the introduction of additional coincident_object data

Previously, the Intersection-type was used to represent where a SingleShape or at which specific subshape a MultiShape was hit. With Coatings, this approach must be rethought from the ground up.

I suggest either a MultiIntersection or specific types to represent intersections at interfaces with:

  • substrate
  • substrate + substrate
  • substrate + coating
  • substrate + substrate + coating

At most three shapes/objects should ever be hit at once, when Coatings are considered as infinitely thin (which they are here).

  • ShapeIntersection is defined and works ✔️
  • ObjectIntersection is defined and works ✔️
  • MultiIntersection is implemented as a stub and needs more discussion (I would favor variant 2 above)

MultiShape intersections

This brings us to the current mechanism as proposed in #57. It works out of the box with the MultiShape-API. However, at closer inspection, there occurs a question that requires more thought with respect to a robust API.

Currently, the intersect3d(::MultiShape, ::AbstractObject, ::AbstractRay-API intends to dispatch the correct interact3d method by replacing the object field of the underlying SingleShape returns with the top-level object (e.g. CubeBeamsplitter consists of Prisms, but Intersection object is raised to CubeBeamsplitter when Prism is hit).

This was intended to allow the user to define a single interact3d for MultShape objects. With the Coating-branch, however, it is now possible to simply "glue" elements together and have them work correctly out of the box. This is unintended, but lucky behavior.

We should therefore consider, if in addition to MultiShape trait we need to introduce a MultiObject flag for AbstractObjects with multiple sub-objects, rather than just shapes (which already works lol).

The MultiObject flag would allow the tracer to run the according interact3d of the sub-object (including Coatings). If defined as a SingleObject, the parent-interact3d method should be called.

If agreed, I will draft a stub.

interact3d extension with multi-shape intersections

As mentioned above, with the increase in capability the interact3d API will need to be extended IMO, since we can handle surface-like treatment of optical interactions then. I do not know how this might look in detail but this could be a very elegant way of wrapping the Coating-branch in a very solid and maintainable API.

@TacHawkes

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

TacHawkes and others added 28 commits August 22, 2026 10:02
…atings and beamsplitters within multi-intersections
…ispatch, and establish agent interaction rules
…ed modularity and optimize normal3d dispatch.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants