Add support to share the polygons of a Path among PathComponent and PathHitbox

Abierto
#4,217 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@adario ya está trabajando en esto.

Desde el 7/11/2026.

  • #4216 de @adario — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
1-2 días
Aptitud para principiantes
15/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
dart, flutter

Línea de trabajo

PR #4216 already contains the proposed implementation, tests, and documentation for PathComponent and PathHitbox. Review that pull request and its tests to understand the change; the issue is complete when the PR is merged or its implementation is otherwise incorporated.

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

Descripción

enhancement
Problem to solve

PathComponent and PathHitbox sample their Path into polygons in their constructor, with
toPolygons, and that sampling is most of what creating one costs. When a game creates many of
them for the same path, like the hitboxes of e.g. enemies spawned over and over, it samples the
same path again for each one: there is no way to reuse polygons already computed, since the
constructor always samples.

Proposal

Add an optional polygons argument to the PathComponent constructor, passed on by PathHitbox.
When it is given, the path is not sampled:

  • The polygons are in the coordinates of the given path, as path.toPolygons() returns them, or
    they are the polygons of another component, given along with its path.
  • They are copied and moved along with the path, so they can be shared safely.
  • sampling, tolerance and filter are not used; they go to toPolygons instead.
final polygons = outline.toPolygons(sampling: 2);

final hitboxes = [
  for (var i = 0; i < 10; i++) PathHitbox(path: outline, polygons: polygons),
];

A named constructor is not an option, since Dart doesn't allow a non-redirecting generative
constructor next to a primary one (non_redirecting_generative_constructor_with_primary).

More information

I have opened PR #4216 with the proposed implementation, along with tests and the documentation of
PathComponent and PathHitbox.

Other
  • Are you interested in working on a PR for this?
Lenguaje dominante
Dart
Estrellas
10.8k
Forks
1.1k
Merge medio
2 d 6 min
PR fusionados (30 d)
56

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 flame-engine/flame

Todos los issues de flame-engine/flame

Issues similares

Más issues de Dart

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.