init biods

This commit is contained in:
Matthew Deville 2026-09-28 10:07:38 +02:00
parent e6f69c8cd8
commit bcf542f963
4 changed files with 137 additions and 731 deletions

578
Cargo.lock generated
View file

@ -162,23 +162,10 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "anes"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
[[package]]
name = "anstyle"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
[[package]] [[package]]
name = "app" name = "app"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"avian2d",
"bevy", "bevy",
] ]
@ -191,12 +178,6 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "arbitrary-chunks"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ad8689a486416c401ea15715a4694de30054248ec627edbf31f49cb64ee4086"
[[package]] [[package]]
name = "arboard" name = "arboard"
version = "3.6.1" version = "3.6.1"
@ -365,44 +346,6 @@ version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
[[package]]
name = "avian2d"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "375fa2f2b6d042bda24d6b2ecea01ef1d7c8b7b3eed5c730d3409df4778588c9"
dependencies = [
"approx",
"arrayvec",
"avian_derive",
"bevy",
"bevy_heavy",
"bevy_math",
"bevy_transform_interpolation",
"bitflags 2.13.2",
"derive_more",
"disqualified",
"glam_matrix_extras",
"itertools 0.15.0",
"obvhs",
"parry2d",
"parry2d-f64",
"smallvec",
"thiserror 2.0.21",
"thread_local",
]
[[package]]
name = "avian_derive"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b95522267606c85f77ba40b55735583618f7a48e873be71a934f71dd5519ce86"
dependencies = [
"proc-macro-error3",
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]] [[package]]
name = "axum" name = "axum"
version = "0.8.9" version = "0.8.9"
@ -949,17 +892,6 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "bevy_heavy"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afbd898e2c06dfba5854db187a3daece1eaf655c8fc385604bbe5b9304ed3f9b"
dependencies = [
"bevy_math",
"bevy_reflect",
"glam_matrix_extras",
]
[[package]] [[package]]
name = "bevy_image" name = "bevy_image"
version = "0.19.1" version = "0.19.1"
@ -1176,8 +1108,8 @@ dependencies = [
"arrayvec", "arrayvec",
"bevy_reflect", "bevy_reflect",
"derive_more", "derive_more",
"glam 0.32.1", "glam",
"itertools 0.14.0", "itertools",
"libm", "libm",
"rand", "rand",
"rand_distr", "rand_distr",
@ -1206,7 +1138,7 @@ dependencies = [
"bytemuck", "bytemuck",
"derive_more", "derive_more",
"encase", "encase",
"glam 0.32.1", "glam",
"half", "half",
"hexasphere", "hexasphere",
"thiserror 2.0.21", "thiserror 2.0.21",
@ -1355,7 +1287,7 @@ dependencies = [
"downcast-rs 2.0.2", "downcast-rs 2.0.2",
"erased-serde", "erased-serde",
"foldhash 0.2.0", "foldhash 0.2.0",
"glam 0.32.1", "glam",
"indexmap", "indexmap",
"inventory", "inventory",
"petgraph", "petgraph",
@ -1417,10 +1349,10 @@ dependencies = [
"derive_more", "derive_more",
"downcast-rs 2.0.2", "downcast-rs 2.0.2",
"encase", "encase",
"glam 0.32.1", "glam",
"image", "image",
"indexmap", "indexmap",
"itertools 0.14.0", "itertools",
"js-sys", "js-sys",
"naga", "naga",
"nonmax", "nonmax",
@ -1667,15 +1599,6 @@ dependencies = [
"thiserror 2.0.21", "thiserror 2.0.21",
] ]
[[package]]
name = "bevy_transform_interpolation"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea40784f1c6a3f61333064ea1d1c7663ef677c1ce46b5ca148c46c4a62c27e62"
dependencies = [
"bevy",
]
[[package]] [[package]]
name = "bevy_ui" name = "bevy_ui"
version = "0.19.1" version = "0.19.1"
@ -1902,16 +1825,6 @@ dependencies = [
"cpufeatures", "cpufeatures",
] ]
[[package]]
name = "block-pseudorand"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2097358495d244a0643746f4d13eedba4608137008cf9dec54e53a3b700115a6"
dependencies = [
"chiapos-chacha8",
"nanorand",
]
[[package]] [[package]]
name = "block2" name = "block2"
version = "0.5.1" version = "0.5.1"
@ -2013,12 +1926,6 @@ dependencies = [
"wayland-client", "wayland-client",
] ]
[[package]]
name = "cast"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.5.1" version = "1.5.1"
@ -2043,67 +1950,6 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
[[package]]
name = "chiapos-chacha8"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33f8be573a85f6c2bc1b8e43834c07e32f95e489b914bf856c0549c3c269cd0a"
dependencies = [
"rayon",
]
[[package]]
name = "ciborium"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"
dependencies = [
"ciborium-io",
"ciborium-ll",
"serde",
]
[[package]]
name = "ciborium-io"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"
[[package]]
name = "ciborium-ll"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
dependencies = [
"ciborium-io",
"half",
]
[[package]]
name = "clap"
version = "4.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946"
dependencies = [
"clap_builder",
]
[[package]]
name = "clap_builder"
version = "4.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
dependencies = [
"anstyle",
"clap_lex",
]
[[package]]
name = "clap_lex"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486"
[[package]] [[package]]
name = "clipboard-win" name = "clipboard-win"
version = "5.4.1" version = "5.4.1"
@ -2277,42 +2123,6 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "criterion"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f"
dependencies = [
"anes",
"cast",
"ciborium",
"clap",
"criterion-plot",
"is-terminal",
"itertools 0.10.5",
"num-traits",
"once_cell",
"oorandom",
"plotters",
"rayon",
"regex",
"serde",
"serde_derive",
"serde_json",
"tinytemplate",
"walkdir",
]
[[package]]
name = "criterion-plot"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
dependencies = [
"cast",
"itertools 0.10.5",
]
[[package]] [[package]]
name = "critical-section" name = "critical-section"
version = "1.2.0" version = "1.2.0"
@ -2328,25 +2138,6 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]]
name = "crossbeam-deque"
version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"
dependencies = [
"crossbeam-utils",
]
[[package]] [[package]]
name = "crossbeam-queue" name = "crossbeam-queue"
version = "0.3.14" version = "0.3.14"
@ -2491,15 +2282,6 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"
[[package]]
name = "ena"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eabffdaee24bd1bf95c5ef7cec31260444317e72ea56c4c91750e8b7ee58d5f1"
dependencies = [
"log",
]
[[package]] [[package]]
name = "encase" name = "encase"
version = "0.12.1" version = "0.12.1"
@ -2871,7 +2653,6 @@ version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f70749695b063ecbf6b62949ccccde2e733ec3ecbbd71d467dca4e5c6c97cca0" checksum = "f70749695b063ecbf6b62949ccccde2e733ec3ecbbd71d467dca4e5c6c97cca0"
dependencies = [ dependencies = [
"approx",
"bytemuck", "bytemuck",
"encase", "encase",
"libm", "libm",
@ -2879,37 +2660,6 @@ dependencies = [
"serde_core", "serde_core",
] ]
[[package]]
name = "glam"
version = "0.33.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "928452f9c953e142b2f0973e4bd5f34445fcaa8069556ea97a3c9d34d15a4cf8"
dependencies = [
"bytemuck",
]
[[package]]
name = "glam_matrix_extras"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db060a7f23a5666ccbe9c770cd0e0e419b2eb94c86a7c8bfd091bacf8b4926cd"
dependencies = [
"bevy_reflect",
"glam 0.32.1",
]
[[package]]
name = "glamx"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59157a5886a9c68eb694df59254f7c9419c5648fc6ca1b728601a8baecc0dfcd"
dependencies = [
"approx",
"glam 0.32.1",
"num-traits",
"simba",
]
[[package]] [[package]]
name = "glow" name = "glow"
version = "0.17.0" version = "0.17.0"
@ -3071,7 +2821,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "177ea6330876de4ef08e184f827b98acc037614a4ce409902c5b0d53a9c2e951" checksum = "177ea6330876de4ef08e184f827b98acc037614a4ce409902c5b0d53a9c2e951"
dependencies = [ dependencies = [
"constgebra", "constgebra",
"glam 0.32.1", "glam",
"tinyvec", "tinyvec",
] ]
@ -3349,26 +3099,6 @@ dependencies = [
"rustversion", "rustversion",
] ]
[[package]]
name = "is-terminal"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
dependencies = [
"hermit-abi",
"libc",
"windows-sys 0.61.2",
]
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]] [[package]]
name = "itertools" name = "itertools"
version = "0.14.0" version = "0.14.0"
@ -3378,15 +3108,6 @@ dependencies = [
"either", "either",
] ]
[[package]]
name = "itertools"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc"
dependencies = [
"either",
]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.18" version = "1.0.18"
@ -3715,12 +3436,6 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "nanorand"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "729eb334247daa1803e0a094d0a5c55711b85571179f5ec6e53eccfdf7008958"
[[package]] [[package]]
name = "ndk" name = "ndk"
version = "0.9.0" version = "0.9.0"
@ -3796,26 +3511,6 @@ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "num-complex"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
dependencies = [
"num-traits",
]
[[package]]
name = "num-derive"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.19" version = "0.2.19"
@ -4154,20 +3849,6 @@ dependencies = [
"objc2-foundation 0.2.2", "objc2-foundation 0.2.2",
] ]
[[package]]
name = "obvhs"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf590a9310ba69b2340562d39f0c9bddd3677130bfd24a5df22941552e791bac"
dependencies = [
"bytemuck",
"glam 0.33.10",
"half",
"log",
"rdst",
"static_assertions",
]
[[package]] [[package]]
name = "offset-allocator" name = "offset-allocator"
version = "0.2.0" version = "0.2.0"
@ -4184,12 +3865,6 @@ version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "oorandom"
version = "11.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
[[package]] [[package]]
name = "orbclient" name = "orbclient"
version = "0.3.55" version = "0.3.55"
@ -4290,72 +3965,6 @@ dependencies = [
"icu_properties", "icu_properties",
] ]
[[package]]
name = "parry2d"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64f0ec92e9560ebd24cbdd071e19e07a96df6a6d4970d8719cc898c7dfdc359a"
dependencies = [
"approx",
"arrayvec",
"bitflags 2.13.2",
"downcast-rs 2.0.2",
"either",
"ena",
"foldhash 0.2.0",
"glamx",
"hashbrown 0.16.1",
"log",
"num-derive",
"num-traits",
"ordered-float",
"rayon",
"simba",
"slab",
"smallvec",
"spade",
"thiserror 2.0.21",
]
[[package]]
name = "parry2d-f64"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9445ae064bfaad3ef13354d2f9a4a5b6e01bbbad770a18aafd38662501b289cb"
dependencies = [
"approx",
"arrayvec",
"bitflags 2.13.2",
"downcast-rs 2.0.2",
"either",
"ena",
"foldhash 0.2.0",
"glamx",
"hashbrown 0.16.1",
"log",
"num-derive",
"num-traits",
"ordered-float",
"rayon",
"simba",
"slab",
"smallvec",
"spade",
"thiserror 2.0.21",
]
[[package]]
name = "partition"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "947f833aaa585cf12b8ec7c0476c98784c49f33b861376ffc84ed92adebf2aba"
[[package]]
name = "paste"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.3.2" version = "2.3.2"
@ -4424,34 +4033,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
[[package]]
name = "plotters"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747"
dependencies = [
"num-traits",
"plotters-backend",
"plotters-svg",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "plotters-backend"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a"
[[package]]
name = "plotters-svg"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670"
dependencies = [
"plotters-backend",
]
[[package]] [[package]]
name = "png" name = "png"
version = "0.18.1" version = "0.18.1"
@ -4529,28 +4110,6 @@ dependencies = [
"toml_edit", "toml_edit",
] ]
[[package]]
name = "proc-macro-error-attr3"
version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e564d14133360e1ae169ffde5da25881b5fa47261665b8e5713c212c27799da"
dependencies = [
"proc-macro2",
"quote",
]
[[package]]
name = "proc-macro-error3"
version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f0d4471b3436c22106b21913b1dda531558918ae9b7ec55d58aa84b43552233"
dependencies = [
"proc-macro-error-attr3",
"proc-macro2",
"quote",
"syn 3.0.6",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.107" version = "1.0.107"
@ -4658,40 +4217,6 @@ dependencies = [
"objc2-quartz-core 0.3.2", "objc2-quartz-core 0.3.2",
] ]
[[package]]
name = "rayon"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
dependencies = [
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
]
[[package]]
name = "rdst"
version = "0.20.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e7970b4e577b76a96d5e56b5f6662b66d1a4e1f5bb026ee118fc31b373c2752"
dependencies = [
"arbitrary-chunks",
"block-pseudorand",
"criterion",
"partition",
"tikv-jemallocator",
"voracious_radix_sort",
]
[[package]] [[package]]
name = "read-fonts" name = "read-fonts"
version = "0.39.2" version = "0.39.2"
@ -4781,12 +4306,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832"
[[package]]
name = "robust"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e27ee8bb91ca0adcf0ecb116293afa12d393f9c2b9b9cd54d33e8078fe19839"
[[package]] [[package]]
name = "ron" name = "ron"
version = "0.12.2" version = "0.12.2"
@ -4854,15 +4373,6 @@ version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
[[package]]
name = "safe_arch"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96b02de82ddbe1b636e6170c21be622223aea188ef2e139be0a5b219ec215323"
dependencies = [
"bytemuck",
]
[[package]] [[package]]
name = "same-file" name = "same-file"
version = "1.0.6" version = "1.0.6"
@ -5009,19 +4519,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "simba"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c99284beb21666094ba2b75bbceda012e610f5479dfcc2d6e2426f53197ffd95"
dependencies = [
"approx",
"num-complex",
"num-traits",
"paste",
"wide",
]
[[package]] [[package]]
name = "simd-adler32" name = "simd-adler32"
version = "0.3.10" version = "0.3.10"
@ -5129,18 +4626,6 @@ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "spade"
version = "2.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9699399fd9349b00b184f5635b074f9ec93afffef30c853f8c875b32c0f8c7fa"
dependencies = [
"hashbrown 0.16.1",
"num-traits",
"robust",
"smallvec",
]
[[package]] [[package]]
name = "spin" name = "spin"
version = "0.10.1" version = "0.10.1"
@ -5335,26 +4820,6 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "tikv-jemalloc-sys"
version = "0.5.4+5.3.0-patched"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "tikv-jemallocator"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca"
dependencies = [
"libc",
"tikv-jemalloc-sys",
]
[[package]] [[package]]
name = "tiny-skia" name = "tiny-skia"
version = "0.11.4" version = "0.11.4"
@ -5391,16 +4856,6 @@ dependencies = [
"zerovec", "zerovec",
] ]
[[package]]
name = "tinytemplate"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
dependencies = [
"serde",
"serde_json",
]
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
version = "1.13.3" version = "1.13.3"
@ -5722,15 +5177,6 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "voracious_radix_sort"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "446e7ffcb6c27a71d05af7e51ef2ee5b71c48424b122a832f2439651e1914899"
dependencies = [
"rayon",
]
[[package]] [[package]]
name = "walkdir" name = "walkdir"
version = "2.5.0" version = "2.5.0"
@ -6126,16 +5572,6 @@ dependencies = [
"web-sys", "web-sys",
] ]
[[package]]
name = "wide"
version = "0.7.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce5da8ecb62bcd8ec8b7ea19f69a51275e91299be594ea5cc6ef7819e16cd03"
dependencies = [
"bytemuck",
"safe_arch",
]
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"

View file

@ -4,5 +4,4 @@
version = "0.1.0" version = "0.1.0"
[dependencies] [dependencies]
avian2d = "0.7"
bevy = { version = "0.19", default-features = false, features = ["2d"] } bevy = { version = "0.19", default-features = false, features = ["2d"] }

View file

@ -1,15 +1,11 @@
use avian2d::prelude::*; use bevy::{platform::collections::HashMap, prelude::*};
use bevy::{ use std::f32::consts::PI;
input::common_conditions::input_just_pressed,
prelude::*,
window::{PrimaryWindow, WindowResized},
};
fn main() { fn main() {
App::new() App::new()
.insert_resource(ClearColor(Color::srgb_u8(26, 26, 46))) .insert_resource(ClearColor(Color::srgb_u8(26, 26, 46)))
.add_plugins(( .insert_resource(Time::<Fixed>::from_hz(60.0))
DefaultPlugins.set(WindowPlugin { .add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window { primary_window: Some(Window {
fit_canvas_to_parent: true, fit_canvas_to_parent: true,
prevent_default_event_handling: false, prevent_default_event_handling: false,
@ -17,160 +13,133 @@ fn main() {
..default() ..default()
}), }),
..default() ..default()
}), }))
PhysicsPlugins::default(),
))
.insert_resource(Time::<Physics>::default().with_relative_speed(5.0))
.insert_resource(DefaultRestitution(
Restitution::PERFECTLY_ELASTIC.with_combine_rule(CoefficientCombine::Max),
))
.add_systems(Startup, setup) .add_systems(Startup, setup)
.add_systems( .add_systems(FixedUpdate, update_boids)
Update,
(
update_screen_edges,
spawn_ball.run_if(input_just_pressed(MouseButton::Left)),
),
)
.run(); .run();
} }
#[derive(Component, Clone, Copy)] const BOID_MAX_VELOCITY: f32 = 200.0;
enum ScreenEdge {
Top, #[derive(Component)]
Bottom, struct Boid {
Left, velocity: Vec2,
Right,
} }
fn setup( fn setup(
mut commands: Commands, mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>, mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ColorMaterial>>, mut materials: ResMut<Assets<ColorMaterial>>,
window: Query<&Window, With<PrimaryWindow>>,
) { ) {
const NUM_BOIDS: usize = 50;
commands.spawn(Camera2d); commands.spawn(Camera2d);
if let Ok(window) = window.single() { // Triangle pointing right
spawn_screen_edges(&mut commands, &mut meshes, &mut materials, window.size()); let triangle_mesh = Mesh2d(meshes.add(Triangle2d::new(
} Vec2::new(10.0, 0.0),
Vec2::new(-3.0, 3.0),
Vec2::new(-3.0, -3.0),
)));
let triangle_material = MeshMaterial2d(materials.add(Color::WHITE));
commands.spawn_batch((0..=NUM_BOIDS).map(move |n| {
let angle = 2.0 * PI / (NUM_BOIDS as f32) * n as f32;
(
Boid {
velocity: Vec2::from_angle(angle) * BOID_MAX_VELOCITY,
},
triangle_mesh.clone(),
triangle_material.clone(),
Transform::default().rotate(Quat::from_rotation_z(angle)),
)
}));
} }
#[derive(Component, Clone, Copy)] struct Model {
struct Ball; separation: Vec2,
alignment: Vec2,
cohesion: Vec2,
}
fn spawn_ball( fn update_boids(
mouse_button: Res<ButtonInput<MouseButton>>, window: Single<&Window, With<bevy::window::PrimaryWindow>>,
window: Single<&Window, With<PrimaryWindow>>, mut query: Query<(Entity, &mut Boid, &mut Transform)>,
camera_query: Single<(&Camera, &GlobalTransform)>, time: Res<Time<Fixed>>,
time: Res<Time>,
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ColorMaterial>>,
) { ) {
const CIRCLE_RADIUS: f32 = 5.0; let dt = time.delta_secs();
let x_bound = window.width() * 0.7;
let y_bound = window.height() * 0.7;
let (camera, camera_transform) = *camera_query; const PROTECTED_RANGE: f32 = 30.0;
if mouse_button.just_pressed(MouseButton::Left) const VISIBLE_RANGE: f32 = 100.0;
&& let Some(cursor_position) = window.cursor_position()
&& let Ok(world_position) = camera.viewport_to_world_2d(camera_transform, cursor_position) let mut model_updates = HashMap::new();
{ for (entity, boid, transform) in query.iter() {
commands.spawn(( let mut nb_neighbors: usize = 0;
RigidBody::Dynamic, let mut separation = Vec2::new(0.0, 0.0);
Collider::circle(CIRCLE_RADIUS), let mut avg_speed = Vec2::new(0.0, 0.0);
LinearVelocity(Vec2::new(time.elapsed_secs().sin(), time.elapsed_secs().cos()) * 100.0), let mut avg_pos = Vec2::new(0.0, 0.0);
Mesh2d(meshes.add(Circle::new(CIRCLE_RADIUS))), for (other_entity, other_boid, other_transform) in query.iter() {
MeshMaterial2d(materials.add(Color::hsl(time.elapsed_secs().sin() * 360.0, 1.0, 0.5))), if entity == other_entity {
Transform::from_xyz(world_position.x, world_position.y, 0.0), continue;
Ball, }
)); let distance = transform
} .translation
} .xy()
.distance(other_transform.translation.xy());
fn spawn_screen_edges(
commands: &mut Commands, if distance > 1.0 && distance < PROTECTED_RANGE {
meshes: &mut Assets<Mesh>, separation +=
materials: &mut Assets<ColorMaterial>, (transform.translation.xy() - other_transform.translation.xy()) / distance;
size: Vec2, } else if distance < VISIBLE_RANGE {
) { avg_speed += other_boid.velocity;
const EDGE_COLOR: Color = Color::srgb_u8(255, 255, 255); avg_pos += other_transform.translation.xy();
nb_neighbors += 1;
let material = materials.add(EDGE_COLOR); }
}
for edge in [ if nb_neighbors > 0 {
ScreenEdge::Top, avg_speed /= nb_neighbors as f32;
ScreenEdge::Bottom, avg_pos /= nb_neighbors as f32;
ScreenEdge::Left, }
ScreenEdge::Right, model_updates.insert(
] { entity,
let (collider, transform, rect_size) = edge_shape(edge, size); Model {
commands.spawn(( separation,
RigidBody::Static, alignment: avg_speed - boid.velocity,
collider, cohesion: avg_pos - transform.translation.xy(),
transform, },
edge, );
Mesh2d(meshes.add(Rectangle::from_size(rect_size))), }
MeshMaterial2d(material.clone()),
)); for (entity, mut boid, mut transform) in query.iter_mut() {
} let mut acceleration = Vec2::new(0.0, 0.0);
} if transform.translation.x < -x_bound / 2.0 {
acceleration.x = 1.0;
fn edge_shape(edge: ScreenEdge, size: Vec2) -> (Collider, Transform, Vec2) { } else if transform.translation.x > x_bound / 2.0 {
const EDGE_THICKNESS: f32 = 5.0; acceleration.x = -1.0;
}
let half = size / 2.0;
let thickness = EDGE_THICKNESS; if transform.translation.y < -y_bound / 2.0 {
acceleration.y = 1.0;
match edge { } else if transform.translation.y > y_bound / 2.0 {
ScreenEdge::Top => { acceleration.y = -1.0;
let rect = Vec2::new(size.x, thickness); }
(
Collider::rectangle(rect.x, rect.y), let out_of_bounds_acceleration = acceleration.normalize_or_zero();
Transform::from_xyz(0.0, half.y - thickness / 2.0, 0.0),
rect, let model_update = model_updates.get(&entity).unwrap();
)
} // Update velocity and apply forces to position
ScreenEdge::Bottom => { boid.velocity += (out_of_bounds_acceleration
let rect = Vec2::new(size.x, thickness); + model_update.separation.normalize_or_zero() * 5.
( + model_update.alignment.normalize_or_zero()
Collider::rectangle(rect.x, rect.y), + model_update.cohesion.normalize_or_zero())
Transform::from_xyz(0.0, -half.y + thickness / 2.0, 0.0), * BOID_MAX_VELOCITY
rect, * dt;
) boid.velocity = boid.velocity.clamp_length_max(BOID_MAX_VELOCITY);
}
ScreenEdge::Left => { transform.translation.x += boid.velocity.x * dt;
let rect = Vec2::new(thickness, size.y); transform.translation.y += boid.velocity.y * dt;
( transform.rotation = Quat::from_rotation_z(boid.velocity.y.atan2(boid.velocity.x));
Collider::rectangle(rect.x, rect.y),
Transform::from_xyz(-half.x + thickness / 2.0, 0.0, 0.0),
rect,
)
}
ScreenEdge::Right => {
let rect = Vec2::new(thickness, size.y);
(
Collider::rectangle(rect.x, rect.y),
Transform::from_xyz(half.x - thickness / 2.0, 0.0, 0.0),
rect,
)
}
}
}
fn update_screen_edges(
mut resized: PopulatedMessageReader<WindowResized>,
mut edges: Query<(&ScreenEdge, &mut Collider, &mut Transform, &Mesh2d)>,
mut meshes: ResMut<Assets<Mesh>>,
) {
for event in resized.read() {
let size = Vec2::new(event.width, event.height);
for (edge, mut collider, mut transform, mesh2d) in &mut edges {
let (new_collider, new_transform, rect_size) = edge_shape(*edge, size);
*collider = new_collider;
*transform = new_transform;
if let Some(mut mesh) = meshes.get_mut(&mesh2d.0) {
*mesh = Rectangle::from_size(rect_size).into();
}
}
} }
} }

View file

@ -10,7 +10,8 @@
}; };
}; };
outputs = inputs@{ outputs =
inputs@{
flake-parts, flake-parts,
nixpkgs, nixpkgs,
rust-overlay, rust-overlay,
@ -24,7 +25,8 @@
"aarch64-darwin" "aarch64-darwin"
]; ];
perSystem = { pkgs, system, ... }: perSystem =
{ pkgs, system, ... }:
let let
overlays = [ (import rust-overlay) ]; overlays = [ (import rust-overlay) ];
rustPkgs = import nixpkgs { rustPkgs = import nixpkgs {
@ -33,22 +35,21 @@
rustToolchain = rustPkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; rustToolchain = rustPkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
cargoLock = fromTOML (builtins.readFile ./Cargo.lock); cargoLock = fromTOML (builtins.readFile ./Cargo.lock);
wasmBindgen = pkgs.lib.findFirst wasmBindgen = pkgs.lib.findFirst (
(pkg: pkg.name == "wasm-bindgen") pkg: pkg.name == "wasm-bindgen"
(throw "Could not find wasm-bindgen package") ) (throw "Could not find wasm-bindgen package") cargoLock.package;
cargoLock.package;
wasm-bindgen-cli = pkgs.buildWasmBindgenCli rec { wasm-bindgen-cli = pkgs.buildWasmBindgenCli rec {
src = pkgs.fetchCrate { src = pkgs.fetchCrate {
pname = "wasm-bindgen-cli"; pname = "wasm-bindgen-cli";
version = wasmBindgen.version; version = wasmBindgen.version;
hash = "sha256-a7lcXJnnZkYReja+iUO7NqqrWyv3toxnUgQb8s4IS5s="; hash = "sha256-pcecKQd7E8Opw6bkFoE569epUi7gh5qpQF1e5PJY6V8=";
}; };
cargoDeps = pkgs.rustPlatform.fetchCargoVendor { cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
inherit src; inherit src;
inherit (src) pname version; inherit (src) pname version;
hash = "sha256-R1Tas33Ursy8kqsxguAkG0ZhNed2n5uFTAhw1l2qlLY="; hash = "sha256-vmUrWVU7kPJJxO5qIVeAkwQyWDELO1Z4Z5gitz2kco8=";
}; };
}; };
in in
@ -60,6 +61,7 @@
pkgs.binaryen pkgs.binaryen
pkgs.brotli pkgs.brotli
pkgs.just pkgs.just
pkgs.watchexec
]; ];
}; };
}; };