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

Aperta
#4,217 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@adario ci sta già lavorando.

Dal 7/11/2026.

  • #4216 di @adario — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
15/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
dart, flutter

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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?
Lingua principale
Dart
Stelle
10.8k
Fork
1.1k
Merge medio
2g 6m
PR unite (30g)
56

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di flame-engine/flame

Tutte le issue di flame-engine/flame

Issue simili

Altre issue su Dart

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.