Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#4,116 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
dart
領域
game-dev

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Dart
スター
10.8k
フォーク
1.1k
平均マージ
1日 15時間
マージ済み PR(30日)
50

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

flame-engine/flame のほかの issue

flame-engine/flame の issue をすべて見る

似ている issue

Dart の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。