-
Notifications
You must be signed in to change notification settings - Fork 5
Add support for Geant4 geometry in Viewport.ClippedViewCSG #2305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for visualizing Geant4 geometry in the ClippedViewCSG viewport system. Unlike the original CSG (Constructive Solid Geometry) assumption where figures don't intersect, Geant4 geometry consists of nested figures where children are fully contained within their parents. The solution employs a rendering heuristic using renderOrder with disabled depthTest to ensure child figures are drawn on top of their parents, preventing z-fighting artifacts.
Key changes:
- Introduced dynamic viewport configuration that switches between zone-based signals (non-Geant4) and figure-based signals (Geant4) when the simulator type changes
- Added recursive handling for nested Geant4 figures in the ClippedViewCSG system with renderOrder calculation based on hierarchy depth
- Implemented
RemoveFigureCommandto properly dispatch removal signals for nested figure hierarchies
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/util/hooks/useKeyboardEditorControls.ts | Routes BasicFigure deletion through new RemoveFigureCommand for proper nested signal handling |
| src/services/StoreService.tsx | Dispatches simulatorChanged signal when simulator type changes to trigger viewport reconfiguration |
| src/ThreeEditor/js/viewport/Viewport.js | Implements dynamic viewport setup that switches signal listeners based on simulator type (zones vs figures) |
| src/ThreeEditor/js/viewport/Viewport.ClippedViewCSG.ts | Adds recursive child handling, renderOrder calculation for Geant4, and detachSignals cleanup method |
| src/ThreeEditor/js/commands/RemoveFigureCommand.ts | New command that recursively dispatches figureRemoved/figureAdded signals for nested Geant4 geometry |
| src/ThreeEditor/js/YaptideEditor.js | Adds simulatorChanged signal definition and dispatches it during project loading |
| src/ThreeEditor/Simulation/Zones/BooleanZone.ts | Dispatches zoneAdded signal during deserialization for viewport initialization |
| src/ThreeEditor/Simulation/Figures/FigureManager.ts | Updates to dispatch figureAdded/figureRemoved signals and notify viewports during deserialization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
grzanka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Closes #2217
This PR forces ClippedViewCSG to work with Geant4 geometry.
The class has been originally written to display the constructive solid geometry that has no intersecting parts.
In Geant4 case all figures are nested inside each other, so this is the exact opposite to the prior assumption.
However, since the cameras in the viewports are fixed to look directly at the slices, and each Geant4 figure is either a) fully within its parent or b) to the side of its sibling, with no intersection, we can employ a simple heuristic to draw children always on top of its parents. We can use renderOrder with depthTest disabled to force the renderer to paint the children after the parent. This gets rid of z-fighting and seems to be working reliably provided that the hierarchy is valid (no intersections).
Since the example has all materials set to black, you need to change them in order to see each view