refactor: use RENDERING_DEFAULTS constant for minimum slab thickness - #2564
Conversation
|
This PR is because we found a small bug in crosshairs, it was checking the minimum value which was expected to be MINIMUM_SLAB_THICKNESS while it was 0.1 in the viewport |
| if (slabThickness < 0.1) { | ||
| // Cannot render zero thickness | ||
| slabThickness = 0.1; | ||
| slabThickness = RENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS; |
There was a problem hiding this comment.
Nop 0.05
…-for-slab-thickness
📝 WalkthroughWalkthroughThe slab thickness example slider minimum and default were raised to 0.05, and the viewport clamp now uses the shared minimum slab thickness constant instead of a hardcoded value. ChangesSlab thickness minimum alignment
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
packages/core/src/RenderingEngine/VolumeViewport.ts (1)
497-499: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUse the shared minimum in the guard condition too.
Line 497still hardcodes0.1, so values between0.05and0.1get incorrectly clamped down to0.05. The threshold should matchRENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS.Proposed fix
- if (slabThickness < 0.1) { + if (slabThickness < RENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS) { // Cannot render zero thickness slabThickness = RENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/RenderingEngine/VolumeViewport.ts` around lines 497 - 499, The slab thickness guard in VolumeViewport still uses a hardcoded threshold instead of the shared minimum, so update the conditional around the slabThickness check to use RENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS in the same place where the clamp is applied. Keep the behavior in VolumeViewport consistent by referencing the shared constant in both the guard and the assignment, rather than comparing against 0.1 directly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@packages/core/src/RenderingEngine/VolumeViewport.ts`:
- Around line 497-499: The slab thickness guard in VolumeViewport still uses a
hardcoded threshold instead of the shared minimum, so update the conditional
around the slabThickness check to use RENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS
in the same place where the clamp is applied. Keep the behavior in
VolumeViewport consistent by referencing the shared constant in both the guard
and the assignment, rather than comparing against 0.1 directly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 35836b1d-4e7e-479f-a06b-c11af990003b
📒 Files selected for processing (2)
packages/core/examples/volumeAPI/index.tspackages/core/src/RenderingEngine/VolumeViewport.ts
|
@theoc0702 can you run the tests locally and post screenshot it passes |
|
is it good ? I see all test running except downstream validation |
…-for-slab-thickness
…-for-slab-thickness
Context
Currently, the minimum slab thickness in
setSlabThicknessis hardcoded to0.1. This PR replaces the hardcoded value with the existingRENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESSconstant to improve maintainability and ensure consistency across the library.Changes & Results
VolumeViewport.ts: Replaced hardcoded0.1withRENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESSin thesetSlabThicknessmethod.Effect:
No functional change for the user, but it centralizes the configuration of the minimum rendering thickness.
Testing
0.1.RENDERING_DEFAULTS.Checklist
PR
Code
Public Documentation Updates
Tested Environment
Summary by CodeRabbit