G354
Light. And still, the ball curves.軽い。それでも、球は曲がる。
G354 is the physics engine we are building for our games. The demos below run its code, built for the web from commit ddf3f1f.G354 は、私たちがゲームのために作っている物理エンジンです。下のデモは、その commit ddf3f1f のコードを Web へ出して動かしています。
g354.twoyearsold.net
Demo code: package:twoyearsold_ui/g354.dart · twoyearsold_ui@ddf3f1fc96b84b1ee20e6f6902b9373b9ea4984cデモのコード: package:twoyearsold_ui/g354.dart · twoyearsold_ui@ddf3f1fc96b84b1ee20e6f6902b9373b9ea4984c
A thousand shots at once千の打ち筋
Slide to add shots. Drag in the box to hit back.つまみで増やし、箱をなぞって打ち返す。
Discs pass through each other: separate tries.円盤は互いに当たらない。1 つずつ別の試し。
Timed: walls and the mallet. Disc-to-disc contact comes in stage 2.測るのは壁とマレットの当たり。円盤どうしの当たりは段 2。
Timed — steps at a time, then divided · — · cross-origin isolated: —— 歩をまとめて測り、— で割る · — · crossOriginIsolated: —
Seed —種 —
The seed is the number that picks each shot's direction and spin. Same seed on this device, same spread.種は打ち出しの並びを決める数。この端末で同じ種なら、同じ広がり。
One launch point, direction and spin a hair apart. Walls and a mallet you move: the contacts of our Air Hockey.同じ所から、わずかに違う向きと回転で打ち出す。壁と動かすマレットは、エアホッケーと同じ当たりです。
Same kick, one spin同じ蹴り、回転ひとつ
Flick up. Only the vermilion ball spins.上へはじく。朱の球だけが回る。
Timed — steps at a time, then divided · — · cross-origin isolated: —— 歩をまとめて測り、— で割る · — · crossOriginIsolated: —
Gravity, air drag and the Magnus force of the spin, stepped at a fixed 1/120 s.重力・空気の抵抗・回転のマグヌスの力を、1/120 秒の決まった刻みで解いています。
In it now今あるもの
- 3D flight: gravity, air drag, Magnus force, spin decay, orientation3D の飛翔: 重力・空気の抵抗・マグヌスの力・回転の減衰・姿勢
- 2D disc contacts: disc to wall, a disc you move2D の円盤の当たり: 円盤と壁・動かす円盤
- Fixed time step, with substeps set by speed決まった刻みと、速さで分ける内の刻み
- Deterministic: no random numbers, no clock inside決定論: 中に乱数も時計も持たない
- Pure Dart. Imports only dart:math and vector_math純粋な Dart。import は dart:math と vector_math だけ
Size: 317 lines · 27.1 KB gzip on the web (JS)大きさ: 317 行 · Web で gzip 27.1 KB(JS)
Not in it yetまだ無いもの
- Stage 1 · The same answer on every machine段 1 · どの機械でも同じ答え
- Stage 2 · Shapes and collision: disc-to-disc contact, boxes, polygons, capsules, no tunneling段 2 · 形と当たり: 円盤どうしの当たり・箱・多角形・カプセル、すり抜けない
- Stage 3 · Rigid bodies, joints, stacking, sleeping段 3 · 剛体・関節・積み・眠り
- Stage 3b · Collision for skeletons段 3b · 骨格の当たり
- Stage 4 · Cloth and rope段 4 · 布とひも
- Stage 5 · Air forces: drag crisis, knuckling段 5 · 空気の力: 抵抗が落ちる所・無回転の揺れ
- Stage 5e · Environment from a seed: wind, gusts, ground段 5e · 種で決まる環境: 風・乱れ・地面
- Stage 6 · Ongoing rounds of tuning for lightness and quality段 6 · 軽さと質の詰め(常設の周)
- Stage I · One World for input and output段 I · 入出力をひとつにする World
- Stage 7a · Contact display, record and replay段 7a · 当たりの表示・録画と再生
- Stage 7b · Ease of use: contact events and worked examples段 7b · 使いやすさの仕上げ: 当たりの知らせ・例
- Later · Soft bodies, buoyancy, water surface, smokeその先 · やわらかい体・浮力・水面・煙
Only numbers that passed a check, each with where it came from. Compared only on the same scene and the same step.確かめの通った数だけを、出どころと一緒に。比べるのは、同じ場面・同じ刻みの数だけ。
G354 is a part that does only disc contacts and ball flight; the others are general rigid-body engines. What we compare is the cost and allocation of one step of the same table, not whether the motions match. In G354's table, contact between pucks is written in the scene itself (see the notes to the table from ticket 1959).G354 は円盤の当たりと球の飛翔だけの部品で、ほかは汎用の剛体エンジンです。比べるのは同じ卓を 1 歩進める重さと確保で、動きの答えの一致ではありません。G354 の卓のパックどうしの当たりは、場面の側に書いた物です(チケット 1959 の表の脚)。
Air hockey table · 5 pucks, 2 mallets · 1/120 sエアホッケーの卓 · パック 5・マレット 2 · 1/120 秒
10000 steps after 2000 warm-up · per-engine step setting below each name暖機 2000 歩の後の 10000 歩 · 刻みの決まりはエンジンの名の下
| Engineエンジン | 1 step, median1 歩・中央値 | 1 step, p991 歩・p99 | Allocated per step1 歩の確保 | Lines of code部品の行数 |
|---|---|---|---|---|
| G354 · twoyearsold_ui@49a6681G354 · twoyearsold_ui@49a66811/120 s, substeps set by speed1/120 秒・速さで内の刻み | 1 step, median1 歩・中央値0.21 µs | 1 step, p991 歩・p990.71 µs | Allocated per step1 歩の確保54.65 B | Lines of code部品の行数317 |
| forge2d 0.14.2+1 · pub.dev · pure Dartforge2d 0.14.2+1 · pub.dev · 純 Dart1/120 s, 10 velocity and 10 position iterations1/120 秒・反復 速さ 10・位置 10 | 1 step, median1 歩・中央値6.33 µs | 1 step, p991 歩・p9941.50 µs | Allocated per step1 歩の確保435.13 B | Lines of code部品の行数18322 |
| forge2d 0.15.3 · pub.dev · Box2D v3.1.1 via FFIforge2d 0.15.3 · pub.dev · 中は Box2D v3.1.1(FFI)1/120 s, 4 substeps1/120 秒・内の刻み 4 | 1 step, median1 歩・中央値1.17 µs | 1 step, p991 歩・p991.83 µs | Allocated per step1 歩の確保20.16 B | Lines of code部品の行数Dart 17221 + C 34193 |
Stacked boxes (pyramid) · 1/60 s積んだ箱(ピラミッド)· 1/60 秒
G354 cannot do this yet (stages 2 and 3). We show no numbers here until it can.G354 にはまだ無い(段 2・3)。できるまで、ここには数を出しません。
Devices端末
- MacMac
- Apple M5 Pro · macOS 27.2.1 · arm64 · Dart 3.12.1 (JIT)Apple M5 Pro · macOS 27.2.1 · arm64 · Dart 3.12.1(JIT)
- Pixel phonePixel のスマートフォン
- Not measured yet未計測
- iPhoneiPhone
- Not measured yet未計測
Source: ticket 1959, checked in ticket 2034. Command: python3 tool/physics_bench/run.py出どころ: チケット 1959、確かめはチケット 2034。命令: python3 tool/physics_bench/run.py
The demos run twoyearsold_ui@ddf3f1fc96b84b1ee20e6f6902b9373b9ea4984c; the table measured twoyearsold_ui@49a6681. The four engine files are the same in both, byte for byte (same git blobs): only the folder and the entry file were renamed (lib/src/physics → lib/src/g354, lib/physics.dart → lib/g354.dart).デモが動かすのは twoyearsold_ui@ddf3f1fc96b84b1ee20e6f6902b9373b9ea4984c、表が測ったのは twoyearsold_ui@49a6681。部品の 4 ファイルはどちらも 1 字も違わない(git の blob が同じ)。違いは置き場の名と入口の名の付け替えだけ(lib/src/physics → lib/src/g354、lib/physics.dart → lib/g354.dart)。
Other engines are named only to say what we measured. No affiliation or endorsement.ほかのエンジンの名は、何を測ったかを言うためだけに書いています。提携・推薦の関係はありません。
Mac and iPhone are trademarks of Apple Inc., registered in the U.S. and other countries and regions. Pixel is a trademark of Google LLC.Mac・iPhone は、米国およびその他の国や地域で登録された Apple Inc. の商標です。Pixel は Google LLC の商標です。
The number beside each demo is measured on your device as you watch. It is not a fixed figure.各デモの横の数は、見ているあなたの端末で、その場で測った物です。決まった数ではありません。