Skip to content

3D viewer violations#9657

Open
openroad-ci wants to merge 3 commits intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:test-3D-Viewer-Violations
Open

3D viewer violations#9657
openroad-ci wants to merge 3 commits intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:test-3D-Viewer-Violations

Conversation

@openroad-ci
Copy link
Collaborator

Fix the issue :
#9412

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

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});
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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
  1. 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;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
target_z = draw_cuboid.zMax() * 2.0f + kHighlightZOffset;
target_z = draw_cuboid.zMax() * kZScale + kHighlightZOffset;
References
  1. Define tunable parameters as named constants instead of using hardcoded magic numbers.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

clang-tidy review says "All clean, LGTM! 👍"

@jferreiraOpenRoad
Copy link
Contributor

🎨 Visual Improvements & Rendering

Solid Chiplet Visualization: Transitioned from wireframe-only to solid-filled face rendering.

    Painter’s Algorithm: Implemented depth sorting (sorted_faces_) to ensure correct draw order (back-to-front).

    Back-Face Culling: Added logic to skip rendering faces not oriented toward the camera, preventing visual artifacts and overlapping during rotation.

Lighting & Shading: Added a simple facet-based lighting model to improve spatial perception:

    Top faces: Rendered brighter.

    Side/Bottom faces: Rendered darker to provide a clear sense of depth and volume.

Expanded Color Palette: Added Teal, Purple, and Pink to better differentiate between chiplets.

    Note: Yellow has been intentionally excluded from the random palette as it is reserved for DRC/Selection highlights.

Z-Axis Scaling: Introduced a configurable scale factor (kZScale = 2.0f) to visually exaggerate the height of chiplet structures, which are often too thin to inspect at a 1:1 ratio.

🖱️ Interaction & Navigation

Synchronized Selection & Highlighting:

    The 3D viewer is now fully synced with the Layout Viewer and DRC Viewer.

    Highlighted objects are rendered with thicker outlines and a yellow fill to match the main UI's visual language.

    Added a selectionFocus animation (pulse/flash effect) to help users quickly locate small components.

Smart Zoom & Auto-Focus:

    Implemented zoomTo(): Automatically centers the camera and adjusts the zoom level to fit the selected object.

    Top-Down Reset: When focusing on a selection, the camera rotation resets to a 2D-like top view for easier localization.

Enhanced Camera Controls:

    Improved panning logic and implemented strict zoom bounds (kMinDistanceBound, kMaxDistanceBound) to prevent the camera from clipping through geometry or "getting lost" in space.

🛠️ Technical Details & Optimization

MainWindow Integration:

    The Chiplet3DWidget now maintains active references to selected_ and highlighted_ sets from the main window.

    Connected new signals to trigger automatic updates whenever changes occur in the Inspector or DRC Viewer.

Performance Optimizations:

    Memory Management: Introduced reusable buffers (polygon_buffer_, face_view_points_) to eliminate heap allocations within the paintEvent loop, significantly reducing CPU overhead during high-FPS interaction.

Copy link
Member

@osamahammad21 osamahammad21 left a comment

Choose a reason for hiding this comment

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

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);
Copy link
Member

Choose a reason for hiding this comment

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

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.

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.

3 participants