Skip to content

Poly Edit: hide edges behind the model; don't draw lines inside n-gons - #242

Merged
crisprintsstuff merged 1 commit into
mainfrom
polyedit-display
Nov 14, 2026
Merged

crisprintsstuff merged 1 commit into
mainfrom
polyedit-display

Conversation

@crisprintsstuff

Copy link
Copy Markdown
Owner

Fixes the two Poly Edit display problems a tester reported.

1. Edges showed through the model

The edited piece's polygon edges were painted by egui on top of the 3D view, culled only by face direction. After an extrusion, front-facing faces behind the new part still showed their edges, as if they were in front.

Now the renderer draws them in its existing depth-tested wireframe pass:

  • DrawItem gains wireframe: bool, which draws one piece's edges even with View > Wireframe off.
  • The edges use the user's wireframe color at opacity 0.9 (ITEM_WIREFRAME_OPACITY).
  • Poly Edit sets the flag on its piece (Editor::poly_wire_piece) and no longer paints those edges itself.

Hover and reach highlights, creases and picks are still painted on top, as interaction feedback.

With the smooth preview on, the cage floats off the smoothed surface, so depth-testing it against that surface would hide most of it. In that mode the cage is still drawn on top, as before.

2. N-gons showed their inner lines

A mesh built from polygons told the renderer which edges are quad diagonals, but not which lie inside n-gons. The wireframe therefore drew the triangulation of every n-gon.

  • Mesh now has set_ngon_edges / ngon_edges / is_inner_edge.
  • They are filled when a mesh is built from a cage (Cage::build_mesh, relink) and when binding a Catmull–Clark stack whose base has n-gons (Multires::bind).
  • The wireframe leaves those edges out, like quad diagonals.

This also covers meshes from the retopology tool and the View > Wireframe overlay.

Verified

  • cargo fmt --check, clippy -D warnings, cargo test --workspace, check_corpus_ip.py.
  • New tests:
    • An L-shaped prism with hexagon caps records 6 inner edges. Every triangle edge is either a polygon side or an inner edge, never both. A relinked cage restores them.
    • poly_wire_piece is on while Poly Edit is open and off with the smooth preview or after Done.
  • Headless screenshots (lavapipe) of that prism in Poly Edit, from an angle where one arm hides the other:
    • The hidden edges aren't drawn.
    • The hexagon tops show only their six sides.
    • With the smooth preview, the cage outline is drawn on top as before.

These screenshots came from a temporary local hack (opening Poly Edit at start), which is not in this PR.

Not verified / notes

  • Not run on a real GPU, Windows or macOS.
  • The per-frame cost is one extra pass over the draw list. Inner edges are looked up only when a mesh's index buffers are rebuilt, i.e. on topology changes. No timing run.
  • Meshes rebuilt by other tools (remesh, import) don't know their polygons, as before: quads are found from the shape, and n-gons don't exist there.
  • In smooth-preview mode the cage is still drawn over the surface.

Generated by Claude Code

A tester reported two display problems in Poly Edit.

Edges showed through the model. The cage edges were painted by egui on
top of the view, with only back-face culling, so after an extrusion the
front-facing faces behind the new part still showed their edges. The
renderer now draws the edited piece's edges in its depth-tested
wireframe pass (a new per-item DrawItem::wireframe flag), so geometry in
front hides them. With the smooth preview on, the cage floats off the
smoothed surface, so it keeps the overlay drawn on top.

N-gons showed their triangulation. A mesh built from polygons told the
renderer which edges are quad diagonals but not which lie inside n-gons,
so the wireframe drew the lines an n-gon is split into. Meshes built
from a cage or a polygon subdivision base now record those edges
(Mesh::set_ngon_edges), and the wireframe leaves them out like quad
diagonals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GEttLK8THCkZ7KHELbSp7g
Signed-off-by: Claude <noreply@anthropic.com>
@crisprintsstuff
crisprintsstuff merged commit 89650c4 into main Nov 14, 2026
5 checks passed
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.

2 participants