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

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

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

@adario がすでに取り組んでいます。

2026年11月7日 から。

  • #4216 @adario による — オープン

評価

難易度
4/5
見積もり時間
1〜2日
初心者へのやさしさ
15/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
dart, flutter

調査の方向性

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.

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

説明

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?
主要言語
Dart
スター
10.8k
フォーク
1.1k
平均マージ
2日 6分
マージ済み PR(30日)
56

環境構築

はじめの一歩

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

flame-engine/flame のほかの issue

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

似ている issue

Dart の issue をもっと見る

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

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