fix(viewport): use a vertex-relative signed area in polygon_overlaps_rect

Abierto
#418 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@cristim ya está trabajando en esto.

Desde el 9/11/2026.

  • #426 de @cristim — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
22/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust

Línea de trabajo

Start in src/viewport/rect_pick.rs at polygon_overlaps_rect: the signed-area loop near line 192, the separating-axis normals near line 208, and the normal.dot(a) terms near lines 213 to 214. Recompute the area relative to the first vertex, keeping exact zero for collinear points. Add tests for a thin triangle near (1e4, 1e4) and an exactly collinear one. Note that open pull request #426 already targets this issue, so coordinate with it before starting.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area/selection effort/xs impact/few priority/p3 severity/low triaged type/bug urgency/eventually

Problem

Raised by a CodeRabbit review of #404 and checked against the code. polygon_overlaps_rect (src/viewport/rect_pick.rs, the signed-area loop near line 192) sums p.x * next.y - next.x * p.y in absolute NDC coordinates. For a sliver polygon whose clipped vertices lie far from the NDC origin (a triangle crossing the near plane gives very large NDC values), the terms cancel badly, so the sign of the area and the zero-area test can be wrong. A wrong sign flips the outward normals used by the separating-axis test near line 208. The normal.dot(a) terms at lines 213 to 214 have the same issue.

It needs near-degenerate triangles with coordinates around 1e3 or more, so it is rare, and it has no known user report.

Change

  • Compute the signed area relative to the first polygon vertex ((p - p0).perp_dot(next - p0)), keeping an exact zero for collinear points and the existing zero-area rejection and bounding-box rejection.
  • Use the same vertex-relative form for the normal.dot(a) terms.
  • Tests: a thin triangle near (1e4, 1e4) keeps its correct overlap result and sign, and an exactly collinear one still returns false.

Related: #404, #30.

Lenguaje dominante
Rust
Estrellas
4
Forks
2
Merge medio
1 d 1 h
PR fusionados (30 d)
225

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de cristim/AztecCraft

Todos los issues de cristim/AztecCraft

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.