diff --git a/Cargo.lock b/Cargo.lock index 28731f041..b67d037f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,9 +30,9 @@ dependencies = [ [[package]] name = "accesskit" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb10ed32c63247e4e39a8f42e8e30fb9442fbf7878c8e4a9849e7e381619bea" +checksum = "74a4b14f3d99c1255dcba8f45621ab1a2e7540a0009652d33989005a4d0bfc6b" [[package]] name = "accesskit_consumer" @@ -40,7 +40,7 @@ version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c17cca53c09fbd7288667b22a201274b9becaa27f0b91bf52a526db95de45e6" dependencies = [ - "accesskit 0.12.2", + "accesskit 0.12.3", ] [[package]] @@ -49,7 +49,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd3b6ae1eabbfbced10e840fd3fce8a93ae84f174b3e4ba892ab7bcb42e477a7" dependencies = [ - "accesskit 0.12.2", + "accesskit 0.12.3", "accesskit_consumer", "objc2", "once_cell", @@ -61,7 +61,7 @@ version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afcae27ec0974fc7c3b0b318783be89fd1b2e66dd702179fe600166a38ff4a0b" dependencies = [ - "accesskit 0.12.2", + "accesskit 0.12.3", "accesskit_consumer", "once_cell", "paste", @@ -75,7 +75,7 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88e39fcec2e10971e188730b7a76bab60647dacc973d4591855ebebcadfaa738" dependencies = [ - "accesskit 0.12.2", + "accesskit 0.12.3", "accesskit_macos", "accesskit_windows", "winit", @@ -104,9 +104,9 @@ checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if 1.0.0", "getrandom 0.2.12", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -154,14 +154,13 @@ dependencies = [ [[package]] name = "alsa" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2562ad8dcf0f789f65c6fdaad8a8a9708ed6b488e649da28c01656ad66b8b47" +checksum = "37fe60779335388a88c01ac6c3be40304d1e349de3ada3b15f7808bb90fa9dce" dependencies = [ "alsa-sys", - "bitflags 1.3.2", + "bitflags 2.5.0", "libc", - "nix 0.24.3", ] [[package]] @@ -293,15 +292,15 @@ dependencies = [ [[package]] name = "asio-sys" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ca0cd2f17aa86bcd7eb6b6a423943352843695eb6adee9bd24a09a9e7568b9a" +checksum = "bb111d0b927c4b860b42a8bd869b94f5f973b0395ed5892f1ab2be2dc6831ea8" dependencies = [ - "bindgen 0.56.0", + "bindgen", "cc", - "num-derive", + "num-derive 0.4.2", "num-traits", - "once_cell", + "parse_cfg", "walkdir", ] @@ -328,13 +327,13 @@ dependencies = [ [[package]] name = "async-channel" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ "concurrent-queue", - "event-listener 4.0.3", - "event-listener-strategy", + "event-listener 5.2.0", + "event-listener-strategy 0.5.0", "futures-core", "pin-project-lite", ] @@ -349,7 +348,7 @@ dependencies = [ "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite 2.2.0", + "futures-lite 2.3.0", "slab", ] @@ -381,7 +380,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" dependencies = [ "event-listener 4.0.3", - "event-listener-strategy", + "event-listener-strategy 0.4.0", "pin-project-lite", ] @@ -448,7 +447,7 @@ dependencies = [ "cc", "cfg-if 1.0.0", "libc", - "miniz_oxide 0.7.1", + "miniz_oxide 0.7.2", "object", "rustc-demangle", ] @@ -505,7 +504,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68080288c932634f6563d3a8299efe0ddc9ea6787539c4c771ba250d089a94f0" dependencies = [ - "accesskit 0.12.2", + "accesskit 0.12.3", "bevy_app", "bevy_derive", "bevy_ecs", @@ -585,9 +584,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f48b9bbe4ec605e4910b5cd1e1a0acbfbe0b80af5f3bcc4489a9fdd1e80058c" dependencies = [ "bevy_macro_utils", - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -640,7 +639,7 @@ dependencies = [ "bevy_render", "bevy_transform", "bevy_utils", - "bitflags 2.4.2", + "bitflags 2.5.0", "radsort", "serde", ] @@ -653,7 +652,7 @@ checksum = "f484318350462c58ba3942a45a656c1fd6b6e484a6b6b7abc3a787ad1a51e500" dependencies = [ "bevy_macro_utils", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -699,9 +698,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8843aa489f159f25cdcd9fee75cd7d221a7098a71eaa72cb2d6b40ac4e3f1ba" dependencies = [ "bevy_macro_utils", - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -792,7 +791,7 @@ dependencies = [ "bevy_log", "bevy_reflect", "bevy_utils", - "smallvec 1.13.1", + "smallvec 1.13.2", ] [[package]] @@ -870,10 +869,10 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e566640c6b6dced73d2006c764c2cffebe1a82be4809486c4a5d7b4b50efed4d" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", "rustc-hash", - "syn 2.0.48", + "syn 2.0.53", "toml_edit 0.20.7", ] @@ -954,12 +953,12 @@ dependencies = [ "bevy_transform", "bevy_utils", "bevy_window", - "bitflags 2.4.2", + "bitflags 2.5.0", "bytemuck", "fixedbitset 0.4.2", "naga_oil", "radsort", - "smallvec 1.13.1", + "smallvec 1.13.2", "thread_local", ] @@ -983,7 +982,7 @@ dependencies = [ "erased-serde", "glam", "serde", - "smallvec 1.13.1", + "smallvec 1.13.2", "smol_str", "thiserror", ] @@ -995,10 +994,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4a8c5475f216e751ef4452a1306b00711f33d2d04d9f149e4c845dfeb6753a0" dependencies = [ "bevy_macro_utils", - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", - "uuid 1.7.0", + "syn 2.0.53", + "uuid 1.8.0", ] [[package]] @@ -1025,21 +1024,21 @@ dependencies = [ "bevy_transform", "bevy_utils", "bevy_window", - "bitflags 2.4.2", + "bitflags 2.5.0", "bytemuck", "codespan-reporting", "downcast-rs", "encase", "futures-lite 1.13.0", "hexasphere", - "image 0.24.8", + "image 0.24.9", "js-sys", "ktx2", "naga 0.13.0", "naga_oil", "ruzstd", "serde", - "smallvec 1.13.1", + "smallvec 1.13.2", "thiserror", "thread_local", "wasm-bindgen", @@ -1054,9 +1053,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d86bfc5a1e7fbeeaec0c4ceab18155530f5506624670965db3415f75826bea" dependencies = [ "bevy_macro_utils", - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -1077,7 +1076,7 @@ dependencies = [ "ron", "serde", "thiserror", - "uuid 1.7.0", + "uuid 1.8.0", ] [[package]] @@ -1097,7 +1096,7 @@ dependencies = [ "bevy_render", "bevy_transform", "bevy_utils", - "bitflags 2.4.2", + "bitflags 2.5.0", "bytemuck", "fixedbitset 0.4.2", "guillotiere", @@ -1195,7 +1194,7 @@ dependencies = [ "bevy_window", "bytemuck", "serde", - "smallvec 1.13.1", + "smallvec 1.13.2", "taffy", "thiserror", ] @@ -1215,7 +1214,7 @@ dependencies = [ "petgraph 0.6.4", "thiserror", "tracing", - "uuid 1.7.0", + "uuid 1.8.0", ] [[package]] @@ -1224,9 +1223,9 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7aafecc952b6b8eb1a93c12590bd867d25df2f4ae1033a01dfdfc3c35ebccfff" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -1272,47 +1271,27 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.56.0" +version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da379dbebc0b76ef63ca68d8fc6e71c0f13e59432e0987e508c1820e6ab5239" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ - "bitflags 1.3.2", - "cexpr 0.4.0", + "bitflags 2.5.0", + "cexpr", "clang-sys", - "clap", - "env_logger 0.8.4", + "itertools", "lazy_static", "lazycell", "log", - "peeking_take_while", - "proc-macro2 1.0.78", + "prettyplease", + "proc-macro2 1.0.79", "quote 1.0.35", "regex", "rustc-hash", - "shlex 0.1.1", + "shlex", + "syn 2.0.53", "which", ] -[[package]] -name = "bindgen" -version = "0.69.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c69fae65a523209d34240b60abe0c42d33d1045d445c0839d8a4894a736e2d" -dependencies = [ - "bitflags 2.4.2", - "cexpr 0.6.0", - "clang-sys", - "lazy_static", - "lazycell", - "peeking_take_while", - "proc-macro2 1.0.78", - "quote 1.0.35", - "regex", - "rustc-hash", - "shlex 1.3.0", - "syn 2.0.48", -] - [[package]] name = "bit-set" version = "0.5.3" @@ -1336,9 +1315,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" dependencies = [ "serde", ] @@ -1363,9 +1342,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" +checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" dependencies = [ "arrayref", "arrayvec 0.7.4", @@ -1405,12 +1384,12 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel 2.1.1", + "async-channel 2.2.0", "async-lock 3.3.0", "async-task", "fastrand 2.0.1", "futures-io", - "futures-lite 2.2.0", + "futures-lite 2.3.0", "piper", "tracing", ] @@ -1426,9 +1405,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" +checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" dependencies = [ "memchr", "serde", @@ -1436,9 +1415,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "bytecount" @@ -1448,22 +1427,22 @@ checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" [[package]] name = "bytemuck" -version = "1.14.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" +checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" +checksum = "4da9a32f3fed317401fa3c862968128267c3106685286e15d5aaa3d7389c2f60" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -1561,7 +1540,7 @@ dependencies = [ "crypto-hash", "curl", "curl-sys", - "env_logger 0.7.1", + "env_logger", "failure", "filetime", "flate2", @@ -1572,7 +1551,7 @@ dependencies = [ "glob", "hex 0.4.3", "home", - "humantime 1.3.0", + "humantime", "ignore", "im-rc", "jobserver", @@ -1608,9 +1587,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed8ef69d8518a5dda55c07425450b58a4e1946f4951eab6d7191ee86c2443d" +checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" dependencies = [ "serde", ] @@ -1629,9 +1608,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.83" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" dependencies = [ "jobserver", "libc", @@ -1643,22 +1622,13 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" -[[package]] -name = "cexpr" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" -dependencies = [ - "nom 5.1.3", -] - [[package]] name = "cexpr" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ - "nom 7.1.3", + "nom", ] [[package]] @@ -1681,16 +1651,16 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "chrono" -version = "0.4.33" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" +checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -1701,7 +1671,7 @@ checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" dependencies = [ "glob", "libc", - "libloading 0.8.1", + "libloading 0.8.3", ] [[package]] @@ -1836,9 +1806,9 @@ checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[package]] name = "constgebra" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd23e864550e6dafc1e41ac78ce4f1ccddc8672b40c403524a04ff3f0518420" +checksum = "e1aaf9b65849a68662ac6c0810c8893a765c960b907dd7cfab9c4a50bf764fbc" dependencies = [ "const_soft_float", ] @@ -1963,7 +1933,7 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f01585027057ff5f0a5bf276174ae4c1594a2c5bde93d5f46a016d76270f5a9" dependencies = [ - "bindgen 0.69.2", + "bindgen", ] [[package]] @@ -1995,27 +1965,25 @@ dependencies = [ [[package]] name = "cpal" -version = "0.15.2" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d959d90e938c5493000514b446987c07aed46c668faaa7d34d6c7a67b1a578c" +checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779" dependencies = [ - "alsa 0.7.1", + "alsa 0.9.0", "core-foundation-sys 0.8.6", "coreaudio-rs 0.11.3", "dasp_sample", - "jni 0.19.0", + "jni 0.21.1", "js-sys", "libc", "mach2", - "ndk 0.7.0", + "ndk 0.8.0", "ndk-context", - "oboe 0.5.0", - "once_cell", - "parking_lot 0.12.1", + "oboe 0.6.1", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "windows 0.46.0", + "windows 0.54.0", ] [[package]] @@ -2035,18 +2003,18 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "crossbeam-channel" -version = "0.5.11" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" +checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" dependencies = [ "crossbeam-utils 0.8.19", ] @@ -2138,24 +2106,24 @@ dependencies = [ [[package]] name = "curl" -version = "0.4.44" +version = "0.4.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "509bd11746c7ac09ebd19f0b17782eae80aadee26237658a6b4808afb5c11a22" +checksum = "1e2161dd6eba090ff1594084e95fd67aeccf04382ffea77999ea94ed42ec67b6" dependencies = [ "curl-sys", "libc", "openssl-probe", "openssl-sys", "schannel", - "socket2 0.4.10", - "winapi 0.3.9", + "socket2", + "windows-sys 0.52.0", ] [[package]] name = "curl-sys" -version = "0.4.70+curl-8.5.0" +version = "0.4.72+curl-8.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c0333d8849afe78a4c8102a429a446bfdd055832af071945520e835ae2d841e" +checksum = "29cbdc8314c447d11e8fd156dcdd031d9e02a7a976163e396b548c03153bc9ea" dependencies = [ "cc", "libc", @@ -2164,7 +2132,7 @@ dependencies = [ "openssl-sys", "pkg-config", "vcpkg", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2173,8 +2141,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e16e44ab292b1dddfdaf7be62cfd8877df52f2f3fde5858d95bab606be259f20" dependencies = [ - "bitflags 2.4.2", - "libloading 0.8.1", + "bitflags 2.5.0", + "libloading 0.8.3", "winapi 0.3.9", ] @@ -2196,7 +2164,7 @@ checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", "strsim 0.10.0", "syn 1.0.109", @@ -2256,7 +2224,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" dependencies = [ - "libloading 0.8.1", + "libloading 0.8.3", ] [[package]] @@ -2345,9 +2313,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "emath" @@ -2386,9 +2354,9 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fe2568f851fd6144a45fa91cfed8fe5ca8fc0b56ba6797bfc1ed2771b90e37c" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -2416,9 +2384,9 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -2427,9 +2395,9 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -2439,20 +2407,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" dependencies = [ "atty", - "humantime 1.3.0", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "env_logger" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" -dependencies = [ - "atty", - "humantime 2.1.0", + "humantime", "log", "regex", "termcolor", @@ -2565,6 +2520,17 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "event-listener" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b5fb89194fa3cad959b833185b3063ba881dbfc7030680b314250779fb4cc91" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + [[package]] name = "event-listener-strategy" version = "0.4.0" @@ -2575,6 +2541,16 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "event-listener-strategy" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" +dependencies = [ + "event-listener 5.2.0", + "pin-project-lite", +] + [[package]] name = "examples" version = "0.1.0" @@ -2593,7 +2569,7 @@ dependencies = [ "pitch_calc", "ringbuf", "time_calc", - "tokio 1.35.1", + "tokio 1.36.0", "walkdir", ] @@ -2613,7 +2589,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", "syn 1.0.109", "synstructure", @@ -2681,7 +2657,7 @@ checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide 0.7.1", + "miniz_oxide 0.7.2", ] [[package]] @@ -2733,9 +2709,9 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -2881,9 +2857,9 @@ dependencies = [ [[package]] name = "futures-lite" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" +checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ "fastrand 2.0.1", "futures-core", @@ -2898,9 +2874,9 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -2988,22 +2964,22 @@ dependencies = [ [[package]] name = "gilrs" -version = "0.10.4" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b2e57a9cb946b5d04ae8638c5f554abb5a9f82c4c950fd5b1fee6d119592fb" +checksum = "499067aa54af19f88732dc418f61f23d5912de1518665bb0eca034ca0d07574c" dependencies = [ "fnv", "gilrs-core", "log", - "uuid 1.7.0", + "uuid 1.8.0", "vec_map", ] [[package]] name = "gilrs-core" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0af1827b7dd2f36d740ae804c1b3ea0d64c12533fb61ff91883005143a0e8c5a" +checksum = "85c132270a155f2548e67d66e731075c336c39098afc555752f3df8f882c720e" dependencies = [ "core-foundation 0.9.4", "inotify 0.10.2", @@ -3012,12 +2988,12 @@ dependencies = [ "libc", "libudev-sys", "log", - "nix 0.27.1", - "uuid 1.7.0", + "nix 0.28.0", + "uuid 1.8.0", "vec_map", "wasm-bindgen", "web-sys", - "windows 0.52.0", + "windows 0.54.0", ] [[package]] @@ -3080,7 +3056,7 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.5", + "regex-automata 0.4.6", "regex-syntax 0.8.2", ] @@ -3115,9 +3091,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "438ffe1a5540d75403feaf23636b164e816e93f6f03131674722b3886ce32a57" dependencies = [ "inflections", - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -3149,7 +3125,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "gpu-alloc-types", ] @@ -3159,7 +3135,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", ] [[package]] @@ -3181,7 +3157,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "gpu-descriptor-types", "hashbrown 0.14.3", ] @@ -3192,7 +3168,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bf0b36e6f090b7e1d8a4b49c0cb81c1f8376f72198c65dd3ad9ff3556b8b78c" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", ] [[package]] @@ -3272,9 +3248,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -3380,12 +3356,6 @@ dependencies = [ "quick-error", ] -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.12.36" @@ -3431,16 +3401,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys 0.8.6", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core", + "windows-core 0.52.0", ] [[package]] @@ -3500,7 +3470,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.5", + "regex-automata 0.4.6", "same-file", "walkdir", "winapi-util", @@ -3552,15 +3522,15 @@ dependencies = [ [[package]] name = "image" -version = "0.24.8" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034bbe799d1909622a74d1193aa50147769440040ff36cb2baa947609b0a4e23" +checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" dependencies = [ "bytemuck", "byteorder", "color_quant", "num-traits", - "png 0.17.11", + "png 0.17.13", ] [[package]] @@ -3576,9 +3546,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.1" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -3635,9 +3605,9 @@ dependencies = [ [[package]] name = "io-kit-sys" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4769cb30e5dcf1710fc6730d3e94f78c47723a014a567de385e113c737394640" +checksum = "617ee6cf8e3f66f3b4ea67a4058564628cde41901316e19f559e14c7c72c5e7b" dependencies = [ "core-foundation-sys 0.8.6", "mach2", @@ -3662,6 +3632,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "0.4.8" @@ -3690,16 +3669,18 @@ dependencies = [ [[package]] name = "jni" -version = "0.20.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "039022cdf4d7b1cf548d31f60ae783138e5fd42013f6271049d7df7afadef96c" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" dependencies = [ "cesu8", + "cfg-if 1.0.0", "combine 4.6.6", "jni-sys", "log", "thiserror", "walkdir", + "windows-sys 0.45.0", ] [[package]] @@ -3710,9 +3691,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] @@ -3728,9 +3709,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -3872,12 +3853,12 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if 1.0.0", - "windows-sys 0.48.0", + "windows-targets 0.52.4", ] [[package]] @@ -3902,7 +3883,7 @@ version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", "redox_syscall 0.4.1", ] @@ -3976,9 +3957,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "lyon" @@ -4128,7 +4109,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "623b5e6cefd76e58f774bd3cc0c6f5c7615c58c03a97815245a25c3c9bdee318" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "block", "core-graphics-types", "foreign-types 0.5.0", @@ -4180,9 +4161,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", "simd-adler32", @@ -4209,9 +4190,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", @@ -4269,7 +4250,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1ceaaa4eedaece7e4ec08c55c640ba03dbb73fb812a6570a59bcf1930d0f70e" dependencies = [ "bit-set", - "bitflags 2.4.2", + "bitflags 2.5.0", "codespan-reporting", "hexf-parse", "indexmap 1.9.3", @@ -4292,8 +4273,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae585df4b6514cf8842ac0f1ab4992edc975892704835b549cf818dc0191249e" dependencies = [ "bit-set", - "bitflags 2.4.2", - "indexmap 2.2.1", + "bitflags 2.5.0", + "indexmap 2.2.5", "log", "num-traits", "pp-rs", @@ -4352,7 +4333,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "tokio 1.35.1", + "tokio 1.36.0", "toml", "walkdir", "web-sys", @@ -4462,7 +4443,7 @@ dependencies = [ "image 0.23.14", "instant", "num_cpus", - "tokio 1.35.1", + "tokio 1.36.0", "wgpu", ] @@ -4518,6 +4499,20 @@ dependencies = [ "thiserror", ] +[[package]] +name = "ndk" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" +dependencies = [ + "bitflags 2.5.0", + "jni-sys", + "log", + "ndk-sys 0.5.0+25.2.9519653", + "num_enum 0.7.2", + "thiserror", +] + [[package]] name = "ndk-context" version = "0.1.1" @@ -4546,8 +4541,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c" dependencies = [ "darling", - "proc-macro-crate", - "proc-macro2 1.0.78", + "proc-macro-crate 1.3.1", + "proc-macro2 1.0.79", "quote 1.0.35", "syn 1.0.109", ] @@ -4570,6 +4565,15 @@ dependencies = [ "jni-sys", ] +[[package]] +name = "ndk-sys" +version = "0.5.0+25.2.9519653" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" +dependencies = [ + "jni-sys", +] + [[package]] name = "net2" version = "0.2.39" @@ -4621,12 +4625,13 @@ dependencies = [ [[package]] name = "nix" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if 1.0.0", + "cfg_aliases", "libc", ] @@ -4653,16 +4658,6 @@ dependencies = [ "rand_xorshift 0.2.0", ] -[[package]] -name = "nom" -version = "5.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b" -dependencies = [ - "memchr", - "version_check", -] - [[package]] name = "nom" version = "7.1.3" @@ -4685,7 +4680,7 @@ version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "crossbeam-channel", "filetime", "fsevent-sys", @@ -4693,7 +4688,7 @@ dependencies = [ "kqueue", "libc", "log", - "mio 0.8.10", + "mio 0.8.11", "walkdir", "windows-sys 0.48.0", ] @@ -4774,26 +4769,36 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", "syn 1.0.109", ] +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2 1.0.79", + "quote 1.0.35", + "syn 2.0.53", +] + [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg 1.1.0", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" dependencies = [ "autocfg 1.1.0", "num-integer", @@ -4825,9 +4830,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg 1.1.0", "libm", @@ -4839,7 +4844,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.4", + "hermit-abi 0.3.9", "libc", ] @@ -4861,14 +4866,23 @@ dependencies = [ "num_enum_derive 0.6.1", ] +[[package]] +name = "num_enum" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +dependencies = [ + "num_enum_derive 0.7.2", +] + [[package]] name = "num_enum_derive" version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.78", + "proc-macro-crate 1.3.1", + "proc-macro2 1.0.79", "quote 1.0.35", "syn 1.0.109", ] @@ -4879,10 +4893,22 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.78", + "proc-macro-crate 1.3.1", + "proc-macro2 1.0.79", + "quote 1.0.35", + "syn 2.0.53", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +dependencies = [ + "proc-macro-crate 3.1.0", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -4948,7 +4974,7 @@ dependencies = [ "jni 0.19.0", "ndk 0.6.0", "ndk-context", - "num-derive", + "num-derive 0.3.3", "num-traits", "oboe-sys 0.4.5", ] @@ -4959,14 +4985,25 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8868cc237ee02e2d9618539a23a8d228b9bb3fc2e7a5b11eed3831de77c395d0" dependencies = [ - "jni 0.20.0", - "ndk 0.7.0", - "ndk-context", - "num-derive", + "num-derive 0.3.3", "num-traits", "oboe-sys 0.5.0", ] +[[package]] +name = "oboe" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb" +dependencies = [ + "jni 0.21.1", + "ndk 0.8.0", + "ndk-context", + "num-derive 0.4.2", + "num-traits", + "oboe-sys 0.6.1", +] + [[package]] name = "oboe-sys" version = "0.4.5" @@ -4985,6 +5022,15 @@ dependencies = [ "cc", ] +[[package]] +name = "oboe-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d" +dependencies = [ + "cc", +] + [[package]] name = "ogg" version = "0.7.1" @@ -5020,11 +5066,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.63" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if 1.0.0", "foreign-types 0.3.2", "libc", @@ -5039,9 +5085,9 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -5052,9 +5098,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.99" +version = "0.9.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" +checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" dependencies = [ "cc", "libc", @@ -5113,7 +5159,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b4b5f600e60dd3a147fb57b4547033d382d1979eb087af310e91cb45a63b1f4" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", "syn 1.0.109", ] @@ -5181,7 +5227,7 @@ dependencies = [ "instant", "libc", "redox_syscall 0.2.16", - "smallvec 1.13.1", + "smallvec 1.13.2", "winapi 0.3.9", ] @@ -5194,21 +5240,24 @@ dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall 0.4.1", - "smallvec 1.13.1", + "smallvec 1.13.2", "windows-targets 0.48.5", ] [[package]] -name = "paste" -version = "1.0.14" +name = "parse_cfg" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "905787a434a2c721408e7c9a252e85f3d93ca0f118a5283022636c0e05a7ea49" +dependencies = [ + "nom", +] [[package]] -name = "peeking_take_while" -version = "0.1.2" +name = "paste" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pennereq" @@ -5248,7 +5297,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset 0.4.2", - "indexmap 2.2.1", + "indexmap 2.2.5", ] [[package]] @@ -5305,9 +5354,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "png" @@ -5323,15 +5372,15 @@ dependencies = [ [[package]] name = "png" -version = "0.17.11" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f6c3c3e617595665b8ea2ff95a86066be38fb121ff920a9c0eb282abcd1da5a" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" dependencies = [ "bitflags 1.3.2", "crc32fast", "fdeflate", "flate2", - "miniz_oxide 0.7.1", + "miniz_oxide 0.7.2", ] [[package]] @@ -5355,6 +5404,16 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "prettyplease" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" +dependencies = [ + "proc-macro2 1.0.79", + "syn 2.0.53", +] + [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -5365,6 +5424,15 @@ dependencies = [ "toml_edit 0.19.15", ] +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit 0.21.1", +] + [[package]] name = "proc-macro2" version = "0.4.30" @@ -5376,18 +5444,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] [[package]] name = "profiling" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f0f7f43585c34e4fdd7497d746bc32e14458cf11c69341cc0587b1d825dde42" +checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" [[package]] name = "publicsuffix" @@ -5429,7 +5497,7 @@ version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", ] [[package]] @@ -5670,9 +5738,9 @@ checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" [[package]] name = "rayon" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" dependencies = [ "either", "rayon-core", @@ -5759,7 +5827,7 @@ checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.5", + "regex-automata 0.4.6", "regex-syntax 0.8.2", ] @@ -5774,9 +5842,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -5812,9 +5880,9 @@ dependencies = [ [[package]] name = "renderdoc-sys" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" [[package]] name = "reqwest" @@ -5884,7 +5952,7 @@ version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b1bb7b48ee48471f55da122c0044fcc7600cfcc85db88240b89cb832935e611" dependencies = [ - "cpal 0.15.2", + "cpal 0.15.3", "lewton 0.10.2", ] @@ -5895,7 +5963,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ "base64 0.21.7", - "bitflags 2.4.2", + "bitflags 2.5.0", "serde", "serde_derive", ] @@ -5907,7 +5975,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2e63d9e6b0d090be1485cf159b1e04c3973d2d3e1614963544ea2ff47a4a981" dependencies = [ "byteorder", - "nom 7.1.3", + "nom", ] [[package]] @@ -5999,11 +6067,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -6039,9 +6107,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "safemem" @@ -6139,22 +6207,22 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -6168,9 +6236,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.113" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa 1.0.10", "ryu", @@ -6212,12 +6280,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" -[[package]] -name = "shlex" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" - [[package]] name = "shlex" version = "1.3.0" @@ -6313,9 +6375,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" dependencies = [ "serde", ] @@ -6350,22 +6412,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "socket2" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -6443,9 +6495,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "svg_fmt" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb1df15f412ee2e9dfc1c504260fa695c1c3f10fe9f4a6ee2d2184d7d6450e2" +checksum = "f83ba502a3265efb76efb89b0a2f7782ad6f2675015d4ce37e4b547dda42b499" [[package]] name = "svgdom" @@ -6487,18 +6539,18 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.48" +version = "2.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", "unicode-ident", ] @@ -6509,7 +6561,7 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", "syn 1.0.109", "unicode-xid 0.2.4", @@ -6569,13 +6621,12 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if 1.0.0", "fastrand 2.0.1", - "redox_syscall 0.4.1", "rustix", "windows-sys 0.52.0", ] @@ -6600,9 +6651,9 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] @@ -6622,27 +6673,27 @@ version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4c60d69f36615a077cc7663b9cb8e42275722d23e58a7fa3d2c7f2915d09d04" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if 1.0.0", "once_cell", @@ -6700,7 +6751,7 @@ dependencies = [ "arrayvec 0.7.4", "bytemuck", "cfg-if 1.0.0", - "png 0.17.11", + "png 0.17.13", "tiny-skia-path", ] @@ -6751,19 +6802,19 @@ dependencies = [ [[package]] name = "tokio" -version = "1.35.1" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes 1.5.0", "libc", - "mio 0.8.10", + "mio 0.8.11", "num_cpus", "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.5", + "socket2", "tokio-macros", "windows-sys 0.48.0", ] @@ -6816,9 +6867,9 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -6925,7 +6976,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.1", + "indexmap 2.2.5", "toml_datetime", "winnow", ] @@ -6936,7 +6987,18 @@ version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ - "indexmap 2.2.1", + "indexmap 2.2.5", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap 2.2.5", "toml_datetime", "winnow", ] @@ -6958,9 +7020,9 @@ version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] @@ -7006,7 +7068,7 @@ dependencies = [ "once_cell", "regex", "sharded-slab", - "smallvec 1.13.1", + "smallvec 1.13.2", "thread_local", "tracing", "tracing-core", @@ -7026,9 +7088,9 @@ dependencies = [ [[package]] name = "transpose" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6522d49d03727ffb138ae4cbc1283d3774f0d10aa7f9bf52e6784c45daf9b23" +checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" dependencies = [ "num-integer", "strength_reduce", @@ -7103,18 +7165,18 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" @@ -7203,9 +7265,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ "getrandom 0.2.12", "serde", @@ -7258,7 +7320,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", ] @@ -7270,9 +7332,9 @@ checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -7309,9 +7371,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -7319,24 +7381,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -7346,9 +7408,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote 1.0.35", "wasm-bindgen-macro-support", @@ -7356,22 +7418,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wayland-client" @@ -7397,7 +7459,7 @@ checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" dependencies = [ "nix 0.24.3", "once_cell", - "smallvec 1.13.1", + "smallvec 1.13.2", "wayland-sys", ] @@ -7430,7 +7492,7 @@ version = "0.29.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", "xml-rs", ] @@ -7448,9 +7510,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -7477,7 +7539,7 @@ dependencies = [ "profiling", "raw-window-handle", "serde", - "smallvec 1.13.1", + "smallvec 1.13.2", "static_assertions", "wasm-bindgen", "wasm-bindgen-futures", @@ -7495,7 +7557,7 @@ checksum = "0f8a44dd301a30ceeed3c27d8c0090433d3da04d7b2a4042738095a424d12ae7" dependencies = [ "arrayvec 0.7.4", "bit-vec", - "bitflags 2.4.2", + "bitflags 2.5.0", "codespan-reporting", "log", "naga 0.13.0", @@ -7505,7 +7567,7 @@ dependencies = [ "ron", "rustc-hash", "serde", - "smallvec 1.13.1", + "smallvec 1.13.2", "thiserror", "web-sys", "wgpu-hal", @@ -7522,7 +7584,7 @@ dependencies = [ "arrayvec 0.7.4", "ash", "bit-set", - "bitflags 2.4.2", + "bitflags 2.5.0", "block", "core-graphics-types", "d3d12", @@ -7534,7 +7596,7 @@ dependencies = [ "js-sys", "khronos-egl", "libc", - "libloading 0.8.1", + "libloading 0.8.3", "log", "metal", "naga 0.13.0", @@ -7545,7 +7607,7 @@ dependencies = [ "raw-window-handle", "renderdoc-sys", "rustc-hash", - "smallvec 1.13.1", + "smallvec 1.13.2", "thiserror", "wasm-bindgen", "web-sys", @@ -7559,7 +7621,7 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee64d7398d0c2f9ca48922c902ef69c42d000c759f3db41e355f4a570b052b67" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "js-sys", "serde", "web-sys", @@ -7567,11 +7629,14 @@ dependencies = [ [[package]] name = "which" -version = "3.1.1" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" dependencies = [ - "libc", + "either", + "home", + "once_cell", + "rustix", ] [[package]] @@ -7644,15 +7709,6 @@ dependencies = [ "windows-targets 0.42.2", ] -[[package]] -name = "windows" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdacb41e6a96a052c6cb63a144f24900236121c6f63f4f8219fef5977ecb0c25" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows" version = "0.48.0" @@ -7666,12 +7722,12 @@ dependencies = [ [[package]] name = "windows" -version = "0.52.0" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" dependencies = [ - "windows-core", - "windows-targets 0.52.0", + "windows-core 0.54.0", + "windows-targets 0.52.4", ] [[package]] @@ -7680,7 +7736,17 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", +] + +[[package]] +name = "windows-core" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +dependencies = [ + "windows-result", + "windows-targets 0.52.4", ] [[package]] @@ -7689,7 +7755,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", "syn 1.0.109", ] @@ -7700,11 +7766,20 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", "syn 1.0.109", ] +[[package]] +name = "windows-result" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd19df78e5168dfb0aedc343d1d1b8d422ab2db6756d2dc3fef75035402a3f64" +dependencies = [ + "windows-targets 0.52.4", +] + [[package]] name = "windows-sys" version = "0.45.0" @@ -7729,7 +7804,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -7764,17 +7839,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] @@ -7791,9 +7866,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" @@ -7809,9 +7884,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" @@ -7827,9 +7902,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" @@ -7845,9 +7920,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" @@ -7863,9 +7938,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" @@ -7881,9 +7956,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" @@ -7899,9 +7974,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "winit" @@ -7918,7 +7993,7 @@ dependencies = [ "instant", "libc", "log", - "mio 0.8.10", + "mio 0.8.11", "ndk 0.7.0", "objc2", "once_cell", @@ -7940,9 +8015,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.5.36" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "818ce546a11a9986bc24f93d0cdf38a8a1a400f1473ea8c82e59f6e0ffab9249" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] @@ -8026,7 +8101,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d498dbd1fd7beb83c86709ae1c33ca50942889473473d287d56ce4770a18edfb" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "syn 1.0.109", "synstructure", ] @@ -8037,9 +8112,9 @@ version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ - "proc-macro2 1.0.78", + "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.53", ] [[package]] diff --git a/bevy_nannou/src/main.rs b/bevy_nannou/src/main.rs index 22272fb34..36e77b18d 100644 --- a/bevy_nannou/src/main.rs +++ b/bevy_nannou/src/main.rs @@ -1,8 +1,11 @@ +use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomPrefilterSettings, BloomSettings}; use bevy::core_pipeline::clear_color::ClearColorConfig; +use bevy::core_pipeline::tonemapping::Tonemapping; use bevy::prelude::shape::Torus; use bevy::prelude::*; use bevy_nannou::NannouPlugin; use bevy_nannou_draw::color::{RED, SALMON, SEAGREEN, SEASHELL, SKYBLUE}; +use bevy_nannou_render::NannouMesh; pub fn main() { App::new() @@ -21,6 +24,40 @@ fn startup(mut commands: Commands, assets: Res, mut meshes: ResMut< color: Color::WHITE, brightness: 1.0, }); + + commands.spawn(PointLightBundle { + point_light: PointLight { + shadows_enabled: true, + intensity: 10_000_000_000., + range: 100.0, + ..default() + }, + transform: Transform::from_xyz(0.0, 500.0, 100.0), + ..default() + }); + // + // commands.spawn(DirectionalLightBundle { + // directional_light: DirectionalLight { + // color: Color::rgb(1.0, 0.00, 0.00), + // shadows_enabled: true, + // ..default() + // }, + // transform: Transform::from_xyz(100.0, 50.0, 100.0) + // .looking_at(Vec3::new(-0.15, -0.05, 0.25), Vec3::Y), + // ..default() + // }); + // + // commands.spawn(DirectionalLightBundle { + // directional_light: DirectionalLight { + // color: Color::rgb(0.0, 0.00, 1.00), + // shadows_enabled: true, + // ..default() + // }, + // transform: Transform::from_xyz(-100.0, -50.0, 100.0) + // .looking_at(Vec3::new(-0.15, -0.05, 0.25), Vec3::Y), + // ..default() + // }); + commands.spawn(PbrBundle { mesh: meshes.add(Mesh::from(Torus { radius: 100.0, @@ -30,10 +67,10 @@ fn startup(mut commands: Commands, assets: Res, mut meshes: ResMut< ..default() }); - commands.spawn( - (Camera3dBundle { + commands.spawn(( + Camera3dBundle { camera: Camera { - hdr: false, + hdr: true, ..Default::default() }, camera_3d: Camera3d { @@ -42,20 +79,32 @@ fn startup(mut commands: Commands, assets: Res, mut meshes: ResMut< ..Default::default() }, transform: Transform::from_xyz(0.0, 0.0, -10.0).looking_at(Vec3::ZERO, Vec3::Z), + tonemapping: Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended projection: OrthographicProjection { scale: 1.0, ..Default::default() } .into(), ..Default::default() - }), - ); + }, + BloomSettings { + intensity: 0.09, + low_frequency_boost: 0.7, + low_frequency_boost_curvature: 0.95, + high_pass_frequency: 1.0, + prefilter_settings: BloomPrefilterSettings { + threshold: 0.1, + threshold_softness: 0.4, + }, + composite_mode: BloomCompositeMode::Additive, + }, + )); let handle = assets.load("images/nannou.png"); commands.insert_resource(MyTexture(handle)); } -fn update_mesh(mut handles: Query<(&Handle, &mut Transform)>) { +fn update_mesh(mut handles: Query<(&Handle, &mut Transform), Without>) { for (_, mut transform) in handles.iter_mut() { transform.translation.x += 1.0; transform.translation.y += 1.0; @@ -79,10 +128,13 @@ fn update_draw( // TODO: why is the texture rotated? // draw.texture(texture_handle.clone(), texture.clone()); - draw.ellipse().w_h(100.0, 100.0).color(SALMON); + draw.ellipse().w_h(100.0, 100.0).color(Color::SALMON); draw.ellipse() .x(100.0 + time.elapsed().as_millis() as f32 / 100.0) .w_h(100.0, 100.0) - .color(SEASHELL); - draw.ellipse().x(-100.0).w_h(100.0, 100.0).color(SKYBLUE); + .color(Color::SEA_GREEN); + draw.ellipse() + .x(-100.0) + .w_h(100.0, 100.0) + .color(Color::BISQUE); } diff --git a/bevy_nannou_draw/src/draw/background.rs b/bevy_nannou_draw/src/draw/background.rs index 99c1f3de6..7c5ece20e 100644 --- a/bevy_nannou_draw/src/draw/background.rs +++ b/bevy_nannou_draw/src/draw/background.rs @@ -1,6 +1,6 @@ -use crate::draw::properties::ColorScalar; use crate::draw::Draw; -use nannou_core::color::{self, IntoLinSrgba, Srgb, Srgba}; +use bevy::prelude::Color; +use nannou_core::color::{self, IntoColor, Srgb, Srgba}; /// A type used to update the background colour. pub struct Background<'a> { @@ -20,22 +20,22 @@ impl<'a> Background<'a> { /// Colors that have no alpha channel will be given an opaque alpha channel value `1.0`. pub fn color(self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { if let Ok(mut state) = self.draw.state.try_write() { - state.background_color = Some(color.into_lin_srgba()); + state.background_color = Some(color.into()); } self } /// Specify the color via red, green and blue channels. - pub fn rgb(self, r: ColorScalar, g: ColorScalar, b: ColorScalar) -> Self { - self.color(Srgb::new(r, g, b)) + pub fn rgb(self, r: f32, g: f32, b: f32) -> Self { + self.color(Color::rgb(r, g, b)) } /// Specify the color via red, green, blue and alpha channels. - pub fn rgba(self, r: ColorScalar, g: ColorScalar, b: ColorScalar, a: ColorScalar) -> Self { - self.color(Srgba::new(r, g, b, a)) + pub fn rgba(self, r: f32, g: f32, b: f32, a: f32) -> Self { + self.color(Color::rgba(r, g, b, a)) } /// Specify the color via hue, saturation and luminance. @@ -47,9 +47,9 @@ impl<'a> Background<'a> { /// /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on /// this color space. - pub fn hsl(self, h: ColorScalar, s: ColorScalar, l: ColorScalar) -> Self { + pub fn hsl(self, h: f32, s: f32, l: f32) -> Self { let hue = h * 360.0; - self.color(color::Hsl::new(hue, s, l)) + self.color(Color::hsl(hue, s, l)) } /// Specify the color via hue, saturation, luminance and an alpha channel. @@ -61,36 +61,36 @@ impl<'a> Background<'a> { /// /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on /// this color space. - pub fn hsla(self, h: ColorScalar, s: ColorScalar, l: ColorScalar, a: ColorScalar) -> Self { + pub fn hsla(self, h: f32, s: f32, l: f32, a: f32) -> Self { let hue = h * 360.0; - self.color(color::Hsla::new(hue, s, l, a)) + self.color(Color::hsla(hue, s, l, a)) } - /// Specify the color via hue, saturation and *value* (brightness). - /// - /// This is sometimes also known as "hsb". - /// - /// The given hue expects a value between `0.0` and `1.0` where `0.0` is 0 degress and `1.0` is - /// 360 degrees (or 2 PI radians). - /// - /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on - /// this color space. - pub fn hsv(self, h: ColorScalar, s: ColorScalar, v: ColorScalar) -> Self { - let hue = h * 360.0; - self.color(color::Hsv::new(hue, s, v)) - } - - /// Specify the color via hue, saturation, *value* (brightness) and an alpha channel. - /// - /// This is sometimes also known as "hsba". - /// - /// The given hue expects a value between `0.0` and `1.0` where `0.0` is 0 degress and `1.0` is - /// 360 degrees (or 2 PI radians). - /// - /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on - /// this color space. - pub fn hsva(self, h: ColorScalar, s: ColorScalar, v: ColorScalar, a: ColorScalar) -> Self { - let hue = h * 360.0; - self.color(color::Hsva::new(hue, s, v, a)) - } + // /// Specify the color via hue, saturation and *value* (brightness). + // /// + // /// This is sometimes also known as "hsb". + // /// + // /// The given hue expects a value between `0.0` and `1.0` where `0.0` is 0 degress and `1.0` is + // /// 360 degrees (or 2 PI radians). + // /// + // /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on + // /// this color space. + // pub fn hsv(self, h: f32, s: f32, v: f32) -> Self { + // let hue = h * 360.0; + // self.color(color::Hsv::new(hue, s, v)) + // } + // + // /// Specify the color via hue, saturation, *value* (brightness) and an alpha channel. + // /// + // /// This is sometimes also known as "hsba". + // /// + // /// The given hue expects a value between `0.0` and `1.0` where `0.0` is 0 degress and `1.0` is + // /// 360 degrees (or 2 PI radians). + // /// + // /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on + // /// this color space. + // pub fn hsva(self, h: f32, s: f32, v: f32, a: f32) -> Self { + // let hue = h * 360.0; + // self.color(color::Hsva::new(hue, s, v, a)) + // } } diff --git a/bevy_nannou_draw/src/draw/drawing.rs b/bevy_nannou_draw/src/draw/drawing.rs index c273f5a4d..75a2b8df6 100644 --- a/bevy_nannou_draw/src/draw/drawing.rs +++ b/bevy_nannou_draw/src/draw/drawing.rs @@ -1,13 +1,12 @@ -use crate::draw::mesh::vertex::{Color, TexCoords}; use crate::draw::primitive::Primitive; use crate::draw::properties::{ - ColorScalar, SetColor, SetDimensions, SetFill, SetOrientation, SetPosition, SetStroke, + SetColor, SetDimensions, SetFill, SetOrientation, SetPosition, SetStroke, }; use crate::draw::{self, Draw}; use bevy::prelude::*; use lyon::path::PathEvent; use lyon::tessellation::{FillOptions, LineCap, LineJoin, StrokeOptions}; -use nannou_core::color::IntoLinSrgba; +use nannou_core::color::IntoColor; use std::marker::PhantomData; /// A **Drawing** in progress. @@ -37,13 +36,13 @@ pub struct Drawing<'a, T> { /// This is particularly useful for paths and meshes. pub struct DrawingContext<'a> { /// The intermediary mesh for buffering yet-to-be-drawn paths and meshes. - pub mesh: &'a mut draw::Mesh, + pub mesh: &'a mut Mesh, /// A re-usable buffer for collecting path events. pub path_event_buffer: &'a mut Vec, /// A re-usable buffer for collecting colored polyline points. pub path_points_colored_buffer: &'a mut Vec<(Vec2, Color)>, /// A re-usable buffer for collecting textured polyline points. - pub path_points_textured_buffer: &'a mut Vec<(Vec2, TexCoords)>, + pub path_points_textured_buffer: &'a mut Vec<(Vec2, Vec2)>, /// A re-usable buffer for collecting text. pub text_buffer: &'a mut String, } @@ -205,7 +204,7 @@ impl<'a, T> Drawing<'a, T> { impl<'a, T> Drawing<'a, T> where - T: SetColor + Into, + T: SetColor + Into, Primitive: Into>, { /// Specify a color. @@ -215,13 +214,13 @@ where /// Colors that have no alpha channel will be given an opaque alpha channel value `1.0`. pub fn color(self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { self.map_ty(|ty| SetColor::color(ty, color)) } /// Specify the color via red, green and blue channels. - pub fn rgb(self, r: ColorScalar, g: ColorScalar, b: ColorScalar) -> Self { + pub fn rgb(self, r: f32, g: f32, b: f32) -> Self { self.map_ty(|ty| SetColor::rgb(ty, r, g, b)) } @@ -231,7 +230,7 @@ where } /// Specify the color via red, green, blue and alpha channels. - pub fn rgba(self, r: ColorScalar, g: ColorScalar, b: ColorScalar, a: ColorScalar) -> Self { + pub fn rgba(self, r: f32, g: f32, b: f32, a: f32) -> Self { self.map_ty(|ty| SetColor::rgba(ty, r, g, b, a)) } @@ -249,7 +248,7 @@ where /// /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on /// this color space. - pub fn hsl(self, h: ColorScalar, s: ColorScalar, l: ColorScalar) -> Self { + pub fn hsl(self, h: f32, s: f32, l: f32) -> Self { self.map_ty(|ty| SetColor::hsl(ty, h, s, l)) } @@ -262,40 +261,40 @@ where /// /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on /// this color space. - pub fn hsla(self, h: ColorScalar, s: ColorScalar, l: ColorScalar, a: ColorScalar) -> Self { + pub fn hsla(self, h: f32, s: f32, l: f32, a: f32) -> Self { self.map_ty(|ty| SetColor::hsla(ty, h, s, l, a)) } - /// Specify the color via hue, saturation and *value* (brightness). - /// - /// This is sometimes also known as "hsb". - /// - /// The given hue expects a value between `0.0` and `1.0` where `0.0` is 0 degress and `1.0` is - /// 360 degrees (or 2 PI radians). - /// - /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on - /// this color space. - pub fn hsv(self, h: ColorScalar, s: ColorScalar, v: ColorScalar) -> Self { - self.map_ty(|ty| SetColor::hsv(ty, h, s, v)) - } - - /// Specify the color via hue, saturation, *value* (brightness) and an alpha channel. - /// - /// This is sometimes also known as "hsba". - /// - /// The given hue expects a value between `0.0` and `1.0` where `0.0` is 0 degress and `1.0` is - /// 360 degrees (or 2 PI radians). - /// - /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on - /// this color space. - pub fn hsva(self, h: ColorScalar, s: ColorScalar, v: ColorScalar, a: ColorScalar) -> Self { - self.map_ty(|ty| SetColor::hsva(ty, h, s, v, a)) - } + // /// Specify the color via hue, saturation and *value* (brightness). + // /// + // /// This is sometimes also known as "hsb". + // /// + // /// The given hue expects a value between `0.0` and `1.0` where `0.0` is 0 degress and `1.0` is + // /// 360 degrees (or 2 PI radians). + // /// + // /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on + // /// this color space. + // pub fn hsv(self, h: f32, s: f32, v: f32) -> Self { + // self.map_ty(|ty| SetColor::hsv(ty, h, s, v)) + // } + // + // /// Specify the color via hue, saturation, *value* (brightness) and an alpha channel. + // /// + // /// This is sometimes also known as "hsba". + // /// + // /// The given hue expects a value between `0.0` and `1.0` where `0.0` is 0 degress and `1.0` is + // /// 360 degrees (or 2 PI radians). + // /// + // /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on + // /// this color space. + // pub fn hsva(self, h: f32, s: f32, v: f32, a: f32) -> Self { + // self.map_ty(|ty| SetColor::hsva(ty, h, s, v, a)) + // } /// Specify the color as gray scale /// /// The given g expects a value between `0.0` and `1.0` where `0.0` is black and `1.0` is white - pub fn gray(self, g: ColorScalar) -> Self { + pub fn gray(self, g: f32) -> Self { self.map_ty(|ty| SetColor::gray(ty, g)) } } diff --git a/bevy_nannou_draw/src/draw/mesh/builder.rs b/bevy_nannou_draw/src/draw/mesh/builder.rs index 8e3233548..d70c7b607 100644 --- a/bevy_nannou_draw/src/draw/mesh/builder.rs +++ b/bevy_nannou_draw/src/draw/mesh/builder.rs @@ -11,12 +11,14 @@ use lyon::tessellation::geometry_builder::{ }; use lyon::tessellation::{FillVertex, GeometryBuilderError, StrokeVertex, VertexId}; +use crate::draw::mesh::MeshExt; use bevy::prelude::*; -use nannou_mesh::{Indices, Points, PushIndex, PushVertex}; +use bevy::render::mesh::Indices; +use bevy::render::render_resource::encase::private::RuntimeSizedArray; pub struct MeshBuilder<'a, A> { /// The mesh that is to be extended. - mesh: &'a mut crate::draw::mesh::Mesh, + mesh: &'a mut Mesh, /// The number of vertices in the mesh when begin was called. begin_vertex_count: u32, /// The number of indices in the mesh when begin was called. @@ -27,13 +29,13 @@ pub struct MeshBuilder<'a, A> { attributes: A, } -pub struct SingleColor(crate::draw::mesh::vertex::Color); +pub struct SingleColor(Color); pub struct ColorPerPoint; pub struct TexCoordsPerPoint; impl<'a, A> MeshBuilder<'a, A> { /// Begin extending the mesh. - fn new(mesh: &'a mut crate::draw::mesh::Mesh, transform: Mat4, attributes: A) -> Self { + fn new(mesh: &'a mut Mesh, transform: Mat4, attributes: A) -> Self { MeshBuilder { mesh, begin_vertex_count: 0, @@ -46,46 +48,54 @@ impl<'a, A> MeshBuilder<'a, A> { impl<'a> MeshBuilder<'a, SingleColor> { /// Begin extending a mesh rendered with a single colour. - pub fn single_color( - mesh: &'a mut crate::draw::mesh::Mesh, - transform: Mat4, - color: crate::draw::mesh::vertex::Color, - ) -> Self { + pub fn single_color(mesh: &'a mut Mesh, transform: Mat4, color: Color) -> Self { Self::new(mesh, transform, SingleColor(color)) } } impl<'a> MeshBuilder<'a, ColorPerPoint> { /// Begin extending a mesh where the path interpolates a unique color per point. - pub fn color_per_point(mesh: &'a mut crate::draw::mesh::Mesh, transform: Mat4) -> Self { + pub fn color_per_point(mesh: &'a mut Mesh, transform: Mat4) -> Self { Self::new(mesh, transform, ColorPerPoint) } } impl<'a> MeshBuilder<'a, TexCoordsPerPoint> { /// Begin extending a mesh where the path interpolates a unique texture coordinates per point. - pub fn tex_coords_per_point(mesh: &'a mut crate::draw::mesh::Mesh, transform: Mat4) -> Self { + pub fn tex_coords_per_point(mesh: &'a mut Mesh, transform: Mat4) -> Self { Self::new(mesh, transform, TexCoordsPerPoint) } } impl<'a, A> GeometryBuilder for MeshBuilder<'a, A> { fn begin_geometry(&mut self) { - self.begin_vertex_count = self.mesh.points().len() as u32; - self.begin_index_count = self.mesh.indices().len() as u32; + self.begin_vertex_count = self.mesh.count_vertices() as u32; + self.begin_index_count = self.mesh.count_indices() as u32; } fn end_geometry(&mut self) -> geometry_builder::Count { geometry_builder::Count { - vertices: self.mesh.points().len() as u32 - self.begin_vertex_count, - indices: self.mesh.indices().len() as u32 - self.begin_index_count, + vertices: self.mesh.count_vertices() as u32 - self.begin_vertex_count, + indices: self.mesh.count_indices() as u32 - self.begin_index_count, } } fn add_triangle(&mut self, a: VertexId, b: VertexId, c: VertexId) { - self.mesh.push_index(a.to_usize() as u32); - self.mesh.push_index(b.to_usize() as u32); - self.mesh.push_index(c.to_usize() as u32); + let indices = self.mesh.indices_mut(); + if let Some(indices) = indices { + match indices { + Indices::U16(indices) => { + indices.push(a.to_usize() as u16); + indices.push(b.to_usize() as u16); + indices.push(c.to_usize() as u16); + } + Indices::U32(indices) => { + indices.push(a.to_usize() as u32); + indices.push(b.to_usize() as u32); + indices.push(c.to_usize() as u32); + } + } + } } fn abort_geometry(&mut self) { @@ -96,7 +106,7 @@ impl<'a, A> GeometryBuilder for MeshBuilder<'a, A> { impl<'a> FillGeometryBuilder for MeshBuilder<'a, SingleColor> { fn add_fill_vertex(&mut self, vertex: FillVertex) -> Result { // Retrieve the index. - let id = VertexId::from_usize(self.mesh.points().len()); + let id = VertexId::from_usize(self.mesh.count_vertices()); let position = vertex.position(); @@ -104,9 +114,11 @@ impl<'a> FillGeometryBuilder for MeshBuilder<'a, SingleColor> { let p = Vec2::new(position.x, position.y).extend(0.0); let point = self.transform.transform_point3(p); let SingleColor(color) = self.attributes; - let tex_coords = crate::draw::mesh::vertex::default_tex_coords(); - let vertex = crate::draw::mesh::vertex::new(point, color, tex_coords); - self.mesh.push_vertex(vertex); + let tex_coords = Vec2::ZERO; + + self.mesh.points_mut().push(point.to_array()); + self.mesh.colors_mut().push(color.as_linear_rgba_f32()); + self.mesh.tex_coords_mut().push(tex_coords.to_array()); // Return the index. Ok(id) @@ -119,7 +131,7 @@ impl<'a> StrokeGeometryBuilder for MeshBuilder<'a, SingleColor> { vertex: StrokeVertex, ) -> Result { // Retrieve the index. - let id = VertexId::from_usize(self.mesh.points().len()); + let id = VertexId::from_usize(self.mesh.count_vertices()); let position = vertex.position(); @@ -127,9 +139,11 @@ impl<'a> StrokeGeometryBuilder for MeshBuilder<'a, SingleColor> { let p = Vec2::new(position.x, position.y).extend(0.0); let point = self.transform.transform_point3(p); let SingleColor(color) = self.attributes; - let tex_coords = crate::draw::mesh::vertex::default_tex_coords(); - let vertex = crate::draw::mesh::vertex::new(point, color, tex_coords); - self.mesh.push_vertex(vertex); + let tex_coords = Vec2::ZERO; + + self.mesh.points_mut().push(point.to_array()); + self.mesh.colors_mut().push(color.as_linear_rgba_f32()); + self.mesh.tex_coords_mut().push(tex_coords.to_array()); // Return the index. Ok(id) @@ -142,7 +156,7 @@ impl<'a> FillGeometryBuilder for MeshBuilder<'a, ColorPerPoint> { mut vertex: FillVertex, ) -> Result { // Retrieve the index. - let id = VertexId::from_usize(self.mesh.points().len()); + let id = VertexId::from_usize(self.mesh.count_vertices()); let position = vertex.position(); @@ -150,10 +164,12 @@ impl<'a> FillGeometryBuilder for MeshBuilder<'a, ColorPerPoint> { let p = Vec2::new(position.x, position.y).extend(0.0); let point = self.transform.transform_point3(p); let col = vertex.interpolated_attributes(); - let color: crate::draw::mesh::vertex::Color = (col[0], col[1], col[2], col[3]).into(); - let tex_coords = crate::draw::mesh::vertex::default_tex_coords(); - let vertex = crate::draw::mesh::vertex::new(point, color, tex_coords); - self.mesh.push_vertex(vertex); + let color = Vec4::new(col[0], col[1], col[2], col[3]); + let tex_coords = Vec2::ZERO; + + self.mesh.points_mut().push(point.to_array()); + self.mesh.colors_mut().push(color.to_array()); + self.mesh.tex_coords_mut().push(tex_coords.to_array()); // Return the index. Ok(id) @@ -166,7 +182,7 @@ impl<'a> StrokeGeometryBuilder for MeshBuilder<'a, ColorPerPoint> { mut vertex: StrokeVertex, ) -> Result { // Retrieve the index. - let id = VertexId::from_usize(self.mesh.points().len()); + let id = VertexId::from_usize(self.mesh.count_vertices()); let position = vertex.position(); @@ -174,10 +190,12 @@ impl<'a> StrokeGeometryBuilder for MeshBuilder<'a, ColorPerPoint> { let p = Vec2::new(position.x, position.y).extend(0.0); let point = self.transform.transform_point3(p); let col = vertex.interpolated_attributes(); - let color: crate::draw::mesh::vertex::Color = (col[0], col[1], col[2], col[3]).into(); - let tex_coords = crate::draw::mesh::vertex::default_tex_coords(); - let vertex = crate::draw::mesh::vertex::new(point, color, tex_coords); - self.mesh.push_vertex(vertex); + let color = Vec4::new(col[0], col[1], col[2], col[3]); + let tex_coords = Vec2::ZERO; + + self.mesh.points_mut().push(point.to_array()); + self.mesh.colors_mut().push(color.to_array()); + self.mesh.tex_coords_mut().push(tex_coords.to_array()); // Return the index. Ok(id) @@ -190,7 +208,7 @@ impl<'a> FillGeometryBuilder for MeshBuilder<'a, TexCoordsPerPoint> { mut vertex: FillVertex, ) -> Result { // Retrieve the index. - let id = VertexId::from_usize(self.mesh.points().len()); + let id = VertexId::from_usize(self.mesh.count_vertices()); let position = vertex.position(); @@ -198,10 +216,12 @@ impl<'a> FillGeometryBuilder for MeshBuilder<'a, TexCoordsPerPoint> { let p = Vec2::new(position.x, position.y).extend(0.0); let point = self.transform.transform_point3(p); let tc = vertex.interpolated_attributes(); - let tex_coords: crate::draw::mesh::vertex::TexCoords = (tc[0], tc[1]).into(); - let color = crate::draw::mesh::vertex::DEFAULT_VERTEX_COLOR; - let vertex = crate::draw::mesh::vertex::new(point, color, tex_coords); - self.mesh.push_vertex(vertex); + let tex_coords = Vec2::new(tc[0], tc[1]); + let color = Color::default(); + + self.mesh.points_mut().push(point.to_array()); + self.mesh.colors_mut().push(color.as_linear_rgba_f32()); + self.mesh.tex_coords_mut().push(tex_coords.to_array()); // Return the index. Ok(id) @@ -214,7 +234,7 @@ impl<'a> StrokeGeometryBuilder for MeshBuilder<'a, TexCoordsPerPoint> { mut vertex: StrokeVertex, ) -> Result { // Retrieve the index. - let id = VertexId::from_usize(self.mesh.points().len()); + let id = VertexId::from_usize(self.mesh.count_vertices()); let position = vertex.position(); @@ -222,10 +242,12 @@ impl<'a> StrokeGeometryBuilder for MeshBuilder<'a, TexCoordsPerPoint> { let p = Vec2::new(position.x, position.y).extend(0.0); let point = self.transform.transform_point3(p); let tc = vertex.interpolated_attributes(); - let tex_coords: crate::draw::mesh::vertex::TexCoords = (tc[0], tc[1]).into(); - let color = crate::draw::mesh::vertex::DEFAULT_VERTEX_COLOR; - let vertex = crate::draw::mesh::vertex::new(point, color, tex_coords); - self.mesh.push_vertex(vertex); + let tex_coords = Vec2::new(tc[0], tc[1]); + let color = Color::default(); + + self.mesh.points_mut().push(point.to_array()); + self.mesh.colors_mut().push(color.as_linear_rgba_f32()); + self.mesh.tex_coords_mut().push(tex_coords.to_array()); // Return the index. Ok(id) diff --git a/bevy_nannou_draw/src/draw/mesh/mod.rs b/bevy_nannou_draw/src/draw/mesh/mod.rs index a8d71d4f8..a6d8e7b6a 100644 --- a/bevy_nannou_draw/src/draw/mesh/mod.rs +++ b/bevy_nannou_draw/src/draw/mesh/mod.rs @@ -1,281 +1,130 @@ //! Items related to the custom mesh type used by the `Draw` API. use bevy::prelude::*; -use bevy::render::extract_component::ExtractComponent; -use nannou_mesh as mesh; -use nannou_mesh::{self, MeshPoints, WithColors, WithIndices, WithTexCoords}; +use bevy::render::mesh::{Indices, PrimitiveTopology, VertexAttributeValues}; +use nannou_mesh::{ClearIndices, ClearVertices}; use std::ops::{Deref, DerefMut}; pub mod builder; -pub mod vertex; pub use self::builder::MeshBuilder; -pub use self::vertex::Vertex; -pub type Points = Vec; -pub type Indices = Vec; -pub type Colors = Vec; -pub type TexCoords = Vec; - -/// The inner mesh type used by the **draw::Mesh**. -pub type MeshType = - WithTexCoords, Indices>, Colors>, TexCoords>; - -/// The custom mesh type used internally by the **Draw** API. -#[derive(Clone, Debug)] -pub struct Mesh { - mesh: MeshType, +pub trait MeshExt { + fn init() -> Mesh; + fn init_with_topology(topology: PrimitiveTopology) -> Mesh; + fn clear(&mut self); + fn points(&self) -> &[[f32; 3]]; + fn points_mut(&mut self) -> &mut Vec<[f32; 3]>; + fn colors(&self) -> &[[f32; 4]]; + fn colors_mut(&mut self) -> &mut Vec<[f32; 4]>; + fn tex_coords(&self) -> &[[f32; 2]]; + fn tex_coords_mut(&mut self) -> &mut Vec<[f32; 2]>; + fn get_index(&self, index: usize) -> u32; + fn count_indices(&self) -> usize; + fn push_index(&mut self, index: u32); } -impl Mesh { - /// The number of raw vertices contained within the mesh. - pub fn raw_vertex_count(&self) -> usize { - mesh::raw_vertex_count(self) - } - - /// The number of vertices that would be yielded by a **Vertices** iterator for the given mesh. - pub fn vertex_count(&self) -> usize { - mesh::vertex_count(self) - } - - /// The number of triangles that would be yielded by a **Triangles** iterator for the given mesh. - pub fn triangle_count(&self) -> usize { - mesh::triangle_count(self) - } - - /// The **Mesh**'s vertex position channel. - pub fn points(&self) -> &[vertex::Point] { - mesh::Points::points(self) +impl MeshExt for Mesh { + fn init() -> Mesh { + Self::init_with_topology(PrimitiveTopology::TriangleList) } - /// The **Mesh**'s vertex indices channel. - pub fn indices(&self) -> &[u32] { - mesh::Indices::indices(self) + fn init_with_topology(topology: PrimitiveTopology) -> Mesh { + let mesh = Mesh::new(topology); + mesh.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, Vec::<[f32; 3]>::new()) + .with_inserted_attribute(Mesh::ATTRIBUTE_COLOR, Vec::<[f32; 4]>::new()) + .with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, Vec::<[f32; 2]>::new()) + .with_indices(Some(Indices::U32(vec![]))) } - /// The **Mesh**'s vertex colors channel. - pub fn colors(&self) -> &[vertex::Color] { - mesh::Colors::colors(self) + fn clear(&mut self) { + *self = Self::init(); } - /// The **Mesh**'s vertex texture coordinates channel. - pub fn tex_coords(&self) -> &[vertex::TexCoords] { - mesh::TexCoords::tex_coords(self) - } - - /// Push the given vertex onto the inner channels. - pub fn push_vertex(&mut self, v: Vertex) { - mesh::push_vertex(self, v); - } + fn points(&self) -> &[[f32; 3]] { + let points = self + .attribute(Mesh::ATTRIBUTE_POSITION) + .expect("Mesh must have ATTRIBUTE_POSITION attribute"); - /// Push the given index onto the inner **Indices** channel. - pub fn push_index(&mut self, i: u32) { - mesh::push_index(self, i); + match points { + VertexAttributeValues::Float32x3(points) => points, + _ => panic!("Mesh ATTRIBUTE_POSITION attribute must be of type Float32x3"), + } } - /// Extend the mesh channels with the given vertices. - pub fn extend_vertices(&mut self, vs: I) - where - I: IntoIterator, - { - mesh::extend_vertices(self, vs); - } + fn points_mut(&mut self) -> &mut Vec<[f32; 3]> { + let points = self + .attribute_mut(Mesh::ATTRIBUTE_POSITION) + .expect("Mesh must have ATTRIBUTE_POSITION attribute"); - /// Extend the **Mesh** indices channel with the given indices. - pub fn extend_indices(&mut self, is: I) - where - I: IntoIterator, - { - mesh::extend_indices(self, is); + match points { + VertexAttributeValues::Float32x3(points) => points, + _ => panic!("Mesh ATTRIBUTE_POSITION attribute must be of type Float32x3"), + } } - /// Extend the **Mesh** with the given vertices and indices. - pub fn extend(&mut self, vs: V, is: I) - where - V: IntoIterator, - I: IntoIterator, - { - self.extend_vertices(vs); - self.extend_indices(is); - } + fn colors(&self) -> &[[f32; 4]] { + let colors = self + .attribute(Mesh::ATTRIBUTE_COLOR) + .expect("Mesh must have ATTRIBUTE_COLOR attribute"); - /// Clear all vertices from the mesh. - pub fn clear_vertices(&mut self) { - mesh::clear_vertices(self); + match colors { + VertexAttributeValues::Float32x4(colors) => colors, + _ => panic!("Mesh ATTRIBUTE_COLOR attribute must be of type Float32x4"), + } } - /// Clear all indices from the mesh. - pub fn clear_indices(&mut self) { - mesh::clear_indices(self); - } + fn colors_mut(&mut self) -> &mut Vec<[f32; 4]> { + let colors = self + .attribute_mut(Mesh::ATTRIBUTE_COLOR) + .expect("Mesh must have ATTRIBUTE_COLOR attribute"); - /// Clear all vertices and indices from the mesh. - pub fn clear(&mut self) { - mesh::clear(self); + match colors { + VertexAttributeValues::Float32x4(colors) => colors, + _ => panic!("Mesh ATTRIBUTE_COLOR attribute must be of type Float32x4"), + } } - /// Produce an iterator yielding all raw (non-index-order) vertices. - pub fn raw_vertices(&self) -> mesh::RawVertices<&Self> { - mesh::raw_vertices(self) - } + fn tex_coords(&self) -> &[[f32; 2]] { + let tex_coords = self + .attribute(Mesh::ATTRIBUTE_UV_0) + .expect("Mesh must have ATTRIBUTE_UV_0 attribute"); - /// Consume self and produce an iterator yielding all raw (non-index_order) vertices. - pub fn into_raw_vertices(self) -> mesh::RawVertices { - mesh::raw_vertices(self) + match tex_coords { + VertexAttributeValues::Float32x2(tex_coords) => tex_coords, + _ => panic!("Mesh ATTRIBUTE_UV_0 attribute must be of type Float32x2"), + } } - /// Extend the mesh from the given slices. - /// - /// This is faster than `extend` which uses iteration internally. - /// - /// **Panic!**s if the length of the given points, colors and tex_coords slices do not match. - pub fn extend_from_slices( - &mut self, - points: &[vertex::Point], - indices: &[u32], - colors: &[vertex::Color], - tex_coords: &[vertex::TexCoords], - ) { - assert_eq!(points.len(), colors.len()); - assert_eq!(points.len(), tex_coords.len()); - let slices = (tex_coords, (colors, (indices, points))); - mesh::ExtendFromSlice::extend_from_slice(&mut self.mesh, slices); - } + fn tex_coords_mut(&mut self) -> &mut Vec<[f32; 2]> { + let tex_coords = self + .attribute_mut(Mesh::ATTRIBUTE_UV_0) + .expect("Mesh must have ATTRIBUTE_UV_0 attribute"); - /// Extend the mesh with the given slices of vertices. - pub fn extend_vertices_from_slices( - &mut self, - points: &[vertex::Point], - colors: &[vertex::Color], - tex_coords: &[vertex::TexCoords], - ) { - self.extend_from_slices(points, &[], colors, tex_coords); + match tex_coords { + VertexAttributeValues::Float32x2(tex_coords) => tex_coords, + _ => panic!("Mesh ATTRIBUTE_UV_0 attribute must be of type Float32x2"), + } } - /// Extend the mesh with the given slices of vertices. - pub fn extend_indices_from_slice(&mut self, indices: &[u32]) { - self.extend_from_slices(&[], indices, &[], &[]); + fn get_index(&self, index: usize) -> u32 { + match self.indices() { + Some(Indices::U32(indices)) => indices[index], + _ => panic!("Mesh must have U32 indices"), + } } - /// Produce an iterator yielding all vertices in the order specified via the vertex indices. - pub fn vertices(&self) -> mesh::Vertices<&Self> { - mesh::vertices(self) + fn count_indices(&self) -> usize { + match self.indices() { + Some(Indices::U32(indices)) => indices.len(), + _ => panic!("Mesh must have U32 indices"), + } } - /// Produce an iterator yielding all triangles. - pub fn triangles(&self) -> mesh::Triangles<&Self> { - mesh::triangles(self) + fn push_index(&mut self, index: u32) { + match self.indices_mut() { + Some(Indices::U32(indices)) => indices.push(index), + _ => panic!("Mesh must have U32 indices"), + } } - - /// Consume self and produce an iterator yielding all vertices in index-order. - pub fn into_vertices(self) -> mesh::Vertices { - mesh::vertices(self) - } - - /// Consume self and produce an iterator yielding all triangles. - pub fn into_triangles(self) -> mesh::Triangles { - mesh::triangles(self) - } -} - -impl Default for Mesh { - fn default() -> Self { - let mesh = Default::default(); - Mesh { mesh } - } -} - -impl Deref for Mesh { - type Target = MeshType; - fn deref(&self) -> &Self::Target { - &self.mesh - } -} - -impl DerefMut for Mesh { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.mesh - } -} - -impl mesh::GetVertex for Mesh { - type Vertex = Vertex; - fn get_vertex(&self, index: u32) -> Option { - mesh::WithTexCoords::get_vertex(&self.mesh, index) - } -} - -impl mesh::Points for Mesh { - type Point = vertex::Point; - type Points = Points; - fn points(&self) -> &Self::Points { - self.mesh.points() - } -} - -impl mesh::Indices for Mesh { - type Index = u32; - type Indices = Indices; - fn indices(&self) -> &Self::Indices { - self.mesh.indices() - } -} - -impl mesh::Colors for Mesh { - type Color = vertex::Color; - type Colors = Colors; - fn colors(&self) -> &Self::Colors { - self.mesh.colors() - } -} - -impl mesh::TexCoords for Mesh { - type TexCoord = Vec2; - type TexCoords = TexCoords; - fn tex_coords(&self) -> &Self::TexCoords { - self.mesh.tex_coords() - } -} - -impl mesh::PushVertex for Mesh { - fn push_vertex(&mut self, v: Vertex) { - self.mesh.push_vertex(v); - } -} - -impl mesh::PushIndex for Mesh { - type Index = u32; - - fn push_index(&mut self, index: Self::Index) { - self.mesh.push_index(index); - } - - fn extend_indices(&mut self, indices: I) - where - I: IntoIterator, - { - self.mesh.extend_indices(indices); - } -} - -impl mesh::ClearIndices for Mesh { - fn clear_indices(&mut self) { - self.mesh.clear_indices(); - } -} - -impl mesh::ClearVertices for Mesh { - fn clear_vertices(&mut self) { - self.mesh.clear_vertices(); - } -} - -#[test] -fn test_method_access() { - let mesh: Mesh = Default::default(); - assert_eq!(None, mesh::GetVertex::get_vertex(&mesh, 0)); - mesh::Points::points(&mesh); - mesh::Indices::indices(&mesh); - mesh::Colors::colors(&mesh); - mesh::TexCoords::tex_coords(&mesh); } diff --git a/bevy_nannou_draw/src/draw/mesh/vertex.rs b/bevy_nannou_draw/src/draw/mesh/vertex.rs deleted file mode 100644 index add835ba6..000000000 --- a/bevy_nannou_draw/src/draw/mesh/vertex.rs +++ /dev/null @@ -1,177 +0,0 @@ -use bevy::prelude::*; -use nannou_core::color; -use nannou_mesh::vertex::{WithColor, WithTexCoords}; - -pub type Point = Vec3; -pub type Color = color::LinSrgba; -pub type TexCoords = Vec2; -pub type Normal = Vec3; -pub type ColoredPoint = WithColor; -pub type ColoredVec2 = WithColor; - -/// The vertex type produced by the **draw::Mesh**'s inner **MeshType**. -pub type Vertex = WithTexCoords, TexCoords>; - -/// The number of channels in the color type. -pub const COLOR_CHANNEL_COUNT: usize = 4; - -pub const DEFAULT_VERTEX_COLOR: Color = color::Alpha { - color: color::rgb::Rgb { - red: 1.0, - green: 1.0, - blue: 1.0, - standard: std::marker::PhantomData, - }, - alpha: 1.0, -}; - -/// Simplified constructor for a **draw::mesh::Vertex**. -pub fn new(point: Point, color: Color, tex_coords: TexCoords) -> Vertex { - WithTexCoords { - tex_coords, - vertex: WithColor { - color, - vertex: point, - }, - } -} - -/// Default texture coordinates, for the case where a type is not textured. -pub fn default_tex_coords() -> TexCoords { - [0.0; 2].into() -} - -/// A type that converts an iterator yielding colored points to an iterator yielding **Vertex**s. -/// -/// Default values are used for tex_coords. -#[derive(Clone, Debug)] -pub struct IterFromColoredPoints { - colored_points: I, -} - -impl IterFromColoredPoints { - /// Produce an iterator that converts an iterator yielding colored points to an iterator - /// yielding **Vertex**s. - /// - /// The default value of `(0.0, 0.0)` is used for tex_coords. - pub fn new

(colored_points: P) -> Self - where - P: IntoIterator>, - I: Iterator>, - { - let colored_points = colored_points.into_iter(); - IterFromColoredPoints { colored_points } - } -} - -impl Iterator for IterFromColoredPoints -where - I: Iterator>, -{ - type Item = Vertex; - fn next(&mut self) -> Option { - self.colored_points.next().map(|vertex| { - let tex_coords = default_tex_coords(); - let vertex = WithTexCoords { tex_coords, vertex }; - vertex - }) - } -} - -/// A type that converts an iterator yielding points to an iterator yielding **Vertex**s. -/// -/// The given `default_color` is used to color every vertex. -/// -/// The default value of `(0.0, 0.0)` is used for tex_coords. -#[derive(Clone, Debug)] -pub struct IterFromPoints { - points: I, - default_color: Color, -} - -/// A type that converts an iterator yielding 2D points to an iterator yielding **Vertex**s. -/// -/// The `z` position for each vertex will be `0.0`. -/// -/// The given `default_color` is used to color every vertex. -/// -/// The default value of `(0.0, 0.0)` is used for tex_coords. -#[derive(Clone, Debug)] -pub struct IterFromVec2s { - points: I, - default_color: Color, -} - -impl IterFromPoints { - /// Produce an iterator that converts an iterator yielding points to an iterator yielding - /// **Vertex**s. - /// - /// The given `default_color` is used to color every vertex. - /// - /// The default value of `(0.0, 0.0)` is used for tex_coords. - pub fn new

(points: P, default_color: Color) -> Self - where - P: IntoIterator, - I: Iterator, - { - let points = points.into_iter(); - IterFromPoints { - points, - default_color, - } - } -} - -impl IterFromVec2s { - /// A type that converts an iterator yielding 2D points to an iterator yielding **Vertex**s. - /// - /// The `z` position for each vertex will be `0.0`. - /// - /// The given `default_color` is used to color every vertex. - /// - /// The default value of `(0.0, 0.0)` is used for tex_coords. - pub fn new

(points: P, default_color: Color) -> Self - where - P: IntoIterator, - I: Iterator, - { - let points = points.into_iter(); - IterFromVec2s { - points, - default_color, - } - } -} - -impl Iterator for IterFromPoints -where - I: Iterator, -{ - type Item = Vertex; - fn next(&mut self) -> Option { - self.points.next().map(|vertex| { - let color = self.default_color; - let vertex = WithColor { vertex, color }; - let tex_coords = default_tex_coords(); - let vertex = WithTexCoords { vertex, tex_coords }; - vertex - }) - } -} - -impl Iterator for IterFromVec2s -where - I: Iterator, -{ - type Item = Vertex; - fn next(&mut self) -> Option { - self.points.next().map(|p| { - let vertex = p.extend(0.0); - let color = self.default_color; - let vertex = WithColor { vertex, color }; - let tex_coords = default_tex_coords(); - let vertex = WithTexCoords { vertex, tex_coords }; - vertex - }) - } -} diff --git a/bevy_nannou_draw/src/draw/mod.rs b/bevy_nannou_draw/src/draw/mod.rs index a8e35f51b..c51440d1e 100644 --- a/bevy_nannou_draw/src/draw/mod.rs +++ b/bevy_nannou_draw/src/draw/mod.rs @@ -8,6 +8,7 @@ use std::mem; use std::rc::Rc; use std::sync::{Arc, RwLock}; +use crate::draw::mesh::MeshExt; use bevy::prelude::*; use bevy::render::render_resource as wgpu; use lyon::path::PathEvent; @@ -16,8 +17,6 @@ use nannou_mesh::Clear; pub use self::background::Background; pub use self::drawing::{Drawing, DrawingContext}; -use self::mesh::vertex::{Color, TexCoords}; -pub use self::mesh::Mesh; use self::primitive::Primitive; pub use self::theme::Theme; @@ -105,7 +104,7 @@ pub struct State { /// The last context used to draw an image, used to detect changes and emit commands for them. last_draw_context: Option, /// If `Some`, the **Draw** should first clear the frame's texture with the given color. - background_color: Option, + background_color: Option, /// Primitives that are in the process of being drawn. /// /// Keys are indices into the `draw_commands` Vec. @@ -124,13 +123,13 @@ pub struct State { #[derive(Clone, Debug)] pub struct IntermediaryState { /// Buffers of vertex data that may be re-used for paths, meshes, etc between view calls. - pub intermediary_mesh: crate::draw::Mesh, + pub intermediary_mesh: Mesh, /// A re-usable buffer for collecting path events. pub path_event_buffer: Vec, /// A re-usable buffer for collecting colored polyline points. pub path_points_colored_buffer: Vec<(Vec2, Color)>, /// A re-usable buffer for collecting textured polyline points. - pub path_points_textured_buffer: Vec<(Vec2, TexCoords)>, + pub path_points_textured_buffer: Vec<(Vec2, Vec2)>, /// A buffer containing all text. pub text_buffer: String, } @@ -612,7 +611,7 @@ impl Draw { impl Default for IntermediaryState { fn default() -> Self { - let intermediary_mesh = Default::default(); + let intermediary_mesh = Mesh::init(); let path_event_buffer = Default::default(); let path_points_colored_buffer = Default::default(); let path_points_textured_buffer = Default::default(); diff --git a/bevy_nannou_draw/src/draw/primitive/arrow.rs b/bevy_nannou_draw/src/draw/primitive/arrow.rs index d4d56273c..e70dc5211 100644 --- a/bevy_nannou_draw/src/draw/primitive/arrow.rs +++ b/bevy_nannou_draw/src/draw/primitive/arrow.rs @@ -2,11 +2,10 @@ use crate::draw::primitive::path; use crate::draw::primitive::Line; use crate::draw::primitive::Primitive; use crate::draw::properties::spatial::{orientation, position}; -use crate::draw::properties::{ColorScalar, SetColor, SetOrientation, SetPosition, SetStroke}; +use crate::draw::properties::{SetColor, SetOrientation, SetPosition, SetStroke}; use crate::draw::{self, Drawing}; use bevy::prelude::*; use lyon::tessellation::StrokeOptions; -use nannou_core::color::LinSrgba; /// A path containing only two points - a start and end. /// @@ -145,9 +144,9 @@ impl SetPosition for Arrow { } } -impl SetColor for Arrow { - fn rgba_mut(&mut self) -> &mut Option { - SetColor::rgba_mut(&mut self.line) +impl SetColor for Arrow { + fn color_mut(&mut self) -> &mut Option { + SetColor::color_mut(&mut self.line) } } @@ -170,7 +169,7 @@ impl draw::render::RenderPrimitive for Arrow { fn render_primitive( self, mut ctxt: draw::render::RenderContext, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) -> draw::render::PrimitiveRender { let Arrow { line, diff --git a/bevy_nannou_draw/src/draw/primitive/ellipse.rs b/bevy_nannou_draw/src/draw/primitive/ellipse.rs index 7dbd70901..ee960e002 100644 --- a/bevy_nannou_draw/src/draw/primitive/ellipse.rs +++ b/bevy_nannou_draw/src/draw/primitive/ellipse.rs @@ -3,12 +3,11 @@ use crate::draw::primitive::polygon::{self, PolygonInit, PolygonOptions, SetPoly use crate::draw::primitive::Primitive; use crate::draw::properties::spatial::{dimension, orientation, position}; use crate::draw::properties::{ - spatial, ColorScalar, LinSrgba, SetColor, SetDimensions, SetOrientation, SetPosition, SetStroke, + spatial, SetColor, SetDimensions, SetOrientation, SetPosition, SetStroke, }; use crate::draw::Drawing; use bevy::prelude::*; use lyon::tessellation::StrokeOptions; -use nannou_core::color::conv::IntoLinSrgba; use nannou_core::geom; /// Properties related to drawing an **Ellipse**. @@ -28,7 +27,7 @@ impl Ellipse { /// Stroke the outline with the given color. pub fn stroke(self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { self.stroke_color(color) } @@ -55,7 +54,7 @@ impl draw::render::RenderPrimitive for Ellipse { fn render_primitive( self, ctxt: draw::render::RenderContext, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) -> draw::render::PrimitiveRender { let Ellipse { dimensions, @@ -130,9 +129,9 @@ impl SetDimensions for Ellipse { } } -impl SetColor for Ellipse { - fn rgba_mut(&mut self) -> &mut Option { - SetColor::rgba_mut(&mut self.polygon) +impl SetColor for Ellipse { + fn color_mut(&mut self) -> &mut Option { + SetColor::color_mut(&mut self.polygon) } } @@ -171,7 +170,7 @@ impl<'a> DrawingEllipse<'a> { /// Stroke the outline with the given color. pub fn stroke(self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { self.map_ty(|ty| ty.stroke(color)) } diff --git a/bevy_nannou_draw/src/draw/primitive/line.rs b/bevy_nannou_draw/src/draw/primitive/line.rs index 5f0ada968..418ef58d4 100644 --- a/bevy_nannou_draw/src/draw/primitive/line.rs +++ b/bevy_nannou_draw/src/draw/primitive/line.rs @@ -1,11 +1,10 @@ use crate::draw::primitive::path; use crate::draw::primitive::{PathStroke, Primitive}; use crate::draw::properties::spatial::{orientation, position}; -use crate::draw::properties::{ColorScalar, SetColor, SetOrientation, SetPosition, SetStroke}; +use crate::draw::properties::{SetColor, SetOrientation, SetPosition, SetStroke}; use crate::draw::{self, Drawing}; use bevy::prelude::*; use lyon::tessellation::StrokeOptions; -use nannou_core::color::LinSrgba; /// A path containing only two points - a start and end. /// @@ -105,9 +104,9 @@ impl SetPosition for Line { } } -impl SetColor for Line { - fn rgba_mut(&mut self) -> &mut Option { - SetColor::rgba_mut(&mut self.path) +impl SetColor for Line { + fn color_mut(&mut self) -> &mut Option { + SetColor::color_mut(&mut self.path) } } @@ -130,7 +129,7 @@ impl draw::render::RenderPrimitive for Line { fn render_primitive( self, mut ctxt: draw::render::RenderContext, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) -> draw::render::PrimitiveRender { let Line { path, start, end } = self; let start = start.unwrap_or(Vec2::new(0.0, 0.0)); diff --git a/bevy_nannou_draw/src/draw/primitive/mesh.rs b/bevy_nannou_draw/src/draw/primitive/mesh.rs index 1cedc5b53..8be7a682e 100644 --- a/bevy_nannou_draw/src/draw/primitive/mesh.rs +++ b/bevy_nannou_draw/src/draw/primitive/mesh.rs @@ -1,20 +1,19 @@ -use crate::draw::mesh::vertex::{self, Point, TexCoords, Vertex}; -use crate::draw::primitive::Primitive; +use crate::draw::mesh::MeshExt; +use crate::draw::primitive::{Primitive, Vertex}; use crate::draw::properties::spatial::{orientation, position}; -use crate::draw::properties::{ColorScalar, LinSrgba, SetColor, SetOrientation, SetPosition}; +use crate::draw::properties::{SetColor, SetOrientation, SetPosition}; use crate::draw::{self, Drawing}; use bevy::prelude::*; -use nannou_core::color::conv::IntoLinSrgba; +use bevy::render::mesh::Indices; use nannou_core::{color, geom}; use std::ops; - /// The mesh type prior to being initialised with vertices or indices. #[derive(Clone, Debug, Default)] pub struct Vertexless; /// Properties related to drawing an arbitrary mesh of colours, geometry and texture. #[derive(Clone, Debug)] -pub struct Mesh { +pub struct PrimitiveMesh { position: position::Properties, orientation: orientation::Properties, vertex_range: ops::Range, @@ -25,7 +24,7 @@ pub struct Mesh { } #[derive(Clone, Debug, Default)] -struct FillColor(Option); +struct FillColor(Option); // A simple iterator for flattening a fixed-size array of indices. struct FlattenIndices { @@ -35,7 +34,7 @@ struct FlattenIndices { current: [usize; 3], } -pub type DrawingMesh<'a> = Drawing<'a, Mesh>; +pub type DrawingMesh<'a> = Drawing<'a, PrimitiveMesh>; impl Vertexless { /// Describe the mesh with a sequence of textured points. @@ -46,20 +45,20 @@ impl Vertexless { /// `Into`. pub fn points_textured( self, - inner_mesh: &mut draw::Mesh, + inner_mesh: &mut Mesh, texture_handle: Handle, points: I, - ) -> Mesh + ) -> PrimitiveMesh where I: IntoIterator, - P: Into, - T: Into, + P: Into, + T: Into, { let points = points.into_iter().map(|(p, t)| { let point = p.into(); - let color = vertex::DEFAULT_VERTEX_COLOR; + let color = Color::default(); let tex_coords = t.into(); - ((point, color), tex_coords).into() + (point, color, tex_coords) }); let vertex_mode = draw::render::VertexMode::Texture; self.points_inner(inner_mesh, points, vertex_mode, Some(texture_handle)) @@ -69,18 +68,18 @@ impl Vertexless { /// /// Each of the points must be represented as a tuple containing the point and the color in /// that order, e.g. `(point, color)`. `point` may be of any type that implements - /// `Into` and `color` may be of any type that implements `IntoLinSrgba`. - pub fn points_colored(self, inner_mesh: &mut draw::Mesh, points: I) -> Mesh + /// `Into` and `color` may be of any type that implements `IntoColor`. + pub fn points_colored(self, inner_mesh: &mut Mesh, points: I) -> PrimitiveMesh where I: IntoIterator, - P: Into, - C: IntoLinSrgba, + P: Into, + C: Into, { let vertices = points.into_iter().map(|(p, c)| { let point = p.into(); - let color = c.into_lin_srgba(); - let tex_coords = vertex::default_tex_coords(); - ((point, color), tex_coords).into() + let color = c.into(); + let tex_coords = Vec2::ZERO; + (point, color, tex_coords) }); let vertex_mode = draw::render::VertexMode::Color; self.points_inner(inner_mesh, vertices, vertex_mode, None) @@ -93,16 +92,16 @@ impl Vertexless { /// This method assumes that the entire mesh should be coloured with a single colour. If a /// colour is not specified via one of the builder methods, a default colour will be retrieved /// from the inner `Theme`. - pub fn points(self, inner_mesh: &mut draw::Mesh, points: I) -> Mesh + pub fn points(self, inner_mesh: &mut Mesh, points: I) -> PrimitiveMesh where I: IntoIterator, - I::Item: Into, + I::Item: Into, { let vertices = points.into_iter().map(|p| { let point = p.into(); - let color = vertex::DEFAULT_VERTEX_COLOR; - let tex_coords = vertex::default_tex_coords(); - ((point, color), tex_coords).into() + let color = Color::default(); + let tex_coords = Vec2::ZERO; + (point, color, tex_coords) }); let vertex_mode = draw::render::VertexMode::Color; let mut mesh = self.points_inner(inner_mesh, vertices, vertex_mode, None); @@ -112,23 +111,25 @@ impl Vertexless { fn points_inner( self, - inner_mesh: &mut draw::Mesh, + inner_mesh: &mut Mesh, vertices: I, vertex_mode: draw::render::VertexMode, texture_handle: Option>, - ) -> Mesh + ) -> PrimitiveMesh where I: Iterator, { - let v_start = inner_mesh.points().len(); - let i_start = inner_mesh.indices().len(); - for (i, vertex) in vertices.enumerate() { - inner_mesh.push_vertex(vertex); - inner_mesh.push_index((v_start + i) as u32); + let v_start = inner_mesh.count_vertices(); + let i_start = inner_mesh.count_indices(); + for (i, (point, color, tex_coords)) in vertices.enumerate() { + inner_mesh.points_mut().push(point.to_array()); + inner_mesh.colors_mut().push(color.as_linear_rgba_f32()); + inner_mesh.tex_coords_mut().push(tex_coords.to_array()); + inner_mesh.push_index(i as u32); } - let v_end = inner_mesh.points().len(); - let i_end = inner_mesh.indices().len(); - Mesh::new(v_start..v_end, i_start..i_end, vertex_mode, texture_handle) + let v_end = inner_mesh.count_vertices(); + let i_end = inner_mesh.count_indices(); + PrimitiveMesh::new(v_start..v_end, i_start..i_end, vertex_mode, texture_handle) } /// Describe the mesh with a sequence of textured triangles. @@ -139,14 +140,14 @@ impl Vertexless { /// `Into`. pub fn tris_textured( self, - inner_mesh: &mut draw::Mesh, + inner_mesh: &mut Mesh, texture_handle: Handle, tris: I, - ) -> Mesh + ) -> PrimitiveMesh where I: IntoIterator>, - P: Into, - T: Into, + P: Into, + T: Into, { let points = tris .into_iter() @@ -159,16 +160,16 @@ impl Vertexless { /// /// Each of the vertices must be represented as a tuple containing the point and the color in /// that order, e.g. `(point, color)`. `point` may be of any type that implements `Into` - /// and `color` may be of any type that implements `IntoLinSrgba`. - pub fn tris_colored(self, inner_mesh: &mut draw::Mesh, tris: I) -> Mesh + /// and `color` may be of any type that implements `IntoColor`. + pub fn tris_colored(self, inner_mesh: &mut Mesh, tris: I) -> PrimitiveMesh where I: IntoIterator>, - P: Into, - C: IntoLinSrgba, + P: Into, + C: Into, { let points = tris .into_iter() - .map(|t| t.map_vertices(|(p, c)| (p.into(), c.into_lin_srgba()))) + .map(|t| t.map_vertices(|(p, c)| (p.into(), c.into()))) .flat_map(geom::Tri::vertices); self.points_colored(inner_mesh, points) } @@ -181,10 +182,10 @@ impl Vertexless { /// This method assumes that the entire mesh should be coloured with a single colour. If a /// colour is not specified via one of the builder methods, a default colour will be retrieved /// from the inner `Theme`. - pub fn tris(self, inner_mesh: &mut draw::Mesh, tris: I) -> Mesh + pub fn tris(self, inner_mesh: &mut Mesh, tris: I) -> PrimitiveMesh where I: IntoIterator>, - V: Into, + V: Into, { let points = tris .into_iter() @@ -203,22 +204,22 @@ impl Vertexless { /// `Into`. pub fn indexed_textured( self, - inner_mesh: &mut draw::Mesh, + inner_mesh: &mut Mesh, texture_handle: Handle, points: V, indices: I, - ) -> Mesh + ) -> PrimitiveMesh where V: IntoIterator, I: IntoIterator, - P: Into, - T: Into, + P: Into, + T: Into, { let vertices = points.into_iter().map(|(p, t)| { let point = p.into(); - let color = vertex::DEFAULT_VERTEX_COLOR; + let color = Color::default(); let tex_coords = t.into(); - ((point, color), tex_coords).into() + (point, color, tex_coords) }); let vertex_mode = draw::render::VertexMode::Texture; self.indexed_inner( @@ -236,24 +237,24 @@ impl Vertexless { /// /// Each of the `points` must be represented as a tuple containing the point and the color in /// that order, e.g. `(point, color)`. `point` may be of any type that implements - /// `Into` and `color` may be of any type that implements `IntoLinSrgba`. + /// `Into` and `color` may be of any type that implements `IntoColor`. pub fn indexed_colored( self, - inner_mesh: &mut draw::Mesh, + inner_mesh: &mut Mesh, points: V, indices: I, - ) -> Mesh + ) -> PrimitiveMesh where V: IntoIterator, I: IntoIterator, - P: Into, - C: IntoLinSrgba, + P: Into, + C: Into, { let vertices = points.into_iter().map(|(p, c)| { let point = p.into(); - let color = c.into_lin_srgba(); - let tex_coords = vertex::default_tex_coords(); - ((point, color), tex_coords).into() + let color = c.into(); + let tex_coords = Vec2::ZERO; + (point, color, tex_coords) }); let vertex_mode = draw::render::VertexMode::Color; self.indexed_inner(inner_mesh, vertices, indices, vertex_mode, None) @@ -264,17 +265,17 @@ impl Vertexless { /// Each trio of `indices` describes a single triangle made up of `points`. /// /// Each point may be any type that may be converted directly into the `Vec3` type. - pub fn indexed(self, inner_mesh: &mut draw::Mesh, points: V, indices: I) -> Mesh + pub fn indexed(self, inner_mesh: &mut Mesh, points: V, indices: I) -> PrimitiveMesh where V: IntoIterator, - V::Item: Into, + V::Item: Into, I: IntoIterator, { let vertices = points.into_iter().map(|p| { let point = p.into(); - let color = vertex::DEFAULT_VERTEX_COLOR; - let tex_coords = vertex::default_tex_coords(); - ((point, color), tex_coords).into() + let color = Color::default(); + let tex_coords = Vec2::ZERO; + (point, color, tex_coords) }); let vertex_mode = draw::render::VertexMode::Color; let mut mesh = self.indexed_inner(inner_mesh, vertices, indices, vertex_mode, None); @@ -284,27 +285,35 @@ impl Vertexless { fn indexed_inner( self, - inner_mesh: &mut draw::Mesh, + inner_mesh: &mut Mesh, vertices: V, indices: I, vertex_mode: draw::render::VertexMode, texture_handle: Option>, - ) -> Mesh + ) -> PrimitiveMesh where V: IntoIterator, I: IntoIterator, { - let v_start = inner_mesh.points().len(); - let i_start = inner_mesh.indices().len(); - inner_mesh.extend_vertices(vertices); - inner_mesh.extend_indices(indices.into_iter().map(|ix| ix as u32)); - let v_end = inner_mesh.points().len(); - let i_end = inner_mesh.indices().len(); - Mesh::new(v_start..v_end, i_start..i_end, vertex_mode, texture_handle) + let v_start = inner_mesh.count_vertices(); + let i_start = inner_mesh.count_indices(); + + for (point, color, tex_coords) in vertices.into_iter() { + inner_mesh.points_mut().push(point.to_array()); + inner_mesh.colors_mut().push(color.as_linear_rgba_f32()); + inner_mesh.tex_coords_mut().push(tex_coords.to_array()); + } + for index in indices { + inner_mesh.push_index(index as u32); + } + + let v_end = inner_mesh.count_vertices(); + let i_end = inner_mesh.count_indices(); + PrimitiveMesh::new(v_start..v_end, i_start..i_end, vertex_mode, texture_handle) } } -impl Mesh { +impl PrimitiveMesh { // Initialise a new `Mesh` with its ranges into the intermediary mesh, ready for drawing. fn new( vertex_range: ops::Range, @@ -315,7 +324,7 @@ impl Mesh { let orientation = Default::default(); let position = Default::default(); let fill_color = None; - Mesh { + PrimitiveMesh { orientation, position, vertex_range, @@ -338,7 +347,7 @@ impl<'a> Drawing<'a, Vertexless> { pub fn points(self, points: I) -> DrawingMesh<'a> where I: IntoIterator, - I::Item: Into, + I::Item: Into, { self.map_ty_with_context(|ty, ctxt| ty.points(ctxt.mesh, points)) } @@ -347,12 +356,12 @@ impl<'a> Drawing<'a, Vertexless> { /// /// Each of the points must be represented as a tuple containing the point and the color in /// that order, e.g. `(point, color)`. `point` may be of any type that implements - /// `Into` and `color` may be of any type that implements `IntoLinSrgba`. + /// `Into` and `color` may be of any type that implements `IntoColor`. pub fn points_colored(self, points: I) -> DrawingMesh<'a> where I: IntoIterator, - P: Into, - C: IntoLinSrgba, + P: Into, + C: Into, { self.map_ty_with_context(|ty, ctxt| ty.points_colored(ctxt.mesh, points)) } @@ -370,8 +379,8 @@ impl<'a> Drawing<'a, Vertexless> { ) -> DrawingMesh<'a> where I: IntoIterator, - P: Into, - T: Into, + P: Into, + T: Into, { self.map_ty_with_context(|ty, ctxt| ty.points_textured(ctxt.mesh, texture_handle, points)) } @@ -387,7 +396,7 @@ impl<'a> Drawing<'a, Vertexless> { pub fn tris(self, tris: I) -> DrawingMesh<'a> where I: IntoIterator>, - V: Into, + V: Into, { self.map_ty_with_context(|ty, ctxt| ty.tris(ctxt.mesh, tris)) } @@ -396,12 +405,12 @@ impl<'a> Drawing<'a, Vertexless> { /// /// Each of the vertices must be represented as a tuple containing the point and the color in /// that order, e.g. `(point, color)`. `point` may be of any type that implements `Into` - /// and `color` may be of any type that implements `IntoLinSrgba`. + /// and `color` may be of any type that implements `IntoColor`. pub fn tris_colored(self, tris: I) -> DrawingMesh<'a> where I: IntoIterator>, - P: Into, - C: IntoLinSrgba, + P: Into, + C: Into, { self.map_ty_with_context(|ty, ctxt| ty.tris_colored(ctxt.mesh, tris)) } @@ -415,8 +424,8 @@ impl<'a> Drawing<'a, Vertexless> { pub fn tris_textured(self, texture_handle: Handle, tris: I) -> DrawingMesh<'a> where I: IntoIterator>, - P: Into, - T: Into, + P: Into, + T: Into, { self.map_ty_with_context(|ty, ctxt| ty.tris_textured(ctxt.mesh, texture_handle, tris)) } @@ -429,7 +438,7 @@ impl<'a> Drawing<'a, Vertexless> { pub fn indexed(self, points: V, indices: I) -> DrawingMesh<'a> where V: IntoIterator, - V::Item: Into, + V::Item: Into, I: IntoIterator, { self.map_ty_with_context(|ty, ctxt| ty.indexed(ctxt.mesh, points, indices)) @@ -441,13 +450,13 @@ impl<'a> Drawing<'a, Vertexless> { /// /// Each of the `points` must be represented as a tuple containing the point and the color in /// that order, e.g. `(point, color)`. `point` may be of any type that implements - /// `Into` and `color` may be of any type that implements `IntoLinSrgba`. + /// `Into` and `color` may be of any type that implements `IntoColor`. pub fn indexed_colored(self, points: V, indices: I) -> DrawingMesh<'a> where V: IntoIterator, I: IntoIterator, - P: Into, - C: IntoLinSrgba, + P: Into, + C: Into, { self.map_ty_with_context(|ty, ctxt| ty.indexed_colored(ctxt.mesh, points, indices)) } @@ -469,8 +478,8 @@ impl<'a> Drawing<'a, Vertexless> { where V: IntoIterator, I: IntoIterator, - P: Into, - T: Into, + P: Into, + T: Into, { self.map_ty_with_context(|ty, ctxt| { ty.indexed_textured(ctxt.mesh, texture_handle, points, indices) @@ -478,13 +487,13 @@ impl<'a> Drawing<'a, Vertexless> { } } -impl draw::render::RenderPrimitive for Mesh { +impl draw::render::RenderPrimitive for PrimitiveMesh { fn render_primitive( self, ctxt: draw::render::RenderContext, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) -> draw::render::PrimitiveRender { - let Mesh { + let PrimitiveMesh { orientation, position, vertex_range, @@ -501,9 +510,9 @@ impl draw::render::RenderPrimitive for Mesh { // We need to update the indices to point to where vertices will be in the new mesh. let old_mesh_vertex_start = vertex_range.start as u32; - let new_mesh_vertex_start = mesh.raw_vertex_count() as u32; + let new_mesh_vertex_start = mesh.count_vertices() as u32; let indices = index_range - .map(|i| ctxt.intermediary_mesh.indices()[i]) + .map(|i| ctxt.intermediary_mesh.get_index(i)) .map(|i| new_mesh_vertex_start + i - old_mesh_vertex_start); // A small function for transforming a point via the transform matrix. @@ -513,24 +522,38 @@ impl draw::render::RenderPrimitive for Mesh { match fill_color { Some(fill) => { let theme_prim = draw::theme::Primitive::Mesh; - let color = fill - .0 - .unwrap_or_else(|| ctxt.theme.fill_lin_srgba(&theme_prim)); + let color = fill.0.unwrap_or_else(|| ctxt.theme.fill(&theme_prim)); let vertices = vertex_range.map(|i| { - let point = transform_point(ctxt.intermediary_mesh.points()[i]); - let tex_coords = ctxt.intermediary_mesh.tex_coords()[i]; - ((point, color), tex_coords).into() + let point = transform_point(ctxt.intermediary_mesh.points()[i].into()); + let tex_coords: Vec2 = ctxt.intermediary_mesh.tex_coords()[i].into(); + (point, color, tex_coords) }); - mesh.extend(vertices, indices); + + for (point, color, tex_coords) in vertices { + mesh.points_mut().push(point.to_array()); + mesh.colors_mut().push(color.as_linear_rgba_f32()); + mesh.tex_coords_mut().push(tex_coords.to_array()); + } + for index in indices { + mesh.push_index(index); + } } None => { let vertices = vertex_range.map(|i| { - let point = transform_point(ctxt.intermediary_mesh.points()[i]); - let color = ctxt.intermediary_mesh.colors()[i]; - let tex_coords = ctxt.intermediary_mesh.tex_coords()[i]; - ((point, color), tex_coords).into() + let point = transform_point(ctxt.intermediary_mesh.points()[i].into()); + let color: Color = ctxt.intermediary_mesh.colors()[i].into(); + let tex_coords: Vec2 = ctxt.intermediary_mesh.tex_coords()[i].into(); + (point, color, tex_coords) }); - mesh.extend(vertices, indices); + + for (point, color, tex_coords) in vertices { + mesh.points_mut().push(point.to_array()); + mesh.colors_mut().push(color.into()); + mesh.tex_coords_mut().push(tex_coords.to_array()); + } + for index in indices { + mesh.push_index(index); + } } } @@ -564,20 +587,20 @@ where } } -impl SetOrientation for Mesh { +impl SetOrientation for PrimitiveMesh { fn properties(&mut self) -> &mut orientation::Properties { SetOrientation::properties(&mut self.orientation) } } -impl SetPosition for Mesh { +impl SetPosition for PrimitiveMesh { fn properties(&mut self) -> &mut position::Properties { SetPosition::properties(&mut self.position) } } -impl SetColor for Mesh { - fn rgba_mut(&mut self) -> &mut Option { +impl SetColor for PrimitiveMesh { + fn color_mut(&mut self) -> &mut Option { &mut self.fill_color.get_or_insert_with(Default::default).0 } } @@ -588,8 +611,8 @@ impl From for Primitive { } } -impl From for Primitive { - fn from(prim: Mesh) -> Self { +impl From for Primitive { + fn from(prim: PrimitiveMesh) -> Self { Primitive::Mesh(prim) } } @@ -603,8 +626,8 @@ impl Into> for Primitive { } } -impl Into> for Primitive { - fn into(self) -> Option { +impl Into> for Primitive { + fn into(self) -> Option { match self { Primitive::Mesh(prim) => Some(prim), _ => None, diff --git a/bevy_nannou_draw/src/draw/primitive/mod.rs b/bevy_nannou_draw/src/draw/primitive/mod.rs index 60272a10f..f8dd32f0c 100644 --- a/bevy_nannou_draw/src/draw/primitive/mod.rs +++ b/bevy_nannou_draw/src/draw/primitive/mod.rs @@ -13,7 +13,7 @@ pub mod tri; pub use self::arrow::Arrow; pub use self::ellipse::Ellipse; pub use self::line::Line; -pub use self::mesh::Mesh; +pub use self::mesh::PrimitiveMesh; pub use self::path::{Path, PathFill, PathInit, PathStroke}; pub use self::polygon::{Polygon, PolygonInit}; pub use self::quad::Quad; @@ -21,6 +21,10 @@ pub use self::rect::Rect; pub use self::text::Text; pub use self::texture::Texture; pub use self::tri::Tri; +use bevy::prelude::Color; +use nannou_core::geom::{Vec2, Vec3}; + +type Vertex = (Vec3, Color, Vec2); /// A wrapper around all primitive sets of properties so that they may be stored within the /// **Draw**'s `drawing` field while they are being drawn. @@ -33,7 +37,7 @@ pub enum Primitive { Ellipse(Ellipse), Line(Line), MeshVertexless(mesh::Vertexless), - Mesh(Mesh), + Mesh(PrimitiveMesh), PathInit(PathInit), PathFill(PathFill), PathStroke(PathStroke), diff --git a/bevy_nannou_draw/src/draw/primitive/path.rs b/bevy_nannou_draw/src/draw/primitive/path.rs index 1fb446bab..8884212ee 100644 --- a/bevy_nannou_draw/src/draw/primitive/path.rs +++ b/bevy_nannou_draw/src/draw/primitive/path.rs @@ -1,15 +1,10 @@ -use crate::draw::mesh::vertex::{Color, TexCoords}; use crate::draw::primitive::Primitive; use crate::draw::properties::spatial::{orientation, position}; -use crate::draw::properties::{ - ColorScalar, SetColor, SetFill, SetOrientation, SetPosition, SetStroke, -}; +use crate::draw::properties::{SetColor, SetFill, SetOrientation, SetPosition, SetStroke}; use crate::draw::{self, Drawing, DrawingContext}; use bevy::prelude::*; use lyon::path::PathEvent; use lyon::tessellation::{FillOptions, FillTessellator, StrokeOptions, StrokeTessellator}; -use nannou_core::color::conv::IntoLinSrgba; -use nannou_core::color::LinSrgba; /// A set of path tessellation options (FillOptions or StrokeOptions). pub trait TessellationOptions { @@ -42,7 +37,7 @@ pub(crate) enum PathEventSourceIter<'a> { close: bool, }, TexturedPoints { - points: &'a mut dyn Iterator, + points: &'a mut dyn Iterator, close: bool, }, } @@ -56,7 +51,7 @@ pub struct PathInit; #[derive(Clone, Debug, Default)] pub struct PathOptions { pub(crate) opts: T, - pub(crate) color: Option, + pub(crate) color: Option, pub(crate) position: position::Properties, pub(crate) orientation: orientation::Properties, } @@ -76,7 +71,7 @@ pub type PathStroke = PathOptions; /// Properties related to drawing a **Path**. #[derive(Clone, Debug)] pub struct Path { - color: Option, + color: Option, position: position::Properties, orientation: orientation::Properties, path_event_src: PathEventSource, @@ -221,7 +216,7 @@ where where I: IntoIterator, P: Into, - C: IntoLinSrgba, + C: Into, { self.points_colored_inner(ctxt, false, points) } @@ -231,7 +226,7 @@ where where I: IntoIterator, P: Into, - C: IntoLinSrgba, + C: Into, { self.points_colored_inner(ctxt, true, points) } @@ -246,7 +241,7 @@ where where I: IntoIterator, P: Into, - TC: Into, + TC: Into, { self.points_textured_inner(ctxt, texture_handle, false, points) } @@ -261,7 +256,7 @@ where where I: IntoIterator, P: Into, - TC: Into, + TC: Into, { self.points_textured_inner(ctxt, texture_handle, true, points) } @@ -285,17 +280,17 @@ where where I: IntoIterator, P: Into, - C: IntoLinSrgba, + C: Into, { let DrawingContext { path_points_colored_buffer, .. } = ctxt; let start = path_points_colored_buffer.len(); - let points = points - .into_iter() - .map(|(p, c)| (p.into(), c.into_lin_srgba())); + let points = points.into_iter().map(|(p, c)| (p.into(), c.into())); + path_points_colored_buffer.extend(points); + let end = path_points_colored_buffer.len(); let path_event_src = PathEventSource::ColoredPoints { range: start..end, @@ -323,7 +318,7 @@ where where I: IntoIterator, P: Into, - TC: Into, + TC: Into, { let DrawingContext { path_points_textured_buffer, @@ -351,25 +346,25 @@ where pub(crate) fn render_path_events( events: I, - color: Option, + color: Option, transform: Mat4, options: Options, theme: &draw::Theme, theme_prim: &draw::theme::Primitive, fill_tessellator: &mut lyon::tessellation::FillTessellator, stroke_tessellator: &mut lyon::tessellation::StrokeTessellator, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) where I: IntoIterator, { let res = match options { Options::Fill(options) => { - let color = color.unwrap_or_else(|| theme.fill_lin_srgba(theme_prim)); + let color = color.unwrap_or_else(|| theme.fill(theme_prim)); let mut mesh_builder = draw::mesh::MeshBuilder::single_color(mesh, transform, color); fill_tessellator.tessellate(events, &options, &mut mesh_builder) } Options::Stroke(options) => { - let color = color.unwrap_or_else(|| theme.stroke_lin_srgba(theme_prim)); + let color = color.unwrap_or_else(|| theme.stroke(theme_prim)); let mut mesh_builder = draw::mesh::MeshBuilder::single_color(mesh, transform, color); stroke_tessellator.tessellate(events, &options, &mut mesh_builder) } @@ -386,7 +381,7 @@ pub(crate) fn render_path_points_colored( options: Options, fill_tessellator: &mut lyon::tessellation::FillTessellator, stroke_tessellator: &mut lyon::tessellation::StrokeTessellator, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) where I: IntoIterator, { @@ -425,9 +420,9 @@ pub(crate) fn render_path_points_textured( options: Options, fill_tessellator: &mut lyon::tessellation::FillTessellator, stroke_tessellator: &mut lyon::tessellation::StrokeTessellator, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) where - I: IntoIterator, + I: IntoIterator, { let path = match points_textured_to_lyon_path(points_textured, close) { None => return, @@ -460,14 +455,14 @@ pub(crate) fn render_path_points_textured( pub(crate) fn render_path_source( // TODO: path_src: PathEventSourceIter, - color: Option, + color: Option, transform: Mat4, options: Options, theme: &draw::Theme, theme_prim: &draw::theme::Primitive, fill_tessellator: &mut lyon::tessellation::FillTessellator, stroke_tessellator: &mut lyon::tessellation::StrokeTessellator, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) { match path_src { PathEventSourceIter::Events(events) => render_path_events( @@ -506,7 +501,7 @@ impl draw::render::RenderPrimitive for Path { fn render_primitive( self, mut ctxt: draw::render::RenderContext, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) -> draw::render::PrimitiveRender { let Path { color, @@ -594,21 +589,19 @@ where I: IntoIterator, { // Build a path with a color attribute for each channel. - let channels = draw::mesh::vertex::COLOR_CHANNEL_COUNT; + let channels = 4; let mut path_builder = lyon::path::Path::builder_with_attributes(channels); // Begin the path. let mut iter = points_colored.into_iter(); let (first_point, first_color) = iter.next()?; let p = first_point.to_array().into(); - let (r, g, b, a) = first_color.into(); - path_builder.begin(p, &[r, g, b, a]); + path_builder.begin(p, &first_color.as_linear_rgba_f32()); // Add the lines, keeping track of the last for (point, color) in iter { let p = point.to_array().into(); - let (r, g, b, a) = color.into(); - path_builder.line_to(p, &[r, g, b, a]); + path_builder.line_to(p, &color.as_linear_rgba_f32()); } // End the path, closing if necessary. @@ -621,7 +614,7 @@ where /// Create a lyon path for the given iterator of textured points. pub fn points_textured_to_lyon_path(points_textured: I, close: bool) -> Option where - I: IntoIterator, + I: IntoIterator, { // Build a path with a texture coords attribute for each channel. let channels = 2; @@ -653,7 +646,7 @@ impl Path { fn new( position: position::Properties, orientation: orientation::Properties, - color: Option, + color: Option, path_event_src: PathEventSource, options: Options, vertex_mode: draw::render::VertexMode, @@ -752,7 +745,7 @@ where where I: IntoIterator, P: Into, - C: IntoLinSrgba, + C: Into, { self.map_ty_with_context(|ty, ctxt| ty.points_colored(ctxt, points)) } @@ -764,7 +757,7 @@ where where I: IntoIterator, P: Into, - C: IntoLinSrgba, + C: Into, { self.map_ty_with_context(|ty, ctxt| ty.points_colored_closed(ctxt, points)) } @@ -778,7 +771,7 @@ where where I: IntoIterator, P: Into, - TC: Into, + TC: Into, { self.map_ty_with_context(|ty, ctxt| ty.points_textured(ctxt, texture_handle, points)) } @@ -794,7 +787,7 @@ where where I: IntoIterator, P: Into, - TC: Into, + TC: Into, { self.map_ty_with_context(|ty, ctxt| ty.points_textured_closed(ctxt, texture_handle, points)) } @@ -838,9 +831,9 @@ impl SetPosition for PathOptions { } } -impl SetColor for PathOptions { - fn rgba_mut(&mut self) -> &mut Option { - SetColor::rgba_mut(&mut self.color) +impl SetColor for PathOptions { + fn color_mut(&mut self) -> &mut Option { + SetColor::color_mut(&mut self.color) } } @@ -856,9 +849,9 @@ impl SetPosition for Path { } } -impl SetColor for Path { - fn rgba_mut(&mut self) -> &mut Option { - SetColor::rgba_mut(&mut self.color) +impl SetColor for Path { + fn color_mut(&mut self) -> &mut Option { + SetColor::color_mut(&mut self.color) } } diff --git a/bevy_nannou_draw/src/draw/primitive/polygon.rs b/bevy_nannou_draw/src/draw/primitive/polygon.rs index e8aaf68e3..7e33703eb 100644 --- a/bevy_nannou_draw/src/draw/primitive/polygon.rs +++ b/bevy_nannou_draw/src/draw/primitive/polygon.rs @@ -1,16 +1,12 @@ use crate::draw::drawing::DrawingContext; -use crate::draw::mesh::vertex::TexCoords; use crate::draw::primitive::path::{self, PathEventSource}; use crate::draw::primitive::Primitive; use crate::draw::properties::spatial::{orientation, position}; -use crate::draw::properties::{ - ColorScalar, LinSrgba, SetColor, SetOrientation, SetPosition, SetStroke, -}; +use crate::draw::properties::{SetColor, SetOrientation, SetPosition, SetStroke}; use crate::draw::{self, Drawing}; use bevy::prelude::*; use lyon::path::PathEvent; use lyon::tessellation::StrokeOptions; -use nannou_core::color::conv::IntoLinSrgba; /// A trait implemented for all polygon draw primitives. pub trait SetPolygon: Sized { @@ -29,9 +25,9 @@ pub trait SetPolygon: Sized { /// are called. fn stroke_color(mut self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { - self.polygon_options_mut().stroke_color = Some(color.into_lin_srgba()); + self.polygon_options_mut().stroke_color = Some(color.into()); self } @@ -54,8 +50,8 @@ pub struct PolygonOptions { pub position: position::Properties, pub orientation: orientation::Properties, pub no_fill: bool, - pub stroke_color: Option, - pub color: Option, + pub stroke_color: Option, + pub color: Option, pub stroke: Option, } @@ -77,7 +73,7 @@ impl PolygonInit { /// Stroke the outline with the given color. pub fn stroke(self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { self.stroke_color(color) } @@ -120,17 +116,16 @@ impl PolygonInit { where I: IntoIterator, P: Into, - C: IntoLinSrgba, + C: Into, { let DrawingContext { path_points_colored_buffer, .. } = ctxt; let start = path_points_colored_buffer.len(); - let points = points - .into_iter() - .map(|(p, c)| (p.into(), c.into_lin_srgba())); + let points = points.into_iter().map(|(p, c)| (p.into(), c.into())); path_points_colored_buffer.extend(points); + let end = path_points_colored_buffer.len(); Polygon { opts: self.opts, @@ -152,7 +147,7 @@ impl PolygonInit { where I: IntoIterator, P: Into, - T: Into, + T: Into, { let DrawingContext { path_points_textured_buffer, @@ -178,7 +173,7 @@ pub fn render_events_themed( events: F, mut ctxt: draw::render::RenderContext, theme_primitive: &draw::theme::Primitive, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) where F: Fn() -> I, I: Iterator, @@ -200,7 +195,7 @@ pub fn render_events_themed( // A function for rendering the path. let mut render = |opts: path::Options, - color: Option, + color: Option, theme: &draw::Theme, fill_tessellator: &mut lyon::tessellation::FillTessellator, stroke_tessellator: &mut lyon::tessellation::StrokeTessellator| { @@ -248,7 +243,7 @@ pub fn render_points_themed( points: I, ctxt: draw::render::RenderContext, theme_primitive: &draw::theme::Primitive, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) where I: Clone + Iterator, { @@ -265,7 +260,7 @@ impl Polygon { pub(crate) fn render_themed( self, ctxt: draw::render::RenderContext, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, theme_primitive: &draw::theme::Primitive, ) -> draw::render::PrimitiveRender { let Polygon { @@ -301,7 +296,7 @@ impl Polygon { let mut render = |src: path::PathEventSourceIter, opts: path::Options, - color: Option, + color: Option, theme: &draw::Theme, fill_tessellator: &mut lyon::tessellation::FillTessellator, stroke_tessellator: &mut lyon::tessellation::StrokeTessellator| { @@ -386,8 +381,7 @@ impl Polygon { ); } PathEventSource::ColoredPoints { range, close } => { - let color = - stroke_color.unwrap_or_else(|| theme.stroke_lin_srgba(theme_primitive)); + let color = stroke_color.unwrap_or_else(|| theme.stroke(theme_primitive)); let mut points_colored = path_points_colored_buffer[range] .iter() .cloned() @@ -437,7 +431,7 @@ impl draw::render::RenderPrimitive for Polygon { fn render_primitive( self, ctxt: draw::render::RenderContext, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) -> draw::render::PrimitiveRender { self.render_themed(ctxt, mesh, &draw::theme::Primitive::Polygon) } @@ -459,7 +453,7 @@ where /// are called. pub fn stroke_color(self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { self.map_ty(|ty| ty.stroke_color(color)) } @@ -474,7 +468,7 @@ impl<'a> DrawingPolygonInit<'a> { /// Stroke the outline with the given color. pub fn stroke(self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { self.map_ty(|ty| ty.stroke(color)) } @@ -501,7 +495,7 @@ impl<'a> DrawingPolygonInit<'a> { where I: IntoIterator, P: Into, - C: IntoLinSrgba, + C: Into, { self.map_ty_with_context(|ty, ctxt| ty.points_colored(ctxt, points)) } @@ -515,7 +509,7 @@ impl<'a> DrawingPolygonInit<'a> { where I: IntoIterator, P: Into, - T: Into, + T: Into, { self.map_ty_with_context(|ty, ctxt| ty.points_textured(ctxt, texture_handle, points)) } @@ -539,9 +533,9 @@ impl SetPosition for PolygonInit { } } -impl SetColor for PolygonInit { - fn rgba_mut(&mut self) -> &mut Option { - SetColor::rgba_mut(&mut self.opts.color) +impl SetColor for PolygonInit { + fn color_mut(&mut self) -> &mut Option { + SetColor::color_mut(&mut self.opts.color) } } @@ -569,9 +563,9 @@ impl SetPosition for Polygon { } } -impl SetColor for Polygon { - fn rgba_mut(&mut self) -> &mut Option { - SetColor::rgba_mut(&mut self.opts.color) +impl SetColor for Polygon { + fn color_mut(&mut self) -> &mut Option { + SetColor::color_mut(&mut self.opts.color) } } diff --git a/bevy_nannou_draw/src/draw/primitive/quad.rs b/bevy_nannou_draw/src/draw/primitive/quad.rs index d1eb33c7f..e09bca3a9 100644 --- a/bevy_nannou_draw/src/draw/primitive/quad.rs +++ b/bevy_nannou_draw/src/draw/primitive/quad.rs @@ -2,12 +2,11 @@ use crate::draw::primitive::polygon::{self, PolygonInit, PolygonOptions, SetPoly use crate::draw::primitive::Primitive; use crate::draw::properties::spatial::{dimension, orientation, position}; use crate::draw::properties::{ - spatial, ColorScalar, LinSrgba, SetColor, SetDimensions, SetOrientation, SetPosition, SetStroke, + spatial, SetColor, SetDimensions, SetOrientation, SetPosition, SetStroke, }; use crate::draw::{self, Drawing}; use bevy::prelude::*; use lyon::tessellation::StrokeOptions; -use nannou_core::color::conv::IntoLinSrgba; use nannou_core::geom; /// Properties related to drawing a **Quad**. @@ -27,7 +26,7 @@ impl Quad { /// Stroke the outline with the given color. pub fn stroke(self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { self.stroke_color(color) } @@ -51,7 +50,7 @@ impl draw::render::RenderPrimitive for Quad { fn render_primitive( self, ctxt: draw::render::RenderContext, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) -> draw::render::PrimitiveRender { let Quad { mut quad, @@ -135,9 +134,9 @@ impl SetDimensions for Quad { } } -impl SetColor for Quad { - fn rgba_mut(&mut self) -> &mut Option { - SetColor::rgba_mut(&mut self.polygon) +impl SetColor for Quad { + fn color_mut(&mut self) -> &mut Option { + SetColor::color_mut(&mut self.polygon) } } diff --git a/bevy_nannou_draw/src/draw/primitive/rect.rs b/bevy_nannou_draw/src/draw/primitive/rect.rs index 92e6b4338..c3359e57a 100644 --- a/bevy_nannou_draw/src/draw/primitive/rect.rs +++ b/bevy_nannou_draw/src/draw/primitive/rect.rs @@ -1,13 +1,10 @@ use crate::draw::primitive::polygon::{self, PolygonInit, PolygonOptions, SetPolygon}; use crate::draw::primitive::Primitive; use crate::draw::properties::spatial::{dimension, orientation, position}; -use crate::draw::properties::{ - ColorScalar, LinSrgba, SetColor, SetDimensions, SetOrientation, SetPosition, SetStroke, -}; +use crate::draw::properties::{SetColor, SetDimensions, SetOrientation, SetPosition, SetStroke}; use crate::draw::{self, Drawing}; use bevy::prelude::*; use lyon::tessellation::StrokeOptions; -use nannou_core::color::conv::IntoLinSrgba; use nannou_core::geom; /// Properties related to drawing a **Rect**. @@ -26,7 +23,7 @@ impl Rect { /// Stroke the outline with the given color. pub fn stroke(self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { self.stroke_color(color) } @@ -36,7 +33,7 @@ impl<'a> DrawingRect<'a> { /// Stroke the outline with the given color. pub fn stroke(self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { self.map_ty(|ty| ty.stroke(color)) } @@ -46,7 +43,7 @@ impl draw::render::RenderPrimitive for Rect { fn render_primitive( self, ctxt: draw::render::RenderContext, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) -> draw::render::PrimitiveRender { let Rect { polygon, @@ -111,9 +108,9 @@ impl SetDimensions for Rect { } } -impl SetColor for Rect { - fn rgba_mut(&mut self) -> &mut Option { - SetColor::rgba_mut(&mut self.polygon) +impl SetColor for Rect { + fn color_mut(&mut self) -> &mut Option { + SetColor::color_mut(&mut self.polygon) } } diff --git a/bevy_nannou_draw/src/draw/primitive/text.rs b/bevy_nannou_draw/src/draw/primitive/text.rs index 4474319ec..71f05fa24 100644 --- a/bevy_nannou_draw/src/draw/primitive/text.rs +++ b/bevy_nannou_draw/src/draw/primitive/text.rs @@ -1,13 +1,11 @@ use crate::draw::drawing::DrawingContext; -use crate::draw::primitive::Primitive; +use crate::draw::mesh::MeshExt; +use crate::draw::primitive::{Primitive, Vertex}; use crate::draw::properties::spatial::{self, dimension, orientation, position}; -use crate::draw::properties::{ - ColorScalar, LinSrgba, SetColor, SetDimensions, SetOrientation, SetPosition, -}; +use crate::draw::properties::{SetColor, SetDimensions, SetOrientation, SetPosition}; use crate::draw::{self, theme, Drawing}; use crate::text::{self, Align, Font, FontSize, Justify, Layout, Scalar, Wrap}; use bevy::prelude::*; -use nannou_core::color::conv::IntoLinSrgba; use nannou_core::geom; /// Properties related to drawing the **Text** primitive. @@ -22,8 +20,8 @@ pub struct Text { /// Styling properties for the **Text** primitive. #[derive(Clone, Debug, Default)] pub struct Style { - pub color: Option, - pub glyph_colors: Vec, // Overrides `color` if non-empty. + pub color: Option, + pub glyph_colors: Vec, // Overrides `color` if non-empty. pub layout: text::layout::Builder, } @@ -153,7 +151,7 @@ impl Text { /// Set a color for each glyph. /// Colors unspecified glyphs using the drawing color. - pub fn glyph_colors(mut self, colors: Vec) -> Self { + pub fn glyph_colors(mut self, colors: Vec) -> Self { self.style.glyph_colors = colors; self } @@ -249,12 +247,9 @@ impl<'a> DrawingText<'a> { pub fn glyph_colors(self, glyph_colors: I) -> Self where I: IntoIterator, - C: IntoLinSrgba, + C: Into, { - let glyph_colors = glyph_colors - .into_iter() - .map(|c| c.into_lin_srgba()) - .collect(); + let glyph_colors = glyph_colors.into_iter().map(|c| c.into()).collect(); self.map_ty(|ty| ty.glyph_colors(glyph_colors)) } @@ -264,7 +259,7 @@ impl draw::render::RenderPrimitive for Text { fn render_primitive( self, ctxt: draw::render::RenderContext, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) -> draw::render::PrimitiveRender { let Text { spatial, @@ -289,7 +284,7 @@ impl draw::render::RenderPrimitive for Text { let w = maybe_x.unwrap_or(200.0); let h = maybe_y.unwrap_or(200.0); let rect: geom::Rect = geom::Rect::from_wh([w, h].into()); - let color = color.unwrap_or_else(|| ctxt.theme.fill_lin_srgba(&theme::Primitive::Text)); + let color = color.unwrap_or_else(|| ctxt.theme.fill(&theme::Primitive::Text)); let text_str = &ctxt.text_buffer[text.clone()]; let text = text::text(text_str).layout(&layout).build(rect); @@ -376,10 +371,9 @@ impl draw::render::RenderPrimitive for Text { let rect = to_nannou_rect(screen_rect); // Create a mesh-compatible vertex from the position and tex_coords. - let v = |p: Vec2, tex_coords: [f32; 2]| -> draw::mesh::Vertex { - let p = transform.transform_point3([p.x, p.y, 0.0].into()); - let point = draw::mesh::vertex::Point::from(p); - draw::mesh::vertex::new(point, g_color.to_owned(), tex_coords.into()) + let v = |p: Vec2, tex_coords: [f32; 2]| -> Vertex { + let point = transform.transform_point3([p.x, p.y, 0.0].into()); + (point, g_color.to_owned(), tex_coords.into()) }; // The sides of the UV rect. @@ -393,11 +387,13 @@ impl draw::render::RenderPrimitive for Text { let bottom_right = v(rect.bottom_right(), [uv_r, uv_b]); let top_left = v(rect.top_left(), [uv_l, uv_t]); let top_right = v(rect.top_right(), [uv_r, uv_t]); - let start_ix = mesh.points().len() as u32; - mesh.push_vertex(top_left); - mesh.push_vertex(bottom_left); - mesh.push_vertex(bottom_right); - mesh.push_vertex(top_right); + let start_ix = mesh.count_vertices() as u32; + + for (point, color, uv) in [top_left, bottom_left, bottom_right, top_right] { + mesh.points_mut().push(point.to_array()); + mesh.colors_mut().push(color.as_linear_rgba_f32()); + mesh.tex_coords_mut().push(uv.to_array()); + } // Now the indices. let tl_ix = start_ix; @@ -435,9 +431,9 @@ impl SetDimensions for Text { } } -impl SetColor for Text { - fn rgba_mut(&mut self) -> &mut Option { - SetColor::rgba_mut(&mut self.style.color) +impl SetColor for Text { + fn color_mut(&mut self) -> &mut Option { + SetColor::color_mut(&mut self.style.color) } } diff --git a/bevy_nannou_draw/src/draw/primitive/texture.rs b/bevy_nannou_draw/src/draw/primitive/texture.rs index 899c0814d..458293153 100644 --- a/bevy_nannou_draw/src/draw/primitive/texture.rs +++ b/bevy_nannou_draw/src/draw/primitive/texture.rs @@ -76,7 +76,7 @@ impl draw::render::RenderPrimitive for Texture { fn render_primitive( self, mut ctxt: draw::render::RenderContext, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) -> draw::render::PrimitiveRender { let Texture { texture_handle, diff --git a/bevy_nannou_draw/src/draw/primitive/tri.rs b/bevy_nannou_draw/src/draw/primitive/tri.rs index b817a33ea..30f122299 100644 --- a/bevy_nannou_draw/src/draw/primitive/tri.rs +++ b/bevy_nannou_draw/src/draw/primitive/tri.rs @@ -1,13 +1,10 @@ use crate::draw::primitive::polygon::{self, PolygonInit, PolygonOptions, SetPolygon}; use crate::draw::primitive::Primitive; use crate::draw::properties::spatial::{dimension, orientation, position}; -use crate::draw::properties::{ - ColorScalar, LinSrgba, SetColor, SetDimensions, SetOrientation, SetPosition, SetStroke, -}; +use crate::draw::properties::{SetColor, SetDimensions, SetOrientation, SetPosition, SetStroke}; use crate::draw::{self, Drawing}; use bevy::prelude::*; use lyon::tessellation::StrokeOptions; -use nannou_core::color::conv::IntoLinSrgba; use nannou_core::geom; /// Properties related to drawing a **Tri**. @@ -27,7 +24,7 @@ impl Tri { /// Stroke the outline with the given color. pub fn stroke(self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { self.stroke_color(color) } @@ -51,7 +48,7 @@ impl<'a> DrawingTri<'a> { /// Stroke the outline with the given color. pub fn stroke(self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { self.map_ty(|ty| ty.stroke(color)) } @@ -71,7 +68,7 @@ impl draw::render::RenderPrimitive for Tri { fn render_primitive( self, ctxt: draw::render::RenderContext, - mesh: &mut draw::Mesh, + mesh: &mut Mesh, ) -> draw::render::PrimitiveRender { let Tri { mut tri, @@ -148,9 +145,9 @@ impl SetDimensions for Tri { } } -impl SetColor for Tri { - fn rgba_mut(&mut self) -> &mut Option { - SetColor::rgba_mut(&mut self.polygon) +impl SetColor for Tri { + fn color_mut(&mut self) -> &mut Option { + SetColor::color_mut(&mut self.polygon) } } diff --git a/bevy_nannou_draw/src/draw/properties/color.rs b/bevy_nannou_draw/src/draw/properties/color.rs index dea093690..f4a2d0fca 100644 --- a/bevy_nannou_draw/src/draw/properties/color.rs +++ b/bevy_nannou_draw/src/draw/properties/color.rs @@ -1,19 +1,10 @@ -use nannou_core::color::{self, Component, IntoLinSrgba, LinSrgba}; +use bevy::prelude::Color; use num_traits::Float; -/// A **Srgba** type with the default Scalar. -pub type DefaultSrgba = color::Srgba; - -/// A **LinSrgba** type with the default Scalar. -pub type DefaultLinSrgba = color::LinSrgba; - /// Nodes that support setting colors. -pub trait SetColor: Sized -where - S: Component, -{ +pub trait SetColor: Sized { /// Provide a mutable reference to the RGBA field which can be used for setting colors. - fn rgba_mut(&mut self) -> &mut Option>; + fn color_mut(&mut self) -> &mut Option; /// Specify a color. /// @@ -22,44 +13,30 @@ where /// Colors that have no alpha channel will be given an opaque alpha channel value `1.0`. fn color(mut self, color: C) -> Self where - C: IntoLinSrgba, + C: Into, { - *self.rgba_mut() = Some(color.into_lin_srgba()); + *self.color_mut() = Some(color.into()); self } /// Specify the color via red, green and blue channels. - fn rgb(self, r: T, g: T, b: T) -> Self - where - T: Component, - S: Float, - { - self.color(color::Srgb::new(r, g, b)) + fn rgb(self, r: f32, g: f32, b: f32) -> Self { + self.color(Color::rgb(r, g, b)) } /// Specify the color via red, green and blue channels as bytes - fn rgb8(self, r: u8, g: u8, b: u8) -> Self - where - S: Float, - { - self.color(color::Srgb::::new(r, g, b)) + fn rgb8(self, r: u8, g: u8, b: u8) -> Self { + self.color(Color::rgb_u8(r, g, b)) } /// Specify the color via red, green, blue and alpha channels. - fn rgba(self, r: T, g: T, b: T, a: T) -> Self - where - T: Component, - S: Float, - { - self.color(color::Srgba::new(r, g, b, a)) + fn rgba(self, r: f32, g: f32, b: f32, a: f32) -> Self { + self.color(Color::rgba(r, g, b, a)) } /// Specify the color via red, green, blue and alpha channels as bytes - fn rgba8(self, r: u8, g: u8, b: u8, a: u8) -> Self - where - S: Float, - { - self.color(color::Srgba::::new(r, g, b, a)) + fn rgba8(self, r: u8, g: u8, b: u8, a: u8) -> Self { + self.color(Color::rgba_u8(r, g, b, a)) } /// Specify the color via hue, saturation and luminance. @@ -71,12 +48,9 @@ where /// /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on /// this color space. - fn hsl(self, h: S, s: S, l: S) -> Self - where - S: Float + Into>, - { - let hue = color::RgbHue::from_degrees(h * S::from(360.0).unwrap()); - self.color(color::Hsl::new(hue, s, l)) + fn hsl(self, h: f32, s: f32, l: f32) -> Self { + let hue = h * 360.0; + self.color(Color::hsl(hue, s, l)) } /// Specify the color via hue, saturation, luminance and an alpha channel. @@ -88,65 +62,52 @@ where /// /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on /// this color space. - fn hsla(self, h: S, s: S, l: S, a: S) -> Self - where - S: Float + Into>, - { - let hue = color::RgbHue::from_degrees(h * S::from(360.0).unwrap()); - self.color(color::Hsla::new(hue, s, l, a)) + fn hsla(self, h: f32, s: f32, l: f32, a: f32) -> Self { + let hue = h * 360.0; + self.color(Color::hsla(hue, s, l, a)) } - /// Specify the color via hue, saturation and *value* (brightness). - /// - /// This is sometimes also known as "hsb". - /// - /// The given hue expects a value between `0.0` and `1.0` where `0.0` is 0 degress and `1.0` is - /// 360 degrees (or 2 PI radians). - /// - /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on - /// this color space. - fn hsv(self, h: S, s: S, v: S) -> Self - where - S: Float, - { - let hue = color::RgbHue::from_degrees(h * S::from(360.0).unwrap()); - self.color(color::Hsv::new(hue, s, v)) - } + // /// Specify the color via hue, saturation and *value* (brightness). + // /// + // /// This is sometimes also known as "hsb". + // /// + // /// The given hue expects a value between `0.0` and `1.0` where `0.0` is 0 degress and `1.0` is + // /// 360 degrees (or 2 PI radians). + // /// + // /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on + // /// this color space. + // fn hsv(self, h: f32, s: f32, v: f32) -> Self { + // let hue = h * 360.0; + // self.color(Color:: (hue, s, v)) + // } - /// Specify the color via hue, saturation, *value* (brightness) and an alpha channel. - /// - /// This is sometimes also known as "hsba". - /// - /// The given hue expects a value between `0.0` and `1.0` where `0.0` is 0 degress and `1.0` is - /// 360 degrees (or 2 PI radians). - /// - /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on - /// this color space. - fn hsva(self, h: S, s: S, v: S, a: S) -> Self - where - S: Float, - { - let hue = color::RgbHue::from_degrees(h * S::from(360.0).unwrap()); - self.color(color::Hsva::new(hue, s, v, a)) - } + // /// Specify the color via hue, saturation, *value* (brightness) and an alpha channel. + // /// + // /// This is sometimes also known as "hsba". + // /// + // /// The given hue expects a value between `0.0` and `1.0` where `0.0` is 0 degress and `1.0` is + // /// 360 degrees (or 2 PI radians). + // /// + // /// See the [wikipedia entry](https://en.wikipedia.org/wiki/HSL_and_HSV) for more details on + // /// this color space. + // fn hsva(self, h: S, s: S, v: S, a: S) -> Self + // where + // S: Float, + // { + // let hue = color::RgbHue::from_degrees(h * S::from(360.0).unwrap()); + // self.color(color::Hsva::new(hue, s, v, a)) + // } /// Specify the color as gray scale /// /// The given g expects a value between `0.0` and `1.0` where `0.0` is black and `1.0` is white - fn gray(self, g: T) -> Self - where - T: Component, - S: Float, - { - self.color(color::Srgb::new(g, g, g)) + fn gray(self, g: f32) -> Self { + self.color(Color::rgb(g, g, g)) } } -impl SetColor for Option> -where - S: Component, -{ - fn rgba_mut(&mut self) -> &mut Option> { +impl SetColor for Option { + fn color_mut(&mut self) -> &mut Option { self } } diff --git a/bevy_nannou_draw/src/draw/properties/mod.rs b/bevy_nannou_draw/src/draw/properties/mod.rs index 8aa8bcf9d..dc566a22d 100644 --- a/bevy_nannou_draw/src/draw/properties/mod.rs +++ b/bevy_nannou_draw/src/draw/properties/mod.rs @@ -17,12 +17,3 @@ pub use self::spatial::dimension::SetDimensions; pub use self::spatial::orientation::SetOrientation; pub use self::spatial::position::SetPosition; pub use self::stroke::SetStroke; - -/// The scalar type used for the color channel values. -pub type ColorScalar = nannou_core::color::DefaultScalar; - -/// The RGBA type used by the `Common` params. -pub type Srgba = color::DefaultSrgba; - -/// The RGBA type used by the `Common` params. -pub type LinSrgba = color::DefaultLinSrgba; diff --git a/bevy_nannou_draw/src/draw/render/mod.rs b/bevy_nannou_draw/src/draw/render/mod.rs index c53758076..267439492 100644 --- a/bevy_nannou_draw/src/draw/render/mod.rs +++ b/bevy_nannou_draw/src/draw/render/mod.rs @@ -1,4 +1,3 @@ -use crate::draw::mesh::vertex::{Color, TexCoords}; use crate::{draw, text}; use bevy::prelude::*; use lyon::path::PathEvent; @@ -10,7 +9,7 @@ use std::ops::{Deref, DerefMut}; /// Draw API primitives that may be rendered via the **Renderer** type. pub trait RenderPrimitive { /// Render self into the given mesh. - fn render_primitive(self, ctxt: RenderContext, mesh: &mut draw::Mesh) -> PrimitiveRender; + fn render_primitive(self, ctxt: RenderContext, mesh: &mut Mesh) -> PrimitiveRender; } /// Information about the way in which a primitive was rendered. @@ -28,10 +27,10 @@ pub struct PrimitiveRender { /// The context provided to primitives to assist with the rendering process. pub struct RenderContext<'a> { pub transform: &'a Mat4, - pub intermediary_mesh: &'a draw::Mesh, + pub intermediary_mesh: &'a Mesh, pub path_event_buffer: &'a [PathEvent], pub path_points_colored_buffer: &'a [(Vec2, Color)], - pub path_points_textured_buffer: &'a [(Vec2, TexCoords)], + pub path_points_textured_buffer: &'a [(Vec2, Vec2)], pub text_buffer: &'a str, pub theme: &'a draw::Theme, pub glyph_cache: &'a mut GlyphCache, @@ -93,7 +92,7 @@ impl Default for PrimitiveRender { } impl RenderPrimitive for draw::Primitive { - fn render_primitive(self, ctxt: RenderContext, mesh: &mut draw::Mesh) -> PrimitiveRender { + fn render_primitive(self, ctxt: RenderContext, mesh: &mut Mesh) -> PrimitiveRender { match self { draw::Primitive::Arrow(prim) => prim.render_primitive(ctxt, mesh), draw::Primitive::Mesh(prim) => prim.render_primitive(ctxt, mesh), diff --git a/bevy_nannou_draw/src/draw/theme.rs b/bevy_nannou_draw/src/draw/theme.rs index 381e2b0a6..3a7a521d2 100644 --- a/bevy_nannou_draw/src/draw/theme.rs +++ b/bevy_nannou_draw/src/draw/theme.rs @@ -1,4 +1,4 @@ -use nannou_core::color::{LinSrgba, Srgba}; +use bevy::prelude::Color; use std::collections::HashMap; /// A set of styling defaults used for coloring texturing geometric primitives that have no entry @@ -6,16 +6,16 @@ use std::collections::HashMap; #[derive(Clone, Debug)] pub struct Theme { /// Fill color defaults. - pub fill_color: Color, + pub fill_color: ThemeColor, /// Stroke color defaults. - pub stroke_color: Color, + pub stroke_color: ThemeColor, } /// A set of defaults used for coloring. #[derive(Clone, Debug)] -pub struct Color { - pub default: Srgba, - pub primitive: HashMap, +pub struct ThemeColor { + pub default: Color, + pub primitive: HashMap, } /// Primitive geometry types that may have unique default styles. @@ -38,8 +38,8 @@ pub enum Primitive { } impl Theme { - /// Retrieve the non-linear sRGBA fill color representation for the given primitive. - pub fn fill_srgba(&self, prim: &Primitive) -> Srgba { + /// Retrieve the fill color representation for the given primitive. + pub fn fill(&self, prim: &Primitive) -> Color { self.fill_color .primitive .get(prim) @@ -47,37 +47,27 @@ impl Theme { .unwrap_or(self.fill_color.default) } - /// Retrieve the linaer sRGBA fill color representation for the given primitive. - pub fn fill_lin_srgba(&self, prim: &Primitive) -> LinSrgba { - self.fill_srgba(prim).into_linear() - } - - /// Retrieve the non-linear sRGBA stroke color representation for the given primitive. - pub fn stroke_srgba(&self, prim: &Primitive) -> Srgba { + /// Retrieve the stroke color representation for the given primitive. + pub fn stroke(&self, prim: &Primitive) -> Color { self.stroke_color .primitive .get(prim) .map(|&c| c) .unwrap_or(self.stroke_color.default) } - - /// Retrieve the linaer sRGBA stroke color representation for the given primitive. - pub fn stroke_lin_srgba(&self, prim: &Primitive) -> LinSrgba { - self.stroke_srgba(prim).into_linear() - } } impl Default for Theme { fn default() -> Self { // TODO: This should be pub const. - let default_fill = Srgba::new(1.0, 1.0, 1.0, 1.0); - let default_stroke = Srgba::new(0.0, 0.0, 0.0, 1.0); + let default_fill = Color::rgba(1.0, 1.0, 1.0, 1.0); + let default_stroke = Color::rgba(0.0, 0.0, 0.0, 1.0); - let fill_color = Color { + let fill_color = ThemeColor { default: default_fill, primitive: Default::default(), }; - let mut stroke_color = Color { + let mut stroke_color = ThemeColor { default: default_stroke, primitive: Default::default(), }; diff --git a/bevy_nannou_render/src/draw_function.rs b/bevy_nannou_render/src/draw_function.rs deleted file mode 100644 index 1382521e3..000000000 --- a/bevy_nannou_render/src/draw_function.rs +++ /dev/null @@ -1,147 +0,0 @@ -use bevy::ecs::query::ROQueryItem; -use bevy::ecs::system::lifetimeless::{Read, SRes}; -use bevy::ecs::system::SystemParamItem; -use bevy::pbr::SetMeshViewBindGroup; -use bevy::render::extract_component::DynamicUniformIndex; -use bevy::render::render_asset::RenderAssets; -use bevy::render::render_phase::{ - PhaseItem, RenderCommand, RenderCommandResult, SetItemPipeline, TrackedRenderPass, -}; -use bevy::render::render_resource as wgpu; - -use crate::pipeline::NannouPipeline; -use crate::{ - DefaultTextureHandle, DrawMesh, DrawMeshHandle, DrawMeshItem, DrawMeshUniform, - DrawMeshUniformBindGroup, TextureBindGroupCache, -}; - -pub type DrawDrawMeshItem3d = ( - SetItemPipeline, - SetMeshViewBindGroup<0>, - SetDrawMeshUniformBindGroup<1>, - SetDrawMeshTextBindGroup<2>, - SetDrawMeshTextureBindGroup<3>, - SetDrawMeshScissor, - DrawDrawMeshItem, -); - -pub struct SetDrawMeshUniformBindGroup; -impl RenderCommand

for SetDrawMeshUniformBindGroup { - type Param = SRes; - type ViewWorldQuery = (); - type ItemWorldQuery = Read>; - - #[inline] - fn render<'w>( - _item: &P, - _view: ROQueryItem<'w, Self::ViewWorldQuery>, - uniform_index: ROQueryItem<'w, Self::ItemWorldQuery>, - bind_group: SystemParamItem<'w, '_, Self::Param>, - pass: &mut TrackedRenderPass<'w>, - ) -> RenderCommandResult { - pass.set_bind_group( - I, - &bind_group.into_inner().bind_group, - &[uniform_index.index()], - ); - RenderCommandResult::Success - } -} - -pub struct SetDrawMeshTextureBindGroup; -impl RenderCommand

for SetDrawMeshTextureBindGroup { - type Param = (SRes, SRes); - type ViewWorldQuery = (); - type ItemWorldQuery = Read; - - #[inline] - fn render<'w>( - _item: &P, - _view: ROQueryItem<'w, Self::ViewWorldQuery>, - draw_mesh_item: ROQueryItem<'w, Self::ItemWorldQuery>, - (default_texture, bind_groups): SystemParamItem<'w, '_, Self::Param>, - pass: &mut TrackedRenderPass<'w>, - ) -> RenderCommandResult { - let texture = match &draw_mesh_item.texture { - None => &default_texture.0, - Some(texture) => texture, - }; - - let Some(bind_group) = bind_groups.into_inner().get(texture) else { - return RenderCommandResult::Failure; - }; - - pass.set_bind_group(I, &bind_group, &[]); - RenderCommandResult::Success - } -} - -pub struct SetDrawMeshTextBindGroup; -impl RenderCommand

for SetDrawMeshTextBindGroup { - type Param = SRes; - type ViewWorldQuery = (); - type ItemWorldQuery = (); - - #[inline] - fn render<'w>( - _item: &P, - _view: ROQueryItem<'w, Self::ViewWorldQuery>, - _entity: ROQueryItem<'w, Self::ItemWorldQuery>, - pipeline: SystemParamItem<'w, '_, Self::Param>, - pass: &mut TrackedRenderPass<'w>, - ) -> RenderCommandResult { - pass.set_bind_group(I, &pipeline.into_inner().text_bind_group, &[]); - RenderCommandResult::Success - } -} - -pub struct SetDrawMeshScissor; -impl RenderCommand

for SetDrawMeshScissor { - type Param = (); - type ViewWorldQuery = (); - type ItemWorldQuery = Read; - - fn render<'w>( - _item: &P, - _view: ROQueryItem<'w, Self::ViewWorldQuery>, - entity: ROQueryItem<'w, Self::ItemWorldQuery>, - _param: SystemParamItem<'w, '_, Self::Param>, - pass: &mut TrackedRenderPass<'w>, - ) -> RenderCommandResult { - if let Some(scissor) = entity.scissor { - pass.set_scissor_rect(scissor.left, scissor.bottom, scissor.width, scissor.height); - } - - RenderCommandResult::Success - } -} - -pub struct DrawDrawMeshItem; -impl RenderCommand

for DrawDrawMeshItem { - type Param = SRes>; - type ViewWorldQuery = Read; - type ItemWorldQuery = Read; - - #[inline] - fn render<'w>( - _item: &P, - handle: ROQueryItem<'w, Self::ViewWorldQuery>, - draw_mesh_item: ROQueryItem<'w, Self::ItemWorldQuery>, - draw_meshes: SystemParamItem<'w, '_, Self::Param>, - pass: &mut TrackedRenderPass<'w>, - ) -> RenderCommandResult { - let Some(mesh) = draw_meshes.into_inner().get(&handle.0) else { - return RenderCommandResult::Failure; - }; - - // Set the buffers. - // Note: this is a no-op if the buffers have already been set on this pass - pass.set_index_buffer(mesh.index_buffer.slice(..), 0, wgpu::IndexFormat::Uint32); - pass.set_vertex_buffer(0, mesh.point_buffer.slice(..)); - pass.set_vertex_buffer(1, mesh.color_buffer.slice(..)); - pass.set_vertex_buffer(2, mesh.tex_coords_buffer.slice(..)); - - pass.draw_indexed(draw_mesh_item.index_range.clone(), 0, 0..1); - RenderCommandResult::Success - } -} diff --git a/bevy_nannou_render/src/lib.rs b/bevy_nannou_render/src/lib.rs index 5c7bae06f..88a53ca7a 100644 --- a/bevy_nannou_render/src/lib.rs +++ b/bevy_nannou_render/src/lib.rs @@ -7,12 +7,15 @@ use bevy::core_pipeline::core_3d; use bevy::core_pipeline::core_3d::{Transparent3d, CORE_3D}; use bevy::ecs::system::lifetimeless::SRes; use bevy::ecs::system::SystemParamItem; +use bevy::prelude::shape::Cube; use bevy::prelude::*; use bevy::render::camera::{ExtractedCamera, NormalizedRenderTarget, RenderTarget}; use bevy::render::extract_component::{ ComponentUniforms, ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin, }; use bevy::render::extract_resource::{ExtractResource, ExtractResourcePlugin}; +use bevy::render::mesh::Indices; +use bevy::render::primitives::Sphere; use bevy::render::render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets}; use bevy::render::render_graph::{RenderGraphApp, ViewNode, ViewNodeRunner}; use bevy::render::render_phase::{AddRenderCommand, DrawFunctions, RenderPhase}; @@ -29,9 +32,9 @@ use bevy::render::{render_resource as wgpu, Extract, RenderSet}; use bevy::render::{Render, RenderApp}; use bevy::window::{PrimaryWindow, WindowRef}; use lyon::lyon_tessellation::{FillTessellator, StrokeTessellator}; +use wgpu_types::PrimitiveTopology; -use crate::draw_function::DrawDrawMeshItem3d; -use bevy_nannou_draw::draw::mesh::vertex; +use bevy_nannou_draw::draw::mesh::MeshExt; use bevy_nannou_draw::draw::render::{ GlyphCache, RenderContext, RenderPrimitive, Scissor, VertexMode, }; @@ -39,11 +42,6 @@ use bevy_nannou_draw::{draw, Draw}; use nannou_core::geom; use nannou_core::math::map_range; -use crate::pipeline::{NannouPipeline, NannouPipelineKey}; - -mod draw_function; -mod pipeline; - pub struct NannouRenderPlugin; pub const NANNOU_SHADER_HANDLE: Handle = Handle::weak_from_u128(43700360588854283521); @@ -58,42 +56,14 @@ impl Plugin for NannouRenderPlugin { ); app.add_systems(Startup, setup_default_texture) - .add_plugins(UniformComponentPlugin::::default()) - .add_plugins(RenderAssetPlugin::::default()) .add_plugins(( ExtractComponentPlugin::::default(), - ExtractComponentPlugin::::default(), ExtractComponentPlugin::::default(), )) .add_plugins(ExtractResourcePlugin::::default()) .insert_resource(GlyphCache::new([1024; 2], 0.1, 0.1)) - .init_asset::() - .add_systems(PreUpdate, clear_draw_items) .add_systems(Update, texture_event_handler) - .add_systems(Last, (add_meshes, update_draw_mesh).chain()); - } - - fn finish(&self, app: &mut App) { - let Ok(render_app) = app.get_sub_app_mut(RenderApp) else { - return; - }; - - render_app - .init_resource::>() - .init_resource::() - .add_render_command::() - .add_systems(ExtractSchedule, extract_draw_items) - .add_systems( - Render, - ( - prepare_default_texture_bind_group, - prepare_texture_bind_groups, - prepare_draw_mesh_uniform_bind_group, - ) - .in_set(RenderSet::PrepareBindGroups), - ) - .add_systems(Render, queue_draw_mesh_items.in_set(RenderSet::Queue)) - .init_resource::(); + .add_systems(Last, update_draw_mesh.chain()); } } @@ -107,34 +77,6 @@ pub struct DefaultTextureHandle(Handle); #[derive(Component, Deref, DerefMut, ExtractComponent, Clone)] pub struct NannouTextureHandle(Handle); -#[derive(Component, ExtractComponent, Clone)] -pub struct DrawMeshItem { - scissor: Option, - texture: Option>, - vertex_mode: VertexMode, - blend: wgpu::BlendState, - topology: wgpu::PrimitiveTopology, - index_range: Range, -} - -#[derive(Component, ExtractComponent, Clone)] -pub struct DrawMeshHandle(Handle); - -/// Create a mesh asset for every draw instance -fn add_meshes( - mut commands: Commands, - mut meshes: ResMut>, - draw: Query<(Entity, Option<&DrawMeshHandle>), With>, -) { - for (entity, handle) in draw.iter() { - if let None = handle { - let mesh = DrawMesh::default(); - let mesh = meshes.add(mesh); - commands.entity(entity).insert(DrawMeshHandle(mesh)); - } - } -} - fn texture_event_handler( mut commands: Commands, mut ev_asset: EventReader>, @@ -164,83 +106,17 @@ fn setup_default_texture(mut commands: Commands, mut images: ResMut>, - default_texture_handle: Res, - render_device: Res, - nannou_pipeline: Res, - mut texture_bind_group_cache: ResMut, -) { - let texture = images.get(&**default_texture_handle).unwrap(); - let bind_group = NannouPipeline::create_texture_bind_group( - &render_device, - &nannou_pipeline.texture_bind_group_layout, - &texture.sampler, - &texture.texture_view, - ); - texture_bind_group_cache.insert((**default_texture_handle).clone(), bind_group); -} - -fn prepare_texture_bind_groups( - gpu_images: Res>, - mut texture_bind_group_cache: ResMut, - render_device: Res, - nannou_textures: Query<&NannouTextureHandle>, -) { - // TODO: maybe don't use components for this? we don't really - // need to run this on every frame, just when the textures change - for texture in nannou_textures.iter() { - if !texture_bind_group_cache.contains_key(&**texture) { - if let Some(gpu_image) = gpu_images.get(&**texture) { - let bind_group_layout = NannouPipeline::create_texture_bind_group_layout( - &render_device, - true, - wgpu::TextureSampleType::Float { filterable: true }, - ); - let bind_group = NannouPipeline::create_texture_bind_group( - &render_device, - &bind_group_layout, - &gpu_image.sampler, - &gpu_image.texture_view, - ); - texture_bind_group_cache.insert((**texture).clone(), bind_group); - } - } - } -} - -fn extract_draw_items(mut commands: Commands, items: Extract>) { - for (entity, item) in items.iter() { - commands.get_or_spawn(entity).insert(( - item.clone(), - DrawMeshUniform { - vertex_mode: item.vertex_mode as u32, - }, - )); - } -} - -fn clear_draw_items(mut commands: Commands, items: Query>) { - for entity in items.iter() { - commands.entity(entity).despawn(); - } -} - // Prepare our mesh for rendering fn update_draw_mesh( mut commands: Commands, mut glyph_cache: ResMut, windows: Query<(&Window, Has)>, - mut meshes: ResMut>, - draw: Query<(&Draw, &DrawMeshHandle, &Camera)>, + mut meshes: ResMut>, + mut materials: ResMut>, + draw: Query<(&Draw, &Camera)>, + mesh_q: Query<(&Handle, &Handle), With>, ) { - for (draw, handle, camera) in &draw { - let Some(mut mesh) = meshes.get_mut(&handle.0) else { - continue; - }; - mesh.clear(); - let mut items: Vec = Vec::new(); - + for (draw, camera) in &draw { let window = if let RenderTarget::Window(window_ref) = camera.target { match window_ref { WindowRef::Primary => { @@ -288,7 +164,6 @@ fn update_draw_mesh( // Keep track of context changes. let mut curr_ctxt = draw::Context::default(); - let mut curr_scissor = None; // Collect all draw commands to avoid borrow errors. let draw_cmds: Vec<_> = draw.drain_commands().collect(); @@ -297,14 +172,10 @@ fn update_draw_mesh( .intermediary_state .read() .expect("failed to lock intermediary state"); - for cmd in draw_cmds { + for (i, cmd) in draw_cmds.into_iter().enumerate() { match cmd { draw::DrawCommand::Context(ctxt) => curr_ctxt = ctxt, draw::DrawCommand::Primitive(prim) => { - // Track the prev index and vertex counts. - let prev_index_count = mesh.indices().len() as u32; - let prev_vert_count = mesh.vertex_count(); - // Info required during rendering. let ctxt = RenderContext { intermediary_mesh: &intermediary_state.intermediary_mesh, @@ -322,204 +193,43 @@ fn update_draw_mesh( output_attachment_scale_factor: scale_factor, }; - // Render the primitive. - let render = prim.render_primitive(ctxt, &mut mesh); - - // If the mesh indices are unchanged, there's nothing to be drawn. - if prev_index_count == mesh.indices().len() as u32 { - assert_eq!( - prev_vert_count, - mesh.vertex_count(), - "vertices were submitted during `render` without submitting indices", - ); - continue; - } - - let new_scissor = curr_ctxt.scissor; - let scissor_changed = Some(new_scissor) != curr_scissor; - - let scissor = if scissor_changed { - curr_scissor = Some(new_scissor); - let rect = match curr_ctxt.scissor { - draw::Scissor::Full => full_rect, - draw::Scissor::Rect(rect) => full_rect - .overlap(rect) - .unwrap_or(geom::Rect::from_w_h(0.0, 0.0)), - draw::Scissor::NoOverlap => geom::Rect::from_w_h(0.0, 0.0), - }; - let [left, bottom] = window_to_scissor(rect.bottom_left().into()); - let (width, height) = rect.w_h(); - let (width, height) = (pt_to_px(width), pt_to_px(height)); - let scissor = Scissor { - left, - bottom, - width, - height, - }; - Some(scissor) - } else { - None + // Get or spawn the mesh and material. + let (mesh, material) = match mesh_q.iter().nth(i) { + // We already have a mesh and material for this index. + Some((mesh, material)) => (mesh.clone(), material.clone()), + // We need to spawn a new mesh and material for this index. + None => { + let mesh = Mesh::init_with_topology(curr_ctxt.topology); + let mesh = meshes.add(mesh); + let material = materials.add(StandardMaterial::default()); + + commands.spawn(( + NannouMesh, + PbrBundle { + mesh: mesh.clone(), + material: material.clone(), + ..default() + }, + )); + + (mesh, material) + } }; - items.push(DrawMeshItem { - scissor, - texture: render.texture_handle.clone(), - vertex_mode: render.vertex_mode, - blend: curr_ctxt.blend, - topology: curr_ctxt.topology, - index_range: prev_index_count..mesh.indices().len() as u32, - }); + // Fetch the mesh and material. + let (mesh, material) = ( + meshes.get_mut(&mesh).unwrap(), + materials.get_mut(&material).unwrap(), + ); + + // Render the primitive. + let render = prim.render_primitive(ctxt, mesh); + material.base_color_texture = render.texture_handle; } } } - - commands.spawn_batch(items); } } -#[derive(Component, ShaderType, Clone, Copy)] -pub struct DrawMeshUniform { - vertex_mode: u32, -} - -// Resource wrapper for our view uniform bind group -#[derive(Resource)] -pub struct DrawMeshUniformBindGroup { - bind_group: wgpu::BindGroup, -} - -impl DrawMeshUniformBindGroup { - fn new( - device: &RenderDevice, - layout: &wgpu::BindGroupLayout, - binding: wgpu::BindingResource, - ) -> DrawMeshUniformBindGroup { - let bind_group = bevy_nannou_wgpu::BindGroupBuilder::new() - .binding(binding) - .build(device, layout); - - DrawMeshUniformBindGroup { bind_group } - } -} - -fn prepare_draw_mesh_uniform_bind_group( - mut commands: Commands, - pipeline: Res, - render_device: Res, - uniforms: Res>, -) { - if let Some(binding) = uniforms.uniforms().binding() { - commands.insert_resource(DrawMeshUniformBindGroup::new( - &render_device, - &pipeline.mesh_bind_group_layout, - binding, - )); - } -} - -#[derive(Asset, Deref, DerefMut, TypePath, Clone, Default, Debug)] -pub struct DrawMesh(draw::Mesh); - -#[derive(Debug, Clone)] -pub struct GpuDrawMesh { - index_buffer: wgpu::Buffer, - point_buffer: wgpu::Buffer, - color_buffer: wgpu::Buffer, - tex_coords_buffer: wgpu::Buffer, -} - -impl RenderAsset for DrawMesh { - type ExtractedAsset = DrawMesh; - type PreparedAsset = GpuDrawMesh; - type Param = SRes; - - fn extract_asset(&self) -> Self::ExtractedAsset { - self.clone() - } - - fn prepare_asset( - mesh: Self::ExtractedAsset, - render_device: &mut SystemParamItem, - ) -> Result> { - let colors = mesh - .colors() - .iter() - .map(|c| Vec4::new(c.red, c.green, c.blue, c.alpha)) - .collect::>(); - let vertex_usage = wgpu::BufferUsages::VERTEX; - let points_bytes = cast_slice(&mesh.points()[..]); - let colors_bytes = cast_slice(&colors); - let tex_coords_bytes = cast_slice(&mesh.tex_coords()); - let indices_bytes = cast_slice(&mesh.indices()); - let point_buffer = render_device.create_buffer_with_data(&BufferInitDescriptor { - label: Some("nannou Renderer point_buffer"), - contents: points_bytes, - usage: vertex_usage, - }); - let color_buffer = render_device.create_buffer_with_data(&BufferInitDescriptor { - label: Some("nannou Renderer color_buffer"), - contents: colors_bytes, - usage: vertex_usage, - }); - let tex_coords_buffer = render_device.create_buffer_with_data(&BufferInitDescriptor { - label: Some("nannou Renderer tex_coords_buffer"), - contents: tex_coords_bytes, - usage: vertex_usage, - }); - let index_buffer = render_device.create_buffer_with_data(&BufferInitDescriptor { - label: Some("nannou Renderer index_buffer"), - contents: indices_bytes, - usage: wgpu::BufferUsages::INDEX, - }); - - Ok(GpuDrawMesh { - index_buffer, - point_buffer, - color_buffer, - tex_coords_buffer, - }) - } -} - -#[derive(Resource, Deref, DerefMut, Default)] -pub struct TextureBindGroupCache(HashMap, wgpu::BindGroup>); - -pub fn queue_draw_mesh_items( - draw_functions: Res>, - pipeline: Res, - mut pipelines: ResMut>, - pipeline_cache: Res, - msaa: Res, - items: Query<(Entity, &DrawMeshItem)>, - mut views: Query<(&ExtractedView, &mut RenderPhase)>, -) { - let draw_function = draw_functions - .read() - .get_id::() - .unwrap(); - for (view, mut transparent_phase) in &mut views { - for (entity, item) in items.iter() { - let key = NannouPipelineKey { - output_color_format: if view.hdr { - ViewTarget::TEXTURE_FORMAT_HDR - } else { - wgpu::TextureFormat::bevy_default() - }, - sample_count: msaa.samples(), - topology: item.topology, - blend_state: item.blend, - }; - - let pipeline = pipelines.specialize(&pipeline_cache, &pipeline, key); - - transparent_phase.add(Transparent3d { - entity, - draw_function, - pipeline, - distance: 0., - batch_range: 0..1, - dynamic_offset: None, - }); - } - } -} +#[derive(Component)] +pub struct NannouMesh; diff --git a/bevy_nannou_render/src/pipeline.rs b/bevy_nannou_render/src/pipeline.rs deleted file mode 100644 index 9433d421d..000000000 --- a/bevy_nannou_render/src/pipeline.rs +++ /dev/null @@ -1,245 +0,0 @@ -use std::hash::Hash; - -use bevy::core_pipeline::core_3d::CORE_3D_DEPTH_FORMAT; -use bevy::pbr::{MeshPipeline, MeshPipelineKey}; -use bevy::prelude::*; -use bevy::render::render_phase::RenderCommand; -use bevy::render::render_resource as wgpu; -use bevy::render::render_resource::{RenderPipelineDescriptor, SpecializedRenderPipeline}; -use bevy::render::renderer::RenderDevice; -use bevy::render::view::ViewTarget; - -use bevy_nannou_draw::draw::mesh; -use bevy_nannou_draw::draw::mesh::vertex::Point; - -use crate::{DrawMeshUniform, NANNOU_SHADER_HANDLE}; - -#[derive(Resource)] -pub struct NannouPipeline { - pub mesh_pipeline: MeshPipeline, - pub glyph_cache_texture: wgpu::Texture, - pub text_bind_group_layout: wgpu::BindGroupLayout, - pub text_bind_group: wgpu::BindGroup, - pub texture_bind_group_layout: wgpu::BindGroupLayout, - pub texture_bind_group: wgpu::BindGroup, - pub mesh_bind_group_layout: wgpu::BindGroupLayout, -} - -// This key is computed and used to cache the pipeline. -#[derive(Eq, PartialEq, Hash, Clone, Copy, Debug)] -pub struct NannouPipelineKey { - pub output_color_format: wgpu::TextureFormat, - pub sample_count: u32, - pub blend_state: wgpu::BlendState, - pub topology: wgpu::PrimitiveTopology, -} - -impl NannouPipeline { - /// The default sample count - pub const DEFAULT_SAMPLE_COUNT: u32 = 1; - /// The default depth format - pub const DEFAULT_DEPTH_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Depth32Float; - pub const DEFAULT_COLOR_BLEND: wgpu::BlendComponent = wgpu::BlendComponent { - src_factor: wgpu::BlendFactor::SrcAlpha, - dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, - operation: wgpu::BlendOperation::Add, - }; - pub const DEFAULT_ALPHA_BLEND: wgpu::BlendComponent = wgpu::BlendComponent { - src_factor: wgpu::BlendFactor::One, - dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, - operation: wgpu::BlendOperation::Add, - }; - /// The default color blend state - pub const DEFAULT_BLEND_STATE: wgpu::BlendState = wgpu::BlendState { - color: Self::DEFAULT_COLOR_BLEND, - alpha: Self::DEFAULT_ALPHA_BLEND, - }; - /// The default primitive topology - pub const DEFAULT_PRIMITIVE_TOPOLOGY: wgpu::PrimitiveTopology = - wgpu::PrimitiveTopology::TriangleList; - pub const GLYPH_CACHE_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::R8Unorm; - - fn render_pipeline( - &self, - color_format: wgpu::TextureFormat, - sample_count: u32, - blend_state: wgpu::BlendState, - topology: wgpu::PrimitiveTopology, - ) -> RenderPipelineDescriptor { - let view_key = MeshPipelineKey::from_msaa_samples(sample_count) - | MeshPipelineKey::from_hdr(color_format == ViewTarget::TEXTURE_FORMAT_HDR) - | MeshPipelineKey::from_primitive_topology(topology); - let view_layout = self.mesh_pipeline.get_view_layout(view_key.into()); - - bevy_nannou_wgpu::RenderPipelineBuilder::from_layout( - &[ - view_layout.clone(), - self.mesh_bind_group_layout.clone(), - self.text_bind_group_layout.clone(), - self.texture_bind_group_layout.clone(), - ], - NANNOU_SHADER_HANDLE, - ) - .vertex_entry_point("vertex") - .fragment_shader(NANNOU_SHADER_HANDLE) - .fragment_entry_point("fragment") - .color_format(color_format) - .add_vertex_buffer::(&[wgpu::VertexAttribute { - format: wgpu::VertexFormat::Float32x3, - offset: 0, - shader_location: 0, - }]) - .add_vertex_buffer::(&[wgpu::VertexAttribute { - format: wgpu::VertexFormat::Float32x4, - offset: 0, - shader_location: 1, - }]) - .add_vertex_buffer::(&[wgpu::VertexAttribute { - format: wgpu::VertexFormat::Float32x2, - offset: 0, - shader_location: 2, - }]) - .depth_format(CORE_3D_DEPTH_FORMAT) - .sample_count(sample_count) - .color_blend(blend_state.color) - .alpha_blend(blend_state.alpha) - .primitive_topology(topology) - .build() - } - - pub(crate) fn create_texture_bind_group_layout( - device: &RenderDevice, - filtering: bool, - texture_sample_type: wgpu::TextureSampleType, - ) -> wgpu::BindGroupLayout { - bevy_nannou_wgpu::BindGroupLayoutBuilder::new() - .sampler(wgpu::ShaderStages::FRAGMENT, filtering) - .texture( - wgpu::ShaderStages::FRAGMENT, - false, - wgpu::TextureViewDimension::D2, - texture_sample_type, - ) - .build(device) - } - - pub fn create_texture_bind_group( - device: &RenderDevice, - layout: &wgpu::BindGroupLayout, - sampler: &wgpu::Sampler, - texture_view: &wgpu::TextureView, - ) -> wgpu::BindGroup { - bevy_nannou_wgpu::BindGroupBuilder::new() - .sampler(sampler) - .texture_view(texture_view) - .build(device, layout) - } - - fn create_text_bind_group_layout( - device: &RenderDevice, - filtering: bool, - ) -> wgpu::BindGroupLayout { - bevy_nannou_wgpu::BindGroupLayoutBuilder::new() - .sampler(wgpu::ShaderStages::FRAGMENT, filtering) - .texture( - wgpu::ShaderStages::FRAGMENT, - false, - wgpu::TextureViewDimension::D2, - wgpu::TextureFormat::R8Unorm - .sample_type(None) - .expect("Expected format to have sample type"), - ) - .build(device) - } - - fn create_text_bind_group( - device: &RenderDevice, - layout: &wgpu::BindGroupLayout, - sampler: &wgpu::Sampler, - glyph_cache_texture_view: &wgpu::TextureView, - ) -> wgpu::BindGroup { - bevy_nannou_wgpu::BindGroupBuilder::new() - .sampler(sampler) - .texture_view(glyph_cache_texture_view) - .build(device, layout) - } -} - -impl SpecializedRenderPipeline for NannouPipeline { - type Key = NannouPipelineKey; - - fn specialize(&self, key: Self::Key) -> RenderPipelineDescriptor { - self.render_pipeline( - key.output_color_format, - key.sample_count, - key.blend_state, - key.topology, - ) - } -} - -impl FromWorld for NannouPipeline { - fn from_world(render_world: &mut World) -> Self { - let device = render_world.get_resource::().unwrap(); - - // Create the glyph cache texture. - let text_sampler_desc = bevy_nannou_wgpu::SamplerBuilder::new().into_descriptor(); - let text_sampler_filtering = bevy_nannou_wgpu::sampler_filtering(&text_sampler_desc); - let text_sampler = device.create_sampler(&text_sampler_desc); - let glyph_cache_texture = bevy_nannou_wgpu::TextureBuilder::new() - .size([1024; 2]) - .usage(wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST) - .format(Self::GLYPH_CACHE_TEXTURE_FORMAT) - .build(device); - - let glyph_cache_texture_view = - glyph_cache_texture.create_view(&wgpu::TextureViewDescriptor::default()); - - // The default texture for the case where the user has not specified one. - let default_texture = bevy_nannou_wgpu::TextureBuilder::new() - .size([64; 2]) - .usage(wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST) - .build(device); - - // Bind group for text. - let text_bind_group_layout = - Self::create_text_bind_group_layout(device, text_sampler_filtering); - let text_bind_group = Self::create_text_bind_group( - device, - &text_bind_group_layout, - &text_sampler, - &glyph_cache_texture_view, - ); - - // Initialise the sampler set with the default sampler. - let sampler_desc = bevy_nannou_wgpu::SamplerBuilder::new().into_descriptor(); - let texture_sampler = device.create_sampler(&sampler_desc); - - let texture_bind_group_layout = Self::create_texture_bind_group_layout( - device, - bevy_nannou_wgpu::sampler_filtering(&sampler_desc), - wgpu::TextureSampleType::Float { filterable: true }, - ); - let texture_bind_group = Self::create_texture_bind_group( - device, - &texture_bind_group_layout, - &texture_sampler, - &default_texture.create_view(&wgpu::TextureViewDescriptor::default()), - ); - - let mesh_bind_group_layout = bevy_nannou_wgpu::BindGroupLayoutBuilder::new() - .uniform_buffer::(wgpu::ShaderStages::VERTEX, true) - .build(device); - let mesh_pipeline = render_world.resource::().clone(); - - NannouPipeline { - mesh_pipeline, - mesh_bind_group_layout, - glyph_cache_texture, - text_bind_group_layout, - text_bind_group, - texture_bind_group_layout, - texture_bind_group, - } - } -}