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

Đang mở
#4,217 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@adario đang làm issue này rồi.

Từ ngày 7/11/2026.

  • #4216 của @adario — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
15/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
dart, flutter
Lĩnh vực
game-dev, performance

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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?
Ngôn ngữ chính
Dart
Star
10.8k
Fork
1.1k
Merge trung bình
2 ngày 6 phút
Pull request đã merge (30 ngày)
56

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của flame-engine/flame

Tất cả issue của flame-engine/flame

Issue tương tự

Thêm issue về Dart

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.