Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Promote Polygon out of experimental and use it for the polygons of paths

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

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
dart
Ambito
game-dev

Direzione di ricerca

Start with the Polygon class in src/experimental/geometry/shapes/polygon.dart, especially its constructor and _initializeEdges(), and read how Path.toPolygons(), PathComponent.polygons and convexPieces() use vertex lists today. Done means edges are computed lazily or on demand, the caller's list is never mutated, Polygon is exported from package:flame/geometry.dart, and the polygon-returning APIs return Polygon before 2.0. Because this changes public API, agree the design with maintainers before writing code.

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

Descrizione

enhancement v2

Problem

There are two ways of representing a polygon in Flame today:

  • The Polygon shape in src/experimental/geometry/shapes/polygon.dart, which is only exported from package:flame/experimental.dart.
  • Plain vertex lists (List<Vector2>), which most of the stable API uses: PolygonComponent, PathComponent.polygons, Path.toPolygons() and convexPieces() (the last two are added in #4097).

Since Polygon is experimental and has some performance issues, the stable APIs can't return it. That's why Path.toPolygons() returns List<List<Vector2>>, which is confusing given its name (see the discussion in #4097).

Issues with the current Polygon

  • The constructor eagerly creates an edge vector for every vertex in _initializeEdges(). In #4097, returning Polygon from toPolygons() cost about 2% more time but roughly twice the memory.
  • When convex isn't given, the constructor may reverse the vertex list that is passed in, in place, which is surprising for the caller.
  • It lives in experimental, so the core extensions and components can't depend on it.

Proposal

  1. Make Polygon cheap to construct: compute edges lazily (or drop the cached list and compute edges on demand), and avoid mutating the caller's list.
  2. Promote Polygon out of experimental into package:flame/geometry.dart.
  3. Before 2.0 stable, change the APIs that return polygons as vertex lists to return Polygon instead, while they're still only in dev releases:
    • Path.toPolygons()
    • PathComponent.polygons (released in flame-v2.0.0-dev.0)
    • convexPieces(), which could return List<Polygon> (with convex: true)

Consumers that need plain lists, like the forge2d Polygon shape, would read .vertices.

Lingua principale
Dart
Stelle
10.8k
Fork
1.1k
Merge medio
1g 17h
PR unite (30g)
51

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.