3D viewer violations#9657
Conversation
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
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.
src/gui/src/chiplet3DWidget.cpp
Outdated
| 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.
src/gui/src/chiplet3DWidget.cpp
Outdated
| 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! 👍" |
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
|
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
| } 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.
Fix the issue :
#9412