3D viewer violations#9657
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces significant enhancements to the 3D chiplet viewer, transitioning it from a wireframe display to a more advanced solid-rendered view. Key improvements include lighting effects, back-face culling, and depth sorting using a painter's algorithm. The viewer is now more interactive, with features like zooming to selected objects and selection-focus animations. The implementation is robust, leveraging modern C++ and performance optimizations such as reusing buffers during painting. The integration with the main window's selection and highlight system is also well-executed. My review includes a couple of suggestions to replace a magic number with a named constant to improve code maintainability, aligning with repository guidelines.
| // Color by Depth (proportional to Z) | ||
| const QVector3D color = kColorPalette[index++ % kColorPalette.size()]; | ||
|
|
||
| const uint32_t base = vertices_.size(); | ||
| for (const auto& p : draw_cuboid.getPoints()) { | ||
| vertices_.push_back({QVector3D(p.x(), p.y(), p.z()), color}); | ||
| vertices_.push_back({QVector3D(p.x(), p.y(), p.z() * 2.0f), color}); |
There was a problem hiding this comment.
The Z-scaling factor 2.0f is used here as a magic number. To improve readability and maintainability, consider defining it as a named constant (e.g., constexpr float kZScale = 2.0f;) in the anonymous namespace at the top of the file. This magic number is also used on line 371.
| vertices_.push_back({QVector3D(p.x(), p.y(), p.z() * 2.0f), color}); | |
| vertices_.push_back({QVector3D(p.x(), p.y(), p.z() * kZScale), color}); |
References
- Define tunable parameters as named constants instead of using hardcoded magic numbers.
| if (c_rect.intersects(bbox)) { | ||
| odb::Cuboid draw_cuboid = cuboid; | ||
| center_transform_.apply(draw_cuboid); | ||
| target_z = draw_cuboid.zMax() * 2.0f + kHighlightZOffset; |
There was a problem hiding this comment.
The Z-scaling factor 2.0f is used here as a magic number. To improve readability and maintainability, consider using the named constant suggested for line 216.
| target_z = draw_cuboid.zMax() * 2.0f + kHighlightZOffset; | |
| target_z = draw_cuboid.zMax() * kZScale + kHighlightZOffset; |
References
- Define tunable parameters as named constants instead of using hardcoded magic numbers.
|
clang-tidy review says "All clean, LGTM! 👍" |
1 similar comment
|
clang-tidy review says "All clean, LGTM! 👍" |
|
🎨 Visual Improvements & Rendering 🖱️ Interaction & Navigation 🛠️ Technical Details & Optimization |
osamahammad21
left a comment
There was a problem hiding this comment.
In general, when I tested this branch I found the following:
- Zoom function is messed up because of the clamping values
- The faces draw over each other in specific angles
- Although hovering over the violation from the DRC widget animates one of the faces of the violating chiplets, it does not highlight the chiplet when the violation is selected.
- Instead of highlighting the chiplet, you should highlight the violation cuboid (minor and could be addressed in a separate PR).
- The drawn matrix changes its z coordinate with different distance_ values
| @@ -303,6 +611,7 @@ void Chiplet3DWidget::wheelEvent(QWheelEvent* e) | |||
| } else { | |||
| distance_ *= kZoomOutFactor; | |||
| } | |||
| distance_ = std::clamp(distance_, kMinDistanceBound, kMaxDistanceBound); | |||
There was a problem hiding this comment.
Is there a logical explanation behind the values of the constants kMinDistanceBound and kMaxDistanceBound? They cause a problem when the distance_ is out of these bounds.
3f6fe76 to
127c781
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
127c781 to
cc018cd
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
cc018cd to
fe0f4de
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
|
New DRC Widget (Web GUI) 3D Viewer Enhancements (chiplet3DWidget.cpp/h & 3d-viewer-widget.js) Database Support (odb::dbDatabaseObserver) Bug Fixes / Lifecycle |
osamahammad21
left a comment
There was a problem hiding this comment.
You should remove the chiplet3DWidtget.* and keep only the web 3d widget.
Also, @maliberty, I am not the best one to review the web gui code, is there a code owner?
Fix the issue :
#9412