diff --git a/.github/workflows/bevy_api_gen.yml b/.github/workflows/bevy_api_gen.yml index 417087bf7f..2a916bce8f 100644 --- a/.github/workflows/bevy_api_gen.yml +++ b/.github/workflows/bevy_api_gen.yml @@ -25,7 +25,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2024-05-20 + toolchain: nightly-2024-11-05 override: true - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 @@ -52,7 +52,7 @@ jobs: with: profile: minimal components: rustfmt - toolchain: nightly-2024-05-20 + toolchain: nightly-2024-11-05 override: true - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 @@ -75,7 +75,7 @@ jobs: rm -rf crates - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2024-05-20 + toolchain: nightly-2024-11-05 components: clippy override: true - name: Rust Cache @@ -98,7 +98,7 @@ jobs: rm -rf crates - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2024-05-20 + toolchain: nightly-2024-11-05 override: true - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 @@ -120,7 +120,7 @@ jobs: rm -rf crates - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2024-05-20 + toolchain: nightly-2024-11-05 override: true - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 diff --git a/.github/workflows/bevy_mod_scripting.yml b/.github/workflows/bevy_mod_scripting.yml index f95933ea09..92497dee1d 100644 --- a/.github/workflows/bevy_mod_scripting.yml +++ b/.github/workflows/bevy_mod_scripting.yml @@ -8,26 +8,36 @@ on: - '.github/workflows/release-plz.yml' - '.github/workflows/bevy_api_gen.yml' - '.github/workflows/macro_tests.yml' + - 'docs/**' name: Check and Lint - bevy_mod_scripting +concurrency: + # Use github.run_id on main branch + # Use github.event.pull_request.number on pull requests, so it's unique per pull request + # Use github.ref on other branches, so it's unique per branch + group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: check: - name: Check + name: Check - ${{ matrix.run_args.label }} runs-on: ${{ matrix.run_args.os }} strategy: matrix: run_args: [ - {os: windows-latest, lua: lua54, cross: x86_64-pc-windows-msvc}, - {os: macOS-latest, lua: lua54, cross: x86_64-apple-darwin}, - {os: ubuntu-latest, lua: lua54, cross: aarch64-unknown-linux-gnu}, - {os: ubuntu-latest, lua: lua51, cross: x86_64-unknown-linux-gnu}, - {os: ubuntu-latest, lua: lua52, cross: x86_64-unknown-linux-gnu}, - {os: ubuntu-latest, lua: lua53, cross: x86_64-unknown-linux-gnu}, - {os: ubuntu-latest, lua: lua54, cross: x86_64-unknown-linux-gnu}, - {os: ubuntu-latest, lua: luajit, cross: x86_64-unknown-linux-gnu}, - {os: ubuntu-latest, lua: luajit52, cross: x86_64-unknown-linux-gnu} + {label: Windows - All Features, os: windows-latest, features: "lua54,rhai,teal,lua_script_api,rhai_script_api,rune", cross: x86_64-pc-windows-msvc }, + {label: MacOS - All Features, os: macOS-latest, features: "lua54,rhai,teal,lua_script_api,rhai_script_api,rune", cross: x86_64-apple-darwin }, + {label: Ubuntu - All Features, os: ubuntu-latest, features: "lua54,lua_script_api,rhai,teal,rhai_script_api,rune", cross: x86_64-unknown-linux-gnu }, + {label: Ubuntu Aarch64 - All Features, os: ubuntu-latest, features: "lua54,rhai,teal,lua_script_api,rhai_script_api,rune", cross: aarch64-unknown-linux-gnu }, + {label: Ubuntu - Lua51, os: ubuntu-latest, features: "lua51,lua_script_api", cross: x86_64-unknown-linux-gnu }, + {label: Ubuntu - Lua52, os: ubuntu-latest, features: "lua52,lua_script_api", cross: x86_64-unknown-linux-gnu }, + {label: Ubuntu - Lua53, os: ubuntu-latest, features: "lua53,lua_script_api", cross: x86_64-unknown-linux-gnu }, + {label: Ubuntu - Luajit, os: ubuntu-latest, features: "luajit,lua_script_api", cross: x86_64-unknown-linux-gnu }, + {label: Ubuntu - Luajit52, os: ubuntu-latest, features: "luajit52,lua_script_api", cross: x86_64-unknown-linux-gnu }, + {label: Ubuntu - Luau, os: ubuntu-latest, features: "luau,lua_script_api", cross: x86_64-unknown-linux-gnu } + ] steps: - if: runner.os == 'linux' @@ -48,7 +58,7 @@ jobs: with: command: check target: ${{ matrix.run_args.cross }} - args: --workspace --features=${{ matrix.run_args.lua }},rhai,teal,lua_script_api,rhai_script_api,rune --profile=ephemeral-build + args: --workspace --features=${{ matrix.run_args.features }} --profile=ephemeral-build fmt: name: Rustfmt diff --git a/.github/workflows/mdbook.yml b/.github/workflows/mdbook.yml new file mode 100644 index 0000000000..80984049ee --- /dev/null +++ b/.github/workflows/mdbook.yml @@ -0,0 +1,38 @@ +name: Deploy mdBook to GitHub Pages + +on: + push: + branches: + - "**" + paths: + - 'docs/**' + - '.github/workflows/mdbook.yml' + +jobs: + + build: + name: Build Book - mdbook + runs-on: ubuntu-latest + steps: + + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Rust Cache + uses: Swatinem/rust-cache@v2.7.3 + - name: Install mdBook + run: cargo install mdbook + + - name: Build the book + run: cd docs && mdbook build + + - name: Deploy to GitHub Pages + if: github.ref == 'refs/heads/main' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/book \ No newline at end of file diff --git a/.github/workflows/pr-titles.yml b/.github/workflows/pr-titles.yml new file mode 100644 index 0000000000..a55a70ffdb --- /dev/null +++ b/.github/workflows/pr-titles.yml @@ -0,0 +1,26 @@ +name: "Lint PR" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + - reopened + +permissions: + pull-requests: read + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: | + fix + feat + chore \ No newline at end of file diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml index a18df1d672..0c16e7328c 100644 --- a/.github/workflows/release-plz.yml +++ b/.github/workflows/release-plz.yml @@ -7,7 +7,8 @@ permissions: on: push: branches: - - [main, staging] + - main + - staging jobs: diff --git a/CHANGELOG.md b/CHANGELOG.md index eafa9f40c6..5d91457df6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +## [0.8.0-alpha.2](https://github.com/makspll/bevy_mod_scripting/compare/v0.8.0-alpha.1...v0.8.0-alpha.2) - 2024-12-03 + +### Fixed + +- bug when compiling without `teal` feature ([#148](https://github.com/makspll/bevy_mod_scripting/pull/148)) + +### Other + +- Small fixes ([#155](https://github.com/makspll/bevy_mod_scripting/pull/155)) +- Luau support attempt ([#154](https://github.com/makspll/bevy_mod_scripting/pull/154)) +- Bump bevy & bevy console ([#153](https://github.com/makspll/bevy_mod_scripting/pull/153)) +- Fix failing doctest ([#146](https://github.com/makspll/bevy_mod_scripting/pull/146)) +- update Cargo.toml dependencies + +## [0.8.0-alpha.1](https://github.com/makspll/bevy_mod_scripting/compare/v0.8.0-alpha.0...v0.8.0-alpha.1) - 2024-11-10 + +### Other + +- Bump Bevy release candidate ([#143](https://github.com/makspll/bevy_mod_scripting/pull/143)) +- update Cargo.toml dependencies + ## [0.7.1](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting-v0.7.0...bevy_mod_scripting-v0.7.1) - 2024-11-03 ### Other diff --git a/Cargo.toml b/Cargo.toml index 9a9b42fa48..c119d32866 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting" -version = "0.7.1" +version = "0.8.0-alpha.2" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" @@ -44,6 +44,7 @@ lua53 = ["bevy_mod_scripting_lua/lua53", "lua"] lua54 = ["bevy_mod_scripting_lua/lua54", "lua"] luajit = ["bevy_mod_scripting_lua/luajit", "lua"] luajit52 = ["bevy_mod_scripting_lua/luajit52", "lua"] +luau = ["bevy_mod_scripting_lua/luau", "lua"] # optional lua_script_api = ["bevy_script_api/lua"] @@ -63,22 +64,22 @@ rune = ["bevy_mod_scripting_rune"] [dependencies] bevy = { workspace = true } bevy_mod_scripting_core = { workspace = true } -bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.7.1", optional = true } -bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.7.1", optional = true } -bevy_mod_scripting_rune = { path = "crates/languages/bevy_mod_scripting_rune", version = "0.7.1", optional = true } -bevy_script_api = { path = "crates/bevy_script_api", version = "0.7.1", optional = true } +bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.8.0-alpha.2", optional = true } +bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.8.0-alpha.2", optional = true } +bevy_mod_scripting_rune = { path = "crates/languages/bevy_mod_scripting_rune", version = "0.8.0-alpha.2", optional = true } +bevy_script_api = { path = "crates/bevy_script_api", version = "0.8.0-alpha.2", optional = true } [workspace.dependencies] -bevy = { version = "0.14.2", default-features = false } -bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.7.1" } -bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.7.1" } +bevy = { version = "0.15.0", default-features = false } +bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.8.0-alpha.2" } +bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.8.0-alpha.2" } [dev-dependencies] bevy = { workspace = true, default-features = true } clap = { version = "4.1", features = ["derive"] } rand = "0.8.5" -bevy_console = "0.12" +bevy_console = "0.13" rhai-rand = "0.1" [workspace] diff --git a/check.sh b/check.sh index c731dd4c03..eb7a8f5488 100755 --- a/check.sh +++ b/check.sh @@ -4,7 +4,7 @@ CURRENT_DIR=$(basename "$PWD") if [[ "$CURRENT_DIR" == "bevy_api_gen" ]]; then - cargo +nightly-2024-05-20 clippy --all-targets --message-format=json + cargo +nightly-2024-11-05 clippy --all-targets --message-format=json else cargo clippy --workspace --all-targets --message-format=json --features="lua54 lua_script_api rhai rhai_script_api teal rune bevy/file_watcher bevy/multi_threaded" fi diff --git a/crates/bevy_api_gen/Cargo.toml b/crates/bevy_api_gen/Cargo.toml index 8a06e6f3f2..501fca03d5 100644 --- a/crates/bevy_api_gen/Cargo.toml +++ b/crates/bevy_api_gen/Cargo.toml @@ -37,17 +37,16 @@ source = "discover" rustc_private = true [rust-analyzer.check] -overrideCommand = ["cargo", "+nightly-2024-05-20", "a", "--message-format=json"] +overrideCommand = ["cargo", "+nightly-2024-11-05", "a", "--message-format=json"] [dependencies] log = "0.4" env_logger = "0.11" -rustc_plugin = "=0.10.0-nightly-2024-05-20" +rustc_plugin = { git = "https://github.com/makspll/rustc_plugin", branch = "feature/rust-1.82.0" } indexmap = "2" tempdir = "0.3" cargo_metadata = "0.18" -rustc_data_structures = "0.0.1" serde_json = "1" serde = "1" clap = { version = "4", features = ["derive", "string"] } diff --git a/crates/bevy_api_gen/readme.md b/crates/bevy_api_gen/readme.md index d8fe50e518..93f556bb94 100644 --- a/crates/bevy_api_gen/readme.md +++ b/crates/bevy_api_gen/readme.md @@ -8,7 +8,7 @@ bevy_api_gen is a Cargo plugin that generates reflection-powered wrappers for Be To install bevy_api_gen, use the following command: ```bash -cargo +nightly-2024-05-20 install bevy_api_gen +cargo +nightly-2024-11-05 install bevy_api_gen ``` # Usage @@ -18,17 +18,17 @@ cargo +nightly-2024-05-20 install bevy_api_gen To run the main codegen process, use the following command: ```bash -cargo +nightly-2024-05-20 bevy-api-gen generate +cargo +nightly-2024-11-05 bevy-api-gen generate ``` -This will perform all parts of the process and generate meta as well as .rs files for each crate in your workspace in your `/target/plugin-nightly-2024-05-20/bevy_api_gen` directory +This will perform all parts of the process and generate meta as well as .rs files for each crate in your workspace in your `/target/plugin-nightly-2024-11-05/bevy_api_gen` directory ## Collect After generating all the files, you can 'collect' them in a mod.rs file like so: ```bash -cargo +nightly-2024-05-20 bevy-api-gen collect +cargo +nightly-2024-11-05 bevy-api-gen collect ``` ## List Types @@ -36,7 +36,7 @@ cargo +nightly-2024-05-20 bevy-api-gen collect To see a list of all `Reflect` implementing types in your workspace run: ```bash -cargo +nightly-2024-05-20 bevy-api-gen list-types > all_types.txt +cargo +nightly-2024-11-05 bevy-api-gen list-types > all_types.txt ``` ## List Templates @@ -44,7 +44,7 @@ cargo +nightly-2024-05-20 bevy-api-gen list-types > all_types.txt To see the list of all templates which you can override use: ```bash -cargo +nightly-2024-05-20 bevy-api-gen list-templates +cargo +nightly-2024-11-05 bevy-api-gen list-templates ``` ## Print Template @@ -52,5 +52,5 @@ cargo +nightly-2024-05-20 bevy-api-gen list-templates You can also print any of the templates to stdout: ```bash -cargo +nightly-2024-05-20 bevy-api-gen print item.tera +cargo +nightly-2024-11-05 bevy-api-gen print item.tera ``` \ No newline at end of file diff --git a/crates/bevy_api_gen/rust-toolchain.toml b/crates/bevy_api_gen/rust-toolchain.toml index 2a12ab9a2b..0d5ae08dc0 100644 --- a/crates/bevy_api_gen/rust-toolchain.toml +++ b/crates/bevy_api_gen/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] components = ["clippy", "rust-src", "rustc-dev", "llvm-tools"] -channel = "nightly-2024-05-20" +channel = "nightly-2024-11-05" diff --git a/crates/bevy_api_gen/src/bin/driver.rs b/crates/bevy_api_gen/src/bin/driver.rs index 0136073b8e..492f0673fb 100644 --- a/crates/bevy_api_gen/src/bin/driver.rs +++ b/crates/bevy_api_gen/src/bin/driver.rs @@ -1,3 +1,4 @@ +#![feature(rustc_private)] use bevy_api_gen::*; fn main() { diff --git a/crates/bevy_api_gen/src/bin/main.rs b/crates/bevy_api_gen/src/bin/main.rs index 626e1169a1..658afed6a0 100644 --- a/crates/bevy_api_gen/src/bin/main.rs +++ b/crates/bevy_api_gen/src/bin/main.rs @@ -1,3 +1,4 @@ +#![feature(rustc_private)] use std::{ collections::HashMap, env, diff --git a/crates/bevy_api_gen/src/context.rs b/crates/bevy_api_gen/src/context.rs index dd18021df5..498a958c42 100644 --- a/crates/bevy_api_gen/src/context.rs +++ b/crates/bevy_api_gen/src/context.rs @@ -138,13 +138,13 @@ impl CachedTraits { .all(|t| self.std_source_traits.contains_key(*t)) } - pub(crate) fn missing_std_source_traits(&self) -> Vec { - STD_SOURCE_TRAITS - .iter() - .filter(|t| !self.std_source_traits.contains_key(**t)) - .map(|s| (*s).to_owned()) - .collect() - } + // pub(crate) fn missing_std_source_traits(&self) -> Vec { + // STD_SOURCE_TRAITS + // .iter() + // .filter(|t| !self.std_source_traits.contains_key(**t)) + // .map(|s| (*s).to_owned()) + // .collect() + // } } #[derive(Clone, Debug)] diff --git a/crates/bevy_api_gen/src/lib.rs b/crates/bevy_api_gen/src/lib.rs index f16b9bee3a..23d294032e 100644 --- a/crates/bevy_api_gen/src/lib.rs +++ b/crates/bevy_api_gen/src/lib.rs @@ -1,15 +1,13 @@ #![feature(rustc_private, let_chains)] #![deny(rustc::internal)] + extern crate rustc_ast; extern crate rustc_driver; extern crate rustc_errors; extern crate rustc_hir; -extern crate rustc_hir_analysis; extern crate rustc_infer; extern crate rustc_interface; -extern crate rustc_lint; extern crate rustc_middle; -extern crate rustc_session; extern crate rustc_span; extern crate rustc_trait_selection; diff --git a/crates/bevy_api_gen/src/meta.rs b/crates/bevy_api_gen/src/meta.rs index 3f85dd3039..a9861da384 100644 --- a/crates/bevy_api_gen/src/meta.rs +++ b/crates/bevy_api_gen/src/meta.rs @@ -94,7 +94,7 @@ impl MetaLoader { let cache = self.cache.borrow(); if cache.contains_key(crate_name) { trace!("Loading meta from cache for: {}", crate_name); - return cache.get(crate_name).cloned(); + cache.get(crate_name).cloned() } else { trace!("Loading meta from filesystem for: {}", crate_name); drop(cache); diff --git a/crates/bevy_api_gen/src/modifying_file_loader.rs b/crates/bevy_api_gen/src/modifying_file_loader.rs index a8c01d85cf..7fab22dd3b 100644 --- a/crates/bevy_api_gen/src/modifying_file_loader.rs +++ b/crates/bevy_api_gen/src/modifying_file_loader.rs @@ -1,7 +1,11 @@ -use std::io; +use std::{ + io, + sync::atomic::{AtomicBool, Ordering}, +}; use log::trace; -use rustc_data_structures::sync::{AtomicBool, Lrc, Ordering}; +use rustc_middle::ty::data_structures::Lrc; +// use rustc_data_structures::sync::{AtomicBool, Lrc}; use rustc_span::source_map::{FileLoader, RealFileLoader}; /// Injects extern statements into the first loaded file (crate root) diff --git a/crates/bevy_api_gen/src/passes/cache_traits.rs b/crates/bevy_api_gen/src/passes/cache_traits.rs index bdbd956815..12e2972bfe 100644 --- a/crates/bevy_api_gen/src/passes/cache_traits.rs +++ b/crates/bevy_api_gen/src/passes/cache_traits.rs @@ -66,11 +66,12 @@ pub(crate) fn cache_traits(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool { .join(", ") ); - panic!( - "Could not find traits: [{}] in crate: {}, did bootstrapping go wrong?", - ctxt.cached_traits.missing_std_source_traits().join(", "), - tcx.crate_name(LOCAL_CRATE) - ) + // TODO: figure out why some crates are missing std::fmt::Display etc + // panic!( + // "Could not find traits: [{}] in crate: {}, did bootstrapping go wrong?", + // ctxt.cached_traits.missing_std_source_traits().join(", "), + // tcx.crate_name(LOCAL_CRATE) + // ) } true diff --git a/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs b/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs index ab016de1f2..8034681a41 100644 --- a/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs +++ b/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs @@ -6,7 +6,9 @@ use rustc_hir::{ Safety, }; use rustc_infer::infer::TyCtxtInferExt; -use rustc_middle::ty::{AdtKind, AssocKind, FieldDef, FnSig, ParamEnv, Ty, TyCtxt, TyKind}; +use rustc_middle::ty::{ + AdtKind, AssocKind, FieldDef, FnSig, ParamEnv, Ty, TyCtxt, TyKind, TypingMode, +}; use rustc_span::Symbol; use rustc_trait_selection::infer::InferCtxtExt; @@ -86,7 +88,6 @@ pub(crate) fn find_methods_and_fields(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> let mut all_impls = ctxt .tcx .inherent_impls(def_id) - .unwrap() .iter() .chain(trait_impls_for_ty.iter().flatten()) .collect::>(); @@ -390,7 +391,7 @@ fn type_is_supported_as_non_proxy_return_val<'tcx>( ) -> bool { trace!("Checkign type is supported as non proxy return val: '{ty:?}' with param_env: '{param_env:?}'"); if let TyKind::Ref(region, _, _) = ty.kind() { - if !region.get_name().is_some_and(|rn| rn.as_str() == "'static") { + if region.get_name().is_none_or(|rn| rn.as_str() != "'static") { return false; } } @@ -410,7 +411,7 @@ pub(crate) fn impls_trait<'tcx>( trait_did: DefId, ) -> bool { tcx.infer_ctxt() - .build() + .build(TypingMode::non_body_analysis()) .type_implements_trait(trait_did, [ty], param_env) .must_apply_modulo_regions() } diff --git a/crates/bevy_api_gen/src/passes/find_trait_impls.rs b/crates/bevy_api_gen/src/passes/find_trait_impls.rs index 65f65e31df..9541869012 100644 --- a/crates/bevy_api_gen/src/passes/find_trait_impls.rs +++ b/crates/bevy_api_gen/src/passes/find_trait_impls.rs @@ -6,7 +6,7 @@ use rustc_infer::{ infer::{InferCtxt, TyCtxtInferExt}, traits::{Obligation, ObligationCause}, }; -use rustc_middle::ty::Ty; +use rustc_middle::ty::{Ty, TypingMode}; use rustc_span::DUMMY_SP; use rustc_trait_selection::traits::ObligationCtxt; @@ -105,7 +105,7 @@ fn type_impl_of_trait( //TODO: false negatives coming from this inference let ty = tcx.type_of(reflect_ty_did).instantiate_identity(); - let infcx = tcx.infer_ctxt().build(); + let infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis()); let result = impl_matches(&infcx, ty, impl_did); log::trace!("Result: {:#?}", result); if result { diff --git a/crates/bevy_api_gen/src/template.rs b/crates/bevy_api_gen/src/template.rs index ce8774e162..e9219d0013 100644 --- a/crates/bevy_api_gen/src/template.rs +++ b/crates/bevy_api_gen/src/template.rs @@ -195,9 +195,8 @@ pub(crate) fn configure_tera_env(tera: &mut Tera, crate_name: &str) { let file = syn::parse_file(&str) .map_err(|e| tera::Error::msg(e.to_string())) - .map_err(|e| { + .inspect_err(|_| { log::error!("prettyplease error on input: ```\n{}\n```", str); - e })?; let out = prettyplease::unparse(&file); diff --git a/crates/bevy_event_priority/CHANGELOG.md b/crates/bevy_event_priority/CHANGELOG.md index 3d3cbfbb1d..bef6372140 100644 --- a/crates/bevy_event_priority/CHANGELOG.md +++ b/crates/bevy_event_priority/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.8.0-alpha.2](https://github.com/makspll/bevy_mod_scripting/compare/bevy_event_priority-v0.8.0-alpha.1...bevy_event_priority-v0.8.0-alpha.2) - 2024-12-03 + +### Other + +- Small fixes ([#155](https://github.com/makspll/bevy_mod_scripting/pull/155)) + +## [0.8.0-alpha.1](https://github.com/makspll/bevy_mod_scripting/compare/bevy_event_priority-v0.8.0-alpha.0...bevy_event_priority-v0.8.0-alpha.1) - 2024-11-10 + +### Other + +- update Cargo.toml dependencies + ## [0.7.0](https://github.com/makspll/bevy_mod_scripting/compare/bevy_event_priority-v0.6.0...bevy_event_priority-v0.7.0) - 2024-11-03 ### Other diff --git a/crates/bevy_event_priority/Cargo.toml b/crates/bevy_event_priority/Cargo.toml index d8e2608495..44b49b815a 100644 --- a/crates/bevy_event_priority/Cargo.toml +++ b/crates/bevy_event_priority/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_event_priority" -version = "0.7.1" +version = "0.8.0-alpha.2" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" diff --git a/crates/bevy_event_priority/src/lib.rs b/crates/bevy_event_priority/src/lib.rs index 98e7546ed8..9dffb1bec9 100644 --- a/crates/bevy_event_priority/src/lib.rs +++ b/crates/bevy_event_priority/src/lib.rs @@ -89,7 +89,7 @@ pub struct PriorityIterator<'w, E: PriorityEvent> { events: &'w mut PriorityEvents, } -impl<'w, E: PriorityEvent> Iterator for PriorityIterator<'w, E> { +impl Iterator for PriorityIterator<'_, E> { type Item = E; fn next(&mut self) -> Option { @@ -108,7 +108,7 @@ impl<'w, E: PriorityEvent> Iterator for PriorityIterator<'w, E> { } } -impl<'s, E: PriorityEvent> PriorityEventReader<'_, 's, E> { +impl PriorityEventReader<'_, '_, E> { /// Iterates over events this reader has not seen yet, while also clearing them. /// Will not remove any events of priority lower than min (0 is highest, inf is lowest) /// but will discard events of higher priority @@ -140,7 +140,7 @@ pub struct PriorityEventWriter<'w, 's, E: PriorityEvent> { marker: PhantomData<&'s usize>, } -impl<'w, 's, E: PriorityEvent> PriorityEventWriter<'w, 's, E> { +impl PriorityEventWriter<'_, '_, E> { pub fn send(&mut self, event: E, prio: u32) { self.events.events.push(EventInstance::new(event, prio)); } diff --git a/crates/bevy_mod_scripting_common/CHANGELOG.md b/crates/bevy_mod_scripting_common/CHANGELOG.md index abc0c70841..6b6f15881a 100644 --- a/crates/bevy_mod_scripting_common/CHANGELOG.md +++ b/crates/bevy_mod_scripting_common/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.8.0-alpha.2](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_common-v0.8.0-alpha.1...bevy_mod_scripting_common-v0.8.0-alpha.2) - 2024-12-03 + +### Other + +- Small fixes ([#155](https://github.com/makspll/bevy_mod_scripting/pull/155)) + ## [0.7.0](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_common-v0.6.0...bevy_mod_scripting_common-v0.7.0) - 2024-11-03 ### Other diff --git a/crates/bevy_mod_scripting_common/Cargo.toml b/crates/bevy_mod_scripting_common/Cargo.toml index 01ed7aa501..0d4ce7ee34 100644 --- a/crates/bevy_mod_scripting_common/Cargo.toml +++ b/crates/bevy_mod_scripting_common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_common" -version = "0.7.1" +version = "0.8.0-alpha.2" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" diff --git a/crates/bevy_mod_scripting_common/src/input.rs b/crates/bevy_mod_scripting_common/src/input.rs index 4ba284dd93..2547c91823 100644 --- a/crates/bevy_mod_scripting_common/src/input.rs +++ b/crates/bevy_mod_scripting_common/src/input.rs @@ -540,7 +540,6 @@ impl VisitSimpleType for TypeConstructorVisitor { #[derive(FromDeriveInput)] #[darling(attributes(proxy), forward_attrs(allow, doc, cfg))] #[allow(clippy::manual_unwrap_or_default)] - pub struct ProxyInput { /// The name of the type for which we are generating a proxy pub ident: syn::Ident, diff --git a/crates/bevy_mod_scripting_core/CHANGELOG.md b/crates/bevy_mod_scripting_core/CHANGELOG.md index 948a69efe9..4b1601dd9f 100644 --- a/crates/bevy_mod_scripting_core/CHANGELOG.md +++ b/crates/bevy_mod_scripting_core/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.8.0-alpha.2](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_core-v0.8.0-alpha.1...bevy_mod_scripting_core-v0.8.0-alpha.2) - 2024-12-03 + +### Other + +- Bump bevy & bevy console ([#153](https://github.com/makspll/bevy_mod_scripting/pull/153)) + +## [0.8.0-alpha.1](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_core-v0.8.0-alpha.0...bevy_mod_scripting_core-v0.8.0-alpha.1) - 2024-11-10 + +### Other + +- update Cargo.toml dependencies + ## [0.7.0](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_core-v0.6.0...bevy_mod_scripting_core-v0.7.0) - 2024-11-03 ### Other diff --git a/crates/bevy_mod_scripting_core/Cargo.toml b/crates/bevy_mod_scripting_core/Cargo.toml index 68847b7a87..e1448c42a5 100644 --- a/crates/bevy_mod_scripting_core/Cargo.toml +++ b/crates/bevy_mod_scripting_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_core" -version = "0.7.1" +version = "0.8.0-alpha.2" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" @@ -23,7 +23,6 @@ doc_always = [] [dependencies] bevy = { workspace = true, default-features = false, features = [ "bevy_asset", - "bevy_gltf", "bevy_animation", "bevy_core_pipeline", "bevy_ui", @@ -32,7 +31,7 @@ bevy = { workspace = true, default-features = false, features = [ "bevy_text", "bevy_sprite", ] } -bevy_event_priority = { path = "../bevy_event_priority", version = "0.7.1" } +bevy_event_priority = { path = "../bevy_event_priority", version = "0.8.0-alpha.2" } thiserror = "1.0.31" paste = "1.0.7" parking_lot = "0.12.1" diff --git a/crates/bevy_script_api/CHANGELOG.md b/crates/bevy_script_api/CHANGELOG.md index bff45034a4..c5726fa0ad 100644 --- a/crates/bevy_script_api/CHANGELOG.md +++ b/crates/bevy_script_api/CHANGELOG.md @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.8.0-alpha.2](https://github.com/makspll/bevy_mod_scripting/compare/bevy_script_api-v0.8.0-alpha.1...bevy_script_api-v0.8.0-alpha.2) - 2024-12-03 + +### Other + +- Small fixes ([#155](https://github.com/makspll/bevy_mod_scripting/pull/155)) +- Luau support attempt ([#154](https://github.com/makspll/bevy_mod_scripting/pull/154)) +- Bump bevy & bevy console ([#153](https://github.com/makspll/bevy_mod_scripting/pull/153)) + +## [0.8.0-alpha.1](https://github.com/makspll/bevy_mod_scripting/compare/bevy_script_api-v0.8.0-alpha.0...bevy_script_api-v0.8.0-alpha.1) - 2024-11-10 + +### Other + +- Bump Bevy release candidate ([#143](https://github.com/makspll/bevy_mod_scripting/pull/143)) + ## [0.7.0](https://github.com/makspll/bevy_mod_scripting/compare/bevy_script_api-v0.6.0...bevy_script_api-v0.7.0) - 2024-11-03 ### Other diff --git a/crates/bevy_script_api/Cargo.toml b/crates/bevy_script_api/Cargo.toml index d4ed591fc4..faabc3bff8 100644 --- a/crates/bevy_script_api/Cargo.toml +++ b/crates/bevy_script_api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_script_api" -version = "0.7.1" +version = "0.8.0-alpha.2" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" @@ -18,7 +18,6 @@ rhai = ["bevy_mod_scripting_rhai"] [dependencies] bevy = { workspace = true, default-features = false, features = [ "bevy_asset", - "bevy_gltf", "bevy_animation", "bevy_core_pipeline", "bevy_ui", @@ -35,8 +34,8 @@ parking_lot = "0.12.1" paste = "1.0.7" thiserror = "1.0.32" # lua -bevy_mod_scripting_lua = { path = "../languages/bevy_mod_scripting_lua", version = "0.7.1", optional = true } -bevy_mod_scripting_lua_derive = { path = "../languages/bevy_mod_scripting_lua_derive", version = "0.7.1", optional = true } -bevy_mod_scripting_rhai = { path = "../languages/bevy_mod_scripting_rhai", version = "0.7.1", optional = true } +bevy_mod_scripting_lua = { path = "../languages/bevy_mod_scripting_lua", version = "0.8.0-alpha.2", optional = true } +bevy_mod_scripting_lua_derive = { path = "../languages/bevy_mod_scripting_lua_derive", version = "0.8.0-alpha.2", optional = true } +bevy_mod_scripting_rhai = { path = "../languages/bevy_mod_scripting_rhai", version = "0.8.0-alpha.2", optional = true } smol_str = "0.2" allocator-api2 = "0.2" diff --git a/crates/bevy_script_api/src/common/bevy/mod.rs b/crates/bevy_script_api/src/common/bevy/mod.rs index ba45a35bd2..6df4b72e6e 100644 --- a/crates/bevy_script_api/src/common/bevy/mod.rs +++ b/crates/bevy_script_api/src/common/bevy/mod.rs @@ -7,12 +7,12 @@ use bevy::{ world::{Command, EntityRef, World}, }, prelude::{ - AppTypeRegistry, BuildWorldChildren, Children, DespawnChildrenRecursive, DespawnRecursive, + AppTypeRegistry, BuildChildren, Children, DespawnChildrenRecursive, DespawnRecursive, Entity, Parent, ReflectComponent, ReflectDefault, ReflectResource, }, reflect::{ - DynamicArray, DynamicEnum, DynamicList, DynamicMap, DynamicStruct, DynamicTuple, - DynamicTupleStruct, TypeRegistration, + DynamicArray, DynamicEnum, DynamicList, DynamicMap, DynamicSet, DynamicStruct, + DynamicTuple, DynamicTupleStruct, TypeRegistration, }, }; use bevy_mod_scripting_core::{prelude::ScriptError, world::WorldPointer}; @@ -169,15 +169,15 @@ impl ScriptWorld { pub fn push_child(&self, parent: Entity, child: Entity) { let mut w = self.write(); - if let Some(mut entity) = w.get_entity_mut(parent) { - entity.push_children(&[child]); + if let Ok(mut entity) = w.get_entity_mut(parent) { + entity.add_children(&[child]); } } pub fn remove_children(&self, parent: Entity, children: &[Entity]) { let mut w = self.write(); - if let Some(mut entity) = w.get_entity_mut(parent) { + if let Ok(mut entity) = w.get_entity_mut(parent) { entity.remove_children(children); } } @@ -185,19 +185,19 @@ impl ScriptWorld { pub fn insert_children(&self, parent: Entity, index: usize, children: &[Entity]) { let mut w = self.write(); - if let Some(mut entity) = w.get_entity_mut(parent) { + if let Ok(mut entity) = w.get_entity_mut(parent) { entity.insert_children(index, children); } } pub fn despawn_children_recursive(&self, entity: Entity) { let mut w = self.write(); - DespawnChildrenRecursive { entity }.apply(&mut w); + DespawnChildrenRecursive { entity, warn: true }.apply(&mut w); } pub fn despawn_recursive(&self, entity: Entity) { let mut w = self.write(); - DespawnRecursive { entity }.apply(&mut w); + DespawnRecursive { entity, warn: true }.apply(&mut w); } pub fn get_type_by_name(&self, type_name: &str) -> Option { @@ -225,7 +225,7 @@ impl ScriptWorld { let mut entity_ref = w .get_entity_mut(entity) - .ok_or_else(|| ScriptError::Other(format!("Entity is not valid {:#?}", entity)))?; + .map_err(|e| ScriptError::Other(format!("Entity is not valid {:#?}. {e}", entity)))?; let component_data = comp_type.data::().ok_or_else(|| { ScriptError::Other(format!("Not a component {}", comp_type.short_name())) @@ -243,13 +243,14 @@ impl ScriptWorld { bevy::reflect::TypeInfo::List(_) => component_data.insert(&mut entity_ref, &DynamicList::default(), ®istry_lock), bevy::reflect::TypeInfo::Array(_) => component_data.insert(&mut entity_ref, &DynamicArray::new(Box::new([])), ®istry_lock), bevy::reflect::TypeInfo::Map(_) => component_data.insert(&mut entity_ref, &DynamicMap::default(), ®istry_lock), - bevy::reflect::TypeInfo::Value(_) => component_data.insert(&mut entity_ref, + bevy::reflect::TypeInfo::Set(_) => component_data.insert(&mut entity_ref, &DynamicSet::default(), ®istry_lock), + bevy::reflect::TypeInfo::Opaque(_) => component_data.insert(&mut entity_ref, comp_type.data::().ok_or_else(|| ScriptError::Other(format!("Component {} is a value or dynamic type with no `ReflectDefault` type_data, cannot instantiate sensible value",comp_type.short_name())))? .default() - .as_ref(), + .as_partial_reflect(), ®istry_lock), - bevy::reflect::TypeInfo::Enum(_) => component_data.insert(&mut entity_ref, &DynamicEnum::default(), ®istry_lock) + bevy::reflect::TypeInfo::Enum(_) => component_data.insert(&mut entity_ref, &DynamicEnum::default(), ®istry_lock), }; // if we do not drop the lock here, line below will complain registry is still borrowed at drop drop(registry_lock); @@ -273,7 +274,7 @@ impl ScriptWorld { let entity_ref = w .get_entity(entity) - .ok_or_else(|| ScriptError::Other(format!("Entity is not valid {:#?}", entity)))?; + .map_err(|e| ScriptError::Other(format!("Entity is not valid {:#?}. {e}", entity)))?; let component_data = comp_type.data::().ok_or_else(|| { ScriptError::Other(format!("Not a component {}", comp_type.short_name())) @@ -296,7 +297,7 @@ impl ScriptWorld { let entity_ref = w .get_entity(entity) - .ok_or_else(|| ScriptError::Other(format!("Entity is not valid {:#?}", entity)))?; + .map_err(|e| ScriptError::Other(format!("Entity is not valid {:#?}. {e}", entity)))?; Ok(component_data.reflect(entity_ref).is_some()) } @@ -310,7 +311,7 @@ impl ScriptWorld { let mut entity_ref = w .get_entity_mut(entity) - .ok_or_else(|| ScriptError::Other(format!("Entity is not valid {:#?}", entity)))?; + .map_err(|e| ScriptError::Other(format!("Entity is not valid {:#?}. {e}", entity)))?; let component_data = comp_type.data::().ok_or_else(|| { ScriptError::Other(format!("Not a component {}", comp_type.short_name())) diff --git a/crates/bevy_script_api/src/common/std.rs b/crates/bevy_script_api/src/common/std.rs index 0f4c929c2e..f3da1234ff 100644 --- a/crates/bevy_script_api/src/common/std.rs +++ b/crates/bevy_script_api/src/common/std.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use bevy::reflect::{FromReflect, GetTypeRegistration, TypePath}; +use bevy::reflect::{FromReflect, GetTypeRegistration, TypePath, Typed}; use crate::{error::ReflectionError, ReflectReference, ValueIndex}; @@ -26,7 +26,7 @@ impl std::fmt::Debug for ScriptVec { } } -impl std::fmt::Display +impl std::fmt::Display for ScriptVec { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -41,7 +41,7 @@ impl std::f } } -impl ScriptVec { +impl ScriptVec { pub fn new_ref(ref_: ReflectReference) -> Self { Self { ref_, @@ -118,7 +118,7 @@ impl Iterator for ScriptVecIterator { } } -impl IntoIterator for ScriptVec { +impl IntoIterator for ScriptVec { type Item = ReflectReference; type IntoIter = ScriptVecIterator; diff --git a/crates/bevy_script_api/src/lua/bevy/mod.rs b/crates/bevy_script_api/src/lua/bevy/mod.rs index 8b2068b235..54715102b7 100644 --- a/crates/bevy_script_api/src/lua/bevy/mod.rs +++ b/crates/bevy_script_api/src/lua/bevy/mod.rs @@ -9,7 +9,7 @@ use crate::lua::{ }; use crate::providers::bevy_ecs::LuaEntity; use crate::{impl_from_lua_with_clone, impl_tealr_type}; -use bevy::hierarchy::BuildWorldChildren; +use bevy::hierarchy::BuildChildren; use bevy::prelude::{AppTypeRegistry, ReflectResource}; use bevy_mod_scripting_core::prelude::*; use bevy_mod_scripting_lua::{prelude::IntoLua, tealr}; @@ -288,8 +288,8 @@ impl TealData for LuaWorld { .map(|e| e.inner()) .collect::, _>>()?; - if let Some(mut entity) = w.get_entity_mut(parent.inner()?) { - entity.push_children(&children); + if let Ok(mut entity) = w.get_entity_mut(parent.inner()?) { + entity.add_children(&children); } Ok(()) diff --git a/crates/bevy_script_api/src/lua/std.rs b/crates/bevy_script_api/src/lua/std.rs index 6dddbe93cb..945b4c16b6 100644 --- a/crates/bevy_script_api/src/lua/std.rs +++ b/crates/bevy_script_api/src/lua/std.rs @@ -106,7 +106,8 @@ impl< + GetTypeRegistration + TypePath + for<'a> FromLuaProxy<'a> - + Clone, + + Clone + + bevy::reflect::Typed, > LuaProxyable for Option { fn ref_to_lua(self_: ReflectReference, lua: &Lua) -> mlua::Result { @@ -246,6 +247,7 @@ impl< + GetTypeRegistration + TypePath + LuaProxyable + + bevy::reflect::Typed + for<'a> FromLuaProxy<'a> + for<'a> IntoLuaProxy<'a> + std::fmt::Debug, @@ -274,6 +276,7 @@ impl< + GetTypeRegistration + TypePath + LuaProxyable + + bevy::reflect::Typed + for<'a> FromLuaProxy<'a> + for<'a> IntoLuaProxy<'a> + std::fmt::Debug, @@ -294,6 +297,7 @@ impl< + GetTypeRegistration + TypePath + LuaProxyable + + bevy::reflect::Typed + for<'a> FromLuaProxy<'a> + for<'a> IntoLuaProxy<'a>, > TealData for LuaVec @@ -384,6 +388,7 @@ impl< + GetTypeRegistration + TypePath + LuaProxyable + + bevy::reflect::Typed + for<'a> FromLuaProxy<'a> + for<'a> IntoLuaProxy<'a> + std::fmt::Debug, @@ -446,6 +451,7 @@ impl< + GetTypeRegistration + TypePath + LuaProxyable + + bevy::reflect::Typed + std::fmt::Debug, > FromLuaProxy<'lua> for Vec { diff --git a/crates/bevy_script_api/src/lua/util.rs b/crates/bevy_script_api/src/lua/util.rs index 2a96a3e538..6c611e0b81 100644 --- a/crates/bevy_script_api/src/lua/util.rs +++ b/crates/bevy_script_api/src/lua/util.rs @@ -287,6 +287,12 @@ macro_rules! impl_tealr_generic{ } + impl ::bevy::reflect::Typed for $name { + fn type_info() -> &'static ::bevy::reflect::TypeInfo { + panic!("This should never be called, I am a dummy implementation") + } + } + impl ::bevy::reflect::TypePath for $name { fn short_type_path() -> &'static str{ panic!("This should never be called, I am a dummy implementation") @@ -297,69 +303,94 @@ macro_rules! impl_tealr_generic{ } } - impl ::bevy::reflect::Reflect for $name { - fn try_apply(&mut self, _: &(dyn bevy::prelude::Reflect + 'static)) -> std::result::Result<(), bevy::reflect::ApplyError> { + impl ::bevy::reflect::PartialReflect for $name { + fn get_represented_type_info(&self) -> std::option::Option<&'static bevy::reflect::TypeInfo> { panic!("This should never be called, I am a dummy implementation"); } - fn into_any(self: Box) -> Box { + fn into_partial_reflect(self: Box) -> Box { panic!("This should never be called, I am a dummy implementation"); } - fn as_any(&self) -> &dyn std::any::Any { + fn as_partial_reflect(&self) -> &dyn ::bevy::reflect::PartialReflect { panic!("This should never be called, I am a dummy implementation"); } - fn as_any_mut(&mut self) -> &mut dyn std::any::Any { + fn as_partial_reflect_mut(&mut self) -> &mut dyn ::bevy::reflect::PartialReflect { panic!("This should never be called, I am a dummy implementation"); } - fn as_reflect(&self) -> &dyn ::bevy::reflect::Reflect { + fn try_into_reflect(self: Box) -> std::result::Result, std::boxed::Box<(dyn bevy::prelude::PartialReflect + 'static)>> { panic!("This should never be called, I am a dummy implementation"); } - fn as_reflect_mut(&mut self) -> &mut dyn ::bevy::reflect::Reflect { + fn try_as_reflect(&self) -> std::option::Option<&(dyn bevy::prelude::Reflect + 'static)> { panic!("This should never be called, I am a dummy implementation"); } - fn apply(&mut self, _: &dyn ::bevy::reflect::Reflect) { + fn try_as_reflect_mut(&mut self) -> std::option::Option<&mut (dyn bevy::prelude::Reflect + 'static)> { panic!("This should never be called, I am a dummy implementation"); } - fn set(&mut self, _: Box) -> Result<(), Box> { + fn try_apply(&mut self, _value: &dyn ::bevy::prelude::PartialReflect) -> std::result::Result<(), ::bevy::reflect::ApplyError> { panic!("This should never be called, I am a dummy implementation"); } - fn reflect_ref(&self) -> bevy::reflect::ReflectRef { + fn reflect_ref(&self) -> ::bevy::reflect::ReflectRef { panic!("This should never be called, I am a dummy implementation"); } - fn reflect_mut(&mut self) -> bevy::reflect::ReflectMut { + fn reflect_mut(&mut self) -> ::bevy::reflect::ReflectMut { panic!("This should never be called, I am a dummy implementation"); } - fn clone_value(&self) -> Box { + fn reflect_owned(self: Box) -> ::bevy::reflect::ReflectOwned { panic!("This should never be called, I am a dummy implementation"); } - fn into_reflect(self: Box) -> Box { + fn clone_value(&self) -> Box { panic!("This should never be called, I am a dummy implementation"); } + } - fn reflect_owned(self: Box) -> ::bevy::reflect::ReflectOwned { + + impl ::bevy::reflect::Reflect for $name { + + fn into_any(self: Box) -> Box { panic!("This should never be called, I am a dummy implementation"); } - fn get_represented_type_info(&self) -> std::option::Option<&'static bevy::reflect::TypeInfo> { + fn as_any(&self) -> &dyn std::any::Any { + panic!("This should never be called, I am a dummy implementation"); + } + + fn as_any_mut(&mut self) -> &mut dyn std::any::Any { + panic!("This should never be called, I am a dummy implementation"); + } + + fn as_reflect(&self) -> &dyn ::bevy::reflect::Reflect { + panic!("This should never be called, I am a dummy implementation"); + } + + fn as_reflect_mut(&mut self) -> &mut dyn ::bevy::reflect::Reflect { + panic!("This should never be called, I am a dummy implementation"); + } + + fn set(&mut self, _: Box) -> Result<(), Box> { + panic!("This should never be called, I am a dummy implementation"); + } + + fn into_reflect(self: Box) -> Box { panic!("This should never be called, I am a dummy implementation"); } } impl ::bevy::reflect::FromReflect for $name { - fn from_reflect(_: &(dyn bevy::prelude::Reflect + 'static)) -> std::option::Option { + fn from_reflect(_: &(dyn bevy::prelude::PartialReflect + 'static)) -> std::option::Option { panic!("This should never be called, I am a dummy implementation"); } + } impl ::bevy::reflect::GetTypeRegistration for $name { diff --git a/crates/bevy_script_api/src/providers/bevy_ecs.rs b/crates/bevy_script_api/src/providers/bevy_ecs.rs index 465b5fa8e3..a790dbc9a4 100644 --- a/crates/bevy_script_api/src/providers/bevy_ecs.rs +++ b/crates/bevy_script_api/src/providers/bevy_ecs.rs @@ -85,21 +85,60 @@ use bevy_script_api::{ r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] struct Entity {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy(derive(), remote = "bevy::ecs::world::OnAdd", functions[])] +#[proxy( + derive(), + remote = "bevy::ecs::world::OnAdd", + functions[r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] struct OnAdd {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy(derive(), remote = "bevy::ecs::world::OnInsert", functions[])] +#[proxy( + derive(), + remote = "bevy::ecs::world::OnInsert", + functions[r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] struct OnInsert {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy(derive(), remote = "bevy::ecs::world::OnRemove", functions[])] +#[proxy( + derive(), + remote = "bevy::ecs::world::OnRemove", + functions[r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] struct OnRemove {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "bevy::ecs::world::OnReplace", + functions[r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct OnReplace {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::ecs::component::ComponentId", @@ -118,6 +157,12 @@ struct OnRemove {} #[lua(kind = "Method")] fn index(self) -> usize; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::component::ComponentId; + "#, r#" @@ -129,12 +174,6 @@ struct OnRemove {} )] fn eq(&self, #[proxy] other: &component::ComponentId) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::component::ComponentId; - "#, r#" @@ -156,6 +195,12 @@ struct ComponentId(); remote = "bevy::ecs::component::Tick", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::component::Tick; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -167,8 +212,8 @@ struct ComponentId(); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::component::Tick; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -205,12 +250,6 @@ struct ComponentId(); this_run: bevy::ecs::component::Tick, ) -> bool; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -225,12 +264,6 @@ struct Tick {} derive(clone), remote = "bevy::ecs::component::ComponentTicks", functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::component::ComponentTicks; - -"#, - r#" /// Returns `true` if the component or resource was added after the system last ran /// (or the system is running for the first time). @@ -259,17 +292,13 @@ struct Tick {} "#, r#" -/// Returns the tick recording the time this component or resource was most recently changed. +/// Creates a new instance with the same change tick for `added` and `changed`. - #[lua(kind = "Method", output(proxy))] - fn last_changed_tick(&self) -> bevy::ecs::component::Tick; - -"#, - r#" -/// Returns the tick recording the time this component or resource was added. - - #[lua(kind = "Method", output(proxy))] - fn added_tick(&self) -> bevy::ecs::component::Tick; + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + change_tick: bevy::ecs::component::Tick, + ) -> bevy::ecs::component::ComponentTicks; "#, r#" @@ -288,6 +317,12 @@ struct Tick {} #[lua(kind = "MutatingMethod")] fn set_changed(&mut self, #[proxy] change_tick: bevy::ecs::component::Tick) -> (); +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::component::ComponentTicks; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -296,7 +331,12 @@ fn index(&self) -> String { } "#] )] -struct ComponentTicks {} +struct ComponentTicks { + #[lua(output(proxy))] + added: bevy::ecs::component::Tick, + #[lua(output(proxy))] + changed: bevy::ecs::component::Tick, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), @@ -311,12 +351,6 @@ struct ComponentTicks {} )] fn eq(&self, #[proxy] other: &identifier::Identifier) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::identifier::Identifier; - "#, r#" /// Returns the value of the low segment of the [`Identifier`]. @@ -348,6 +382,12 @@ struct ComponentTicks {} #[lua(kind = "Function", output(proxy))] fn from_bits(value: u64) -> bevy::ecs::identifier::Identifier; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::identifier::Identifier; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -369,6 +409,27 @@ struct Identifier {} "#] )] struct EntityHash {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::ecs::removal_detection::RemovedComponentEntity", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::removal_detection::RemovedComponentEntity; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct RemovedComponentEntity(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy(derive(), remote = "bevy::ecs::system::SystemIdMarker", functions[])] +struct SystemIdMarker {} #[derive(Default)] pub(crate) struct Globals; impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { @@ -391,6 +452,13 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { "Tick", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, )?; + instances + .add_instance( + "ComponentTicks", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaComponentTicks, + >::new, + )?; instances .add_instance( "Identifier", @@ -428,6 +496,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider { .process_type::() .process_type::() .process_type::() + .process_type::() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< @@ -439,6 +508,11 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider { bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, >() .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaComponentTicks, + >, + >() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< @@ -446,6 +520,8 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider { >, >() .process_type::() + .process_type::() + .process_type::() }, ), ) @@ -470,10 +546,15 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::< + bevy::ecs::removal_detection::RemovedComponentEntity, + >(); + app.register_foreign_lua_type::(); } } diff --git a/crates/bevy_script_api/src/providers/bevy_hierarchy.rs b/crates/bevy_script_api/src/providers/bevy_hierarchy.rs index e064a5cc5f..23708e43fc 100644 --- a/crates/bevy_script_api/src/providers/bevy_hierarchy.rs +++ b/crates/bevy_script_api/src/providers/bevy_hierarchy.rs @@ -33,11 +33,46 @@ struct Children(); derive(), remote = "bevy::hierarchy::prelude::Parent", functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &components::parent::Parent) -> bool; + +"#, + r#" /// Gets the [`Entity`] ID of the parent. #[lua(kind = "Method", output(proxy))] fn get(&self) -> bevy::ecs::entity::Entity; +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Parent(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::hierarchy::HierarchyEvent", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::hierarchy::HierarchyEvent; + "#, r#" @@ -47,7 +82,7 @@ struct Children(); composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &components::parent::Parent) -> bool; + fn eq(&self, #[proxy] other: &events::HierarchyEvent) -> bool; "#, r#" @@ -63,7 +98,7 @@ fn index(&self) -> String { } "#] )] -struct Parent(); +struct HierarchyEvent {} #[derive(Default)] pub(crate) struct Globals; impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { @@ -98,6 +133,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyHierarchyAPIProvider { .expect("Something went wrong documenting globals") .process_type::() .process_type::() + .process_type::() }, ), ) @@ -120,5 +156,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyHierarchyAPIProvider { fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); } } diff --git a/crates/bevy_script_api/src/providers/bevy_input.rs b/crates/bevy_script_api/src/providers/bevy_input.rs index d06224cc9a..852d5a9058 100644 --- a/crates/bevy_script_api/src/providers/bevy_input.rs +++ b/crates/bevy_script_api/src/providers/bevy_input.rs @@ -4,6 +4,7 @@ #![cfg_attr(rustfmt, rustfmt_skip)] use super::bevy_ecs::*; use super::bevy_reflect::*; +use super::bevy_core::*; use super::bevy_math::*; extern crate self as bevy_script_api; use bevy_script_api::{ @@ -11,94 +12,73 @@ use bevy_script_api::{ }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( - derive(clone), + derive(), remote = "bevy::input::gamepad::Gamepad", functions[r#" +/// Returns the USB vendor ID as assigned by the USB-IF, if available. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method")] + fn vendor_id(&self) -> std::option::Option; "#, r#" +/// Returns the USB product ID as assigned by the [vendor], if available. +/// [vendor]: Self::vendor_id - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::Gamepad; + #[lua(kind = "Method")] + fn product_id(&self) -> std::option::Option; "#, r#" +/// Returns the left stick as a [`Vec2`] - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::Gamepad) -> bool; + #[lua(kind = "Method", output(proxy))] + fn left_stick(&self) -> bevy::math::Vec2; "#, r#" -/// Creates a new [`Gamepad`]. +/// Returns the right stick as a [`Vec2`] - #[lua(kind = "Function", output(proxy))] - fn new(id: usize) -> bevy::input::gamepad::Gamepad; + #[lua(kind = "Method", output(proxy))] + fn right_stick(&self) -> bevy::math::Vec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Gamepad { - id: usize, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadAxis", - functions[r#" +/// Returns the directional pad as a [`Vec2`] - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadAxis) -> bool; + #[lua(kind = "Method", output(proxy))] + fn dpad(&self) -> bevy::math::Vec2; "#, r#" -/// Creates a new [`GamepadAxis`]. -/// # Examples -/// ``` -/// # use bevy_input::gamepad::{GamepadAxis, GamepadAxisType, Gamepad}; -/// # -/// let gamepad_axis = GamepadAxis::new( -/// Gamepad::new(1), -/// GamepadAxisType::LeftStickX, -/// ); -/// ``` +/// Returns `true` if the [`GamepadButton`] has been pressed. - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - axis_type: bevy::input::gamepad::GamepadAxisType, - ) -> bevy::input::gamepad::GamepadAxis; + #[lua(kind = "Method")] + fn pressed(&self, #[proxy] button_type: bevy::input::gamepad::GamepadButton) -> bool; "#, r#" +/// Returns `true` if the [`GamepadButton`] has been pressed during the current frame. +/// Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_released`]. - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadAxis; + #[lua(kind = "Method")] + fn just_pressed( + &self, + #[proxy] + button_type: bevy::input::gamepad::GamepadButton, + ) -> bool; "#, r#" +/// Returns `true` if the [`GamepadButton`] has been released during the current frame. +/// Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_pressed`]. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method")] + fn just_released( + &self, + #[proxy] + button_type: bevy::input::gamepad::GamepadButton, + ) -> bool; "#, r#" @@ -108,21 +88,22 @@ fn index(&self) -> String { } "#] )] -struct GamepadAxis { - #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] - axis_type: bevy::input::gamepad::GamepadAxisType, -} +struct Gamepad {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadAxisType", + remote = "bevy::input::gamepad::GamepadAxis", functions[r#" #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadAxis; + "#, r#" @@ -132,13 +113,7 @@ struct GamepadAxis { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadAxisType) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadAxisType; + fn eq(&self, #[proxy] other: &gamepad::GamepadAxis) -> bool; "#, r#" @@ -148,7 +123,7 @@ fn index(&self) -> String { } "#] )] -struct GamepadAxisType {} +struct GamepadAxis {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), @@ -175,27 +150,6 @@ struct GamepadAxisType {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::gamepad::GamepadButton; -"#, - r#" -/// Creates a new [`GamepadButton`]. -/// # Examples -/// ``` -/// # use bevy_input::gamepad::{GamepadButton, GamepadButtonType, Gamepad}; -/// # -/// let gamepad_button = GamepadButton::new( -/// Gamepad::new(1), -/// GamepadButtonType::South, -/// ); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - button_type: bevy::input::gamepad::GamepadButtonType, - ) -> bevy::input::gamepad::GamepadButton; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -204,37 +158,15 @@ fn index(&self) -> String { } "#] )] -struct GamepadButton { - #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] - button_type: bevy::input::gamepad::GamepadButtonType, -} +struct GamepadButton {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadButtonType", + remote = "bevy::input::gamepad::GamepadSettings", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonType; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadButtonType) -> bool; + fn clone(&self) -> bevy::input::gamepad::GamepadSettings; "#, r#" @@ -244,7 +176,17 @@ fn index(&self) -> String { } "#] )] -struct GamepadButtonType {} +struct GamepadSettings { + #[lua(output(proxy))] + default_button_settings: bevy::input::gamepad::ButtonSettings, + #[lua(output(proxy))] + default_axis_settings: bevy::input::gamepad::AxisSettings, + #[lua(output(proxy))] + default_button_axis_settings: bevy::input::gamepad::ButtonAxisSettings, + button_settings: ReflectedValue, + axis_settings: ReflectedValue, + button_axis_settings: ReflectedValue, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), @@ -254,6 +196,12 @@ struct GamepadButtonType {} #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::KeyCode; + "#, r#" @@ -265,12 +213,6 @@ struct GamepadButtonType {} )] fn eq(&self, #[proxy] other: &keyboard::KeyCode) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::KeyCode; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -286,12 +228,6 @@ struct KeyCode {} remote = "bevy::input::mouse::MouseButton", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseButton; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -300,6 +236,12 @@ struct KeyCode {} )] fn eq(&self, #[proxy] other: &mouse::MouseButton) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::MouseButton; + "#, r#" @@ -359,12 +301,6 @@ struct TouchInput { remote = "bevy::input::keyboard::KeyboardFocusLost", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::KeyboardFocusLost; - -"#, - r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); @@ -379,6 +315,12 @@ struct TouchInput { )] fn eq(&self, #[proxy] other: &keyboard::KeyboardFocusLost) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::KeyboardFocusLost; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -405,14 +347,14 @@ struct KeyboardFocusLost {} "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::KeyboardInput; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::KeyboardInput; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -429,10 +371,77 @@ struct KeyboardInput { logical_key: bevy::input::keyboard::Key, #[lua(output(proxy))] state: bevy::input::ButtonState, + repeat: bool, #[lua(output(proxy))] window: bevy::ecs::entity::Entity, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::mouse::AccumulatedMouseMotion", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &mouse::AccumulatedMouseMotion) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::AccumulatedMouseMotion; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AccumulatedMouseMotion { + #[lua(output(proxy))] + delta: bevy::math::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::mouse::AccumulatedMouseScroll", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &mouse::AccumulatedMouseScroll) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::AccumulatedMouseScroll; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AccumulatedMouseScroll { + #[lua(output(proxy))] + unit: bevy::input::mouse::MouseScrollUnit, + #[lua(output(proxy))] + delta: bevy::math::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::input::mouse::MouseButtonInput", @@ -564,14 +573,14 @@ struct MouseWheel { "#, r#" -/// Creates a [`GamepadAxisChangedEvent`]. +/// Creates a new [`GamepadAxisChangedEvent`] #[lua(kind = "Function", output(proxy))] fn new( #[proxy] - gamepad: bevy::input::gamepad::Gamepad, + entity: bevy::ecs::entity::Entity, #[proxy] - axis_type: bevy::input::gamepad::GamepadAxisType, + axis: bevy::input::gamepad::GamepadAxis, value: f32, ) -> bevy::input::gamepad::GamepadAxisChangedEvent; @@ -585,9 +594,9 @@ fn index(&self) -> String { )] struct GamepadAxisChangedEvent { #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, + entity: bevy::ecs::entity::Entity, #[lua(output(proxy))] - axis_type: bevy::input::gamepad::GamepadAxisType, + axis: bevy::input::gamepad::GamepadAxis, value: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -595,6 +604,21 @@ struct GamepadAxisChangedEvent { derive(clone), remote = "bevy::input::gamepad::GamepadButtonChangedEvent", functions[r#" +/// Creates a new [`GamepadButtonChangedEvent`] + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + entity: bevy::ecs::entity::Entity, + #[proxy] + button: bevy::input::gamepad::GamepadButton, + #[proxy] + state: bevy::input::ButtonState, + value: f32, + ) -> bevy::input::gamepad::GamepadButtonChangedEvent; + +"#, + r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::gamepad::GamepadButtonChangedEvent; @@ -610,19 +634,6 @@ struct GamepadAxisChangedEvent { )] fn eq(&self, #[proxy] other: &gamepad::GamepadButtonChangedEvent) -> bool; -"#, - r#" -/// Creates a [`GamepadButtonChangedEvent`]. - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - button_type: bevy::input::gamepad::GamepadButtonType, - value: f32, - ) -> bevy::input::gamepad::GamepadButtonChangedEvent; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -633,19 +644,29 @@ fn index(&self) -> String { )] struct GamepadButtonChangedEvent { #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, + entity: bevy::ecs::entity::Entity, + #[lua(output(proxy))] + button: bevy::input::gamepad::GamepadButton, #[lua(output(proxy))] - button_type: bevy::input::gamepad::GamepadButtonType, + state: bevy::input::ButtonState, value: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadButtonInput", + remote = "bevy::input::gamepad::GamepadButtonStateChangedEvent", functions[r#" +/// Creates a new [`GamepadButtonStateChangedEvent`] - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonInput; + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + entity: bevy::ecs::entity::Entity, + #[proxy] + button: bevy::input::gamepad::GamepadButton, + #[proxy] + state: bevy::input::ButtonState, + ) -> bevy::input::gamepad::GamepadButtonStateChangedEvent; "#, r#" @@ -662,7 +683,13 @@ struct GamepadButtonChangedEvent { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadButtonInput) -> bool; + fn eq(&self, #[proxy] other: &gamepad::GamepadButtonStateChangedEvent) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadButtonStateChangedEvent; "#, r#" @@ -672,7 +699,9 @@ fn index(&self) -> String { } "#] )] -struct GamepadButtonInput { +struct GamepadButtonStateChangedEvent { + #[lua(output(proxy))] + entity: bevy::ecs::entity::Entity, #[lua(output(proxy))] button: bevy::input::gamepad::GamepadButton, #[lua(output(proxy))] @@ -681,14 +710,37 @@ struct GamepadButtonInput { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadConnectionEvent", + remote = "bevy::input::gamepad::GamepadConnection", functions[r#" + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadConnection) -> bool; + +"#, + r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadConnectionEvent; + fn clone(&self) -> bevy::input::gamepad::GamepadConnection; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct GamepadConnection {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::gamepad::GamepadConnectionEvent", + functions[r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -705,7 +757,7 @@ struct GamepadButtonInput { #[lua(kind = "Function", output(proxy))] fn new( #[proxy] - gamepad: bevy::input::gamepad::Gamepad, + gamepad: bevy::ecs::entity::Entity, #[proxy] connection: bevy::input::gamepad::GamepadConnection, ) -> bevy::input::gamepad::GamepadConnectionEvent; @@ -724,6 +776,12 @@ struct GamepadButtonInput { #[lua(kind = "Method")] fn disconnected(&self) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadConnectionEvent; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -734,7 +792,7 @@ fn index(&self) -> String { )] struct GamepadConnectionEvent { #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, + gamepad: bevy::ecs::entity::Entity, #[lua(output(proxy))] connection: bevy::input::gamepad::GamepadConnection, } @@ -744,9 +802,38 @@ struct GamepadConnectionEvent { remote = "bevy::input::gamepad::GamepadEvent", functions[r#" + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadEvent) -> bool; + +"#, + r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::gamepad::GamepadEvent; +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct GamepadEvent {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::gamepad::GamepadInput", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" @@ -756,7 +843,13 @@ struct GamepadConnectionEvent { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadEvent) -> bool; + fn eq(&self, #[proxy] other: &gamepad::GamepadInput) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadInput; "#, r#" @@ -766,41 +859,157 @@ fn index(&self) -> String { } "#] )] -struct GamepadEvent {} +struct GamepadInput {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( - derive(), - remote = "bevy::input::gamepad::GamepadSettings", + derive(clone), + remote = "bevy::input::gamepad::GamepadRumbleRequest", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadRumbleRequest; + +"#, + r#" +/// Get the [`Entity`] associated with this request. + + #[lua(kind = "Method", output(proxy))] + fn gamepad(&self) -> bevy::ecs::entity::Entity; + +"#] +)] +struct GamepadRumbleRequest {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::gamepad::RawGamepadAxisChangedEvent", functions[r#" +/// Creates a [`RawGamepadAxisChangedEvent`]. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::ecs::entity::Entity, + #[proxy] + axis_type: bevy::input::gamepad::GamepadAxis, + value: f32, + ) -> bevy::input::gamepad::RawGamepadAxisChangedEvent; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::RawGamepadAxisChangedEvent) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::RawGamepadAxisChangedEvent; + +"#, + r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -struct GamepadSettings { +struct RawGamepadAxisChangedEvent { #[lua(output(proxy))] - default_button_settings: bevy::input::gamepad::ButtonSettings, + gamepad: bevy::ecs::entity::Entity, #[lua(output(proxy))] - default_axis_settings: bevy::input::gamepad::AxisSettings, + axis: bevy::input::gamepad::GamepadAxis, + value: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::gamepad::RawGamepadButtonChangedEvent", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::RawGamepadButtonChangedEvent) -> bool; + +"#, + r#" +/// Creates a [`RawGamepadButtonChangedEvent`]. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::ecs::entity::Entity, + #[proxy] + button_type: bevy::input::gamepad::GamepadButton, + value: f32, + ) -> bevy::input::gamepad::RawGamepadButtonChangedEvent; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::RawGamepadButtonChangedEvent; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct RawGamepadButtonChangedEvent { #[lua(output(proxy))] - default_button_axis_settings: bevy::input::gamepad::ButtonAxisSettings, - button_settings: ReflectedValue, - axis_settings: ReflectedValue, - button_axis_settings: ReflectedValue, + gamepad: bevy::ecs::entity::Entity, + #[lua(output(proxy))] + button: bevy::input::gamepad::GamepadButton, + value: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::gamepad::RawGamepadEvent", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::RawGamepadEvent) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::RawGamepadEvent; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) } +"#] +)] +struct RawGamepadEvent {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::input::gestures::PinchGesture", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gestures::PinchGesture; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -809,6 +1018,12 @@ struct GamepadSettings { )] fn eq(&self, #[proxy] other: &gestures::PinchGesture) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gestures::PinchGesture; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -824,6 +1039,12 @@ struct PinchGesture(f32); remote = "bevy::input::gestures::RotationGesture", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gestures::RotationGesture; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -832,12 +1053,6 @@ struct PinchGesture(f32); )] fn eq(&self, #[proxy] other: &gestures::RotationGesture) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gestures::RotationGesture; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -882,12 +1097,6 @@ struct DoubleTapGesture {} remote = "bevy::input::gestures::PanGesture", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gestures::PanGesture; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -896,6 +1105,12 @@ struct DoubleTapGesture {} )] fn eq(&self, #[proxy] other: &gestures::PanGesture) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gestures::PanGesture; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -911,12 +1126,6 @@ struct PanGesture(#[lua(output(proxy))] bevy::math::Vec2); remote = "bevy::input::ButtonState", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::ButtonState; - -"#, - r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); @@ -931,6 +1140,12 @@ struct PanGesture(#[lua(output(proxy))] bevy::math::Vec2); )] fn eq(&self, #[proxy] other: &ButtonState) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::ButtonState; + "#, r#" /// Is this button pressed? @@ -950,45 +1165,25 @@ struct ButtonState {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadInfo", + remote = "bevy::input::gamepad::ButtonSettings", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadInfo) -> bool; + fn eq(&self, #[proxy] other: &gamepad::ButtonSettings) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadInfo; + fn clone(&self) -> bevy::input::gamepad::ButtonSettings; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct GamepadInfo { - name: std::string::String, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::ButtonSettings", - functions[r#" /// Returns `true` if the button is pressed. /// A button is considered pressed if the `value` passed is greater than or equal to the press threshold. @@ -1035,12 +1230,6 @@ struct GamepadInfo { #[lua(kind = "MutatingMethod")] fn set_release_threshold(&mut self, value: f32) -> f32; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::ButtonSettings; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1064,12 +1253,6 @@ struct ButtonSettings {} )] fn eq(&self, #[proxy] other: &gamepad::AxisSettings) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::AxisSettings; - "#, r#" /// Get the value above which inputs will be rounded up to 1.0. @@ -1174,6 +1357,12 @@ struct ButtonSettings {} old_value: std::option::Option, ) -> std::option::Option; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::AxisSettings; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1188,6 +1377,12 @@ struct AxisSettings {} derive(clone), remote = "bevy::input::gamepad::ButtonAxisSettings", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::ButtonAxisSettings; + +"#, + r#" /// Filters the `new_value` based on the `old_value`, according to the [`ButtonAxisSettings`]. /// Returns the clamped `new_value`, according to the [`ButtonAxisSettings`], if the change /// exceeds the settings threshold, and `None` otherwise. @@ -1199,12 +1394,6 @@ struct AxisSettings {} old_value: std::option::Option, ) -> std::option::Option; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::ButtonAxisSettings; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1221,22 +1410,38 @@ struct ButtonAxisSettings { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadConnection", + remote = "bevy::input::gamepad::GamepadRumbleIntensity", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadConnection; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadConnection) -> bool; + fn eq(&self, #[proxy] other: &gamepad::GamepadRumbleIntensity) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadRumbleIntensity; + +"#, + r#" +/// Creates a new rumble intensity with weak motor intensity set to the given value. +/// Clamped within the `0.0` to `1.0` range. + + #[lua(kind = "Function", output(proxy))] + fn weak_motor(intensity: f32) -> bevy::input::gamepad::GamepadRumbleIntensity; + +"#, + r#" +/// Creates a new rumble intensity with strong motor intensity set to the given value. +/// Clamped within the `0.0` to `1.0` range. + + #[lua(kind = "Function", output(proxy))] + fn strong_motor(intensity: f32) -> bevy::input::gamepad::GamepadRumbleIntensity; "#, r#" @@ -1246,13 +1451,22 @@ fn index(&self) -> String { } "#] )] -struct GamepadConnection {} +struct GamepadRumbleIntensity { + strong_motor: f32, + weak_motor: f32, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::input::keyboard::Key", functions[r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -1261,12 +1475,6 @@ struct GamepadConnection {} )] fn eq(&self, #[proxy] other: &keyboard::Key) -> bool; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" @@ -1288,12 +1496,6 @@ struct Key {} remote = "bevy::input::keyboard::NativeKeyCode", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::NativeKeyCode; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -1308,6 +1510,12 @@ struct Key {} #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::NativeKeyCode; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1323,6 +1531,12 @@ struct NativeKeyCode {} remote = "bevy::input::keyboard::NativeKey", functions[r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::keyboard::NativeKey; @@ -1337,12 +1551,6 @@ struct NativeKeyCode {} )] fn eq(&self, #[proxy] other: &keyboard::NativeKey) -> bool; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1361,6 +1569,12 @@ struct NativeKey {} #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::MouseScrollUnit; + "#, r#" @@ -1372,12 +1586,6 @@ struct NativeKey {} )] fn eq(&self, #[proxy] other: &mouse::MouseScrollUnit) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseScrollUnit; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1396,6 +1604,12 @@ struct MouseScrollUnit {} #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touch::TouchPhase; + "#, r#" @@ -1407,12 +1621,6 @@ struct MouseScrollUnit {} )] fn eq(&self, #[proxy] other: &touch::TouchPhase) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touch::TouchPhase; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1428,6 +1636,12 @@ struct TouchPhase {} remote = "bevy::input::touch::ForceTouch", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touch::ForceTouch; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -1436,12 +1650,6 @@ struct TouchPhase {} )] fn eq(&self, #[proxy] other: &touch::ForceTouch) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touch::ForceTouch; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1460,40 +1668,51 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { >(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> { instances .add_instance( - "Gamepad", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + "GamepadAxisChangedEvent", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaGamepadAxisChangedEvent, + >::new, )?; instances .add_instance( - "GamepadAxis", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + "GamepadButtonChangedEvent", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaGamepadButtonChangedEvent, + >::new, )?; instances .add_instance( - "GamepadButton", + "GamepadButtonStateChangedEvent", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadButton, + LuaGamepadButtonStateChangedEvent, >::new, )?; instances .add_instance( - "GamepadAxisChangedEvent", + "GamepadConnectionEvent", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadAxisChangedEvent, + LuaGamepadConnectionEvent, >::new, )?; instances .add_instance( - "GamepadButtonChangedEvent", + "RawGamepadAxisChangedEvent", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadButtonChangedEvent, + LuaRawGamepadAxisChangedEvent, >::new, )?; instances .add_instance( - "GamepadConnectionEvent", + "RawGamepadButtonChangedEvent", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadConnectionEvent, + LuaRawGamepadButtonChangedEvent, + >::new, + )?; + instances + .add_instance( + "GamepadRumbleIntensity", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaGamepadRumbleIntensity, >::new, )?; Ok(()) @@ -1522,28 +1741,16 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { tw.document_global_instance::() .expect("Something went wrong documenting globals") .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadAxis, - >, - >() - .process_type::() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadButton, - >, - >() - .process_type::() + .process_type::() .process_type::() .process_type::() .process_type::() .process_type::() .process_type::() + .process_type::() + .process_type::() .process_type::() .process_type::() .process_type::() @@ -1559,7 +1766,13 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { LuaGamepadButtonChangedEvent, >, >() - .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaGamepadButtonStateChangedEvent, + >, + >() + .process_type::() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< @@ -1567,17 +1780,35 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { >, >() .process_type::() - .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaRawGamepadAxisChangedEvent, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaRawGamepadButtonChangedEvent, + >, + >() + .process_type::() .process_type::() .process_type::() .process_type::() .process_type::() .process_type::() - .process_type::() .process_type::() .process_type::() .process_type::() - .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaGamepadRumbleIntensity, + >, + >() .process_type::() .process_type::() .process_type::() @@ -1606,14 +1837,15 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); @@ -1621,20 +1853,30 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { app.register_foreign_lua_type::< bevy::input::gamepad::GamepadButtonChangedEvent, >(); - app.register_foreign_lua_type::(); + app.register_foreign_lua_type::< + bevy::input::gamepad::GamepadButtonStateChangedEvent, + >(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::< + bevy::input::gamepad::RawGamepadAxisChangedEvent, + >(); + app.register_foreign_lua_type::< + bevy::input::gamepad::RawGamepadButtonChangedEvent, + >(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/bevy_math.rs b/crates/bevy_script_api/src/providers/bevy_math.rs index 461fb0b5a7..57cd3657ff 100644 --- a/crates/bevy_script_api/src/providers/bevy_math.rs +++ b/crates/bevy_script_api/src/providers/bevy_math.rs @@ -10,18 +10,82 @@ use bevy_script_api::{ #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::CompassOctant", + remote = "bevy::math::AspectRatio", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::AspectRatio; "#, r#" +/// Returns the aspect ratio as a f32 value. + + #[lua(kind = "Method")] + fn ratio(&self) -> f32; + +"#, + r#" +/// Returns the inverse of this aspect ratio (height/width). + + #[lua(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::AspectRatio; + +"#, + r#" +/// Returns true if the aspect ratio represents a landscape orientation. + + #[lua(kind = "Method")] + fn is_landscape(&self) -> bool; + +"#, + r#" +/// Returns true if the aspect ratio represents a portrait orientation. + + #[lua(kind = "Method")] + fn is_portrait(&self) -> bool; + +"#, + r#" +/// Returns true if the aspect ratio is exactly square. + + #[lua(kind = "Method")] + fn is_square(&self) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &aspect_ratio::AspectRatio) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AspectRatio(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::CompassOctant", + functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::CompassOctant; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" @@ -48,6 +112,12 @@ struct CompassOctant {} remote = "bevy::math::CompassQuadrant", functions[r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -62,11 +132,151 @@ struct CompassOctant {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::CompassQuadrant; +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct CompassQuadrant {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Isometry2d", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::prelude::Dir2) -> bevy::math::prelude::Dir2; + "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::prelude::Vec2) -> bevy::math::prelude::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Isometry2d) -> bevy::math::Isometry2d; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &isometry::Isometry2d) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::Isometry2d; + +"#, + r#" +/// Create a two-dimensional isometry from a rotation and a translation. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + translation: bevy::math::prelude::Vec2, + #[proxy] + rotation: bevy::math::Rot2, + ) -> bevy::math::Isometry2d; + +"#, + r#" +/// Create a two-dimensional isometry from a rotation. + + #[lua(kind = "Function", output(proxy))] + fn from_rotation(#[proxy] rotation: bevy::math::Rot2) -> bevy::math::Isometry2d; + +"#, + r#" +/// Create a two-dimensional isometry from a translation. + + #[lua(kind = "Function", output(proxy))] + fn from_translation( + #[proxy] + translation: bevy::math::prelude::Vec2, + ) -> bevy::math::Isometry2d; + +"#, + r#" +/// Create a two-dimensional isometry from a translation with the given `x` and `y` components. + + #[lua(kind = "Function", output(proxy))] + fn from_xy(x: f32, y: f32) -> bevy::math::Isometry2d; + +"#, + r#" +/// The inverse isometry that undoes this one. + + #[lua(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::Isometry2d; + +"#, + r#" +/// Compute `iso1.inverse() * iso2` in a more efficient way for one-shot cases. +/// If the same isometry is used multiple times, it is more efficient to instead compute +/// the inverse once and use that for each transformation. + + #[lua(kind = "Method", output(proxy))] + fn inverse_mul( + &self, + #[proxy] + rhs: bevy::math::Isometry2d, + ) -> bevy::math::Isometry2d; + +"#, + r#" +/// Transform a point by rotating and translating it using this isometry. + + #[lua(kind = "Method", output(proxy))] + fn transform_point( + &self, + #[proxy] + point: bevy::math::prelude::Vec2, + ) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Transform a point by rotating and translating it using the inverse of this isometry. +/// This is more efficient than `iso.inverse().transform_point(point)` for one-shot cases. +/// If the same isometry is used multiple times, it is more efficient to instead compute +/// the inverse once and use that for each transformation. + + #[lua(kind = "Method", output(proxy))] + fn inverse_transform_point( + &self, + #[proxy] + point: bevy::math::prelude::Vec2, + ) -> bevy::math::prelude::Vec2; "#, r#" @@ -76,29 +286,81 @@ fn index(&self) -> String { } "#] )] -struct CompassQuadrant {} +struct Isometry2d { + #[lua(output(proxy))] + rotation: bevy::math::Rot2, + #[lua(output(proxy))] + translation: bevy::math::prelude::Vec2, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::AspectRatio", + remote = "bevy::math::Isometry3d", functions[r#" -/// Create a new `AspectRatio` from a given `width` and `height`. + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::Isometry3d; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +/// Create a three-dimensional isometry from a rotation. #[lua(kind = "Function", output(proxy))] - fn new(width: f32, height: f32) -> bevy::math::AspectRatio; + fn from_rotation( + #[proxy] + rotation: bevy::math::prelude::Quat, + ) -> bevy::math::Isometry3d; "#, r#" -/// Create a new `AspectRatio` from a given amount of `x` pixels and `y` pixels. +/// Create a three-dimensional isometry from a translation with the given `x`, `y`, and `z` components. #[lua(kind = "Function", output(proxy))] - fn from_pixels(x: u32, y: u32) -> bevy::math::AspectRatio; + fn from_xyz(x: f32, y: f32, z: f32) -> bevy::math::Isometry3d; "#, r#" +/// The inverse isometry that undoes this one. - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::AspectRatio; + #[lua(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::Isometry3d; + +"#, + r#" +/// Compute `iso1.inverse() * iso2` in a more efficient way for one-shot cases. +/// If the same isometry is used multiple times, it is more efficient to instead compute +/// the inverse once and use that for each transformation. + + #[lua(kind = "Method", output(proxy))] + fn inverse_mul( + &self, + #[proxy] + rhs: bevy::math::Isometry3d, + ) -> bevy::math::Isometry3d; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Isometry3d) -> bevy::math::Isometry3d; "#, r#" @@ -109,7 +371,31 @@ struct CompassQuadrant {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &aspect_ratio::AspectRatio) -> bool; + fn eq(&self, #[proxy] other: &isometry::Isometry3d) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::prelude::Vec3) -> bevy::math::prelude::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::prelude::Dir3) -> bevy::math::prelude::Dir3; "#, r#" @@ -119,22 +405,25 @@ fn index(&self) -> String { } "#] )] -struct AspectRatio(); +struct Isometry3d { + #[lua(output(proxy))] + rotation: bevy::math::prelude::Quat, + #[lua(output(proxy))] + translation: bevy::math::Vec3A, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::math::Ray2d", functions[r#" /// Create a new `Ray2d` from a given origin and direction -/// # Panics -/// Panics if the given `direction` is zero (or very close to zero), or non-finite. #[lua(kind = "Function", output(proxy))] fn new( #[proxy] origin: bevy::math::prelude::Vec2, #[proxy] - direction: bevy::math::prelude::Vec2, + direction: bevy::math::prelude::Dir2, ) -> bevy::math::Ray2d; "#, @@ -194,12 +483,6 @@ struct Ray2d { remote = "bevy::math::Ray3d", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::Ray3d; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -211,15 +494,13 @@ struct Ray2d { "#, r#" /// Create a new `Ray3d` from a given origin and direction -/// # Panics -/// Panics if the given `direction` is zero (or very close to zero), or non-finite. #[lua(kind = "Function", output(proxy))] fn new( #[proxy] origin: bevy::math::prelude::Vec3, #[proxy] - direction: bevy::math::prelude::Vec3, + direction: bevy::math::prelude::Dir3, ) -> bevy::math::Ray3d; "#, @@ -242,6 +523,12 @@ struct Ray2d { plane: bevy::math::primitives::InfinitePlane3d, ) -> std::option::Option; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::Ray3d; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -261,7 +548,7 @@ struct Ray3d { derive(clone), remote = "bevy::math::Rot2", functions[r#" -/// Rotates a [`Vec2`] by a [`Rot2`]. +/// Rotates the [`Dir2`] using a [`Rot2`]. #[lua( as_trait = "std::ops::Mul", @@ -270,11 +557,14 @@ struct Ray3d { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::prelude::Vec2) -> bevy::math::prelude::Vec2; + fn mul( + self, + #[proxy] + direction: bevy::math::prelude::Dir2, + ) -> bevy::math::prelude::Dir2; "#, r#" -/// Rotates the [`Dir2`] using a [`Rot2`]. #[lua( as_trait = "std::ops::Mul", @@ -283,21 +573,24 @@ struct Ray3d { composite = "mul", metamethod = "Mul", )] - fn mul( - self, - #[proxy] - direction: bevy::math::prelude::Dir2, - ) -> bevy::math::prelude::Dir2; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::Rot2; + fn mul(self, #[proxy] rhs: bevy::math::Rot2) -> bevy::math::Rot2; "#, r#" /// Creates a [`Rot2`] from a counterclockwise angle in radians. +/// # Note +/// The input rotation will always be clamped to the range `(-Ï€, Ï€]` by design. +/// # Example +/// ``` +/// # use bevy_math::Rot2; +/// # use approx::assert_relative_eq; +/// # use std::f32::consts::{FRAC_PI_2, PI}; +/// let rot1 = Rot2::radians(3.0 * FRAC_PI_2); +/// let rot2 = Rot2::radians(-FRAC_PI_2); +/// assert_relative_eq!(rot1, rot2); +/// let rot3 = Rot2::radians(PI); +/// assert_relative_eq!(rot1 * rot1, rot3); +/// ``` #[lua(kind = "Function", output(proxy))] fn radians(radians: f32) -> bevy::math::Rot2; @@ -305,10 +598,41 @@ struct Ray3d { "#, r#" /// Creates a [`Rot2`] from a counterclockwise angle in degrees. +/// # Note +/// The input rotation will always be clamped to the range `(-180°, 180°]` by design. +/// # Example +/// ``` +/// # use bevy_math::Rot2; +/// # use approx::assert_relative_eq; +/// let rot1 = Rot2::degrees(270.0); +/// let rot2 = Rot2::degrees(-90.0); +/// assert_relative_eq!(rot1, rot2); +/// let rot3 = Rot2::degrees(180.0); +/// assert_relative_eq!(rot1 * rot1, rot3); +/// ``` #[lua(kind = "Function", output(proxy))] fn degrees(degrees: f32) -> bevy::math::Rot2; +"#, + r#" +/// Creates a [`Rot2`] from a counterclockwise fraction of a full turn of 360 degrees. +/// # Note +/// The input rotation will always be clamped to the range `(-50%, 50%]` by design. +/// # Example +/// ``` +/// # use bevy_math::Rot2; +/// # use approx::assert_relative_eq; +/// let rot1 = Rot2::turn_fraction(0.75); +/// let rot2 = Rot2::turn_fraction(-0.25); +/// assert_relative_eq!(rot1, rot2); +/// let rot3 = Rot2::turn_fraction(0.5); +/// assert_relative_eq!(rot1 * rot1, rot3); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn turn_fraction(fraction: f32) -> bevy::math::Rot2; + "#, r#" /// Creates a [`Rot2`] from the sine and cosine of an angle in radians. @@ -333,6 +657,13 @@ struct Ray3d { #[lua(kind = "Method")] fn as_degrees(self) -> f32; +"#, + r#" +/// Returns the rotation as a fraction of a full 360 degree turn. + + #[lua(kind = "Method")] + fn as_turn_fraction(self) -> f32; + "#, r#" /// Returns the sine and cosine of the rotation angle in radians. @@ -383,6 +714,15 @@ struct Ray3d { #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::Rot2; +"#, + r#" +/// Returns `self` after an approximate normalization, assuming the value is already nearly normalized. +/// Useful for preventing numerical error accumulation. +/// See [`Dir3::fast_renormalize`](crate::Dir3::fast_renormalize) for an example of when such error accumulation might occur. + + #[lua(kind = "Method", output(proxy))] + fn fast_renormalize(self) -> bevy::math::Rot2; + "#, r#" /// Returns `true` if the rotation is neither infinite nor NaN. @@ -419,6 +759,13 @@ struct Ray3d { #[lua(kind = "Method")] fn angle_between(self, #[proxy] other: bevy::math::Rot2) -> f32; +"#, + r#" +/// Returns the angle in radians needed to make `self` and `other` coincide. + + #[lua(kind = "Method")] + fn angle_to(self, #[proxy] other: bevy::math::Rot2) -> f32; + "#, r#" /// Returns the inverse of the rotation. This is also the conjugate @@ -486,6 +833,7 @@ struct Ray3d { "#, r#" +/// Rotates a [`Vec2`] by a [`Rot2`]. #[lua( as_trait = "std::ops::Mul", @@ -494,7 +842,7 @@ struct Ray3d { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Rot2) -> bevy::math::Rot2; + fn mul(self, #[proxy] rhs: bevy::math::prelude::Vec2) -> bevy::math::prelude::Vec2; "#, r#" @@ -507,6 +855,12 @@ struct Ray3d { )] fn eq(&self, #[proxy] other: &rotation2d::Rot2) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::Rot2; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -524,6 +878,17 @@ struct Rot2 { derive(clone), remote = "bevy::math::prelude::Dir2", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &direction::Dir2) -> bool; + +"#, + r#" /// Create a [`Dir2`] from a [`Vec2`] that is already normalized. /// # Warning /// `value` must be normalized, i.e its length must be `1.0`. @@ -534,6 +899,15 @@ struct Rot2 { value: bevy::math::prelude::Vec2, ) -> bevy::math::prelude::Dir2; +"#, + r#" +/// Create a direction from its `x` and `y` components, assuming the resulting vector is normalized. +/// # Warning +/// The vector produced from `x` and `y` must be normalized, i.e its length must be `1.0`. + + #[lua(kind = "Function", output(proxy))] + fn from_xy_unchecked(x: f32, y: f32) -> bevy::math::prelude::Dir2; + "#, r#" /// Returns the inner [`Vec2`] @@ -615,6 +989,27 @@ struct Rot2 { #[lua(kind = "Method", output(proxy))] fn rotation_to_y(self) -> bevy::math::Rot2; +"#, + r#" +/// Returns `self` after an approximate normalization, assuming the value is already nearly normalized. +/// Useful for preventing numerical error accumulation. +/// See [`Dir3::fast_renormalize`] for an example of when such error accumulation might occur. + + #[lua(kind = "Method", output(proxy))] + fn fast_renormalize(self) -> bevy::math::prelude::Dir2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::prelude::Dir2; + "#, r#" @@ -633,16 +1028,35 @@ struct Rot2 { )] fn mul(self, rhs: f32) -> bevy::math::prelude::Vec2; +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Dir2(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::prelude::Dir3", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::prelude::Dir3; + "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] other: &direction::Dir2) -> bool; + fn mul(self, rhs: f32) -> bevy::math::prelude::Vec3; "#, r#" @@ -654,31 +1068,18 @@ struct Rot2 { composite = "neg", metamethod = "Unm", )] - fn neg(self) -> bevy::math::prelude::Dir2; + fn neg(self) -> bevy::math::prelude::Dir3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Dir2(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::prelude::Dir3", - functions[r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "eq", + metamethod = "Eq", )] - fn neg(self) -> bevy::math::prelude::Dir3; + fn eq(&self, #[proxy] other: &direction::Dir3) -> bool; "#, r#" @@ -692,6 +1093,15 @@ struct Dir2(); value: bevy::math::prelude::Vec3, ) -> bevy::math::prelude::Dir3; +"#, + r#" +/// Create a direction from its `x`, `y`, and `z` components, assuming the resulting vector is normalized. +/// # Warning +/// The vector produced from `x`, `y`, and `z` must be normalized, i.e its length must be `1.0`. + + #[lua(kind = "Function", output(proxy))] + fn from_xyz_unchecked(x: f32, y: f32, z: f32) -> bevy::math::prelude::Dir3; + "#, r#" /// Returns the inner [`Vec3`] @@ -733,32 +1143,34 @@ struct Dir2(); "#, r#" +/// Returns `self` after an approximate normalization, assuming the value is already nearly normalized. +/// Useful for preventing numerical error accumulation. +/// # Example +/// The following seemingly benign code would start accumulating errors over time, +/// leading to `dir` eventually not being normalized anymore. +/// ``` +/// # use bevy_math::prelude::*; +/// # let N: usize = 200; +/// let mut dir = Dir3::X; +/// let quaternion = Quat::from_euler(EulerRot::XYZ, 1.0, 2.0, 3.0); +/// for i in 0..N { +/// dir = quaternion * dir; +/// } +/// ``` +/// Instead, do the following. +/// ``` +/// # use bevy_math::prelude::*; +/// # let N: usize = 200; +/// let mut dir = Dir3::X; +/// let quaternion = Quat::from_euler(EulerRot::XYZ, 1.0, 2.0, 3.0); +/// for i in 0..N { +/// dir = quaternion * dir; +/// dir = dir.fast_renormalize(); +/// } +/// ``` - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::prelude::Dir3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &direction::Dir3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::prelude::Vec3; + #[lua(kind = "Method", output(proxy))] + fn fast_renormalize(self) -> bevy::math::prelude::Dir3; "#, r#" @@ -774,41 +1186,21 @@ struct Dir3(); derive(clone), remote = "bevy::math::prelude::Dir3A", functions[r#" +/// Create a [`Dir3A`] from a [`Vec3A`] that is already normalized. +/// # Warning +/// `value` must be normalized, i.e its length must be `1.0`. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::prelude::Dir3A; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &direction::Dir3A) -> bool; + #[lua(kind = "Function", output(proxy))] + fn new_unchecked(#[proxy] value: bevy::math::Vec3A) -> bevy::math::prelude::Dir3A; "#, r#" -/// Create a [`Dir3A`] from a [`Vec3A`] that is already normalized. +/// Create a direction from its `x`, `y`, and `z` components, assuming the resulting vector is normalized. /// # Warning -/// `value` must be normalized, i.e its length must be `1.0`. +/// The vector produced from `x`, `y`, and `z` must be normalized, i.e its length must be `1.0`. #[lua(kind = "Function", output(proxy))] - fn new_unchecked(#[proxy] value: bevy::math::Vec3A) -> bevy::math::prelude::Dir3A; + fn from_xyz_unchecked(x: f32, y: f32, z: f32) -> bevy::math::prelude::Dir3A; "#, r#" @@ -849,6 +1241,38 @@ struct Dir3(); s: f32, ) -> bevy::math::prelude::Dir3A; +"#, + r#" +/// Returns `self` after an approximate normalization, assuming the value is already nearly normalized. +/// Useful for preventing numerical error accumulation. +/// See [`Dir3::fast_renormalize`] for an example of when such error accumulation might occur. + + #[lua(kind = "Method", output(proxy))] + fn fast_renormalize(self) -> bevy::math::prelude::Dir3A; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &direction::Dir3A) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec3A; + "#, r#" @@ -861,6 +1285,12 @@ struct Dir3(); )] fn neg(self) -> bevy::math::prelude::Dir3A; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::prelude::Dir3A; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -875,6 +1305,29 @@ struct Dir3A(); derive(clone), remote = "bevy::math::prelude::IRect", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &rects::irect::IRect) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::prelude::IRect; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" /// Create a new rectangle from two corner points. /// The two points do not need to be the minimum and/or maximum corners. /// They only need to be two opposite corners. @@ -913,7 +1366,7 @@ struct Dir3A(); "#, r#" /// Create a new rectangle from its center and size. -/// # Rounding Behaviour +/// # Rounding Behavior /// If the size contains odd numbers they will be rounded down to the nearest whole number. /// # Panics /// This method panics if any of the components of the size is negative. @@ -1009,7 +1462,7 @@ struct Dir3A(); "#, r#" /// Rectangle half-size. -/// # Rounding Behaviour +/// # Rounding Behavior /// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size. /// # Examples /// ``` @@ -1024,7 +1477,7 @@ struct Dir3A(); "#, r#" /// The center point of the rectangle. -/// # Rounding Behaviour +/// # Rounding Behavior /// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center. /// # Examples /// ``` @@ -1152,29 +1605,6 @@ struct Dir3A(); #[lua(kind = "Method", output(proxy))] fn as_urect(&self) -> bevy::math::prelude::URect; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::prelude::IRect; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &rects::irect::IRect) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1194,6 +1624,23 @@ struct IRect { derive(clone), remote = "bevy::math::prelude::Rect", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::prelude::Rect; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &rects::rect::Rect) -> bool; + +"#, + r#" /// Create a new rectangle from two corner points. /// The two points do not need to be the minimum and/or maximum corners. /// They only need to be two opposite corners. @@ -1488,23 +1935,6 @@ struct IRect { #[lua(kind = "Method", output(proxy))] fn as_urect(&self) -> bevy::math::prelude::URect; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::prelude::Rect; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &rects::rect::Rect) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1524,6 +1954,29 @@ struct Rect { derive(clone), remote = "bevy::math::prelude::URect", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::prelude::URect; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &rects::urect::URect) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" /// Create a new rectangle from two corner points. /// The two points do not need to be the minimum and/or maximum corners. /// They only need to be two opposite corners. @@ -1562,7 +2015,7 @@ struct Rect { "#, r#" /// Create a new rectangle from its center and size. -/// # Rounding Behaviour +/// # Rounding Behavior /// If the size contains odd numbers they will be rounded down to the nearest whole number. /// # Panics /// This method panics if any of the components of the size is negative or if `origin - (size / 2)` results in any negatives. @@ -1658,7 +2111,7 @@ struct Rect { "#, r#" /// Rectangle half-size. -/// # Rounding Behaviour +/// # Rounding Behavior /// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size. /// # Examples /// ``` @@ -1673,7 +2126,7 @@ struct Rect { "#, r#" /// The center point of the rectangle. -/// # Rounding Behaviour +/// # Rounding Behavior /// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center. /// # Examples /// ``` @@ -1785,44 +2238,21 @@ struct Rect { /// ``` #[lua(kind = "Method", output(proxy))] - fn inflate(&self, expansion: i32) -> bevy::math::prelude::URect; - -"#, - r#" -/// Returns self as [`Rect`] (f32) - - #[lua(kind = "Method", output(proxy))] - fn as_rect(&self) -> bevy::math::prelude::Rect; - -"#, - r#" -/// Returns self as [`IRect`] (i32) - - #[lua(kind = "Method", output(proxy))] - fn as_irect(&self) -> bevy::math::prelude::IRect; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &rects::urect::URect) -> bool; + fn inflate(&self, expansion: i32) -> bevy::math::prelude::URect; "#, r#" +/// Returns self as [`Rect`] (f32) - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::prelude::URect; + #[lua(kind = "Method", output(proxy))] + fn as_rect(&self) -> bevy::math::prelude::Rect; "#, r#" +/// Returns self as [`IRect`] (i32) - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method", output(proxy))] + fn as_irect(&self) -> bevy::math::prelude::IRect; "#, r#" @@ -1851,6 +2281,12 @@ struct Affine3 { derive(clone), remote = "bevy::math::bounding::Aabb2d", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::Aabb2d; + +"#, + r#" /// Constructs an AABB from its center and half-size. #[lua(kind = "Function", output(proxy))] @@ -1881,12 +2317,6 @@ struct Affine3 { point: bevy::math::prelude::Vec2, ) -> bevy::math::prelude::Vec2; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::bounding::Aabb2d; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1906,12 +2336,6 @@ struct Aabb2d { derive(clone), remote = "bevy::math::bounding::BoundingCircle", functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::bounding::BoundingCircle; - -"#, - r#" /// Constructs a bounding circle from its center and radius. #[lua(kind = "Function", output(proxy))] @@ -1948,6 +2372,12 @@ struct Aabb2d { point: bevy::math::prelude::Vec2, ) -> bevy::math::prelude::Vec2; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::BoundingCircle; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1971,6 +2401,33 @@ struct BoundingCircle { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::primitives::Circle; +"#, + r#" +/// Create a new [`Circle`] from a `radius` + + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32) -> bevy::math::primitives::Circle; + +"#, + r#" +/// Get the diameter of the circle + + #[lua(kind = "Method")] + fn diameter(&self) -> f32; + +"#, + r#" +/// Finds the point on the circle that is closest to the given `point`. +/// If the point is outside the circle, the returned point will be on the perimeter of the circle. +/// Otherwise, it will be inside the circle and returned as is. + + #[lua(kind = "Method", output(proxy))] + fn closest_point( + &self, + #[proxy] + point: bevy::math::prelude::Vec2, + ) -> bevy::math::prelude::Vec2; + "#, r#" @@ -1984,23 +2441,62 @@ struct BoundingCircle { "#, r#" -/// Create a new [`Circle`] from a `radius` +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Circle { + radius: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Annulus", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Annulus) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Annulus; + +"#, + r#" +/// Create a new [`Annulus`] from the radii of the inner and outer circle #[lua(kind = "Function", output(proxy))] - fn new(radius: f32) -> bevy::math::primitives::Circle; + fn new(inner_radius: f32, outer_radius: f32) -> bevy::math::primitives::Annulus; "#, r#" -/// Get the diameter of the circle +/// Get the diameter of the annulus #[lua(kind = "Method")] fn diameter(&self) -> f32; "#, r#" -/// Finds the point on the circle that is closest to the given `point`. -/// If the point is outside the circle, the returned point will be on the perimeter of the circle. -/// Otherwise, it will be inside the circle and returned as is. +/// Get the thickness of the annulus + + #[lua(kind = "Method")] + fn thickness(&self) -> f32; + +"#, + r#" +/// Finds the point on the annulus that is closest to the given `point`: +/// - If the point is outside of the annulus completely, the returned point will be on the outer perimeter. +/// - If the point is inside of the inner circle (hole) of the annulus, the returned point will be on the inner perimeter. +/// - Otherwise, the returned point is overlapping the annulus and returned as is. #[lua(kind = "Method", output(proxy))] fn closest_point( @@ -2017,8 +2513,11 @@ fn index(&self) -> String { } "#] )] -struct Circle { - radius: f32, +struct Annulus { + #[lua(output(proxy))] + inner_circle: bevy::math::primitives::Circle, + #[lua(output(proxy))] + outer_circle: bevy::math::primitives::Circle, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -2187,6 +2686,12 @@ struct Arc2d { )] fn eq(&self, #[proxy] other: &primitives::dim2::Capsule2d) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Capsule2d; + "#, r#" /// Create a new `Capsule2d` from a radius and length @@ -2196,9 +2701,10 @@ struct Arc2d { "#, r#" +/// Get the part connecting the semicircular ends of the capsule as a [`Rectangle`] - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Capsule2d; + #[lua(kind = "Method", output(proxy))] + fn to_inner_rectangle(&self) -> bevy::math::primitives::Rectangle; "#, r#" @@ -2217,23 +2723,6 @@ struct Capsule2d { derive(clone), remote = "bevy::math::primitives::CircularSector", functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::CircularSector; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::CircularSector) -> bool; - -"#, - r#" /// Create a new [`CircularSector`] from a `radius` and an `angle` #[lua(kind = "Function", output(proxy))] @@ -2331,10 +2820,20 @@ struct Capsule2d { "#, r#" -/// Returns the area of this sector - #[lua(kind = "Method")] - fn area(&self) -> f32; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::CircularSector; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::CircularSector) -> bool; "#, r#" @@ -2353,23 +2852,6 @@ struct CircularSector { derive(clone), remote = "bevy::math::primitives::CircularSegment", functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::CircularSegment; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::CircularSegment) -> bool; - -"#, - r#" /// Create a new [`CircularSegment`] from a `radius`, and an `angle` #[lua(kind = "Function", output(proxy))] @@ -2465,10 +2947,20 @@ struct CircularSector { "#, r#" -/// Returns the area of this segment - #[lua(kind = "Method")] - fn area(&self) -> f32; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::CircularSegment) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::CircularSegment; "#, r#" @@ -2487,17 +2979,6 @@ struct CircularSegment { derive(clone), remote = "bevy::math::primitives::Ellipse", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::Ellipse) -> bool; - -"#, - r#" /// Create a new `Ellipse` from half of its width and height. /// This corresponds to the two perpendicular radii defining the ellipse. @@ -2552,6 +3033,17 @@ struct CircularSegment { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::primitives::Ellipse; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Ellipse) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -2570,12 +3062,6 @@ struct Ellipse { remote = "bevy::math::primitives::Line2d", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Line2d; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -2584,6 +3070,12 @@ struct Ellipse { )] fn eq(&self, #[proxy] other: &primitives::dim2::Line2d) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Line2d; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -2601,6 +3093,17 @@ struct Line2d { derive(clone), remote = "bevy::math::primitives::Plane2d", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Plane2d) -> bool; + +"#, + r#" /// Create a new `Plane2d` from a normal /// # Panics /// Panics if the given `normal` is zero (or very close to zero), or non-finite. @@ -2611,17 +3114,6 @@ struct Line2d { normal: bevy::math::prelude::Vec2, ) -> bevy::math::primitives::Plane2d; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::Plane2d) -> bool; - "#, r#" @@ -2645,6 +3137,17 @@ struct Plane2d { derive(clone), remote = "bevy::math::primitives::Rectangle", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Rectangle) -> bool; + +"#, + r#" /// Create a new `Rectangle` from a full width and height #[lua(kind = "Function", output(proxy))] @@ -2700,17 +3203,6 @@ struct Plane2d { point: bevy::math::prelude::Vec2, ) -> bevy::math::prelude::Vec2; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::Rectangle) -> bool; - "#, r#" @@ -2757,7 +3249,7 @@ struct Rectangle { /// Panics if `circumradius` is negative #[lua(kind = "Function", output(proxy))] - fn new(circumradius: f32, sides: usize) -> bevy::math::primitives::RegularPolygon; + fn new(circumradius: f32, sides: u32) -> bevy::math::primitives::RegularPolygon; "#, r#" @@ -2830,30 +3322,13 @@ fn index(&self) -> String { struct RegularPolygon { #[lua(output(proxy))] circumcircle: bevy::math::primitives::Circle, - sides: usize, + sides: u32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::math::primitives::Rhombus", functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Rhombus; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::Rhombus) -> bool; - -"#, - r#" /// Create a new `Rhombus` from a vertical and horizontal diagonal sizes. #[lua(kind = "Function", output(proxy))] @@ -2912,6 +3387,23 @@ struct RegularPolygon { point: bevy::math::prelude::Vec2, ) -> bevy::math::prelude::Vec2; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Rhombus) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Rhombus; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -2929,6 +3421,23 @@ struct Rhombus { derive(clone), remote = "bevy::math::primitives::Segment2d", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Segment2d) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Segment2d; + +"#, + r#" /// Create a new `Segment2d` from a direction and full length of the segment #[lua(kind = "Function", output(proxy))] @@ -2952,23 +3461,6 @@ struct Rhombus { #[lua(kind = "Method", output(proxy))] fn point2(&self) -> bevy::math::prelude::Vec2; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Segment2d; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::Segment2d) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -2988,6 +3480,17 @@ struct Segment2d { remote = "bevy::math::primitives::Triangle2d", functions[r#" + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Triangle2d) -> bool; + +"#, + r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::primitives::Triangle2d; @@ -3043,17 +3546,6 @@ struct Segment2d { #[lua(kind = "Method", output(proxy))] fn reversed(self) -> bevy::math::primitives::Triangle2d; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::Triangle2d) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3100,6 +3592,12 @@ struct Aabb3d { derive(clone), remote = "bevy::math::bounding::BoundingSphere", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::BoundingSphere; + +"#, + r#" /// Get the radius of the bounding sphere #[lua(kind = "Method")] @@ -3112,12 +3610,6 @@ struct Aabb3d { #[lua(kind = "Method", output(proxy))] fn aabb_3d(&self) -> bevy::math::bounding::Aabb3d; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::bounding::BoundingSphere; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3137,6 +3629,17 @@ struct BoundingSphere { derive(clone), remote = "bevy::math::primitives::Sphere", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::Sphere) -> bool; + +"#, + r#" /// Create a new [`Sphere`] from a `radius` #[lua(kind = "Function", output(proxy))] @@ -3162,17 +3665,6 @@ struct BoundingSphere { point: bevy::math::prelude::Vec3, ) -> bevy::math::prelude::Vec3; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim3::Sphere) -> bool; - "#, r#" @@ -3195,6 +3687,12 @@ struct Sphere { derive(clone), remote = "bevy::math::primitives::Cuboid", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Cuboid; + +"#, + r#" /// Create a new `Cuboid` from a full x, y, and z length #[lua(kind = "Function", output(proxy))] @@ -3265,12 +3763,6 @@ struct Sphere { )] fn eq(&self, #[proxy] other: &primitives::dim3::Cuboid) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Cuboid; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3297,12 +3789,6 @@ struct Cuboid { )] fn eq(&self, #[proxy] other: &primitives::dim3::Cylinder) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Cylinder; - "#, r#" /// Create a new `Cylinder` from a radius and full height @@ -3332,6 +3818,12 @@ struct Cuboid { #[lua(kind = "Method")] fn base_area(&self) -> f32; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Cylinder; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3349,17 +3841,6 @@ struct Cylinder { derive(clone), remote = "bevy::math::primitives::Capsule3d", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim3::Capsule3d) -> bool; - -"#, - r#" /// Create a new `Capsule3d` from a radius and length #[lua(kind = "Function", output(proxy))] @@ -3379,6 +3860,17 @@ struct Cylinder { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::primitives::Capsule3d; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::Capsule3d) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3407,9 +3899,10 @@ struct Capsule3d { "#, r#" +/// Create a new [`Cone`] from a radius and height. - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Cone; + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32, height: f32) -> bevy::math::primitives::Cone; "#, r#" @@ -3441,6 +3934,12 @@ struct Capsule3d { #[lua(kind = "Method")] fn base_area(&self) -> f32; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Cone; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3491,6 +3990,62 @@ struct ConicalFrustum { derive(clone), remote = "bevy::math::primitives::InfinitePlane3d", functions[r#" +/// Computes an [`Isometry3d`] which transforms points from the plane in 3D space with the given +/// `origin` to the XY-plane. +/// ## Guarantees +/// * the transformation is a [congruence] meaning it will preserve all distances and angles of +/// the transformed geometry +/// * uses the least rotation possible to transform the geometry +/// * if two geometries are transformed with the same isometry, then the relations between +/// them, like distances, are also preserved +/// * compared to projections, the transformation is lossless (up to floating point errors) +/// reversible +/// ## Non-Guarantees +/// * the rotation used is generally not unique +/// * the orientation of the transformed geometry in the XY plane might be arbitrary, to +/// enforce some kind of alignment the user has to use an extra transformation ontop of this +/// one +/// See [`isometries_xy`] for example usescases. +/// [congruence]: https://en.wikipedia.org/wiki/Congruence_(geometry) +/// [`isometries_xy`]: `InfinitePlane3d::isometries_xy` + + #[lua(kind = "Method", output(proxy))] + fn isometry_into_xy( + &self, + #[proxy] + origin: bevy::math::prelude::Vec3, + ) -> bevy::math::Isometry3d; + +"#, + r#" +/// Computes an [`Isometry3d`] which transforms points from the XY-plane to this plane with the +/// given `origin`. +/// ## Guarantees +/// * the transformation is a [congruence] meaning it will preserve all distances and angles of +/// the transformed geometry +/// * uses the least rotation possible to transform the geometry +/// * if two geometries are transformed with the same isometry, then the relations between +/// them, like distances, are also preserved +/// * compared to projections, the transformation is lossless (up to floating point errors) +/// reversible +/// ## Non-Guarantees +/// * the rotation used is generally not unique +/// * the orientation of the transformed geometry in the XY plane might be arbitrary, to +/// enforce some kind of alignment the user has to use an extra transformation ontop of this +/// one +/// See [`isometries_xy`] for example usescases. +/// [congruence]: https://en.wikipedia.org/wiki/Congruence_(geometry) +/// [`isometries_xy`]: `InfinitePlane3d::isometries_xy` + + #[lua(kind = "Method", output(proxy))] + fn isometry_from_xy( + &self, + #[proxy] + origin: bevy::math::prelude::Vec3, + ) -> bevy::math::Isometry3d; + +"#, + r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::primitives::InfinitePlane3d; @@ -3555,6 +4110,12 @@ struct Line3d { derive(clone), remote = "bevy::math::primitives::Segment3d", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Segment3d; + +"#, + r#" /// Create a new `Segment3d` from a direction and full length of the segment #[lua(kind = "Function", output(proxy))] @@ -3578,12 +4139,6 @@ struct Line3d { #[lua(kind = "Method", output(proxy))] fn point2(&self) -> bevy::math::prelude::Vec3; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Segment3d; - "#, r#" @@ -3638,12 +4193,6 @@ struct Segment3d { #[lua(kind = "Method")] fn outer_radius(&self) -> f32; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Torus; - "#, r#" @@ -3655,6 +4204,12 @@ struct Segment3d { )] fn eq(&self, #[proxy] other: &primitives::dim3::Torus) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Torus; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3672,23 +4227,6 @@ struct Torus { derive(clone), remote = "bevy::math::primitives::Triangle3d", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim3::Triangle3d) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Triangle3d; - -"#, - r#" /// Create a new [`Triangle3d`] from points `a`, `b`, and `c`. #[lua(kind = "Function", output(proxy))] @@ -3749,10 +4287,27 @@ struct Torus { "#, r#" -/// Get the circumcenter of the triangle. +/// Get the circumcenter of the triangle. + + #[lua(kind = "Method", output(proxy))] + fn circumcenter(&self) -> bevy::math::prelude::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::Triangle3d) -> bool; + +"#, + r#" - #[lua(kind = "Method", output(proxy))] - fn circumcenter(&self) -> bevy::math::prelude::Vec3; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Triangle3d; "#, r#" @@ -3845,12 +4400,6 @@ struct RayCast2d { derive(clone), remote = "bevy::math::bounding::AabbCast2d", functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::bounding::AabbCast2d; - -"#, - r#" /// Construct an [`AabbCast2d`] from an [`Aabb2d`], origin, [`Dir2`], and max distance. #[lua(kind = "Function", output(proxy))] @@ -3888,6 +4437,12 @@ struct RayCast2d { aabb: bevy::math::bounding::Aabb2d, ) -> std::option::Option; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::AabbCast2d; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3969,6 +4524,12 @@ struct BoundingCircleCast { derive(clone), remote = "bevy::math::bounding::RayCast3d", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::RayCast3d; + +"#, + r#" /// Construct a [`RayCast3d`] from a [`Ray3d`] and max distance. #[lua(kind = "Function", output(proxy))] @@ -4007,12 +4568,6 @@ struct BoundingCircleCast { sphere: &bounding::bounded3d::BoundingSphere, ) -> std::option::Option; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::bounding::RayCast3d; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -4125,58 +4680,91 @@ struct BoundingSphereCast { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::FloatOrd", + remote = "bevy::math::curve::interval::Interval", functions[r#" +/// Get the start of this interval. - #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] - fn lt(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + #[lua(kind = "Method")] + fn start(self) -> f32; "#, r#" +/// Get the end of this interval. - #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] - fn le(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + #[lua(kind = "Method")] + fn end(self) -> f32; "#, r#" +/// Get the length of this interval. Note that the result may be infinite (`f32::INFINITY`). - #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] - fn gt(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + #[lua(kind = "Method")] + fn length(self) -> f32; "#, r#" +/// Returns `true` if this interval is bounded — that is, if both its start and end are finite. +/// Equivalently, an interval is bounded if its length is finite. - #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] - fn ge(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + #[lua(kind = "Method")] + fn is_bounded(self) -> bool; "#, r#" +/// Returns `true` if this interval has a finite start. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + #[lua(kind = "Method")] + fn has_finite_start(self) -> bool; "#, r#" +/// Returns `true` if this interval has a finite end. - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::FloatOrd; + #[lua(kind = "Method")] + fn has_finite_end(self) -> bool; + +"#, + r#" +/// Returns `true` if `item` is contained in this interval. + + #[lua(kind = "Method")] + fn contains(self, item: f32) -> bool; + +"#, + r#" +/// Returns `true` if the other interval is contained in this interval. +/// This is non-strict: each interval will contain itself. + + #[lua(kind = "Method")] + fn contains_interval( + self, + #[proxy] + other: bevy::math::curve::interval::Interval, + ) -> bool; + +"#, + r#" +/// Clamp the given `value` to lie within this interval. + + #[lua(kind = "Method")] + fn clamp(self, value: f32) -> f32; "#, r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::FloatOrd; + fn clone(&self) -> bevy::math::curve::interval::Interval; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &curve::interval::Interval) -> bool; "#, r#" @@ -4186,50 +4774,45 @@ fn index(&self) -> String { } "#] )] -struct FloatOrd(f32); +struct Interval {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::primitives::Annulus", + remote = "bevy::math::FloatOrd", functions[r#" -/// Create a new [`Annulus`] from the radii of the inner and outer circle - #[lua(kind = "Function", output(proxy))] - fn new(inner_radius: f32, outer_radius: f32) -> bevy::math::primitives::Annulus; + #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] + fn lt(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; "#, r#" -/// Get the diameter of the annulus - #[lua(kind = "Method")] - fn diameter(&self) -> f32; + #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] + fn le(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; "#, r#" -/// Get the thickness of the annulus - #[lua(kind = "Method")] - fn thickness(&self) -> f32; + #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] + fn gt(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; "#, r#" -/// Finds the point on the annulus that is closest to the given `point`: -/// - If the point is outside of the annulus completely, the returned point will be on the outer perimeter. -/// - If the point is inside of the inner circle (hole) of the annulus, the returned point will be on the inner perimeter. -/// - Otherwise, the returned point is overlapping the annulus and returned as is. - #[lua(kind = "Method", output(proxy))] - fn closest_point( - &self, - #[proxy] - point: bevy::math::prelude::Vec2, - ) -> bevy::math::prelude::Vec2; + #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] + fn ge(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Annulus; + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::FloatOrd; "#, r#" @@ -4240,7 +4823,13 @@ struct FloatOrd(f32); composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &primitives::dim2::Annulus) -> bool; + fn eq(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::FloatOrd; "#, r#" @@ -4250,28 +4839,12 @@ fn index(&self) -> String { } "#] )] -struct Annulus { - #[lua(output(proxy))] - inner_circle: bevy::math::primitives::Circle, - #[lua(output(proxy))] - outer_circle: bevy::math::primitives::Circle, -} +struct FloatOrd(f32); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::math::primitives::Plane3d", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim3::Plane3d) -> bool; - -"#, - r#" /// Create a new `Plane3d` from a normal and a half size /// # Panics /// Panics if the given `normal` is zero (or very close to zero), or non-finite. @@ -4290,6 +4863,17 @@ struct Annulus { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::primitives::Plane3d; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::Plane3d) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -4310,17 +4894,6 @@ struct Plane3d { remote = "bevy::math::primitives::Tetrahedron", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim3::Tetrahedron) -> bool; - -"#, - r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::primitives::Tetrahedron; @@ -4359,6 +4932,17 @@ struct Plane3d { #[lua(kind = "Method", output(proxy))] fn centroid(&self) -> bevy::math::prelude::Vec3; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::Tetrahedron) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -4370,6 +4954,35 @@ fn index(&self) -> String { struct Tetrahedron { vertices: ReflectedValue, } +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::curve::easing::EaseFunction", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::curve::easing::EaseFunction; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &curve::easing::EaseFunction) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct EaseFunction {} #[derive(Default)] pub(crate) struct Globals; impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { @@ -4379,8 +4992,13 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { >(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> { instances .add_instance( - "AspectRatio", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + "Isometry2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Isometry3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( @@ -4444,6 +5062,11 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { "Circle", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, )?; + instances + .add_instance( + "Annulus", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; instances .add_instance( "Arc2d", @@ -4525,6 +5148,11 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { "Capsule3d", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, )?; + instances + .add_instance( + "Cone", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; instances .add_instance( "Segment3d", @@ -4574,11 +5202,6 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { LuaBoundingSphereCast, >::new, )?; - instances - .add_instance( - "Annulus", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; instances .add_instance( "Plane3d", @@ -4614,12 +5237,19 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { |tw| { tw.document_global_instance::() .expect("Something went wrong documenting globals") + .process_type::() .process_type::() .process_type::() - .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaIsometry2d, + >, + >() + .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaAspectRatio, + LuaIsometry3d, >, >() .process_type::() @@ -4673,6 +5303,10 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, @@ -4755,6 +5389,9 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { >, >() .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() .process_type::() .process_type::() .process_type::() @@ -4810,11 +5447,8 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { LuaBoundingSphereCast, >, >() + .process_type::() .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, @@ -4825,6 +5459,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { LuaTetrahedron, >, >() + .process_type::() }, ), ) @@ -4845,9 +5480,11 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { Ok(()) } fn register_with_app(&self, app: &mut bevy::app::App) { + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); @@ -4861,6 +5498,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); @@ -4892,9 +5530,10 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); } } diff --git a/crates/bevy_script_api/src/providers/bevy_reflect.rs b/crates/bevy_script_api/src/providers/bevy_reflect.rs index 357cd40615..45daa85da3 100644 --- a/crates/bevy_script_api/src/providers/bevy_reflect.rs +++ b/crates/bevy_script_api/src/providers/bevy_reflect.rs @@ -7,10 +7,326 @@ use bevy_script_api::{ lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicBool", + functions[r#" +/// Creates a new `AtomicBool`. +/// # Examples +/// ``` +/// use std::sync::atomic::AtomicBool; +/// let atomic_true = AtomicBool::new(true); +/// let atomic_false = AtomicBool::new(false); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(v: bool) -> std::sync::atomic::AtomicBool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicBool {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicI16", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicI16; +///let atomic_forty_two = AtomicI16::new(42); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(v: i16) -> std::sync::atomic::AtomicI16; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicI16 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicI32", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicI32; +///let atomic_forty_two = AtomicI32::new(42); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(v: i32) -> std::sync::atomic::AtomicI32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicI32 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicI64", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicI64; +///let atomic_forty_two = AtomicI64::new(42); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(v: i64) -> std::sync::atomic::AtomicI64; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicI64 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicI8", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicI8; +///let atomic_forty_two = AtomicI8::new(42); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(v: i8) -> std::sync::atomic::AtomicI8; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicI8 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicIsize", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicIsize; +///let atomic_forty_two = AtomicIsize::new(42); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(v: isize) -> std::sync::atomic::AtomicIsize; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicIsize {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicU16", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicU16; +///let atomic_forty_two = AtomicU16::new(42); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(v: u16) -> std::sync::atomic::AtomicU16; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicU16 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicU32", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicU32; +///let atomic_forty_two = AtomicU32::new(42); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(v: u32) -> std::sync::atomic::AtomicU32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicU32 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicU64", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicU64; +///let atomic_forty_two = AtomicU64::new(42); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(v: u64) -> std::sync::atomic::AtomicU64; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicU64 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicU8", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicU8; +///let atomic_forty_two = AtomicU8::new(42); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(v: u8) -> std::sync::atomic::AtomicU8; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicU8 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicUsize", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicUsize; +///let atomic_forty_two = AtomicUsize::new(42); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(v: usize) -> std::sync::atomic::AtomicUsize; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicUsize {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::utils::Duration", functions[r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u32) -> bevy::utils::Duration; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::utils::Duration; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_utils::Duration) -> bool; + +"#, + r#" /// Creates a new `Duration` from the specified number of whole seconds and /// additional nanoseconds. /// If the number of nanoseconds is greater than 1 billion (the number of @@ -47,7 +363,7 @@ use bevy_script_api::{ /// # Examples /// ``` /// use std::time::Duration; -/// let duration = Duration::from_millis(2569); +/// let duration = Duration::from_millis(2_569); /// assert_eq!(2, duration.as_secs()); /// assert_eq!(569_000_000, duration.subsec_nanos()); /// ``` @@ -63,7 +379,7 @@ use bevy_script_api::{ /// use std::time::Duration; /// let duration = Duration::from_micros(1_000_002); /// assert_eq!(1, duration.as_secs()); -/// assert_eq!(2000, duration.subsec_nanos()); +/// assert_eq!(2_000, duration.subsec_nanos()); /// ``` #[lua(kind = "Function", output(proxy))] @@ -113,7 +429,7 @@ use bevy_script_api::{ /// # Examples /// ``` /// use std::time::Duration; -/// let duration = Duration::new(5, 730023852); +/// let duration = Duration::new(5, 730_023_852); /// assert_eq!(duration.as_secs(), 5); /// ``` /// To determine the total number of seconds represented by the `Duration` @@ -134,7 +450,7 @@ use bevy_script_api::{ /// # Examples /// ``` /// use std::time::Duration; -/// let duration = Duration::from_millis(5432); +/// let duration = Duration::from_millis(5_432); /// assert_eq!(duration.as_secs(), 5); /// assert_eq!(duration.subsec_millis(), 432); /// ``` @@ -168,7 +484,7 @@ use bevy_script_api::{ /// # Examples /// ``` /// use std::time::Duration; -/// let duration = Duration::from_millis(5010); +/// let duration = Duration::from_millis(5_010); /// assert_eq!(duration.as_secs(), 5); /// assert_eq!(duration.subsec_nanos(), 10_000_000); /// ``` @@ -182,8 +498,8 @@ use bevy_script_api::{ /// # Examples /// ``` /// use std::time::Duration; -/// let duration = Duration::new(5, 730023852); -/// assert_eq!(duration.as_millis(), 5730); +/// let duration = Duration::new(5, 730_023_852); +/// assert_eq!(duration.as_millis(), 5_730); /// ``` #[lua(kind = "Method")] @@ -195,8 +511,8 @@ use bevy_script_api::{ /// # Examples /// ``` /// use std::time::Duration; -/// let duration = Duration::new(5, 730023852); -/// assert_eq!(duration.as_micros(), 5730023); +/// let duration = Duration::new(5, 730_023_852); +/// assert_eq!(duration.as_micros(), 5_730_023); /// ``` #[lua(kind = "Method")] @@ -208,13 +524,26 @@ use bevy_script_api::{ /// # Examples /// ``` /// use std::time::Duration; -/// let duration = Duration::new(5, 730023852); -/// assert_eq!(duration.as_nanos(), 5730023852); +/// let duration = Duration::new(5, 730_023_852); +/// assert_eq!(duration.as_nanos(), 5_730_023_852); /// ``` #[lua(kind = "Method")] fn as_nanos(&self) -> u128; +"#, + r#" +/// Computes the absolute difference between `self` and `other`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// assert_eq!(Duration::new(100, 0).abs_diff(Duration::new(80, 0)), Duration::new(20, 0)); +/// assert_eq!(Duration::new(100, 400_000_000).abs_diff(Duration::new(110, 0)), Duration::new(9, 600_000_000)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn abs_diff(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Duration; + "#, r#" /// Saturating `Duration` addition. Computes `self + other`, returning [`Duration::MAX`] @@ -270,7 +599,7 @@ use bevy_script_api::{ "#, r#" /// Returns the number of seconds contained by this `Duration` as `f64`. -/// The returned value does include the fractional (nanosecond) part of the duration. +/// The returned value includes the fractional (nanosecond) part of the duration. /// # Examples /// ``` /// use std::time::Duration; @@ -284,7 +613,7 @@ use bevy_script_api::{ "#, r#" /// Returns the number of seconds contained by this `Duration` as `f32`. -/// The returned value does include the fractional (nanosecond) part of the duration. +/// The returned value includes the fractional (nanosecond) part of the duration. /// # Examples /// ``` /// use std::time::Duration; @@ -381,7 +710,7 @@ use bevy_script_api::{ /// use std::time::Duration; /// let dur = Duration::new(2, 700_000_000); /// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_641)); -/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847800, 0)); +/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847_800, 0)); /// ``` #[lua(kind = "Method", output(proxy))] @@ -389,7 +718,7 @@ use bevy_script_api::{ "#, r#" -/// Divide `Duration` by `f64`. +/// Divides `Duration` by `f64`. /// # Panics /// This method will panic if result is negative, overflows `Duration` or not finite. /// # Examples @@ -405,7 +734,7 @@ use bevy_script_api::{ "#, r#" -/// Divide `Duration` by `f32`. +/// Divides `Duration` by `f32`. /// # Panics /// This method will panic if result is negative, overflows `Duration` or not finite. /// # Examples @@ -423,49 +752,43 @@ use bevy_script_api::{ "#, r#" +/// Divides `Duration` by `Duration` and returns `f64`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur1 = Duration::new(2, 700_000_000); +/// let dur2 = Duration::new(5, 400_000_000); +/// assert_eq!(dur1.div_duration_f64(dur2), 0.5); +/// ``` - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u32) -> bevy::utils::Duration; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; + #[lua(kind = "Method")] + fn div_duration_f64(self, #[proxy] rhs: bevy::utils::Duration) -> f64; "#, r#" +/// Divides `Duration` by `Duration` and returns `f32`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur1 = Duration::new(2, 700_000_000); +/// let dur2 = Duration::new(5, 400_000_000); +/// assert_eq!(dur1.div_duration_f32(dur2), 0.5); +/// ``` - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::utils::Duration; + #[lua(kind = "Method")] + fn div_duration_f32(self, #[proxy] rhs: bevy::utils::Duration) -> f32; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "add", + metamethod = "Add", )] - fn sub(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; + fn add(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; "#, r#" @@ -481,6 +804,18 @@ use bevy_script_api::{ "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Duration {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::utils::Instant", + functions[r#" #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); @@ -494,22 +829,10 @@ use bevy_script_api::{ composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &bevy_utils::Duration) -> bool; + fn eq(&self, #[proxy] other: &bevy_utils::Instant) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Duration {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::utils::Instant", - functions[r#" #[lua( as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", @@ -532,24 +855,22 @@ struct Duration {} "#, r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" +/// Returns the amount of time elapsed from another instant to this one, +/// or zero duration if that instant is later than this one. /// # Panics -/// This function may panic if the resulting point in time cannot be represented by the -/// underlying data structure. See [`Instant::checked_add`] for a version without panic. +/// Previous Rust versions panicked when `other` was later than `self`. Currently this +/// method saturates. Future versions may reintroduce the panic in some circumstances. +/// See [Monotonicity]. +/// [Monotonicity]: Instant#monotonicity #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "sub", + metamethod = "Sub", )] - fn add(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; + fn sub(self, #[proxy] other: bevy::utils::Instant) -> bevy::utils::Duration; "#, r#" @@ -635,33 +956,18 @@ struct Duration {} "#, r#" -/// Returns the amount of time elapsed from another instant to this one, -/// or zero duration if that instant is later than this one. /// # Panics -/// Previous Rust versions panicked when `other` was later than `self`. Currently this -/// method saturates. Future versions may reintroduce the panic in some circumstances. -/// See [Monotonicity]. -/// [Monotonicity]: Instant#monotonicity +/// This function may panic if the resulting point in time cannot be represented by the +/// underlying data structure. See [`Instant::checked_add`] for a version without panic. #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] other: bevy::utils::Instant) -> bevy::utils::Duration; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + composite = "add", + metamethod = "Add", )] - fn eq(&self, #[proxy] other: &bevy_utils::Instant) -> bool; + fn add(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; "#, r#" @@ -679,23 +985,12 @@ struct Instant(); functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::path::PathBuf; - -"#, - r#" -/// Clones the contents of `source` into `self`. -/// This method is preferred over simply assigning `source.clone()` to `self`, -/// as it avoids reallocation if possible. - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "MutatingMethod", + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone_from(&mut self, #[proxy] source: &std::path::PathBuf) -> (); + fn eq(&self, #[proxy] other: &std::path::PathBuf) -> bool; "#, r#" @@ -798,12 +1093,23 @@ struct Instant(); r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] other: &std::path::PathBuf) -> bool; + fn clone(&self) -> std::path::PathBuf; + +"#, + r#" +/// Clones the contents of `source` into `self`. +/// This method is preferred over simply assigning `source.clone()` to `self`, +/// as it avoids reallocation if possible. + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "MutatingMethod", + )] + fn clone_from(&mut self, #[proxy] source: &std::path::PathBuf) -> (); "#, r#" @@ -820,6 +1126,16 @@ struct PathBuf {} remote = "std::ops::RangeFull", functions[r#" + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> std::ops::RangeFull; + +"#, + r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); @@ -834,16 +1150,6 @@ struct PathBuf {} )] fn eq(&self, #[proxy] other: &std::ops::RangeFull) -> bool; -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::ops::RangeFull; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -858,15 +1164,17 @@ struct RangeFull {} derive(clone), remote = "bevy::math::Quat", functions[r#" +/// Subtracts the `rhs` quaternion from `self`. +/// The difference is not guaranteed to be normalized. #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "sub", + metamethod = "Sub", )] - fn neg(self) -> bevy::math::Quat; + fn sub(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; "#, r#" @@ -884,30 +1192,25 @@ struct RangeFull {} "#, r#" -/// Adds two quaternions. -/// The sum is not guaranteed to be normalized. -/// Note that addition is not the same as combining the rotations represented by the -/// two quaternions! That corresponds to multiplication. #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "add", - metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + fn clone(&self) -> bevy::math::Quat; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Neg", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "neg", + metamethod = "Unm", )] - fn eq(&self, #[proxy] rhs: &glam::Quat) -> bool; + fn neg(self) -> bevy::math::Quat; "#, r#" @@ -923,13 +1226,59 @@ struct RangeFull {} "#, r#" +/// Multiplies a quaternion and a 3D vector, returning the rotated vector. +/// # Panics +/// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::Quat; + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" +/// Adds two quaternions. +/// The sum is not guaranteed to be normalized. +/// Note that addition is not the same as combining the rotations represented by the +/// two quaternions! That corresponds to multiplication. + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + +"#, + r#" +/// Divides a quaternion by a scalar value. +/// The quotient is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Quat; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Quat) -> bool; "#, r#" @@ -1019,6 +1368,10 @@ struct RangeFull {} "#, r#" /// Creates a quaternion from a 3x3 rotation matrix. +/// Note if the input matrix contain scales, shears, or other non-rotation transformations then +/// the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn from_mat3(#[proxy] mat: &glam::Mat3) -> bevy::math::Quat; @@ -1026,13 +1379,22 @@ struct RangeFull {} "#, r#" /// Creates a quaternion from a 3x3 SIMD aligned rotation matrix. +/// Note if the input matrix contain scales, shears, or other non-rotation transformations then +/// the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn from_mat3a(#[proxy] mat: &glam::Mat3A) -> bevy::math::Quat; "#, r#" -/// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. +/// Creates a quaternion from the upper 3x3 rotation matrix inside a homogeneous 4x4 matrix. +/// Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations +/// then the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any column of the upper 3x3 rotation matrix is not normalized when +/// `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn from_mat4(#[proxy] mat: &glam::Mat4) -> bevy::math::Quat; @@ -1106,7 +1468,7 @@ struct RangeFull {} /// Returns the rotation angles for the given euler rotation sequence. #[lua(kind = "Method")] - fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f32, f32, f32); + fn to_euler(self, #[proxy] order: bevy::math::EulerRot) -> (f32, f32, f32); "#, r#" @@ -1194,6 +1556,7 @@ struct RangeFull {} "#, r#" +/// Returns `true` if any elements are `NAN`. #[lua(kind = "Method")] fn is_nan(self) -> bool; @@ -1223,6 +1586,24 @@ struct RangeFull {} #[lua(kind = "Method")] fn angle_between(self, #[proxy] rhs: bevy::math::Quat) -> f32; +"#, + r#" +/// Rotates towards `rhs` up to `max_angle` (in radians). +/// When `max_angle` is `0.0`, the result will be equal to `self`. When `max_angle` is equal to +/// `self.angle_between(rhs)`, the result will be equal to `rhs`. If `max_angle` is negative, +/// rotates towards the exact opposite of `rhs`. Will not go past the target. +/// Both quaternions must be normalized. +/// # Panics +/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn rotate_towards( + &self, + #[proxy] + rhs: bevy::math::Quat, + max_angle: f32, + ) -> bevy::math::Quat; + "#, r#" /// Returns true if the absolute difference of all elements between `self` and `rhs` @@ -1283,6 +1664,11 @@ struct RangeFull {} "#, r#" /// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. +/// Note if the input affine matrix contain scales, shears, or other non-rotation +/// transformations then the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input affine matrix column is not normalized when `glam_assert` is +/// enabled. #[lua(kind = "Function", output(proxy))] fn from_affine3(#[proxy] a: &glam::Affine3A) -> bevy::math::Quat; @@ -1300,40 +1686,6 @@ struct RangeFull {} #[lua(kind = "Method", output(proxy))] fn as_dquat(self) -> bevy::math::DQuat; -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_f64(self) -> bevy::math::DQuat; - -"#, - r#" -/// Divides a quaternion by a scalar value. -/// The quotient is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Quat; - -"#, - r#" -/// Subtracts the `rhs` quaternion from `self`. -/// The difference is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; - "#, r#" /// Multiplies two quaternions. If they each represent a rotation, the result will @@ -1352,26 +1704,11 @@ struct RangeFull {} )] fn mul(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; -"#, - r#" -/// Multiplies a quaternion and a 3D vector, returning the rotated vector. -/// # Panics -/// Will panic if `self` is not normalized when `glam_assert` is enabled. - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -1381,6 +1718,18 @@ struct Quat(); derive(clone), remote = "bevy::math::Vec3", functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec3; + +"#, + r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] @@ -1646,6 +1995,14 @@ struct Quat(); #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec3; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -1656,7 +2013,7 @@ struct Quat(); "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec3; @@ -1716,10 +2073,10 @@ struct Quat(); "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::Vec3; @@ -1915,23 +2272,27 @@ struct Quat(); "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f32) -> bevy::math::Vec3; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f32) -> bevy::math::Vec3; @@ -1956,7 +2317,30 @@ struct Quat(); "#, r#" -/// Returns the angle (in radians) between two vectors. +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::Vec3, eta: f32) -> bevy::math::Vec3; + +"#, + r#" +/// Returns the angle (in radians) between two vectors in the range `[0, +Ï€]`. /// The inputs do not need to be unit vectors however they must be non-zero. #[lua(kind = "Method")] @@ -2027,30 +2411,43 @@ struct Quat(); composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn div(self, rhs: f32) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Sub", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn eq(&self, #[proxy] other: &glam::Vec3) -> bool; + fn sub(self, rhs: f32) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "add", + metamethod = "Add", )] - fn sub(self, rhs: f32) -> bevy::math::Vec3; + fn add(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec3; "#, r#" @@ -2062,67 +2459,79 @@ struct Quat(); composite = "div", metamethod = "Div", )] - fn div(self, rhs: f32) -> bevy::math::Vec3; + fn div(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "sub", + metamethod = "Sub", )] - fn mul(self, rhs: f32) -> bevy::math::Vec3; + fn sub(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn add(self, rhs: f32) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "div", + metamethod = "Div", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn div(self, #[proxy] rhs: &glam::Vec3) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "neg", + metamethod = "Unm", )] - fn sub(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn neg(self) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, rhs: f32) -> bevy::math::Vec3; + fn rem(self, #[proxy] rhs: &glam::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::Vec3) -> bevy::math::Vec3; "#, r#" @@ -2134,29 +2543,31 @@ struct Quat(); composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: f32) -> bevy::math::Vec3; + fn rem(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::Vec3; + fn mul(self, #[proxy] rhs: &glam::Vec3) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::Vec3; + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" @@ -2168,13 +2579,34 @@ struct Quat(); composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn add(self, #[proxy] rhs: &glam::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::Vec3) -> bool; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -2202,25 +2634,24 @@ struct Vec3 { functions[r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn eq(&self, #[proxy] other: &glam::IVec2) -> bool; "#, r#" @@ -2232,26 +2663,198 @@ struct Vec3 { composite = "add", metamethod = "Add", )] - fn add(self, rhs: i32) -> bevy::math::IVec2; + fn add(self, #[proxy] rhs: &glam::IVec2) -> bevy::math::IVec2; "#, r#" -/// Creates a new vector. - #[lua(kind = "Function", output(proxy))] - fn new(x: i32, y: i32) -> bevy::math::IVec2; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i32) -> bevy::math::IVec2; "#, r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: i32) -> bevy::math::IVec2; -"#, - r#" -/// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use -/// for each element of `self`. + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i32) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::IVec2; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i32) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: i32) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: i32) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::IVec2; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: i32, y: i32) -> bevy::math::IVec2; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: i32) -> bevy::math::IVec2; + +"#, + r#" +/// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use +/// for each element of `self`. /// A true element in the mask uses the corresponding element from `if_true`, and false /// uses the element from `if_false`. @@ -2669,31 +3272,64 @@ struct Vec3 { composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: i32) -> bevy::math::IVec2; + fn sub(self, #[proxy] rhs: &glam::IVec2) -> bevy::math::IVec2; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +struct IVec2 { + x: i32, + y: i32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::IVec3", + functions[r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "add", + metamethod = "Add", )] - fn div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "div", + metamethod = "Div", )] - fn rem(self, rhs: i32) -> bevy::math::IVec2; + fn div(self, rhs: i32) -> bevy::math::IVec3; "#, r#" @@ -2705,17 +3341,19 @@ struct Vec3 { composite = "sub", metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn sub(self, #[proxy] rhs: &glam::IVec3) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::IVec2; + fn mul(self, rhs: i32) -> bevy::math::IVec3; "#, r#" @@ -2727,19 +3365,17 @@ struct Vec3 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: i32) -> bevy::math::IVec2; + fn div(self, #[proxy] rhs: &glam::IVec3) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "neg", - metamethod = "Unm", )] - fn neg(self) -> bevy::math::IVec2; + fn clone(&self) -> bevy::math::IVec3; "#, r#" @@ -2751,7 +3387,19 @@ struct Vec3 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn add(self, #[proxy] rhs: &glam::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" @@ -2762,86 +3410,91 @@ struct Vec3 { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &glam::IVec2) -> bool; + fn eq(&self, #[proxy] other: &glam::IVec3) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "neg", + metamethod = "Unm", )] - fn mul(self, rhs: i32) -> bevy::math::IVec2; + fn neg(self) -> bevy::math::IVec3; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i32) -> bevy::math::IVec3; + "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -struct IVec2 { - x: i32, - y: i32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::IVec3", - functions[r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::IVec3; + fn mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Add", + kind = "MetaFunction", output(proxy), + composite = "add", + metamethod = "Add", )] - fn clone(&self) -> bevy::math::IVec3; + fn add(self, rhs: i32) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, rhs: i32) -> bevy::math::IVec3; + fn mul(self, #[proxy] rhs: &glam::IVec3) -> bevy::math::IVec3; "#, r#" @@ -3277,37 +3930,65 @@ struct IVec2 { r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn rem(self, #[proxy] rhs: &glam::IVec3) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "sub", + metamethod = "Sub", )] - fn rem(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn sub(self, rhs: i32) -> bevy::math::IVec3; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +struct IVec3 { + x: i32, + y: i32, + z: i32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::IVec4", + functions[r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "sub", + metamethod = "Sub", )] - fn add(self, rhs: i32) -> bevy::math::IVec3; + fn sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -3319,19 +4000,17 @@ struct IVec2 { composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: i32) -> bevy::math::IVec3; + fn rem(self, #[proxy] rhs: &glam::IVec4) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "mul", - metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn clone(&self) -> bevy::math::IVec4; "#, r#" @@ -3343,19 +4022,7 @@ struct IVec2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: i32) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn mul(self, rhs: i32) -> bevy::math::IVec4; "#, r#" @@ -3366,19 +4033,7 @@ struct IVec2 { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &glam::IVec3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn eq(&self, #[proxy] other: &glam::IVec4) -> bool; "#, r#" @@ -3396,94 +4051,67 @@ struct IVec2 { composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: i32) -> bevy::math::IVec3; + fn sub(self, rhs: i32) -> bevy::math::IVec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -struct IVec3 { - x: i32, - y: i32, - z: i32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::IVec4", - functions[r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, rhs: i32) -> bevy::math::IVec4; + fn rem(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::IVec4; + fn mul(self, #[proxy] rhs: &glam::IVec4) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "sub", + metamethod = "Sub", )] - fn rem(self, rhs: i32) -> bevy::math::IVec4; + fn sub(self, #[proxy] rhs: &glam::IVec4) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Neg", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "neg", + metamethod = "Unm", )] - fn eq(&self, #[proxy] other: &glam::IVec4) -> bool; + fn neg(self) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, rhs: i32) -> bevy::math::IVec4; + fn mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -3513,31 +4141,67 @@ struct IVec3 { r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "div", + metamethod = "Div", )] - fn add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn div(self, rhs: i32) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "rem", + metamethod = "Mod", )] - fn div(self, rhs: i32) -> bevy::math::IVec4; + fn rem(self, rhs: i32) -> bevy::math::IVec4; "#, r#" -/// Creates a new vector. - #[lua(kind = "Function", output(proxy))] + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::IVec4) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::IVec4) -> bevy::math::IVec4; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] fn new(x: i32, y: i32, z: i32, w: i32) -> bevy::math::IVec4; "#, @@ -3949,63 +4613,11 @@ struct IVec3 { rhs: bevy::math::UVec4, ) -> bevy::math::IVec4; -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::IVec4; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -4034,23 +4646,49 @@ struct IVec4 { functions[r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn mul(self, #[proxy] rhs: &glam::I64Vec2) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Rem", + kind = "MetaFunction", output(proxy), + composite = "rem", + metamethod = "Mod", )] - fn clone(&self) -> bevy::math::I64Vec2; + fn rem(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i64) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -4062,30 +4700,49 @@ struct IVec4 { composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: i64) -> bevy::math::I64Vec2; + fn sub(self, #[proxy] rhs: &glam::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Div", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "div", + metamethod = "Div", )] - fn eq(&self, #[proxy] other: &glam::I64Vec2) -> bool; + fn div(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn rem(self, rhs: i64) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" @@ -4097,7 +4754,7 @@ struct IVec4 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: i64) -> bevy::math::I64Vec2; + fn div(self, #[proxy] rhs: &glam::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -4536,61 +5193,82 @@ struct IVec4 { r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "sub", + metamethod = "Sub", )] - fn add(self, rhs: i64) -> bevy::math::I64Vec2; + fn sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "div", + metamethod = "Div", )] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::I64Vec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "sub", + metamethod = "Sub", )] - fn mul(self, rhs: i64) -> bevy::math::I64Vec2; + fn sub(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec2; + fn add(self, #[proxy] rhs: &glam::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -4614,19 +5292,13 @@ struct IVec4 { composite = "rem", metamethod = "Mod", )] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + fn rem(self, #[proxy] rhs: &glam::I64Vec2) -> bevy::math::I64Vec2; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -4641,11 +5313,13 @@ struct I64Vec2 { functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Neg", + kind = "MetaFunction", output(proxy), + composite = "neg", + metamethod = "Unm", )] - fn clone(&self) -> bevy::math::I64Vec3; + fn neg(self) -> bevy::math::I64Vec3; "#, r#" @@ -4657,31 +5331,53 @@ struct I64Vec2 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn div(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "rem", - metamethod = "Mod", )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec3; + fn clone(&self) -> bevy::math::I64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: i64) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" @@ -4693,31 +5389,49 @@ struct I64Vec2 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: i64) -> bevy::math::I64Vec3; + fn div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "sub", + metamethod = "Sub", )] - fn neg(self) -> bevy::math::I64Vec3; + fn sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "div", + metamethod = "Div", )] - fn mul(self, rhs: i64) -> bevy::math::I64Vec3; + fn div(self, #[proxy] rhs: &glam::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -4734,8 +5448,14 @@ struct I64Vec2 { "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" @@ -4748,6 +5468,18 @@ struct I64Vec2 { )] fn eq(&self, #[proxy] other: &glam::I64Vec3) -> bool; +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + "#, r#" @@ -4760,6 +5492,42 @@ struct I64Vec2 { )] fn sub(self, rhs: i64) -> bevy::math::I64Vec3; +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + "#, r#" /// Creates a new vector. @@ -5198,17 +5966,45 @@ struct I64Vec2 { rhs: bevy::math::U64Vec3, ) -> bevy::math::I64Vec3; +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct I64Vec3 { + x: i64, + y: i64, + z: i64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::I64Vec4", + functions[r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "div", + metamethod = "Div", )] - fn add(self, rhs: i64) -> bevy::math::I64Vec3; + fn div(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" @@ -5220,7 +6016,7 @@ struct I64Vec2 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn add(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" @@ -5232,94 +6028,192 @@ struct I64Vec2 { composite = "rem", metamethod = "Mod", )] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn rem(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct I64Vec3 { - x: i64, - y: i64, - z: i64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::I64Vec4", - functions[r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Div", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "div", + metamethod = "Div", )] - fn eq(&self, #[proxy] other: &glam::I64Vec4) -> bool; + fn div(self, #[proxy] rhs: &glam::I64Vec4) -> bevy::math::I64Vec4; "#, r#" -/// Creates a new vector. - #[lua(kind = "Function", output(proxy))] - fn new(x: i64, y: i64, z: i64, w: i64) -> bevy::math::I64Vec4; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -/// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] - fn splat(v: i64) -> bevy::math::I64Vec4; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" -/// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use -/// for each element of `self`. -/// A true element in the mask uses the corresponding element from `if_true`, and false -/// uses the element from `if_false`. - #[lua(kind = "Function", output(proxy))] - fn select( - #[proxy] - mask: bevy::math::BVec4, - #[proxy] - if_true: bevy::math::I64Vec4, - #[proxy] - if_false: bevy::math::I64Vec4, - ) -> bevy::math::I64Vec4; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" -/// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i64; 4]) -> bevy::math::I64Vec4; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" -/// `[x, y, z, w]` - #[lua(kind = "Method")] - fn to_array(&self) -> [i64; 4]; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" -/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. -/// Truncation to [`I64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. - #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::I64Vec3; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" -/// Creates a 4D vector from `self` with the given value of `x`. - - #[lua(kind = "Method", output(proxy))] - fn with_x(self, x: i64) -> bevy::math::I64Vec4; + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i64) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::I64Vec4) -> bool; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: i64, y: i64, z: i64, w: i64) -> bevy::math::I64Vec4; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: i64) -> bevy::math::I64Vec4; + +"#, + r#" +/// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use +/// for each element of `self`. +/// A true element in the mask uses the corresponding element from `if_true`, and false +/// uses the element from `if_false`. + + #[lua(kind = "Function", output(proxy))] + fn select( + #[proxy] + mask: bevy::math::BVec4, + #[proxy] + if_true: bevy::math::I64Vec4, + #[proxy] + if_false: bevy::math::I64Vec4, + ) -> bevy::math::I64Vec4; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [i64; 4]) -> bevy::math::I64Vec4; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [i64; 4]; + +"#, + r#" +/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. +/// Truncation to [`I64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. + + #[lua(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::I64Vec3; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `x`. + + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: i64) -> bevy::math::I64Vec4; "#, r#" @@ -5689,67 +6583,82 @@ struct I64Vec3 { r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "rem", + metamethod = "Mod", )] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn rem(self, #[proxy] rhs: &glam::I64Vec4) -> bevy::math::I64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "neg", + metamethod = "Unm", )] - fn add(self, rhs: i64) -> bevy::math::I64Vec4; + fn neg(self) -> bevy::math::I64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "mul", + metamethod = "Mul", )] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn mul(self, #[proxy] rhs: &glam::I64Vec4) -> bevy::math::I64Vec4; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::I64Vec4; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct I64Vec4 { + x: i64, + y: i64, + z: i64, + w: i64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::UVec2", + functions[r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i64) -> bevy::math::I64Vec4; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec4; + fn add(self, rhs: u32) -> bevy::math::UVec2; "#, r#" @@ -5761,97 +6670,79 @@ struct I64Vec3 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "add", + metamethod = "Add", )] - fn neg(self) -> bevy::math::I64Vec4; + fn add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, rhs: i64) -> bevy::math::I64Vec4; + fn rem(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "eq", + metamethod = "Eq", )] - fn sub(self, rhs: i64) -> bevy::math::I64Vec4; + fn eq(&self, #[proxy] other: &glam::UVec2) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "mul", - metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn clone(&self) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn rem(self, #[proxy] rhs: &glam::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::I64Vec4; + fn mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct I64Vec4 { - x: i64, - y: i64, - z: i64, - w: i64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::UVec2", - functions[r#" #[lua( as_trait = "std::ops::Sub", @@ -5860,19 +6751,7 @@ struct I64Vec4 { composite = "sub", metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u32) -> bevy::math::UVec2; + fn sub(self, #[proxy] rhs: &glam::UVec2) -> bevy::math::UVec2; "#, r#" @@ -5890,58 +6769,17 @@ struct I64Vec4 { r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "div", + metamethod = "Div", )] - fn sub(self, rhs: u32) -> bevy::math::UVec2; + fn div(self, #[proxy] rhs: &glam::UVec2) -> bevy::math::UVec2; "#, r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u32) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u32) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::UVec2) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -/// Creates a new vector. +/// Creates a new vector. #[lua(kind = "Function", output(proxy))] fn new(x: u32, y: u32) -> bevy::math::UVec2; @@ -6265,6 +7103,18 @@ struct I64Vec4 { #[lua(kind = "Method", output(proxy))] fn saturating_add_signed(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::UVec2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + "#, r#" @@ -6275,59 +7125,61 @@ struct I64Vec4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn mul(self, #[proxy] rhs: &glam::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "sub", + metamethod = "Sub", )] - fn rem(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn sub(self, rhs: u32) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn mul(self, rhs: u32) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "add", + metamethod = "Add", )] - fn div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn add(self, #[proxy] rhs: &glam::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Div", + kind = "MetaFunction", output(proxy), + composite = "div", + metamethod = "Div", )] - fn clone(&self) -> bevy::math::UVec2; + fn div(self, rhs: u32) -> bevy::math::UVec2; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -6354,49 +7206,61 @@ struct UVec2 { functions[r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "div", + metamethod = "Div", )] - fn mul(self, rhs: u32) -> bevy::math::UVec3; + fn div(self, #[proxy] rhs: &glam::UVec3) -> bevy::math::UVec3; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "add", + metamethod = "Add", )] - fn div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "mul", + metamethod = "Mul", )] - fn rem(self, rhs: u32) -> bevy::math::UVec3; + fn mul(self, #[proxy] rhs: &glam::UVec3) -> bevy::math::UVec3; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, rhs: u32) -> bevy::math::UVec3; + fn mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u32) -> bevy::math::UVec3; "#, r#" @@ -6408,71 +7272,88 @@ struct UVec2 { composite = "rem", metamethod = "Mod", )] - fn rem(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn rem(self, #[proxy] rhs: &glam::UVec3) -> bevy::math::UVec3; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "eq", + metamethod = "Eq", )] - fn sub(self, rhs: u32) -> bevy::math::UVec3; + fn eq(&self, #[proxy] other: &glam::UVec3) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "add", + metamethod = "Add", )] - fn sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn add(self, #[proxy] rhs: &glam::UVec3) -> bevy::math::UVec3; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Div", + kind = "MetaFunction", output(proxy), + composite = "div", + metamethod = "Div", )] - fn clone(&self) -> bevy::math::UVec3; + fn div(self, rhs: u32) -> bevy::math::UVec3; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn rem(self, rhs: u32) -> bevy::math::UVec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn rem(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::UVec3) -> bevy::math::UVec3; "#, r#" @@ -6484,7 +7365,7 @@ struct UVec2 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: u32) -> bevy::math::UVec3; + fn div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -6845,18 +7726,49 @@ struct UVec2 { r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Add", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "add", + metamethod = "Add", )] - fn eq(&self, #[proxy] other: &glam::UVec3) -> bool; + fn add(self, rhs: u32) -> bevy::math::UVec3; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u32) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -6884,116 +7796,41 @@ struct UVec3 { functions[r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "mul", + metamethod = "Mul", )] - fn rem(self, rhs: u32) -> bevy::math::UVec4; + fn mul(self, #[proxy] rhs: &glam::UVec4) -> bevy::math::UVec4; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Div", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "div", + metamethod = "Div", )] - fn eq(&self, #[proxy] other: &glam::UVec4) -> bool; + fn div(self, rhs: u32) -> bevy::math::UVec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "div", + metamethod = "Div", )] - fn add(self, rhs: u32) -> bevy::math::UVec4; + fn div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u32) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u32) -> bevy::math::UVec4; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" -/// Creates a new vector. +/// Creates a new vector. #[lua(kind = "Function", output(proxy))] fn new(x: u32, y: u32, z: u32, w: u32) -> bevy::math::UVec4; @@ -7332,6 +8169,28 @@ struct UVec3 { #[lua(kind = "Method", output(proxy))] fn saturating_add_signed(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::UVec4; +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::UVec4; + "#, r#" @@ -7354,7 +8213,120 @@ struct UVec3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: u32) -> bevy::math::UVec4; + fn mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u32) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u32) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::UVec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u32) -> bevy::math::UVec4; "#, r#" @@ -7366,13 +8338,13 @@ struct UVec3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn mul(self, rhs: u32) -> bevy::math::UVec4; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -7401,57 +8373,225 @@ struct UVec4 { functions[r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Rem", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "rem", + metamethod = "Mod", )] - fn eq(&self, #[proxy] other: &glam::U64Vec2) -> bool; + fn rem(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Div", + kind = "MetaFunction", output(proxy), + composite = "div", + metamethod = "Div", )] - fn clone(&self) -> bevy::math::U64Vec2; + fn div(self, rhs: u64) -> bevy::math::U64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec2; + fn rem(self, #[proxy] rhs: &glam::U64Vec2) -> bevy::math::U64Vec2; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" -/// Creates a new vector. - #[lua(kind = "Function", output(proxy))] - fn new(x: u64, y: u64) -> bevy::math::U64Vec2; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: u64) -> bevy::math::U64Vec2; -"#, - r#" + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u64) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u64) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u64) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u64) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::U64Vec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: u64, y: u64) -> bevy::math::U64Vec2; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: u64) -> bevy::math::U64Vec2; + +"#, + r#" /// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use /// for each element of `self`. /// A true element in the mask uses the corresponding element from `if_true`, and false @@ -7772,289 +8912,75 @@ struct UVec4 { "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct U64Vec2 { + x: u64, + y: u64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::U64Vec3", + functions[r#" +/// Creates a new vector. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + #[lua(kind = "Function", output(proxy))] + fn new(x: u64, y: u64, z: u64) -> bevy::math::U64Vec3; "#, r#" +/// Creates a vector with all elements set to `v`. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u64) -> bevy::math::U64Vec2; + #[lua(kind = "Function", output(proxy))] + fn splat(v: u64) -> bevy::math::U64Vec3; "#, r#" +/// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use +/// for each element of `self`. +/// A true element in the mask uses the corresponding element from `if_true`, and false +/// uses the element from `if_false`. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + #[lua(kind = "Function", output(proxy))] + fn select( + #[proxy] + mask: bevy::math::BVec3, + #[proxy] + if_true: bevy::math::U64Vec3, + #[proxy] + if_false: bevy::math::U64Vec3, + ) -> bevy::math::U64Vec3; "#, r#" +/// Creates a new vector from an array. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u64) -> bevy::math::U64Vec2; + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [u64; 3]) -> bevy::math::U64Vec3; "#, r#" +/// `[x, y, z]` - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec2; + #[lua(kind = "Method")] + fn to_array(&self) -> [u64; 3]; "#, r#" +/// Creates a 4D vector from `self` and the given `w` value. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + #[lua(kind = "Method", output(proxy))] + fn extend(self, w: u64) -> bevy::math::U64Vec4; "#, r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u64) -> bevy::math::U64Vec2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct U64Vec2 { - x: u64, - y: u64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::U64Vec3", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u64) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u64) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec3; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: u64, y: u64, z: u64) -> bevy::math::U64Vec3; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: u64) -> bevy::math::U64Vec3; - -"#, - r#" -/// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use -/// for each element of `self`. -/// A true element in the mask uses the corresponding element from `if_true`, and false -/// uses the element from `if_false`. - - #[lua(kind = "Function", output(proxy))] - fn select( - #[proxy] - mask: bevy::math::BVec3, - #[proxy] - if_true: bevy::math::U64Vec3, - #[proxy] - if_false: bevy::math::U64Vec3, - ) -> bevy::math::U64Vec3; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [u64; 3]) -> bevy::math::U64Vec3; - -"#, - r#" -/// `[x, y, z]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [u64; 3]; - -"#, - r#" -/// Creates a 4D vector from `self` and the given `w` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, w: u64) -> bevy::math::U64Vec4; - -"#, - r#" -/// Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. -/// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. +/// Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. +/// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. #[lua(kind = "Method", output(proxy))] fn truncate(self) -> bevy::math::U64Vec2; @@ -8366,30 +9292,25 @@ struct U64Vec2 { r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] other: &glam::U64Vec3) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + fn mul(self, rhs: u64) -> bevy::math::U64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, rhs: u64) -> bevy::math::U64Vec3; + fn rem(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -8401,35 +9322,43 @@ struct U64Vec2 { composite = "sub", metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn sub(self, #[proxy] rhs: &glam::U64Vec3) -> bevy::math::U64Vec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct U64Vec3 { - x: u64, - y: u64, - z: u64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::U64Vec4", - functions[r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "div", + metamethod = "Div", )] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn div(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -8441,7 +9370,106 @@ struct U64Vec3 { composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec4; + fn sub(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u64) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::U64Vec3) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::U64Vec3; "#, r#" @@ -8453,7 +9481,70 @@ struct U64Vec3 { composite = "sub", metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct U64Vec3 { + x: u64, + y: u64, + z: u64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::U64Vec4", + functions[r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::U64Vec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" @@ -8471,11 +9562,25 @@ struct U64Vec3 { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Rem", + kind = "MetaFunction", output(proxy), + composite = "rem", + metamethod = "Mod", )] - fn clone(&self) -> bevy::math::U64Vec4; + fn rem(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" @@ -8830,36 +9935,55 @@ struct U64Vec3 { r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Add", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "add", + metamethod = "Add", )] - fn eq(&self, #[proxy] other: &glam::U64Vec4) -> bool; + fn add(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, rhs: u64) -> bevy::math::U64Vec4; + fn mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, rhs: u64) -> bevy::math::U64Vec4; + fn mul(self, #[proxy] rhs: &glam::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -8871,7 +9995,7 @@ struct U64Vec3 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn add(self, #[proxy] rhs: &glam::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -8885,41 +10009,69 @@ struct U64Vec3 { )] fn rem(self, rhs: u64) -> bevy::math::U64Vec4; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "sub", + metamethod = "Sub", )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn sub(self, #[proxy] rhs: &glam::U64Vec4) -> bevy::math::U64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "add", + metamethod = "Add", )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec4; + fn add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u64) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::U64Vec4; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -8936,13 +10088,25 @@ struct U64Vec4 { functions[r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, rhs: f32) -> bevy::math::Vec2; + fn rem(self, #[proxy] rhs: &glam::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec2; "#, r#" @@ -8954,7 +10118,19 @@ struct U64Vec4 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn add(self, #[proxy] rhs: &glam::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::Vec2) -> bevy::math::Vec2; "#, r#" @@ -8968,6 +10144,18 @@ struct U64Vec4 { )] fn mul(self, rhs: f32) -> bevy::math::Vec2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + "#, r#" @@ -8978,17 +10166,42 @@ struct U64Vec4 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn div(self, rhs: f32) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::Vec2; + fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f32) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::Vec2) -> bool; "#, r#" @@ -9235,6 +10448,14 @@ struct U64Vec4 { #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec2; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -9245,7 +10466,7 @@ struct U64Vec4 { "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec2; @@ -9305,10 +10526,10 @@ struct U64Vec4 { "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::Vec2; @@ -9504,23 +10725,27 @@ struct U64Vec4 { "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec2; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f32) -> bevy::math::Vec2; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f32) -> bevy::math::Vec2; @@ -9543,6 +10768,29 @@ struct U64Vec4 { b: bevy::math::Vec2, ) -> bevy::math::Vec2; +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::Vec2, eta: f32) -> bevy::math::Vec2; + "#, r#" /// Creates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in @@ -9563,12 +10811,18 @@ struct U64Vec4 { "#, r#" -/// Returns the angle (in radians) between `self` and `rhs` in the range `[-Ï€, +Ï€]`. -/// The inputs do not need to be unit vectors however they must be non-zero. #[lua(kind = "Method")] fn angle_between(self, #[proxy] rhs: bevy::math::Vec2) -> f32; +"#, + r#" +/// Returns the angle of rotation (in radians) from `self` to `rhs` in the range `[-Ï€, +Ï€]`. +/// The inputs do not need to be unit vectors however they must be non-zero. + + #[lua(kind = "Method")] + fn angle_to(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + "#, r#" /// Returns a vector that is equal to `self` rotated by 90 degrees. @@ -9593,6 +10847,21 @@ struct U64Vec4 { #[lua(kind = "Method", output(proxy))] fn rotate(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; +"#, + r#" +/// Rotates towards `rhs` up to `max_angle` (in radians). +/// When `max_angle` is `0.0`, the result will be equal to `self`. When `max_angle` is equal to +/// `self.angle_between(rhs)`, the result will be equal to `rhs`. If `max_angle` is negative, +/// rotates towards the exact opposite of `rhs`. Will not go past the target. + + #[lua(kind = "Method", output(proxy))] + fn rotate_towards( + &self, + #[proxy] + rhs: bevy::math::Vec2, + max_angle: f32, + ) -> bevy::math::Vec2; + "#, r#" /// Casts all elements of `self` to `f64`. @@ -9632,25 +10901,23 @@ struct U64Vec4 { r#" #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "rem", - metamethod = "Mod", )] - fn rem(self, rhs: f32) -> bevy::math::Vec2; + fn clone(&self) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "sub", + metamethod = "Sub", )] - fn rem(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn sub(self, rhs: f32) -> bevy::math::Vec2; "#, r#" @@ -9668,12 +10935,13 @@ struct U64Vec4 { r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] other: &glam::Vec2) -> bool; + fn mul(self, #[proxy] rhs: &glam::Vec2) -> bevy::math::Vec2; "#, r#" @@ -9685,49 +10953,49 @@ struct U64Vec4 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: f32) -> bevy::math::Vec2; + fn div(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "sub", + metamethod = "Sub", )] - fn neg(self) -> bevy::math::Vec2; + fn sub(self, #[proxy] rhs: &glam::Vec2) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn rem(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "neg", + metamethod = "Unm", )] - fn sub(self, rhs: f32) -> bevy::math::Vec2; + fn neg(self) -> bevy::math::Vec2; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -9754,25 +11022,13 @@ struct Vec2 { functions[r#" #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f32) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "rem", + metamethod = "Mod", )] - fn sub(self, rhs: f32) -> bevy::math::Vec3A; + fn rem(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -9790,37 +11046,37 @@ struct Vec2 { r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::Vec3A; + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "rem", + metamethod = "Mod", )] - fn div(self, rhs: f32) -> bevy::math::Vec3A; + fn rem(self, #[proxy] rhs: &glam::Vec3A) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn mul(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" @@ -9832,19 +11088,54 @@ struct Vec2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Vec3A; + fn mul(self, #[proxy] rhs: &glam::Vec3A) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn rem(self, rhs: f32) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Vec3A) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Vec3A; "#, r#" @@ -9891,6 +11182,14 @@ struct Vec2 { #[lua(kind = "Method")] fn to_array(&self) -> [f32; 3]; +"#, + r#" +/// Creates a [`Vec3A`] from the `x`, `y` and `z` elements of `self` discarding `w`. +/// On architectures where SIMD is supported such as SSE2 on `x86_64` this conversion is a noop. + + #[lua(kind = "Function", output(proxy))] + fn from_vec4(#[proxy] v: bevy::math::Vec4) -> bevy::math::Vec3A; + "#, r#" /// Creates a 4D vector from `self` and the given `w` value. @@ -10113,6 +11412,14 @@ struct Vec2 { #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec3A; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -10123,7 +11430,7 @@ struct Vec2 { "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec3A; @@ -10183,10 +11490,10 @@ struct Vec2 { "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::Vec3A; @@ -10390,23 +11697,27 @@ struct Vec2 { "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3A; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f32) -> bevy::math::Vec3A; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f32) -> bevy::math::Vec3A; @@ -10431,7 +11742,30 @@ struct Vec2 { "#, r#" -/// Returns the angle (in radians) between two vectors. +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::Vec3A, eta: f32) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns the angle (in radians) between two vectors in the range `[0, +Ï€]`. /// The inputs do not need to be unit vectors however they must be non-zero. #[lua(kind = "Method")] @@ -10496,12 +11830,13 @@ struct Vec2 { r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Div", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "div", + metamethod = "Div", )] - fn eq(&self, #[proxy] rhs: &glam::Vec3A) -> bool; + fn div(self, #[proxy] rhs: &glam::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -10517,25 +11852,37 @@ struct Vec2 { r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "div", + metamethod = "Div", )] - fn rem(self, rhs: f32) -> bevy::math::Vec3A; + fn div(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "sub", + metamethod = "Sub", )] - fn rem(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn sub(self, rhs: f32) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -10549,11 +11896,35 @@ struct Vec2 { )] fn div(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f32) -> bevy::math::Vec3A; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -10575,99 +11946,276 @@ struct Vec3A(); derive(clone), remote = "bevy::math::Vec4", functions[r#" -/// Creates a new vector. - #[lua(kind = "Function", output(proxy))] - fn new(x: f32, y: f32, z: f32, w: f32) -> bevy::math::Vec4; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" -/// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] - fn splat(v: f32) -> bevy::math::Vec4; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::Vec4) -> bevy::math::Vec4; "#, r#" -/// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use -/// for each element of `self`. -/// A true element in the mask uses the corresponding element from `if_true`, and false -/// uses the element from `if_false`. - #[lua(kind = "Function", output(proxy))] - fn select( - #[proxy] - mask: bevy::math::BVec4A, - #[proxy] - if_true: bevy::math::Vec4, - #[proxy] - if_false: bevy::math::Vec4, - ) -> bevy::math::Vec4; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec4; "#, r#" -/// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f32; 4]) -> bevy::math::Vec4; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Vec4; "#, r#" -/// `[x, y, z, w]` - #[lua(kind = "Method")] - fn to_array(&self) -> [f32; 4]; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" -/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. -/// Truncation to [`Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. -/// To truncate to [`Vec3A`] use [`Vec3A::from()`]. - #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::Vec3; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f32) -> bevy::math::Vec4; "#, r#" -/// Creates a 4D vector from `self` with the given value of `x`. - #[lua(kind = "Method", output(proxy))] - fn with_x(self, x: f32) -> bevy::math::Vec4; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" -/// Creates a 4D vector from `self` with the given value of `y`. - #[lua(kind = "Method", output(proxy))] - fn with_y(self, y: f32) -> bevy::math::Vec4; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Vec4) -> bool; "#, r#" -/// Creates a 4D vector from `self` with the given value of `z`. - #[lua(kind = "Method", output(proxy))] - fn with_z(self, z: f32) -> bevy::math::Vec4; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec4; "#, r#" -/// Creates a 4D vector from `self` with the given value of `w`. - #[lua(kind = "Method", output(proxy))] - fn with_w(self, w: f32) -> bevy::math::Vec4; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::Vec4) -> bevy::math::Vec4; "#, r#" -/// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::Vec4) -> f32; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Vec4; "#, r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Vec4; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: f32, y: f32, z: f32, w: f32) -> bevy::math::Vec4; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: f32) -> bevy::math::Vec4; + +"#, + r#" +/// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use +/// for each element of `self`. +/// A true element in the mask uses the corresponding element from `if_true`, and false +/// uses the element from `if_false`. + + #[lua(kind = "Function", output(proxy))] + fn select( + #[proxy] + mask: bevy::math::BVec4A, + #[proxy] + if_true: bevy::math::Vec4, + #[proxy] + if_false: bevy::math::Vec4, + ) -> bevy::math::Vec4; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f32; 4]) -> bevy::math::Vec4; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [f32; 4]; + +"#, + r#" +/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. +/// Truncation to [`Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. +/// To truncate to [`Vec3A`] use [`Vec3A::from()`]. + + #[lua(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::Vec3; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `x`. + + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: f32) -> bevy::math::Vec4; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `y`. + + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: f32) -> bevy::math::Vec4; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `z`. + + #[lua(kind = "Method", output(proxy))] + fn with_z(self, z: f32) -> bevy::math::Vec4; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `w`. + + #[lua(kind = "Method", output(proxy))] + fn with_w(self, w: f32) -> bevy::math::Vec4; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::Vec4) -> f32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -10834,6 +12382,14 @@ struct Vec3A(); #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec4A; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -10844,7 +12400,7 @@ struct Vec3A(); "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec4A; @@ -10904,10 +12460,10 @@ struct Vec3A(); "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::Vec4; @@ -11103,23 +12659,27 @@ struct Vec3A(); "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec4; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f32) -> bevy::math::Vec4; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f32) -> bevy::math::Vec4; @@ -11142,6 +12702,29 @@ struct Vec3A(); b: bevy::math::Vec4, ) -> bevy::math::Vec4; +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::Vec4, eta: f32) -> bevy::math::Vec4; + "#, r#" /// Casts all elements of `self` to `f64`. @@ -11181,36 +12764,13 @@ struct Vec3A(); r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Vec4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::Vec4; + fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -11228,176 +12788,66 @@ struct Vec3A(); r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "rem", + metamethod = "Mod", )] - fn sub(self, rhs: f32) -> bevy::math::Vec4; + fn rem(self, #[proxy] rhs: &glam::Vec4) -> bevy::math::Vec4; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +struct Vec4(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::BVec2", + functions[r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", + composite = "eq", + metamethod = "Eq", )] - fn div(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn eq(&self, #[proxy] other: &glam::BVec2) -> bool; "#, r#" +/// Creates a new vector mask. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn new(x: bool, y: bool) -> bevy::math::BVec2; "#, r#" +/// Creates a vector mask with all elements set to `v`. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn splat(v: bool) -> bevy::math::BVec2; "#, r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f32) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -struct Vec4(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::BVec2", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::BVec2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec2; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -/// Creates a new vector mask. - - #[lua(kind = "Function", output(proxy))] - fn new(x: bool, y: bool) -> bevy::math::BVec2; - -"#, - r#" -/// Creates a vector mask with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: bool) -> bevy::math::BVec2; - -"#, - r#" -/// Creates a new vector mask from a bool array. +/// Creates a new vector mask from a bool array. #[lua(kind = "Function", output(proxy))] fn from_array(a: [bool; 2]) -> bevy::math::BVec2; @@ -11441,11 +12891,27 @@ struct Vec4(); #[lua(kind = "MutatingMethod")] fn set(&mut self, index: usize, value: bool) -> (); +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec2; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -11458,27 +12924,6 @@ struct BVec2 { derive(clone), remote = "bevy::math::BVec3", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::BVec3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec3; - -"#, - r#" /// Creates a new vector mask. #[lua(kind = "Function", output(proxy))] @@ -11537,6 +12982,27 @@ struct BVec2 { #[lua(kind = "MutatingMethod")] fn set(&mut self, index: usize, value: bool) -> (); +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::BVec3) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec3; + "#, r#" @@ -11547,7 +13013,7 @@ struct BVec2 { r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -11563,22 +13029,22 @@ struct BVec3 { functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::BVec4; + fn eq(&self, #[proxy] other: &glam::BVec4) -> bool; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] other: &glam::BVec4) -> bool; + fn clone(&self) -> bevy::math::BVec4; "#, r#" @@ -11650,7 +13116,7 @@ struct BVec3 { r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -11667,49 +13133,60 @@ struct BVec4 { functions[r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "add", + metamethod = "Add", )] - fn mul(self, rhs: f64) -> bevy::math::DVec2; + fn add(self, rhs: f64) -> bevy::math::DVec2; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "add", + metamethod = "Add", )] - fn sub(self, rhs: f64) -> bevy::math::DVec2; + fn add(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "neg", + metamethod = "Unm", )] - fn rem(self, rhs: f64) -> bevy::math::DVec2; + fn neg(self) -> bevy::math::DVec2; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, rhs: f64) -> bevy::math::DVec2; + fn mul(self, #[proxy] rhs: &glam::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::DVec2) -> bool; "#, r#" @@ -11739,46 +13216,37 @@ struct BVec4 { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Rem", + kind = "MetaFunction", output(proxy), + composite = "rem", + metamethod = "Mod", )] - fn clone(&self) -> bevy::math::DVec2; + fn rem(self, rhs: f64) -> bevy::math::DVec2; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "rem", + metamethod = "Mod", )] - fn neg(self) -> bevy::math::DVec2; + fn rem(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] other: &glam::DVec2) -> bool; + fn mul(self, rhs: f64) -> bevy::math::DVec2; "#, r#" @@ -12025,6 +13493,14 @@ struct BVec4 { #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec2; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -12035,7 +13511,7 @@ struct BVec4 { "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec2; @@ -12095,10 +13571,10 @@ struct BVec4 { "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::DVec2; @@ -12302,23 +13778,27 @@ struct BVec4 { "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec2; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f64) -> bevy::math::DVec2; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f64) -> bevy::math::DVec2; @@ -12341,6 +13821,29 @@ struct BVec4 { b: bevy::math::DVec2, ) -> bevy::math::DVec2; +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::DVec2, eta: f64) -> bevy::math::DVec2; + "#, r#" /// Creates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in @@ -12361,12 +13864,18 @@ struct BVec4 { "#, r#" -/// Returns the angle (in radians) between `self` and `rhs` in the range `[-Ï€, +Ï€]`. -/// The inputs do not need to be unit vectors however they must be non-zero. #[lua(kind = "Method")] fn angle_between(self, #[proxy] rhs: bevy::math::DVec2) -> f64; +"#, + r#" +/// Returns the angle of rotation (in radians) from `self` to `rhs` in the range `[-Ï€, +Ï€]`. +/// The inputs do not need to be unit vectors however they must be non-zero. + + #[lua(kind = "Method")] + fn angle_to(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + "#, r#" /// Returns a vector that is equal to `self` rotated by 90 degrees. @@ -12391,6 +13900,21 @@ struct BVec4 { #[lua(kind = "Method", output(proxy))] fn rotate(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; +"#, + r#" +/// Rotates towards `rhs` up to `max_angle` (in radians). +/// When `max_angle` is `0.0`, the result will be equal to `self`. When `max_angle` is equal to +/// `self.angle_between(rhs)`, the result will be equal to `rhs`. If `max_angle` is negative, +/// rotates towards the exact opposite of `rhs`. Will not go past the target. + + #[lua(kind = "Method", output(proxy))] + fn rotate_towards( + &self, + #[proxy] + rhs: bevy::math::DVec2, + max_angle: f64, + ) -> bevy::math::DVec2; + "#, r#" /// Casts all elements of `self` to `f32`. @@ -12438,6 +13962,40 @@ struct BVec4 { )] fn sub(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DVec2; + "#, r#" @@ -12450,6 +14008,18 @@ struct BVec4 { )] fn div(self, rhs: f64) -> bevy::math::DVec2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f64) -> bevy::math::DVec2; + "#, r#" @@ -12460,13 +14030,25 @@ struct BVec4 { composite = "rem", metamethod = "Mod", )] - fn rem(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn rem(self, #[proxy] rhs: &glam::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::DVec2) -> bevy::math::DVec2; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -12499,53 +14081,53 @@ struct DVec2 { composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: f64) -> bevy::math::DVec3; + fn rem(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Add", + kind = "MetaFunction", output(proxy), + composite = "add", + metamethod = "Add", )] - fn clone(&self) -> bevy::math::DVec3; + fn add(self, rhs: f64) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "div", + metamethod = "Div", )] - fn sub(self, rhs: f64) -> bevy::math::DVec3; + fn div(self, rhs: f64) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "sub", - metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn clone(&self) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "div", + metamethod = "Div", )] - fn rem(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn div(self, #[proxy] rhs: &glam::DVec3) -> bevy::math::DVec3; "#, r#" @@ -12557,7 +14139,7 @@ struct DVec2 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn add(self, #[proxy] rhs: &glam::DVec3) -> bevy::math::DVec3; "#, r#" @@ -12569,42 +14151,55 @@ struct DVec2 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: f64) -> bevy::math::DVec3; + fn div(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Sub", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn eq(&self, #[proxy] other: &glam::DVec3) -> bool; + fn sub(self, rhs: f64) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn mul(self, rhs: f64) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn rem(self, rhs: f64) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::DVec3) -> bevy::math::DVec3; "#, r#" @@ -12616,31 +14211,31 @@ struct DVec2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f64) -> bevy::math::DVec3; + fn mul(self, #[proxy] rhs: &glam::DVec3) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, rhs: f64) -> bevy::math::DVec3; + fn rem(self, #[proxy] rhs: &glam::DVec3) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "sub", + metamethod = "Sub", )] - fn neg(self) -> bevy::math::DVec3; + fn sub(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" @@ -12909,6 +14504,14 @@ struct DVec2 { #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec3; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -12919,7 +14522,7 @@ struct DVec2 { "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec3; @@ -12979,10 +14582,10 @@ struct DVec2 { "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::DVec3; @@ -13186,23 +14789,27 @@ struct DVec2 { "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec3; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f64) -> bevy::math::DVec3; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f64) -> bevy::math::DVec3; @@ -13227,7 +14834,30 @@ struct DVec2 { "#, r#" -/// Returns the angle (in radians) between two vectors. +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::DVec3, eta: f64) -> bevy::math::DVec3; + +"#, + r#" +/// Returns the angle (in radians) between two vectors in the range `[0, +Ï€]`. /// The inputs do not need to be unit vectors however they must be non-zero. #[lua(kind = "Method")] @@ -13297,34 +14927,30 @@ struct DVec2 { "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -struct DVec3 { - x: f64, - y: f64, - z: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DVec4", - functions[r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -13332,113 +14958,7 @@ struct DVec3 { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &glam::DVec4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f64) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f64) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f64) -> bevy::math::DVec4; + fn eq(&self, #[proxy] other: &glam::DVec3) -> bool; "#, r#" @@ -13450,22 +14970,38 @@ struct DVec3 { composite = "neg", metamethod = "Unm", )] - fn neg(self) -> bevy::math::DVec4; + fn neg(self) -> bevy::math::DVec3; "#, r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DVec4; - +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} "#, r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +struct DVec3 { + x: f64, + y: f64, + z: f64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::DVec4", + functions[r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] @@ -13724,6 +15260,14 @@ struct DVec3 { #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec4; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -13734,7 +15278,7 @@ struct DVec3 { "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec4; @@ -13794,10 +15338,10 @@ struct DVec3 { "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::DVec4; @@ -14001,23 +15545,27 @@ struct DVec3 { "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec4; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f64) -> bevy::math::DVec4; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f64) -> bevy::math::DVec4; @@ -14040,6 +15588,29 @@ struct DVec3 { b: bevy::math::DVec4, ) -> bevy::math::DVec4; +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::DVec4, eta: f64) -> bevy::math::DVec4; + "#, r#" /// Casts all elements of `self` to `f32`. @@ -14075,6 +15646,18 @@ struct DVec3 { #[lua(kind = "Method", output(proxy))] fn as_u64vec4(&self) -> bevy::math::U64Vec4; +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::DVec4) -> bevy::math::DVec4; + "#, r#" @@ -14089,35 +15672,6 @@ struct DVec3 { "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -struct DVec4 { - x: f64, - y: f64, - z: f64, - w: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Mat2", - functions[r#" #[lua( as_trait = "std::ops::Neg", @@ -14126,29 +15680,31 @@ struct DVec4 { composite = "neg", metamethod = "Unm", )] - fn neg(self) -> bevy::math::Mat2; + fn neg(self) -> bevy::math::DVec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + fn rem(self, #[proxy] rhs: &glam::DVec4) -> bevy::math::DVec4; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Add", + kind = "MetaFunction", output(proxy), + composite = "add", + metamethod = "Add", )] - fn clone(&self) -> bevy::math::Mat2; + fn add(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" @@ -14160,7 +15716,19 @@ struct DVec4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn mul(self, #[proxy] rhs: &glam::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f64) -> bevy::math::DVec4; "#, r#" @@ -14171,31 +15739,31 @@ struct DVec4 { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] rhs: &glam::Mat2) -> bool; + fn eq(&self, #[proxy] other: &glam::DVec4) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "div", + metamethod = "Div", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + fn div(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" @@ -14207,7 +15775,31 @@ struct DVec4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Mat2; + fn mul(self, rhs: f64) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f64) -> bevy::math::DVec4; "#, r#" @@ -14219,7 +15811,106 @@ struct DVec4 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: f32) -> bevy::math::Mat2; + fn div(self, #[proxy] rhs: &glam::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DVec4; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +struct DVec4 { + x: f64, + y: f64, + z: f64, + w: f64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Mat2", + functions[r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; "#, r#" @@ -14282,6 +15973,21 @@ struct DVec4 { #[lua(kind = "Function", output(proxy))] fn from_mat3(#[proxy] m: bevy::math::Mat3) -> bevy::math::Mat2; +"#, + r#" +/// Creates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 2. + + #[lua(kind = "Function", output(proxy))] + fn from_mat3_minor( + #[proxy] + m: bevy::math::Mat3, + i: usize, + j: usize, + ) -> bevy::math::Mat2; + "#, r#" /// Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. @@ -14289,6 +15995,21 @@ struct DVec4 { #[lua(kind = "Function", output(proxy))] fn from_mat3a(#[proxy] m: bevy::math::Mat3A) -> bevy::math::Mat2; +"#, + r#" +/// Creates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 2. + + #[lua(kind = "Function", output(proxy))] + fn from_mat3a_minor( + #[proxy] + m: bevy::math::Mat3A, + i: usize, + j: usize, + ) -> bevy::math::Mat2; + "#, r#" /// Returns the matrix column for the given `index`. @@ -14414,11 +16135,92 @@ struct DVec4 { #[lua(kind = "Method", output(proxy))] fn as_dmat2(&self) -> bevy::math::DMat2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Mat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Mat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Mat2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Mat2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Mat2; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -14453,6 +16255,18 @@ struct Mat2(); remote = "bevy::math::Mat3", functions[r#" + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + +"#, + r#" + #[lua( as_trait = "std::ops::Mul", kind = "MetaFunction", @@ -14460,21 +16274,68 @@ struct Mat2(); composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3; + fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; "#, r#" -/// Creates a 3x3 matrix from three column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::Vec3, - #[proxy] - y_axis: bevy::math::Vec3, - #[proxy] - z_axis: bevy::math::Vec3, - ) -> bevy::math::Mat3; + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Mat3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Mat3) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Mat3; + +"#, + r#" +/// Creates a 3x3 matrix from three column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::Vec3, + #[proxy] + y_axis: bevy::math::Vec3, + #[proxy] + z_axis: bevy::math::Vec3, + ) -> bevy::math::Mat3; "#, r#" @@ -14506,6 +16367,21 @@ struct Mat2(); #[lua(kind = "Function", output(proxy))] fn from_mat4(#[proxy] m: bevy::math::Mat4) -> bevy::math::Mat3; +"#, + r#" +/// Creates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 3. + + #[lua(kind = "Function", output(proxy))] + fn from_mat4_minor( + #[proxy] + m: bevy::math::Mat4, + i: usize, + j: usize, + ) -> bevy::math::Mat3; + "#, r#" /// Creates a 3D rotation matrix from the given quaternion. @@ -14539,6 +16415,17 @@ struct Mat2(); c: f32, ) -> bevy::math::Mat3; +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the input matrix contains scales, shears, or other non-rotation transformations then +/// the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method")] + fn to_euler(&self, #[proxy] order: bevy::math::EulerRot) -> (f32, f32, f32); + "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. @@ -14779,31 +16666,7 @@ struct Mat2(); composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Mat3; + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3; "#, r#" @@ -14827,30 +16690,6 @@ struct Mat2(); )] fn clone(&self) -> bevy::math::Mat3; -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Mat3; - "#, r#" @@ -14867,30 +16706,19 @@ struct Mat2(); r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] rhs: &glam::Mat3) -> bool; + fn mul(self, rhs: f32) -> bevy::math::Mat3; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -14932,6 +16760,29 @@ struct Mat3 { remote = "bevy::math::Mat3A", functions[r#" + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Mat3A) -> bool; + +"#, + r#" + #[lua( as_trait = "std::ops::Mul", kind = "MetaFunction", @@ -14941,6 +16792,30 @@ struct Mat3 { )] fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Mat3A; + "#, r#" @@ -14951,7 +16826,7 @@ struct Mat3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3A; + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -14997,6 +16872,21 @@ struct Mat3 { #[lua(kind = "Function", output(proxy))] fn from_mat4(#[proxy] m: bevy::math::Mat4) -> bevy::math::Mat3A; +"#, + r#" +/// Creates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 3. + + #[lua(kind = "Function", output(proxy))] + fn from_mat4_minor( + #[proxy] + m: bevy::math::Mat4, + i: usize, + j: usize, + ) -> bevy::math::Mat3A; + "#, r#" /// Creates a 3D rotation matrix from the given quaternion. @@ -15030,6 +16920,17 @@ struct Mat3 { c: f32, ) -> bevy::math::Mat3A; +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the input matrix contains scales, shears, or other non-rotation transformations then +/// the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method")] + fn to_euler(&self, #[proxy] order: bevy::math::EulerRot) -> (f32, f32, f32); + "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. @@ -15264,24 +17165,25 @@ struct Mat3 { r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Div", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "div", + metamethod = "Div", )] - fn eq(&self, #[proxy] rhs: &glam::Mat3A) -> bool; + fn div(self, rhs: f32) -> bevy::math::Mat3A; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3A; "#, r#" @@ -15293,18 +17195,6 @@ struct Mat3 { )] fn clone(&self) -> bevy::math::Mat3A; -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Mat3A; - "#, r#" @@ -15315,7 +17205,7 @@ struct Mat3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn mul(self, rhs: f32) -> bevy::math::Mat3A; "#, r#" @@ -15327,50 +17217,14 @@ struct Mat3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Mat3A; + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Mat3A; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} "#, r#" #[lua(kind = "MetaMethod", raw, metamethod="Index")] @@ -15411,42 +17265,6 @@ struct Mat3A { remote = "bevy::math::Mat4", functions[r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -15459,59 +17277,13 @@ struct Mat3A { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "div", + metamethod = "Div", )] - fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Mat4; + fn div(self, rhs: f32) -> bevy::math::Mat4; "#, r#" @@ -15667,6 +17439,18 @@ struct Mat3A { c: f32, ) -> bevy::math::Mat4; +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations +/// then the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any column of the upper 3x3 rotation matrix is not normalized when +/// `glam_assert` is enabled. + + #[lua(kind = "Method")] + fn to_euler(&self, #[proxy] order: bevy::math::EulerRot) -> (f32, f32, f32); + "#, r#" /// Creates an affine transformation matrix containing a 3D rotation around the x axis of @@ -15835,7 +17619,8 @@ struct Mat3A { "#, r#" -/// Creates a right-handed perspective projection matrix with [-1,1] depth range. +/// Creates a right-handed perspective projection matrix with `[-1,1]` depth range. +/// Useful to map the standard right-handed coordinate system into what OpenGL expects. /// This is the same as the OpenGL `gluPerspective` function. /// See @@ -15850,6 +17635,7 @@ struct Mat3A { "#, r#" /// Creates a left-handed perspective projection matrix with `[0,1]` depth range. +/// Useful to map the standard left-handed coordinate system into what WebGPU/Metal/Direct3D expect. /// # Panics /// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is /// enabled. @@ -15865,6 +17651,7 @@ struct Mat3A { "#, r#" /// Creates a right-handed perspective projection matrix with `[0,1]` depth range. +/// Useful to map the standard right-handed coordinate system into what WebGPU/Metal/Direct3D expect. /// # Panics /// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is /// enabled. @@ -15880,8 +17667,11 @@ struct Mat3A { "#, r#" /// Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. +/// Like `perspective_lh`, but with an infinite value for `z_far`. +/// The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. /// # Panics -/// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. #[lua(kind = "Function", output(proxy))] fn perspective_infinite_lh( @@ -15892,7 +17682,8 @@ struct Mat3A { "#, r#" -/// Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. +/// Creates an infinite reverse left-handed perspective projection matrix with `[0,1]` depth range. +/// Similar to `perspective_infinite_lh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. /// # Panics /// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. @@ -15905,8 +17696,12 @@ struct Mat3A { "#, r#" -/// Creates an infinite right-handed perspective projection matrix with -/// `[0,1]` depth range. +/// Creates an infinite right-handed perspective projection matrix with `[0,1]` depth range. +/// Like `perspective_rh`, but with an infinite value for `z_far`. +/// The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. +/// # Panics +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. #[lua(kind = "Function", output(proxy))] fn perspective_infinite_rh( @@ -15917,8 +17712,10 @@ struct Mat3A { "#, r#" -/// Creates an infinite reverse right-handed perspective projection matrix -/// with `[0,1]` depth range. +/// Creates an infinite reverse right-handed perspective projection matrix with `[0,1]` depth range. +/// Similar to `perspective_infinite_rh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. +/// # Panics +/// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn perspective_infinite_reverse_rh( @@ -15933,6 +17730,7 @@ struct Mat3A { /// range. This is the same as the OpenGL `glOrtho` function in OpenGL. /// See /// +/// Useful to map a right-handed coordinate system to the normalized device coordinates that OpenGL expects. #[lua(kind = "Function", output(proxy))] fn orthographic_rh_gl( @@ -15947,6 +17745,7 @@ struct Mat3A { "#, r#" /// Creates a left-handed orthographic projection matrix with `[0,1]` depth range. +/// Useful to map a left-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect. #[lua(kind = "Function", output(proxy))] fn orthographic_lh( @@ -15961,6 +17760,7 @@ struct Mat3A { "#, r#" /// Creates a right-handed orthographic projection matrix with `[0,1]` depth range. +/// Useful to map a right-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect. #[lua(kind = "Function", output(proxy))] fn orthographic_rh( @@ -16008,6 +17808,16 @@ struct Mat3A { #[lua(kind = "Method", output(proxy))] fn transform_vector3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; +"#, + r#" +/// Transforms the given [`Vec3A`] as a 3D point, applying perspective correction. +/// This is the equivalent of multiplying the [`Vec3A`] as a 4D vector where `w` is `1.0`. +/// The perspective divide is performed meaning the resulting 3D vector is divided by `w`. +/// This method assumes that `self` contains a projective transform. + + #[lua(kind = "Method", output(proxy))] + fn project_point3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + "#, r#" /// Transforms the given [`Vec3A`] as 3D point. @@ -16094,95 +17904,49 @@ struct Mat3A { "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaVec4::new_ref( - self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ - label:"col", - get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - })), - get_mut: std::sync::Arc::new(move |ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(*idx)) - } else { - Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) - } - }) - }) - ) - ) -} -"#] -)] -struct Mat4 { - #[lua(output(proxy))] - x_axis: bevy::math::Vec4, - #[lua(output(proxy))] - y_axis: bevy::math::Vec4, - #[lua(output(proxy))] - z_axis: bevy::math::Vec4, - #[lua(output(proxy))] - w_axis: bevy::math::Vec4, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DMat2", - functions[r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Add", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "add", + metamethod = "Add", )] - fn eq(&self, #[proxy] rhs: &glam::DMat2) -> bool; + fn add(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, rhs: f64) -> bevy::math::DMat2; + fn mul(self, rhs: f32) -> bevy::math::Mat4; "#, r#" #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "neg", - metamethod = "Unm", )] - fn neg(self) -> bevy::math::DMat2; + fn clone(&self) -> bevy::math::Mat4; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "neg", + metamethod = "Unm", )] - fn mul(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + fn neg(self) -> bevy::math::Mat4; "#, r#" @@ -16194,19 +17958,19 @@ struct Mat4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f64) -> bevy::math::DMat2; + fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Mat4; "#, r#" @@ -16218,37 +17982,60 @@ struct Mat4 { composite = "sub", metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn sub(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; "#, r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DMat2; - +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} "#, r#" -/// Creates a 2x2 matrix from two column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] +#[lua(kind = "MetaMethod", raw, metamethod="Index")] +fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(LuaVec4::new_ref( + self.reflect_ref(ctx.get_world()?).sub_ref(bevy_script_api::ReflectionPathElement::SubReflection{ + label:"col", + get: std::sync::Arc::new(|ref_| Err(bevy_script_api::error::ReflectionError::InsufficientProvenance{ + path: "".to_owned(), + msg: "Cannot get column of matrix with immutable reference".to_owned() + })), + get_mut: std::sync::Arc::new(move |ref_| { + if ref_.is::(){ + Ok(ref_.downcast_mut::() + .unwrap() + .col_mut(*idx)) + } else { + Err(bevy_script_api::error::ReflectionError::CannotDowncast{from: ref_.get_represented_type_info().unwrap().type_path().into(), to:"Mat3".into()}) + } + }) + }) + ) + ) +} +"#] +)] +struct Mat4 { + #[lua(output(proxy))] + x_axis: bevy::math::Vec4, + #[lua(output(proxy))] + y_axis: bevy::math::Vec4, + #[lua(output(proxy))] + z_axis: bevy::math::Vec4, + #[lua(output(proxy))] + w_axis: bevy::math::Vec4, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::DMat2", + functions[r#" +/// Creates a 2x2 matrix from two column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] x_axis: bevy::math::DVec2, #[proxy] y_axis: bevy::math::DVec2, @@ -16303,6 +18090,21 @@ struct Mat4 { #[lua(kind = "Function", output(proxy))] fn from_mat3(#[proxy] m: bevy::math::DMat3) -> bevy::math::DMat2; +"#, + r#" +/// Creates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 2. + + #[lua(kind = "Function", output(proxy))] + fn from_mat3_minor( + #[proxy] + m: bevy::math::DMat3, + i: usize, + j: usize, + ) -> bevy::math::DMat2; + "#, r#" /// Returns the matrix column for the given `index`. @@ -16428,11 +18230,116 @@ struct Mat4 { #[lua(kind = "Method", output(proxy))] fn as_mat2(&self) -> bevy::math::Mat2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DMat2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DMat2; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -16473,37 +18380,37 @@ struct DMat2 { functions[r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "add", + metamethod = "Add", )] - fn sub(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + fn add(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::DMat3; + fn mul(self, rhs: f64) -> bevy::math::DMat3; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "sub", + metamethod = "Sub", )] - fn add(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + fn sub(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; "#, r#" @@ -16515,6 +18422,30 @@ struct DMat2 { )] fn clone(&self) -> bevy::math::DMat3; +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DMat3; + "#, r#" @@ -16527,6 +18458,18 @@ struct DMat2 { )] fn div(self, rhs: f64) -> bevy::math::DMat3; +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DMat3; + "#, r#" @@ -16537,7 +18480,18 @@ struct DMat2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DMat3; + fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DMat3) -> bool; "#, r#" @@ -16583,6 +18537,21 @@ struct DMat2 { #[lua(kind = "Function", output(proxy))] fn from_mat4(#[proxy] m: bevy::math::DMat4) -> bevy::math::DMat3; +"#, + r#" +/// Creates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 3. + + #[lua(kind = "Function", output(proxy))] + fn from_mat4_minor( + #[proxy] + m: bevy::math::DMat4, + i: usize, + j: usize, + ) -> bevy::math::DMat3; + "#, r#" /// Creates a 3D rotation matrix from the given quaternion. @@ -16620,6 +18589,17 @@ struct DMat2 { c: f64, ) -> bevy::math::DMat3; +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the input matrix contains scales, shears, or other non-rotation transformations then +/// the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method")] + fn to_euler(&self, #[proxy] order: bevy::math::EulerRot) -> (f64, f64, f64); + "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. @@ -16843,58 +18823,11 @@ struct DMat2 { #[lua(kind = "Method", output(proxy))] fn as_mat3(&self) -> bevy::math::Mat3; -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DMat3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DMat3; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -16936,17 +18869,6 @@ struct DMat3 { remote = "bevy::math::DMat4", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DMat4) -> bool; - -"#, - r#" - #[lua( as_trait = "std::ops::Mul", kind = "MetaFunction", @@ -16954,29 +18876,19 @@ struct DMat3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f64) -> bevy::math::DMat4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DMat4; + fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "div", + metamethod = "Div", )] - fn sub(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + fn div(self, rhs: f64) -> bevy::math::DMat4; "#, r#" @@ -16988,31 +18900,30 @@ struct DMat3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DMat4; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "sub", + metamethod = "Sub", )] - fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn sub(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", + composite = "eq", + metamethod = "Eq", )] - fn add(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + fn eq(&self, #[proxy] rhs: &glam::DMat4) -> bool; "#, r#" @@ -17024,7 +18935,7 @@ struct DMat3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DMat4; + fn mul(self, rhs: f64) -> bevy::math::DMat4; "#, r#" @@ -17162,6 +19073,18 @@ struct DMat3 { c: f64, ) -> bevy::math::DMat4; +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations +/// then the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any column of the upper 3x3 rotation matrix is not normalized when +/// `glam_assert` is enabled. + + #[lua(kind = "Method")] + fn to_euler(&self, #[proxy] order: bevy::math::EulerRot) -> (f64, f64, f64); + "#, r#" /// Creates an affine transformation matrix containing a 3D rotation around the x axis of @@ -17330,7 +19253,8 @@ struct DMat3 { "#, r#" -/// Creates a right-handed perspective projection matrix with [-1,1] depth range. +/// Creates a right-handed perspective projection matrix with `[-1,1]` depth range. +/// Useful to map the standard right-handed coordinate system into what OpenGL expects. /// This is the same as the OpenGL `gluPerspective` function. /// See @@ -17345,6 +19269,7 @@ struct DMat3 { "#, r#" /// Creates a left-handed perspective projection matrix with `[0,1]` depth range. +/// Useful to map the standard left-handed coordinate system into what WebGPU/Metal/Direct3D expect. /// # Panics /// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is /// enabled. @@ -17360,6 +19285,7 @@ struct DMat3 { "#, r#" /// Creates a right-handed perspective projection matrix with `[0,1]` depth range. +/// Useful to map the standard right-handed coordinate system into what WebGPU/Metal/Direct3D expect. /// # Panics /// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is /// enabled. @@ -17375,8 +19301,11 @@ struct DMat3 { "#, r#" /// Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. +/// Like `perspective_lh`, but with an infinite value for `z_far`. +/// The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. /// # Panics -/// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. #[lua(kind = "Function", output(proxy))] fn perspective_infinite_lh( @@ -17387,7 +19316,8 @@ struct DMat3 { "#, r#" -/// Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. +/// Creates an infinite reverse left-handed perspective projection matrix with `[0,1]` depth range. +/// Similar to `perspective_infinite_lh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. /// # Panics /// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. @@ -17400,8 +19330,12 @@ struct DMat3 { "#, r#" -/// Creates an infinite right-handed perspective projection matrix with -/// `[0,1]` depth range. +/// Creates an infinite right-handed perspective projection matrix with `[0,1]` depth range. +/// Like `perspective_rh`, but with an infinite value for `z_far`. +/// The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. +/// # Panics +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. #[lua(kind = "Function", output(proxy))] fn perspective_infinite_rh( @@ -17412,8 +19346,10 @@ struct DMat3 { "#, r#" -/// Creates an infinite reverse right-handed perspective projection matrix -/// with `[0,1]` depth range. +/// Creates an infinite reverse right-handed perspective projection matrix with `[0,1]` depth range. +/// Similar to `perspective_infinite_rh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. +/// # Panics +/// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn perspective_infinite_reverse_rh( @@ -17428,6 +19364,7 @@ struct DMat3 { /// range. This is the same as the OpenGL `glOrtho` function in OpenGL. /// See /// +/// Useful to map a right-handed coordinate system to the normalized device coordinates that OpenGL expects. #[lua(kind = "Function", output(proxy))] fn orthographic_rh_gl( @@ -17442,6 +19379,7 @@ struct DMat3 { "#, r#" /// Creates a left-handed orthographic projection matrix with `[0,1]` depth range. +/// Useful to map a left-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect. #[lua(kind = "Function", output(proxy))] fn orthographic_lh( @@ -17456,6 +19394,7 @@ struct DMat3 { "#, r#" /// Creates a right-handed orthographic projection matrix with `[0,1]` depth range. +/// Useful to map a right-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect. #[lua(kind = "Function", output(proxy))] fn orthographic_rh( @@ -17587,19 +19526,41 @@ struct DMat3 { r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DMat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "add", + metamethod = "Add", )] - fn div(self, rhs: f64) -> bevy::math::DMat4; + fn add(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -17644,12 +19605,13 @@ struct DMat4 { functions[r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] rhs: &glam::Affine2) -> bool; + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Affine2; "#, r#" @@ -17661,7 +19623,40 @@ struct DMat4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Affine2; + fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Affine2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Affine2) -> bool; "#, r#" @@ -17835,13 +19830,31 @@ struct DMat4 { "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Affine2 { + #[lua(output(proxy))] + matrix2: bevy::math::Mat2, + #[lua(output(proxy))] + translation: bevy::math::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Affine3A", + functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::Affine2; + fn eq(&self, #[proxy] rhs: &glam::Affine3A) -> bool; "#, r#" @@ -17853,39 +19866,20 @@ struct DMat4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Affine3A; "#, r#" #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "mul", - metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + fn clone(&self) -> bevy::math::Affine3A; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct Affine2 { - #[lua(output(proxy))] - matrix2: bevy::math::Mat2, - #[lua(output(proxy))] - translation: bevy::math::Vec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Affine3A", - functions[r#" /// Creates an affine transform from three column vectors. #[lua(kind = "Function", output(proxy))] @@ -18171,17 +20165,6 @@ struct Affine2 { #[lua(kind = "Method", output(proxy))] fn inverse(&self) -> bevy::math::Affine3A; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Affine3A) -> bool; - "#, r#" @@ -18194,33 +20177,11 @@ struct Affine2 { )] fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Affine3A; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Affine3A; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -18412,22 +20373,22 @@ struct Affine3A { r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] rhs: &glam::DAffine2) -> bool; + fn clone(&self) -> bevy::math::DAffine2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::DAffine2; + fn eq(&self, #[proxy] rhs: &glam::DAffine2) -> bool; "#, r#" @@ -18445,7 +20406,7 @@ struct Affine3A { r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -18460,6 +20421,51 @@ struct DAffine2 { derive(clone), remote = "bevy::math::DAffine3", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DAffine3) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DAffine3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DAffine3; + +"#, + r#" /// Creates an affine transform from three column vectors. #[lua(kind = "Function", output(proxy))] @@ -18729,56 +20735,11 @@ struct DAffine2 { #[lua(kind = "Method", output(proxy))] fn inverse(&self) -> bevy::math::DAffine3; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DAffine3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DAffine3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DAffine3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -18793,15 +20754,19 @@ struct DAffine3 { derive(clone), remote = "bevy::math::DQuat", functions[r#" +/// Adds two quaternions. +/// The sum is not guaranteed to be normalized. +/// Note that addition is not the same as combining the rotations represented by the +/// two quaternions! That corresponds to multiplication. #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "add", + metamethod = "Add", )] - fn neg(self) -> bevy::math::DQuat; + fn add(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" @@ -18819,28 +20784,21 @@ struct DAffine3 { "#, r#" +/// Multiplies two quaternions. If they each represent a rotation, the result will +/// represent the combined rotation. +/// Note that due to floating point rounding the result may not be perfectly +/// normalized. +/// # Panics +/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DQuat) -> bool; - -"#, - r#" -/// Divides a quaternion by a scalar value. -/// The quotient is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, rhs: f64) -> bevy::math::DQuat; + fn mul(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" @@ -18934,13 +20892,22 @@ struct DAffine3 { "#, r#" /// Creates a quaternion from a 3x3 rotation matrix. +/// Note if the input matrix contain scales, shears, or other non-rotation transformations then +/// the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn from_mat3(#[proxy] mat: &glam::DMat3) -> bevy::math::DQuat; "#, r#" -/// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. +/// Creates a quaternion from the upper 3x3 rotation matrix inside a homogeneous 4x4 matrix. +/// Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations +/// then the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any column of the upper 3x3 rotation matrix is not normalized when +/// `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn from_mat4(#[proxy] mat: &glam::DMat4) -> bevy::math::DQuat; @@ -19014,7 +20981,7 @@ struct DAffine3 { /// Returns the rotation angles for the given euler rotation sequence. #[lua(kind = "Method")] - fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f64, f64, f64); + fn to_euler(self, #[proxy] order: bevy::math::EulerRot) -> (f64, f64, f64); "#, r#" @@ -19102,6 +21069,7 @@ struct DAffine3 { "#, r#" +/// Returns `true` if any elements are `NAN`. #[lua(kind = "Method")] fn is_nan(self) -> bool; @@ -19131,6 +21099,24 @@ struct DAffine3 { #[lua(kind = "Method")] fn angle_between(self, #[proxy] rhs: bevy::math::DQuat) -> f64; +"#, + r#" +/// Rotates towards `rhs` up to `max_angle` (in radians). +/// When `max_angle` is `0.0`, the result will be equal to `self`. When `max_angle` is equal to +/// `self.angle_between(rhs)`, the result will be equal to `rhs`. If `max_angle` is negative, +/// rotates towards the exact opposite of `rhs`. Will not go past the target. +/// Both quaternions must be normalized. +/// # Panics +/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn rotate_towards( + &self, + #[proxy] + rhs: bevy::math::DQuat, + max_angle: f64, + ) -> bevy::math::DQuat; + "#, r#" /// Returns true if the absolute difference of all elements between `self` and `rhs` @@ -19191,6 +21177,11 @@ struct DAffine3 { "#, r#" /// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. +/// Note if the input affine matrix contain scales, shears, or other non-rotation +/// transformations then the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input affine matrix column is not normalized when `glam_assert` is +/// enabled. #[lua(kind = "Function", output(proxy))] fn from_affine3(#[proxy] a: &glam::DAffine3) -> bevy::math::DQuat; @@ -19204,87 +21195,84 @@ struct DAffine3 { "#, r#" - #[lua(kind = "Method", output(proxy))] - fn as_f32(self) -> bevy::math::Quat; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DQuat; "#, r#" -/// Subtracts the `rhs` quaternion from `self`. -/// The difference is not guaranteed to be normalized. +/// Multiplies a quaternion and a 3D vector, returning the rotated vector. +/// # Panics +/// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// Adds two quaternions. -/// The sum is not guaranteed to be normalized. -/// Note that addition is not the same as combining the rotations represented by the -/// two quaternions! That corresponds to multiplication. #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "neg", + metamethod = "Unm", )] - fn add(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + fn neg(self) -> bevy::math::DQuat; "#, r#" -/// Multiplies a quaternion and a 3D vector, returning the rotated vector. -/// # Panics -/// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn eq(&self, #[proxy] rhs: &glam::DQuat) -> bool; "#, r#" -/// Multiplies two quaternions. If they each represent a rotation, the result will -/// represent the combined rotation. -/// Note that due to floating point rounding the result may not be perfectly -/// normalized. -/// # Panics -/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. +/// Subtracts the `rhs` quaternion from `self`. +/// The difference is not guaranteed to be normalized. #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "sub", + metamethod = "Sub", )] - fn mul(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + fn sub(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" +/// Divides a quaternion by a scalar value. +/// The quotient is not guaranteed to be normalized. #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Div", + kind = "MetaFunction", output(proxy), + composite = "div", + metamethod = "Div", )] - fn clone(&self) -> bevy::math::DQuat; + fn div(self, rhs: f64) -> bevy::math::DQuat; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -19338,17 +21326,6 @@ struct EulerRot {} derive(clone), remote = "bevy::math::BVec3A", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::BVec3A) -> bool; - -"#, - r#" /// Creates a new vector mask. #[lua(kind = "Function", output(proxy))] @@ -19419,9 +21396,20 @@ struct EulerRot {} "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::BVec3A) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -19433,11 +21421,12 @@ struct BVec3A(); functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::BVec4A; + fn eq(&self, #[proxy] rhs: &glam::BVec4A) -> bool; "#, r#" @@ -19503,18 +21492,17 @@ struct BVec3A(); r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] rhs: &glam::BVec4A) -> bool; + fn clone(&self) -> bevy::math::BVec4A; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -19525,6 +21513,16 @@ struct BVec4A(); remote = "smol_str::SmolStr", functions[r#" + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> smol_str::SmolStr; + +"#, + r#" + #[lua(kind = "Method")] fn to_string(&self) -> std::string::String; @@ -19557,21 +21555,11 @@ struct BVec4A(); )] fn eq(&self, #[proxy] other: &smol_str::SmolStr) -> bool; -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> smol_str::SmolStr; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -19581,98 +21569,118 @@ struct SmolStr(); derive(clone), remote = "uuid::Uuid", functions[r#" -/// Returns the version number of the UUID. -/// This represents the algorithm used to generate the value. -/// This method is the future-proof alternative to [`Uuid::get_version`]. + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +/// The 'nil UUID' (all zeros). +/// The nil UUID is a special form of UUID that is specified to have all +/// 128 bits set to zero. +/// # References +/// * [Nil UUID in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-5.9) /// # Examples /// Basic usage: /// ``` /// # use uuid::Uuid; -/// # fn main() -> Result<(), uuid::Error> { -/// let my_uuid = Uuid::parse_str("02f09a3f-1624-3b1d-8409-44eff7708208")?; -/// assert_eq!(3, my_uuid.get_version_num()); -/// # Ok(()) -/// # } +/// let uuid = Uuid::nil(); +/// assert_eq!( +/// "00000000-0000-0000-0000-000000000000", +/// uuid.hyphenated().to_string(), +/// ); /// ``` + + #[lua(kind = "Function", output(proxy))] + fn nil() -> uuid::Uuid; + +"#, + r#" +/// The 'max UUID' (all ones). +/// The max UUID is a special form of UUID that is specified to have all +/// 128 bits set to one. /// # References -/// * [Version Field in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-4.2) +/// * [Max UUID in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-5.10) +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// let uuid = Uuid::max(); +/// assert_eq!( +/// "ffffffff-ffff-ffff-ffff-ffffffffffff", +/// uuid.hyphenated().to_string(), +/// ); +/// ``` - #[lua(kind = "Method")] - fn get_version_num(&self) -> usize; + #[lua(kind = "Function", output(proxy))] + fn max() -> uuid::Uuid; "#, r#" -/// Returns a 128bit value containing the value. -/// The bytes in the UUID will be packed directly into a `u128`. +/// Creates a UUID from a 128bit value. /// # Examples +/// Basic usage: /// ``` /// # use uuid::Uuid; -/// # fn main() -> Result<(), uuid::Error> { -/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; +/// let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128; +/// let uuid = Uuid::from_u128(v); /// assert_eq!( -/// uuid.as_u128(), -/// 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8, +/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", +/// uuid.hyphenated().to_string(), /// ); -/// # Ok(()) -/// # } /// ``` - #[lua(kind = "Method")] - fn as_u128(&self) -> u128; + #[lua(kind = "Function", output(proxy))] + fn from_u128(v: u128) -> uuid::Uuid; "#, r#" -/// Returns a 128bit little-endian value containing the value. -/// The bytes in the `u128` will be flipped to convert into big-endian -/// order. This is based on the endianness of the UUID, rather than the -/// target environment so bytes will be flipped on both big and little -/// endian machines. -/// Note that this will produce a different result than -/// [`Uuid::to_fields_le`], because the entire UUID is reversed, rather -/// than reversing the individual fields in-place. +/// Creates a UUID from a 128bit value in little-endian order. +/// The entire value will be flipped to convert into big-endian order. +/// This is based on the endianness of the UUID, rather than the target +/// environment so bytes will be flipped on both big and little endian +/// machines. /// # Examples +/// Basic usage: /// ``` /// # use uuid::Uuid; -/// # fn main() -> Result<(), uuid::Error> { -/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; +/// let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128; +/// let uuid = Uuid::from_u128_le(v); /// assert_eq!( -/// uuid.to_u128_le(), -/// 0xd8d7d6d5d4d3d2d1c2c1b2b1a4a3a2a1, +/// "d8d7d6d5-d4d3-d2d1-c2c1-b2b1a4a3a2a1", +/// uuid.hyphenated().to_string(), /// ); -/// # Ok(()) -/// # } /// ``` - #[lua(kind = "Method")] - fn to_u128_le(&self) -> u128; + #[lua(kind = "Function", output(proxy))] + fn from_u128_le(v: u128) -> uuid::Uuid; "#, r#" -/// Returns two 64bit values containing the value. -/// The bytes in the UUID will be split into two `u64`. -/// The first u64 represents the 64 most significant bits, -/// the second one represents the 64 least significant. +/// Creates a UUID from two 64bit values. /// # Examples +/// Basic usage: /// ``` /// # use uuid::Uuid; -/// # fn main() -> Result<(), uuid::Error> { -/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; +/// let hi = 0xa1a2a3a4b1b2c1c2u64; +/// let lo = 0xd1d2d3d4d5d6d7d8u64; +/// let uuid = Uuid::from_u64_pair(hi, lo); /// assert_eq!( -/// uuid.as_u64_pair(), -/// (0xa1a2a3a4b1b2c1c2, 0xd1d2d3d4d5d6d7d8), +/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", +/// uuid.hyphenated().to_string(), /// ); -/// # Ok(()) -/// # } /// ``` - #[lua(kind = "Method")] - fn as_u64_pair(&self) -> (u64, u64); + #[lua(kind = "Function", output(proxy))] + fn from_u64_pair(high_bits: u64, low_bits: u64) -> uuid::Uuid; "#, r#" -/// Consumes self and returns the underlying byte value of the UUID. +/// Creates a UUID using the supplied bytes. /// # Examples +/// Basic usage: /// ``` +/// # fn main() -> Result<(), uuid::Error> { /// # use uuid::Uuid; /// let bytes = [ /// 0xa1, 0xa2, 0xa3, 0xa4, @@ -19681,92 +21689,69 @@ struct SmolStr(); /// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, /// ]; /// let uuid = Uuid::from_bytes(bytes); -/// assert_eq!(bytes, uuid.into_bytes()); +/// assert_eq!( +/// uuid.hyphenated().to_string(), +/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8" +/// ); +/// # Ok(()) +/// # } /// ``` - #[lua(kind = "Method")] - fn into_bytes(self) -> [u8; 16]; + #[lua(kind = "Function", output(proxy))] + fn from_bytes(bytes: [u8; 16]) -> uuid::Uuid; "#, r#" -/// Returns the bytes of the UUID in little-endian order. -/// The bytes will be flipped to convert into little-endian order. This is -/// based on the endianness of the UUID, rather than the target environment -/// so bytes will be flipped on both big and little endian machines. +/// Creates a UUID using the supplied bytes in little endian order. +/// The individual fields encoded in the buffer will be flipped. /// # Examples +/// Basic usage: /// ``` -/// use uuid::Uuid; /// # fn main() -> Result<(), uuid::Error> { -/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; +/// # use uuid::Uuid; +/// let bytes = [ +/// 0xa1, 0xa2, 0xa3, 0xa4, +/// 0xb1, 0xb2, +/// 0xc1, 0xc2, +/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, +/// ]; +/// let uuid = Uuid::from_bytes_le(bytes); /// assert_eq!( -/// uuid.to_bytes_le(), -/// ([ -/// 0xa4, 0xa3, 0xa2, 0xa1, 0xb2, 0xb1, 0xc2, 0xc1, 0xd1, 0xd2, -/// 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 -/// ]) +/// "a4a3a2a1-b2b1-c2c1-d1d2-d3d4d5d6d7d8", +/// uuid.hyphenated().to_string(), /// ); /// # Ok(()) /// # } /// ``` - #[lua(kind = "Method")] - fn to_bytes_le(&self) -> [u8; 16]; - -"#, - r#" -/// Tests if the UUID is nil (all zeros). - - #[lua(kind = "Method")] - fn is_nil(&self) -> bool; - -"#, - r#" -/// Tests if the UUID is max (all ones). - - #[lua(kind = "Method")] - fn is_max(&self) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_bytes_le(b: [u8; 16]) -> uuid::Uuid; "#, r#" -/// A buffer that can be used for `encode_...` calls, that is -/// guaranteed to be long enough for any of the format adapters. +/// Creates a random UUID. +/// This uses the [`getrandom`] crate to utilise the operating system's RNG +/// as the source of random numbers. If you'd like to use a custom +/// generator, don't use this method: generate random bytes using your +/// custom generator and pass them to the +/// [`uuid::Builder::from_random_bytes`][from_random_bytes] function +/// instead. +/// Note that usage of this method requires the `v4` feature of this crate +/// to be enabled. /// # Examples +/// Basic usage: /// ``` -/// # use uuid::Uuid; -/// let uuid = Uuid::nil(); -/// assert_eq!( -/// uuid.simple().encode_lower(&mut Uuid::encode_buffer()), -/// "00000000000000000000000000000000" -/// ); -/// assert_eq!( -/// uuid.hyphenated() -/// .encode_lower(&mut Uuid::encode_buffer()), -/// "00000000-0000-0000-0000-000000000000" -/// ); -/// assert_eq!( -/// uuid.urn().encode_lower(&mut Uuid::encode_buffer()), -/// "urn:uuid:00000000-0000-0000-0000-000000000000" -/// ); +/// # use uuid::{Uuid, Version}; +/// let uuid = Uuid::new_v4(); +/// assert_eq!(Some(Version::Random), uuid.get_version()); /// ``` +/// # References +/// * [UUID Version 4 in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-5.4) +/// [`getrandom`]: https://crates.io/crates/getrandom +/// [from_random_bytes]: struct.Builder.html#method.from_random_bytes - #[lua(kind = "Function")] - fn encode_buffer() -> [u8; 45]; - -"#, - r#" -/// If the UUID is the correct version (v1, or v6) this will return the -/// node value as a 6-byte array. For other versions this will return `None`. - - #[lua(kind = "Method")] - fn get_node_id( - &self, - ) -> bevy::reflect::erased_serde::__private::serde::__private::Option<[u8; 6]>; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Function", output(proxy))] + fn new_v4() -> uuid::Uuid; "#, r#" @@ -19781,112 +21766,108 @@ struct SmolStr(); "#, r#" -/// The 'nil UUID' (all zeros). -/// The nil UUID is a special form of UUID that is specified to have all -/// 128 bits set to zero. -/// # References -/// * [Nil UUID in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-5.9) -/// # Examples -/// Basic usage: -/// ``` -/// # use uuid::Uuid; -/// let uuid = Uuid::nil(); -/// assert_eq!( -/// "00000000-0000-0000-0000-000000000000", -/// uuid.hyphenated().to_string(), -/// ); -/// ``` - #[lua(kind = "Function", output(proxy))] - fn nil() -> uuid::Uuid; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> uuid::Uuid; "#, r#" -/// The 'max UUID' (all ones). -/// The max UUID is a special form of UUID that is specified to have all -/// 128 bits set to one. -/// # References -/// * [Max UUID in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-5.10) +/// Returns the version number of the UUID. +/// This represents the algorithm used to generate the value. +/// This method is the future-proof alternative to [`Uuid::get_version`]. /// # Examples /// Basic usage: /// ``` /// # use uuid::Uuid; -/// let uuid = Uuid::max(); -/// assert_eq!( -/// "ffffffff-ffff-ffff-ffff-ffffffffffff", -/// uuid.hyphenated().to_string(), -/// ); +/// # fn main() -> Result<(), uuid::Error> { +/// let my_uuid = Uuid::parse_str("02f09a3f-1624-3b1d-8409-44eff7708208")?; +/// assert_eq!(3, my_uuid.get_version_num()); +/// # Ok(()) +/// # } /// ``` +/// # References +/// * [Version Field in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-4.2) - #[lua(kind = "Function", output(proxy))] - fn max() -> uuid::Uuid; + #[lua(kind = "Method")] + fn get_version_num(&self) -> usize; "#, r#" -/// Creates a UUID from a 128bit value. +/// Returns a 128bit value containing the value. +/// The bytes in the UUID will be packed directly into a `u128`. /// # Examples -/// Basic usage: /// ``` /// # use uuid::Uuid; -/// let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128; -/// let uuid = Uuid::from_u128(v); +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; /// assert_eq!( -/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", -/// uuid.hyphenated().to_string(), +/// uuid.as_u128(), +/// 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8, /// ); +/// # Ok(()) +/// # } /// ``` - #[lua(kind = "Function", output(proxy))] - fn from_u128(v: u128) -> uuid::Uuid; + #[lua(kind = "Method")] + fn as_u128(&self) -> u128; "#, r#" -/// Creates a UUID from a 128bit value in little-endian order. -/// The entire value will be flipped to convert into big-endian order. -/// This is based on the endianness of the UUID, rather than the target -/// environment so bytes will be flipped on both big and little endian -/// machines. +/// Returns a 128bit little-endian value containing the value. +/// The bytes in the `u128` will be flipped to convert into big-endian +/// order. This is based on the endianness of the UUID, rather than the +/// target environment so bytes will be flipped on both big and little +/// endian machines. +/// Note that this will produce a different result than +/// [`Uuid::to_fields_le`], because the entire UUID is reversed, rather +/// than reversing the individual fields in-place. /// # Examples -/// Basic usage: /// ``` /// # use uuid::Uuid; -/// let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128; -/// let uuid = Uuid::from_u128_le(v); +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; /// assert_eq!( -/// "d8d7d6d5-d4d3-d2d1-c2c1-b2b1a4a3a2a1", -/// uuid.hyphenated().to_string(), +/// uuid.to_u128_le(), +/// 0xd8d7d6d5d4d3d2d1c2c1b2b1a4a3a2a1, /// ); +/// # Ok(()) +/// # } /// ``` - #[lua(kind = "Function", output(proxy))] - fn from_u128_le(v: u128) -> uuid::Uuid; + #[lua(kind = "Method")] + fn to_u128_le(&self) -> u128; "#, r#" -/// Creates a UUID from two 64bit values. +/// Returns two 64bit values containing the value. +/// The bytes in the UUID will be split into two `u64`. +/// The first u64 represents the 64 most significant bits, +/// the second one represents the 64 least significant. /// # Examples -/// Basic usage: /// ``` /// # use uuid::Uuid; -/// let hi = 0xa1a2a3a4b1b2c1c2u64; -/// let lo = 0xd1d2d3d4d5d6d7d8u64; -/// let uuid = Uuid::from_u64_pair(hi, lo); +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; /// assert_eq!( -/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", -/// uuid.hyphenated().to_string(), +/// uuid.as_u64_pair(), +/// (0xa1a2a3a4b1b2c1c2, 0xd1d2d3d4d5d6d7d8), /// ); +/// # Ok(()) +/// # } /// ``` - #[lua(kind = "Function", output(proxy))] - fn from_u64_pair(high_bits: u64, low_bits: u64) -> uuid::Uuid; + #[lua(kind = "Method")] + fn as_u64_pair(&self) -> (u64, u64); "#, r#" -/// Creates a UUID using the supplied bytes. +/// Consumes self and returns the underlying byte value of the UUID. /// # Examples -/// Basic usage: /// ``` -/// # fn main() -> Result<(), uuid::Error> { /// # use uuid::Uuid; /// let bytes = [ /// 0xa1, 0xa2, 0xa3, 0xa4, @@ -19895,85 +21876,92 @@ struct SmolStr(); /// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, /// ]; /// let uuid = Uuid::from_bytes(bytes); -/// assert_eq!( -/// uuid.hyphenated().to_string(), -/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8" -/// ); -/// # Ok(()) -/// # } +/// assert_eq!(bytes, uuid.into_bytes()); /// ``` - #[lua(kind = "Function", output(proxy))] - fn from_bytes(bytes: [u8; 16]) -> uuid::Uuid; + #[lua(kind = "Method")] + fn into_bytes(self) -> [u8; 16]; "#, r#" -/// Creates a UUID using the supplied bytes in little endian order. -/// The individual fields encoded in the buffer will be flipped. +/// Returns the bytes of the UUID in little-endian order. +/// The bytes will be flipped to convert into little-endian order. This is +/// based on the endianness of the UUID, rather than the target environment +/// so bytes will be flipped on both big and little endian machines. /// # Examples -/// Basic usage: /// ``` +/// use uuid::Uuid; /// # fn main() -> Result<(), uuid::Error> { -/// # use uuid::Uuid; -/// let bytes = [ -/// 0xa1, 0xa2, 0xa3, 0xa4, -/// 0xb1, 0xb2, -/// 0xc1, 0xc2, -/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, -/// ]; -/// let uuid = Uuid::from_bytes_le(bytes); +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; /// assert_eq!( -/// "a4a3a2a1-b2b1-c2c1-d1d2-d3d4d5d6d7d8", -/// uuid.hyphenated().to_string(), +/// uuid.to_bytes_le(), +/// ([ +/// 0xa4, 0xa3, 0xa2, 0xa1, 0xb2, 0xb1, 0xc2, 0xc1, 0xd1, 0xd2, +/// 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 +/// ]) /// ); /// # Ok(()) /// # } /// ``` - #[lua(kind = "Function", output(proxy))] - fn from_bytes_le(b: [u8; 16]) -> uuid::Uuid; + #[lua(kind = "Method")] + fn to_bytes_le(&self) -> [u8; 16]; "#, r#" +/// Tests if the UUID is nil (all zeros). - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> uuid::Uuid; + #[lua(kind = "Method")] + fn is_nil(&self) -> bool; "#, r#" -/// Creates a random UUID. -/// This uses the [`getrandom`] crate to utilise the operating system's RNG -/// as the source of random numbers. If you'd like to use a custom -/// generator, don't use this method: generate random bytes using your -/// custom generator and pass them to the -/// [`uuid::Builder::from_random_bytes`][from_random_bytes] function -/// instead. -/// Note that usage of this method requires the `v4` feature of this crate -/// to be enabled. +/// Tests if the UUID is max (all ones). + + #[lua(kind = "Method")] + fn is_max(&self) -> bool; + +"#, + r#" +/// A buffer that can be used for `encode_...` calls, that is +/// guaranteed to be long enough for any of the format adapters. /// # Examples -/// Basic usage: /// ``` -/// # use uuid::{Uuid, Version}; -/// let uuid = Uuid::new_v4(); -/// assert_eq!(Some(Version::Random), uuid.get_version()); +/// # use uuid::Uuid; +/// let uuid = Uuid::nil(); +/// assert_eq!( +/// uuid.simple().encode_lower(&mut Uuid::encode_buffer()), +/// "00000000000000000000000000000000" +/// ); +/// assert_eq!( +/// uuid.hyphenated() +/// .encode_lower(&mut Uuid::encode_buffer()), +/// "00000000-0000-0000-0000-000000000000" +/// ); +/// assert_eq!( +/// uuid.urn().encode_lower(&mut Uuid::encode_buffer()), +/// "urn:uuid:00000000-0000-0000-0000-000000000000" +/// ); /// ``` -/// # References -/// * [UUID Version 4 in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-5.4) -/// [`getrandom`]: https://crates.io/crates/getrandom -/// [from_random_bytes]: struct.Builder.html#method.from_random_bytes - #[lua(kind = "Function", output(proxy))] - fn new_v4() -> uuid::Uuid; + #[lua(kind = "Function")] + fn encode_buffer() -> [u8; 45]; + +"#, + r#" +/// If the UUID is the correct version (v1, or v6) this will return the +/// node value as a 6-byte array. For other versions this will return `None`. + + #[lua(kind = "Method")] + fn get_node_id( + &self, + ) -> bevy::reflect::erased_serde::__private::serde::__private::Option<[u8; 6]>; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -19985,6 +21973,61 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { 'lua, T: bevy_mod_scripting_lua::tealr::mlu::InstanceCollector<'lua>, >(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> { + instances + .add_instance( + "AtomicBool", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicI16", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicI32", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicI64", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicI8", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicIsize", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicU16", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicU32", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicU64", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicU8", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicUsize", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; instances .add_instance( "Duration", @@ -20215,6 +22258,72 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyReflectAPIProvider { |tw| { tw.document_global_instance::() .expect("Something went wrong documenting globals") + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicBool, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicI16, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicI32, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicI64, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicI8, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicIsize, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicU16, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicU32, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicU64, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicU8, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicUsize, + >, + >() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< @@ -20410,6 +22519,17 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyReflectAPIProvider { Ok(()) } fn register_with_app(&self, app: &mut bevy::app::App) { + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/bevy_time.rs b/crates/bevy_script_api/src/providers/bevy_time.rs index 377313b2c9..715be7fd92 100644 --- a/crates/bevy_script_api/src/providers/bevy_time.rs +++ b/crates/bevy_script_api/src/providers/bevy_time.rs @@ -53,6 +53,17 @@ struct Real {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::time::prelude::Timer; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &timer::Timer) -> bool; + "#, r#" /// Creates a new timer with a given duration. @@ -149,6 +160,14 @@ struct Real {} #[lua(kind = "Method")] fn elapsed_secs(&self) -> f32; +"#, + r#" +/// Returns the time elapsed on the timer as an `f64`. +/// See also [`Timer::elapsed`](Timer::elapsed). + + #[lua(kind = "Method")] + fn elapsed_secs_f64(&self) -> f64; + "#, r#" /// Sets the elapsed time of the timer without any other considerations. @@ -262,7 +281,7 @@ struct Real {} "#, r#" /// Returns `true` if the timer is paused. -/// See also [`Stopwatch::paused`](Stopwatch::paused). +/// See also [`Stopwatch::is_paused`](Stopwatch::is_paused). /// # Examples /// ``` /// # use bevy_time::*; @@ -380,17 +399,6 @@ struct Real {} #[lua(kind = "Method")] fn times_finished_this_tick(&self) -> u32; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &timer::Timer) -> bool; - "#, r#" @@ -412,12 +420,6 @@ struct Timer {} remote = "bevy::time::prelude::TimerMode", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -426,6 +428,12 @@ struct Timer {} )] fn eq(&self, #[proxy] other: &timer::TimerMode) -> bool; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" @@ -471,13 +479,8 @@ struct Virtual {} "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &stopwatch::Stopwatch) -> bool; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::time::Stopwatch; "#, r#" @@ -487,7 +490,7 @@ struct Virtual {} /// # use bevy_time::*; /// let stopwatch = Stopwatch::new(); /// assert_eq!(stopwatch.elapsed_secs(), 0.0); -/// assert_eq!(stopwatch.paused(), false); +/// assert_eq!(stopwatch.is_paused(), false); /// ``` #[lua(kind = "Function", output(proxy))] @@ -568,7 +571,7 @@ struct Virtual {} /// let mut stopwatch = Stopwatch::new(); /// stopwatch.pause(); /// stopwatch.tick(Duration::from_secs_f32(1.5)); -/// assert!(stopwatch.paused()); +/// assert!(stopwatch.is_paused()); /// assert_eq!(stopwatch.elapsed_secs(), 0.0); /// ``` @@ -587,7 +590,7 @@ struct Virtual {} /// stopwatch.tick(Duration::from_secs_f32(1.0)); /// stopwatch.unpause(); /// stopwatch.tick(Duration::from_secs_f32(1.0)); -/// assert!(!stopwatch.paused()); +/// assert!(!stopwatch.is_paused()); /// assert_eq!(stopwatch.elapsed_secs(), 1.0); /// ``` @@ -601,15 +604,15 @@ struct Virtual {} /// ``` /// # use bevy_time::*; /// let mut stopwatch = Stopwatch::new(); -/// assert!(!stopwatch.paused()); +/// assert!(!stopwatch.is_paused()); /// stopwatch.pause(); -/// assert!(stopwatch.paused()); +/// assert!(stopwatch.is_paused()); /// stopwatch.unpause(); -/// assert!(!stopwatch.paused()); +/// assert!(!stopwatch.is_paused()); /// ``` #[lua(kind = "Method")] - fn paused(&self) -> bool; + fn is_paused(&self) -> bool; "#, r#" @@ -630,8 +633,13 @@ struct Virtual {} "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::time::Stopwatch; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &stopwatch::Stopwatch) -> bool; "#, r#" diff --git a/crates/bevy_script_api/src/providers/bevy_transform.rs b/crates/bevy_script_api/src/providers/bevy_transform.rs index 0a55f0c67d..57bcb23f0c 100644 --- a/crates/bevy_script_api/src/providers/bevy_transform.rs +++ b/crates/bevy_script_api/src/providers/bevy_transform.rs @@ -5,8 +5,8 @@ use super::bevy_ecs::*; use super::bevy_reflect::*; use super::bevy_core::*; -use super::bevy_hierarchy::*; use super::bevy_math::*; +use super::bevy_hierarchy::*; extern crate self as bevy_script_api; use bevy_script_api::{ lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, @@ -17,9 +17,53 @@ use bevy_script_api::{ remote = "bevy::transform::components::GlobalTransform", functions[r#" + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul( + self, + #[proxy] + global_transform: bevy::transform::components::GlobalTransform, + ) -> bevy::transform::components::GlobalTransform; + +"#, + r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::transform::components::GlobalTransform; +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul( + self, + #[proxy] + transform: bevy::transform::components::Transform, + ) -> bevy::transform::components::GlobalTransform; + "#, r#" @@ -64,6 +108,15 @@ use bevy_script_api::{ scale: bevy::math::Vec3, ) -> bevy::transform::components::GlobalTransform; +"#, + r#" + + #[lua(kind = "Function", output(proxy))] + fn from_isometry( + #[proxy] + iso: bevy::math::Isometry3d, + ) -> bevy::transform::components::GlobalTransform; + "#, r#" /// Returns the 3d affine transformation matrix as a [`Mat4`]. @@ -87,6 +140,17 @@ use bevy_script_api::{ #[lua(kind = "Method", output(proxy))] fn compute_transform(&self) -> bevy::transform::components::Transform; +"#, + r#" +/// Returns the isometric part of the transformation as an [isometry]. Any scaling done by the +/// transformation will be ignored. +/// The transform is expected to be non-degenerate and without shearing, or the output +/// will be invalid. +/// [isometry]: Isometry3d + + #[lua(kind = "Method", output(proxy))] + fn to_isometry(&self) -> bevy::math::Isometry3d; + "#, r#" /// Returns the [`Transform`] `self` would have if it was a child of an entity @@ -183,6 +247,27 @@ use bevy_script_api::{ #[lua(kind = "Method", output(proxy))] fn translation_vec3a(&self) -> bevy::math::Vec3A; +"#, + r#" +/// Get the rotation as a [`Quat`]. +/// The transform is expected to be non-degenerate and without shearing, or the output will be invalid. +/// # Warning +/// This is calculated using `to_scale_rotation_translation`, meaning that you +/// should probably use it directly if you also need translation or scale. + + #[lua(kind = "Method", output(proxy))] + fn rotation(&self) -> bevy::math::Quat; + +"#, + r#" +/// Get the scale as a [`Vec3`]. +/// The transform is expected to be non-degenerate and without shearing, or the output will be invalid. +/// Some of the computations overlap with `to_scale_rotation_translation`, which means you should use +/// it instead if you also need rotation. + + #[lua(kind = "Method", output(proxy))] + fn scale(&self) -> bevy::math::Vec3; + "#, r#" /// Get an upper bound of the radius from the given `extents`. @@ -192,8 +277,35 @@ use bevy_script_api::{ "#, r#" -/// Transforms the given `point`, applying shear, scale, rotation and translation. -/// This moves `point` into the local space of this [`GlobalTransform`]. +/// Transforms the given point from local space to global space, applying shear, scale, rotation and translation. +/// It can be used like this: +/// ``` +/// # use bevy_transform::prelude::{GlobalTransform}; +/// # use bevy_math::prelude::Vec3; +/// let global_transform = GlobalTransform::from_xyz(1., 2., 3.); +/// let local_point = Vec3::new(1., 2., 3.); +/// let global_point = global_transform.transform_point(local_point); +/// assert_eq!(global_point, Vec3::new(2., 4., 6.)); +/// ``` +/// ``` +/// # use bevy_transform::prelude::{GlobalTransform}; +/// # use bevy_math::Vec3; +/// let global_point = Vec3::new(2., 4., 6.); +/// let global_transform = GlobalTransform::from_xyz(1., 2., 3.); +/// let local_point = global_transform.affine().inverse().transform_point3(global_point); +/// assert_eq!(local_point, Vec3::new(1., 2., 3.)) +/// ``` +/// To apply shear, scale, and rotation *without* applying translation, different functions are available: +/// ``` +/// # use bevy_transform::prelude::{GlobalTransform}; +/// # use bevy_math::prelude::Vec3; +/// let global_transform = GlobalTransform::from_xyz(1., 2., 3.); +/// let local_direction = Vec3::new(1., 2., 3.); +/// let global_direction = global_transform.affine().transform_vector3(local_direction); +/// assert_eq!(global_direction, Vec3::new(1., 2., 3.)); +/// let roundtripped_local_direction = global_transform.affine().inverse().transform_vector3(global_direction); +/// assert_eq!(roundtripped_local_direction, local_direction); +/// ``` #[lua(kind = "Method", output(proxy))] fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; @@ -210,50 +322,6 @@ use bevy_script_api::{ transform: bevy::transform::components::Transform, ) -> bevy::transform::components::GlobalTransform; -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul( - self, - #[proxy] - global_transform: bevy::transform::components::GlobalTransform, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul( - self, - #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -268,56 +336,6 @@ struct GlobalTransform(); derive(clone), remote = "bevy::transform::components::Transform", functions[r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul( - self, - #[proxy] - global_transform: bevy::transform::components::GlobalTransform, - ) -> bevy::transform::components::GlobalTransform; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::transform::components::Transform; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul( - self, - #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::Transform; - -"#, - r#" /// Creates a new [`Transform`] at the position `(x, y, z)`. In 2d, the `z` component /// is used for z-ordering elements: higher `z`-value will be in front of lower /// `z`-value. @@ -369,6 +387,17 @@ struct GlobalTransform(); scale: bevy::math::Vec3, ) -> bevy::transform::components::Transform; +"#, + r#" +/// Creates a new [`Transform`] that is equivalent to the given [isometry]. +/// [isometry]: Isometry3d + + #[lua(kind = "Function", output(proxy))] + fn from_isometry( + #[proxy] + iso: bevy::math::Isometry3d, + ) -> bevy::transform::components::Transform; + "#, r#" /// Returns this [`Transform`] with a new translation. @@ -603,12 +632,13 @@ struct GlobalTransform(); "#, r#" /// Transforms the given `point`, applying scale, rotation and translation. -/// If this [`Transform`] has a parent, this will transform a `point` that is -/// relative to the parent's [`Transform`] into one relative to this [`Transform`]. -/// If this [`Transform`] does not have a parent, this will transform a `point` -/// that is in global space into one relative to this [`Transform`]. -/// If you want to transform a `point` in global space to the local space of this [`Transform`], -/// consider using [`GlobalTransform::transform_point()`] instead. +/// If this [`Transform`] has an ancestor entity with a [`Transform`] component, +/// [`Transform::transform_point`] will transform a point in local space into its +/// parent transform's space. +/// If this [`Transform`] does not have a parent, [`Transform::transform_point`] will +/// transform a point in local space into worldspace coordinates. +/// If you always want to transform a point in local space to worldspace, or if you need +/// the inverse transformations, see [`GlobalTransform::transform_point()`]. #[lua(kind = "Method", output(proxy))] fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; @@ -622,6 +652,30 @@ struct GlobalTransform(); #[lua(kind = "Method")] fn is_finite(&self) -> bool; +"#, + r#" +/// Get the [isometry] defined by this transform's rotation and translation, ignoring scale. +/// [isometry]: Isometry3d + + #[lua(kind = "Method", output(proxy))] + fn to_isometry(&self) -> bevy::math::Isometry3d; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul( + self, + #[proxy] + global_transform: bevy::transform::components::GlobalTransform, + ) -> bevy::transform::components::GlobalTransform; + "#, r#" @@ -633,6 +687,40 @@ struct GlobalTransform(); )] fn eq(&self, #[proxy] other: &components::transform::Transform) -> bool; +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul( + self, + #[proxy] + transform: bevy::transform::components::Transform, + ) -> bevy::transform::components::Transform; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::transform::components::Transform; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] diff --git a/crates/bevy_script_api/src/providers/bevy_window.rs b/crates/bevy_script_api/src/providers/bevy_window.rs deleted file mode 100644 index 2c00201875..0000000000 --- a/crates/bevy_script_api/src/providers/bevy_window.rs +++ /dev/null @@ -1,1776 +0,0 @@ -// @generated by cargo bevy-api-gen generate, modify the templates not this file -#![allow(clippy::all)] -#![allow(unused, deprecated, dead_code)] -#![cfg_attr(rustfmt, rustfmt_skip)] -use super::bevy_ecs::*; -use super::bevy_reflect::*; -use super::bevy_math::*; -extern crate self as bevy_script_api; -use bevy_script_api::{ - lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, -}; -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::CursorEntered", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::CursorEntered) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::CursorEntered; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct CursorEntered { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::CursorIcon", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::CursorIcon; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &cursor::CursorIcon) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct CursorIcon {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::CursorLeft", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::CursorLeft) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::CursorLeft; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct CursorLeft { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::CursorMoved", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::CursorMoved; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::CursorMoved) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct CursorMoved { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] - position: bevy::math::Vec2, - delta: ReflectedValue, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::FileDragAndDrop", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::FileDragAndDrop; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::FileDragAndDrop) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct FileDragAndDrop {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::Ime", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::Ime) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::Ime; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Ime {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::MonitorSelection", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::MonitorSelection) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::MonitorSelection; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct MonitorSelection {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::ReceivedCharacter", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::ReceivedCharacter; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::ReceivedCharacter) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct ReceivedCharacter { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] - char: smol_str::SmolStr, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::Window", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::Window; - -"#, - r#" -/// Setting to true will attempt to maximize the window. -/// Setting to false will attempt to un-maximize the window. - - #[lua(kind = "MutatingMethod")] - fn set_maximized(&mut self, maximized: bool) -> (); - -"#, - r#" -/// Setting to true will attempt to minimize the window. -/// Setting to false will attempt to un-minimize the window. - - #[lua(kind = "MutatingMethod")] - fn set_minimized(&mut self, minimized: bool) -> (); - -"#, - r#" -/// The window's client area width in logical pixels. -/// See [`WindowResolution`] for an explanation about logical/physical sizes. - - #[lua(kind = "Method")] - fn width(&self) -> f32; - -"#, - r#" -/// The window's client area height in logical pixels. -/// See [`WindowResolution`] for an explanation about logical/physical sizes. - - #[lua(kind = "Method")] - fn height(&self) -> f32; - -"#, - r#" -/// The window's client size in logical pixels -/// See [`WindowResolution`] for an explanation about logical/physical sizes. - - #[lua(kind = "Method", output(proxy))] - fn size(&self) -> bevy::math::Vec2; - -"#, - r#" -/// The window's client area width in physical pixels. -/// See [`WindowResolution`] for an explanation about logical/physical sizes. - - #[lua(kind = "Method")] - fn physical_width(&self) -> u32; - -"#, - r#" -/// The window's client area height in physical pixels. -/// See [`WindowResolution`] for an explanation about logical/physical sizes. - - #[lua(kind = "Method")] - fn physical_height(&self) -> u32; - -"#, - r#" -/// The window's client size in physical pixels -/// See [`WindowResolution`] for an explanation about logical/physical sizes. - - #[lua(kind = "Method", output(proxy))] - fn physical_size(&self) -> bevy::math::UVec2; - -"#, - r#" -/// The window's scale factor. -/// Ratio of physical size to logical size, see [`WindowResolution`]. - - #[lua(kind = "Method")] - fn scale_factor(&self) -> f32; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Window { - #[lua(output(proxy))] - cursor: bevy::window::Cursor, - #[lua(output(proxy))] - present_mode: bevy::window::PresentMode, - #[lua(output(proxy))] - mode: bevy::window::WindowMode, - #[lua(output(proxy))] - position: bevy::window::prelude::WindowPosition, - #[lua(output(proxy))] - resolution: bevy::window::WindowResolution, - title: std::string::String, - name: std::option::Option, - #[lua(output(proxy))] - composite_alpha_mode: bevy::window::CompositeAlphaMode, - #[lua(output(proxy))] - resize_constraints: bevy::window::prelude::WindowResizeConstraints, - resizable: bool, - #[lua(output(proxy))] - enabled_buttons: bevy::window::EnabledButtons, - decorations: bool, - transparent: bool, - focused: bool, - #[lua(output(proxy))] - window_level: bevy::window::WindowLevel, - canvas: std::option::Option, - fit_canvas_to_parent: bool, - prevent_default_event_handling: bool, - #[lua(output(proxy))] - internal: bevy::window::InternalWindowState, - ime_enabled: bool, - #[lua(output(proxy))] - ime_position: bevy::math::Vec2, - window_theme: ReflectedValue, - visible: bool, - skip_taskbar: bool, - desired_maximum_frame_latency: ReflectedValue, - recognize_pinch_gesture: bool, - recognize_rotation_gesture: bool, - recognize_doubletap_gesture: bool, - recognize_pan_gesture: ReflectedValue, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::WindowMoved", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowMoved) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::WindowMoved; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowMoved { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] - position: bevy::math::IVec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::WindowPosition", - functions[r#" -/// Creates a new [`WindowPosition`] at a position. - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - position: bevy::math::IVec2, - ) -> bevy::window::prelude::WindowPosition; - -"#, - r#" -/// Set the position to a specific point. - - #[lua(kind = "MutatingMethod")] - fn set(&mut self, #[proxy] position: bevy::math::IVec2) -> (); - -"#, - r#" -/// Set the window to a specific monitor. - - #[lua(kind = "MutatingMethod")] - fn center( - &mut self, - #[proxy] - monitor: bevy::window::prelude::MonitorSelection, - ) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::WindowPosition; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowPosition) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowPosition {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::WindowResizeConstraints", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowResizeConstraints) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::WindowResizeConstraints; - -"#, - r#" -/// Checks if the constraints are valid. -/// Will output warnings if it isn't. - - #[lua(kind = "Method", output(proxy))] - fn check_constraints(&self) -> bevy::window::prelude::WindowResizeConstraints; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowResizeConstraints { - min_width: f32, - min_height: f32, - max_width: f32, - max_height: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowResized", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowResized) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowResized; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowResized { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - width: f32, - height: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowCreated", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowCreated; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowCreated) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowCreated { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowClosing", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowClosing) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowClosing; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowClosing { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowClosed", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowClosed; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowClosed) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowClosed { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowCloseRequested", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowCloseRequested; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowCloseRequested) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowCloseRequested { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowDestroyed", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowDestroyed; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowDestroyed) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowDestroyed { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::RequestRedraw", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::RequestRedraw; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::RequestRedraw) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct RequestRedraw {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowFocused", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowFocused; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowFocused) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowFocused { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - focused: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowOccluded", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowOccluded; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowOccluded) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowOccluded { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - occluded: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowScaleFactorChanged", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowScaleFactorChanged; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowScaleFactorChanged) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowScaleFactorChanged { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - scale_factor: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowBackendScaleFactorChanged", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowBackendScaleFactorChanged; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowBackendScaleFactorChanged) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowBackendScaleFactorChanged { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - scale_factor: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowThemeChanged", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowThemeChanged) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowThemeChanged; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowThemeChanged { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] - theme: bevy::window::WindowTheme, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::AppLifecycle", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::AppLifecycle; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::AppLifecycle) -> bool; - -"#, - r#" -/// Return `true` if the app can be updated. - - #[lua(kind = "Method")] - fn is_active(&self) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct AppLifecycle {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::PrimaryWindow", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::PrimaryWindow) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::PrimaryWindow; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct PrimaryWindow {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowTheme", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowTheme; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowTheme) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowTheme {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowRef", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowRef; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowRef {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::NormalizedWindowRef", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -/// Fetch the entity of this window reference - - #[lua(kind = "Method", output(proxy))] - fn entity(&self) -> bevy::ecs::entity::Entity; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::NormalizedWindowRef) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::NormalizedWindowRef; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct NormalizedWindowRef(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::Cursor", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::Cursor; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Cursor { - #[lua(output(proxy))] - icon: bevy::window::prelude::CursorIcon, - visible: bool, - #[lua(output(proxy))] - grab_mode: bevy::window::CursorGrabMode, - hit_test: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::PresentMode", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::PresentMode) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::PresentMode; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct PresentMode {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowMode", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowMode; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowMode) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowMode {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowResolution", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowResolution; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowResolution) -> bool; - -"#, - r#" -/// Creates a new [`WindowResolution`]. - - #[lua(kind = "Function", output(proxy))] - fn new(physical_width: f32, physical_height: f32) -> bevy::window::WindowResolution; - -"#, - r#" -/// Builder method for adding a scale factor override to the resolution. - - #[lua(kind = "Method", output(proxy))] - fn with_scale_factor_override( - self, - scale_factor_override: f32, - ) -> bevy::window::WindowResolution; - -"#, - r#" -/// The window's client area width in logical pixels. - - #[lua(kind = "Method")] - fn width(&self) -> f32; - -"#, - r#" -/// The window's client area height in logical pixels. - - #[lua(kind = "Method")] - fn height(&self) -> f32; - -"#, - r#" -/// The window's client size in logical pixels - - #[lua(kind = "Method", output(proxy))] - fn size(&self) -> bevy::math::Vec2; - -"#, - r#" -/// The window's client area width in physical pixels. - - #[lua(kind = "Method")] - fn physical_width(&self) -> u32; - -"#, - r#" -/// The window's client area height in physical pixels. - - #[lua(kind = "Method")] - fn physical_height(&self) -> u32; - -"#, - r#" -/// The window's client size in physical pixels - - #[lua(kind = "Method", output(proxy))] - fn physical_size(&self) -> bevy::math::UVec2; - -"#, - r#" -/// The ratio of physical pixels to logical pixels. -/// `physical_pixels = logical_pixels * scale_factor` - - #[lua(kind = "Method")] - fn scale_factor(&self) -> f32; - -"#, - r#" -/// The window scale factor as reported by the window backend. -/// This value is unaffected by [`WindowResolution::scale_factor_override`]. - - #[lua(kind = "Method")] - fn base_scale_factor(&self) -> f32; - -"#, - r#" -/// The scale factor set with [`WindowResolution::set_scale_factor_override`]. -/// This value may be different from the scale factor reported by the window backend. - - #[lua(kind = "Method")] - fn scale_factor_override(&self) -> std::option::Option; - -"#, - r#" -/// Set the window's logical resolution. - - #[lua(kind = "MutatingMethod")] - fn set(&mut self, width: f32, height: f32) -> (); - -"#, - r#" -/// Set the window's physical resolution. -/// This will ignore the scale factor setting, so most of the time you should -/// prefer to use [`WindowResolution::set`]. - - #[lua(kind = "MutatingMethod")] - fn set_physical_resolution(&mut self, width: u32, height: u32) -> (); - -"#, - r#" -/// Set the window's scale factor, this may get overridden by the backend. - - #[lua(kind = "MutatingMethod")] - fn set_scale_factor(&mut self, scale_factor: f32) -> (); - -"#, - r#" -/// Set the window's scale factor, and apply it to the currently known physical size. -/// This may get overridden by the backend. This is mostly useful on window creation, -/// so that the window is created with the expected size instead of waiting for a resize -/// event after its creation. - - #[lua(kind = "MutatingMethod")] - fn set_scale_factor_and_apply_to_physical_size(&mut self, scale_factor: f32) -> (); - -"#, - r#" -/// Set the window's scale factor, this will be used over what the backend decides. -/// This can change the logical and physical sizes if the resulting physical -/// size is not within the limits. - - #[lua(kind = "MutatingMethod")] - fn set_scale_factor_override( - &mut self, - scale_factor_override: std::option::Option, - ) -> (); - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowResolution {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::CompositeAlphaMode", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::CompositeAlphaMode; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::CompositeAlphaMode) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct CompositeAlphaMode {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::EnabledButtons", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::EnabledButtons; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::EnabledButtons) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct EnabledButtons { - minimize: bool, - maximize: bool, - close: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::WindowLevel", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowLevel; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowLevel) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct WindowLevel {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::InternalWindowState", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::InternalWindowState; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::InternalWindowState) -> bool; - -"#, - r#" -/// Consumes the current maximize request, if it exists. This should only be called by window backends. - - #[lua(kind = "MutatingMethod")] - fn take_maximize_request(&mut self) -> std::option::Option; - -"#, - r#" -/// Consumes the current minimize request, if it exists. This should only be called by window backends. - - #[lua(kind = "MutatingMethod")] - fn take_minimize_request(&mut self) -> std::option::Option; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct InternalWindowState {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::CursorGrabMode", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::CursorGrabMode; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::CursorGrabMode) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct CursorGrabMode {} -#[derive(Default)] -pub(crate) struct Globals; -impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { - fn add_instances< - 'lua, - T: bevy_mod_scripting_lua::tealr::mlu::InstanceCollector<'lua>, - >(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> { - instances - .add_instance( - "WindowPosition", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaWindowPosition, - >::new, - )?; - instances - .add_instance( - "WindowResolution", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaWindowResolution, - >::new, - )?; - Ok(()) - } -} -pub struct BevyWindowAPIProvider; -impl bevy_mod_scripting_core::hosts::APIProvider for BevyWindowAPIProvider { - type APITarget = std::sync::Mutex; - type ScriptContext = std::sync::Mutex; - type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; - fn attach_api( - &mut self, - ctx: &mut Self::APITarget, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context"); - bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx) - .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other( - e.to_string(), - )) - } - fn get_doc_fragment(&self) -> Option { - Some( - bevy_mod_scripting_lua::docs::LuaDocFragment::new( - "BevyWindowAPI", - |tw| { - tw.document_global_instance::() - .expect("Something went wrong documenting globals") - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaWindowPosition, - >, - >() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaWindowResolution, - >, - >() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - }, - ), - ) - } - fn setup_script( - &mut self, - script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn setup_script_runtime( - &mut self, - world_ptr: bevy_mod_scripting_core::world::WorldPointer, - _script_data: &bevy_mod_scripting_core::hosts::ScriptData, - ctx: &mut Self::ScriptContext, - ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { - Ok(()) - } - fn register_with_app(&self, app: &mut bevy::app::App) { - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::< - bevy::window::prelude::WindowResizeConstraints, - >(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - } -} diff --git a/crates/bevy_script_api/src/providers/mod.rs b/crates/bevy_script_api/src/providers/mod.rs index 0f2e29eded..1c5636d277 100644 --- a/crates/bevy_script_api/src/providers/mod.rs +++ b/crates/bevy_script_api/src/providers/mod.rs @@ -9,7 +9,6 @@ pub mod bevy_input; pub mod bevy_core; pub mod bevy_time; pub mod bevy_hierarchy; -pub mod bevy_window; pub mod bevy_reflect; extern crate self as bevy_script_api; use bevy_mod_scripting_core::docs::DocFragment; @@ -29,7 +28,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for LuaBevyAPIProvider { bevy_core::BevyCoreAPIProvider.attach_api(ctx)?; bevy_time::BevyTimeAPIProvider.attach_api(ctx)?; bevy_hierarchy::BevyHierarchyAPIProvider.attach_api(ctx)?; - bevy_window::BevyWindowAPIProvider.attach_api(ctx)?; bevy_reflect::BevyReflectAPIProvider.attach_api(ctx)?; Ok(()) } @@ -42,7 +40,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for LuaBevyAPIProvider { bevy_core::BevyCoreAPIProvider.get_doc_fragment(), bevy_time::BevyTimeAPIProvider.get_doc_fragment(), bevy_hierarchy::BevyHierarchyAPIProvider.get_doc_fragment(), - bevy_window::BevyWindowAPIProvider.get_doc_fragment(), bevy_reflect::BevyReflectAPIProvider.get_doc_fragment(), ] .into_iter() @@ -78,7 +75,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for LuaBevyAPIProvider { bevy_core::BevyCoreAPIProvider.register_with_app(app); bevy_time::BevyTimeAPIProvider.register_with_app(app); bevy_hierarchy::BevyHierarchyAPIProvider.register_with_app(app); - bevy_window::BevyWindowAPIProvider.register_with_app(app); bevy_reflect::BevyReflectAPIProvider.register_with_app(app); } } diff --git a/crates/bevy_script_api/src/rhai/std.rs b/crates/bevy_script_api/src/rhai/std.rs index 0ed09d8c41..88e8dc5db5 100644 --- a/crates/bevy_script_api/src/rhai/std.rs +++ b/crates/bevy_script_api/src/rhai/std.rs @@ -121,6 +121,7 @@ impl< + TypePath + Clone + FromRhaiProxy + + bevy::reflect::Typed + GetTypeRegistration, > RhaiProxyable for Option { @@ -249,11 +250,24 @@ impl ToRhaiProxy for Option { /// Composite trait composing the various traits required for a type `T` to be used as part of a RhaiVec pub trait RhaiVecElem: - FromReflect + GetTypeRegistration + TypePath + RhaiProxyable + FromRhaiProxy + Clone + FromReflect + + GetTypeRegistration + + TypePath + + RhaiProxyable + + FromRhaiProxy + + Clone + + bevy::reflect::Typed { } -impl - RhaiVecElem for T +impl< + T: FromReflect + + GetTypeRegistration + + TypePath + + RhaiProxyable + + FromRhaiProxy + + Clone + + bevy::reflect::Typed, + > RhaiVecElem for T { } diff --git a/crates/bevy_script_api/src/sub_reflect.rs b/crates/bevy_script_api/src/sub_reflect.rs index 9ec2395229..fcd5f55dd6 100644 --- a/crates/bevy_script_api/src/sub_reflect.rs +++ b/crates/bevy_script_api/src/sub_reflect.rs @@ -1,3 +1,4 @@ +use bevy::reflect::PartialReflect; use parking_lot::RwLock; use std::fmt; use std::fmt::{Debug, Display}; @@ -122,47 +123,47 @@ impl ReflectionPathElement { match self { ReflectionPathElement::SubReflection { get, .. } => get(base), ReflectionPathElement::FieldAccess(field) => match base.reflect_ref() { - ReflectRef::Struct(s) => { - s.field(field) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such field".to_owned(), - }) - } + ReflectRef::Struct(s) => s + .field(field) + .and_then(PartialReflect::try_as_reflect) + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such field".to_owned(), + }), _ => Err(ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such field".to_owned(), }), }, ReflectionPathElement::IndexAccess(index) => match base.reflect_ref() { - ReflectRef::TupleStruct(s) => { - s.field(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectRef::Tuple(s) => { - s.field(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectRef::List(s) => { - s.get(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectRef::Array(s) => { - s.get(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } + ReflectRef::TupleStruct(s) => s + .field(*index) + .and_then(PartialReflect::try_as_reflect) + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), + ReflectRef::Tuple(s) => s + .field(*index) + .and_then(PartialReflect::try_as_reflect) + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), + ReflectRef::List(s) => s + .get(*index) + .and_then(PartialReflect::try_as_reflect) + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), + ReflectRef::Array(s) => s + .get(*index) + .and_then(PartialReflect::try_as_reflect) + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), _ => Err(ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such element".to_owned(), @@ -178,47 +179,47 @@ impl ReflectionPathElement { match self { ReflectionPathElement::SubReflection { get_mut, .. } => get_mut(base), ReflectionPathElement::FieldAccess(field) => match base.reflect_mut() { - ReflectMut::Struct(s) => { - s.field_mut(field) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such field".to_owned(), - }) - } + ReflectMut::Struct(s) => s + .field_mut(field) + .and_then(PartialReflect::try_as_reflect_mut) + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such field".to_owned(), + }), _ => Err(ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such field".to_owned(), }), }, ReflectionPathElement::IndexAccess(index) => match base.reflect_mut() { - ReflectMut::TupleStruct(s) => { - s.field_mut(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectMut::Tuple(s) => { - s.field_mut(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectMut::List(s) => { - s.get_mut(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectMut::Array(s) => { - s.get_mut(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } + ReflectMut::TupleStruct(s) => s + .field_mut(*index) + .and_then(PartialReflect::try_as_reflect_mut) + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), + ReflectMut::Tuple(s) => s + .field_mut(*index) + .and_then(PartialReflect::try_as_reflect_mut) + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), + ReflectMut::List(s) => s + .get_mut(*index) + .and_then(PartialReflect::try_as_reflect_mut) + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), + ReflectMut::Array(s) => s + .get_mut(*index) + .and_then(PartialReflect::try_as_reflect_mut) + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), _ => Err(ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such element".to_owned(), @@ -289,9 +290,9 @@ impl ReflectionPath { ) -> Result<&'a mut dyn Reflect, ReflectionError> { if let Some(first) = self.accesses.first() { if self.accesses.len() > 1 { - return self.accesses[1..] + self.accesses[1..] .iter() - .try_fold(first.sub_ref_mut(ref_)?, |a, access| access.sub_ref_mut(a)); + .try_fold(first.sub_ref_mut(ref_)?, |a, access| access.sub_ref_mut(a)) } else { first.sub_ref_mut(ref_) } @@ -310,9 +311,9 @@ impl ReflectionPath { let entity_ref = g.get_entity(*entity) - .ok_or_else(|| ReflectionError::InvalidBaseReference { + .map_err(|e| ReflectionError::InvalidBaseReference { base: self.base.to_string(), - reason: "This entity does not exist".to_owned(), + reason: format!("This entity could not be retrieved. {e}"), })?; let ref_ = self.walk_path(comp.reflect(entity_ref).ok_or_else(|| { diff --git a/crates/languages/bevy_mod_scripting_lua/CHANGELOG.md b/crates/languages/bevy_mod_scripting_lua/CHANGELOG.md index 9fb02650d8..4133728e3a 100644 --- a/crates/languages/bevy_mod_scripting_lua/CHANGELOG.md +++ b/crates/languages/bevy_mod_scripting_lua/CHANGELOG.md @@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.8.0-alpha.2](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_lua-v0.8.0-alpha.1...bevy_mod_scripting_lua-v0.8.0-alpha.2) - 2024-12-03 + +### Fixed + +- bug when compiling without `teal` feature ([#148](https://github.com/makspll/bevy_mod_scripting/pull/148)) + +### Other + +- Luau support attempt ([#154](https://github.com/makspll/bevy_mod_scripting/pull/154)) +- Fix failing doctest ([#146](https://github.com/makspll/bevy_mod_scripting/pull/146)) + +## [0.8.0-alpha.1](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_lua-v0.8.0-alpha.0...bevy_mod_scripting_lua-v0.8.0-alpha.1) - 2024-11-10 + +### Other + +- update Cargo.toml dependencies + ## [0.7.1](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_lua-v0.7.0...bevy_mod_scripting_lua-v0.7.1) - 2024-11-03 ### Other diff --git a/crates/languages/bevy_mod_scripting_lua/Cargo.toml b/crates/languages/bevy_mod_scripting_lua/Cargo.toml index 3ba93e1c33..746078c822 100644 --- a/crates/languages/bevy_mod_scripting_lua/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_lua/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_lua" -version = "0.7.1" +version = "0.8.0-alpha.2" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" @@ -30,6 +30,7 @@ lua53 = ["tealr/mlua_lua53"] lua54 = ["tealr/mlua_lua54"] luajit = ["tealr/mlua_luajit"] luajit52 = ["tealr/mlua_luajit52"] +luau = ["tealr/mlua_luau"] mlua_serialize = ["tealr/mlua_serialize"] mlua_macros = ["tealr/mlua_macros"] mlua_async = ["tealr/mlua_async"] diff --git a/crates/languages/bevy_mod_scripting_lua/src/assets.rs b/crates/languages/bevy_mod_scripting_lua/src/assets.rs index 2b87fcdfcb..7e3e50d74b 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/assets.rs @@ -1,5 +1,5 @@ use bevy::{ - asset::{io::Reader, Asset, AssetLoader, AsyncReadExt}, + asset::{io::Reader, Asset, AssetLoader}, reflect::TypePath, utils::BoxedFuture, }; @@ -130,24 +130,20 @@ impl AssetLoader for LuaLoader { type Settings = (); type Error = Error; - fn load<'a>( - &'a self, - reader: &'a mut Reader, //bytes: &'a [u8], - _settings: &'a (), - load_context: &'a mut bevy::asset::LoadContext, - ) -> impl bevy::utils::ConditionalSendFuture< - Output = std::result::Result< - ::Asset, - ::Error, - >, + async fn load( + &self, + reader: &mut dyn Reader, //bytes: &'a [u8], + _settings: &(), + load_context: &mut bevy::asset::LoadContext<'_>, + ) -> std::result::Result< + ::Asset, + ::Error, > { bevy::prelude::info!("lua loader invoked: {:#}", load_context.asset_path()); - Box::pin(async move { - let mut bytes = Vec::new(); - reader.read_to_end(&mut bytes).await?; - let bytes = old_lua_load(bytes.as_slice(), load_context).await?; - Ok(LuaFile { bytes }) //}) - }) + let mut bytes = Vec::new(); + reader.read_to_end(&mut bytes).await?; + let bytes = old_lua_load(bytes.as_slice(), load_context).await?; + Ok(LuaFile { bytes }) } #[cfg(feature = "teal")] diff --git a/crates/languages/bevy_mod_scripting_lua/src/docs.rs b/crates/languages/bevy_mod_scripting_lua/src/docs.rs index 8bdd53be48..9fbb42b0d5 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/docs.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/docs.rs @@ -101,10 +101,10 @@ impl DocFragment for LuaDocFragment { tw.given_types.iter_mut().for_each(|tg| { if let TypeGenerator::Record(rg) = tg { rg.fields - .sort_by(|f1, f2| f1.name.deref().cmp(&f2.name.deref())); + .sort_by(|f1, f2| f1.name.deref().cmp(f2.name.deref())); rg.fields.dedup_by(|a, b| a.name == b.name); rg.static_fields - .sort_by(|f1, f2| f1.name.deref().cmp(&f2.name.deref())); + .sort_by(|f1, f2| f1.name.deref().cmp(f2.name.deref())); rg.static_fields.dedup_by(|a, b| a.name == b.name); for field in rg.fields.iter_mut().chain(rg.static_fields.iter_mut()) { escape_name(&mut field.name); @@ -217,7 +217,7 @@ fn escape_name(raw: &mut NameContainer) { "local", // Declarations "record", // Teal extra ]; - let Ok(name) = str::from_utf8(&raw) else { + let Ok(name) = str::from_utf8(raw) else { return; }; if KEYWORD_FIELDS.contains(&name) { diff --git a/crates/languages/bevy_mod_scripting_lua/src/util.rs b/crates/languages/bevy_mod_scripting_lua/src/util.rs index bbf7bb52a0..9b84ba5584 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/util.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/util.rs @@ -35,8 +35,8 @@ macro_rules! lua_path { /// /// Current configuration will provide "/scripts/*.lua" paths /// ```rust -/// use bevy_mod_scripting::lua_path; -/// assert_eq!("scripts/build/my_script.lua",lua_path!("my_script")) +/// use bevy_mod_scripting_lua::lua_path; +/// assert_eq!("scripts/my_script.lua",lua_path!("my_script")) /// ``` #[cfg(not(feature = "teal"))] #[macro_export] diff --git a/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml b/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml index c95fe287ec..476d102e60 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_lua_derive" -version = "0.7.1" +version = "0.8.0-alpha.2" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" @@ -23,7 +23,7 @@ path = "src/lib.rs" proc-macro = true [dependencies] -bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.7.1" } +bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.8.0-alpha.2" } paste = "1.0.7" darling = "0.20" syn = { version = "2.0.38", features = ["full", "fold", "extra-traits"] } diff --git a/crates/languages/bevy_mod_scripting_rhai/CHANGELOG.md b/crates/languages/bevy_mod_scripting_rhai/CHANGELOG.md index dda344c62b..f7daba88d8 100644 --- a/crates/languages/bevy_mod_scripting_rhai/CHANGELOG.md +++ b/crates/languages/bevy_mod_scripting_rhai/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.8.0-alpha.2](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_rhai-v0.8.0-alpha.1...bevy_mod_scripting_rhai-v0.8.0-alpha.2) - 2024-12-03 + +### Other + +- update Cargo.toml dependencies + +## [0.8.0-alpha.1](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_rhai-v0.8.0-alpha.0...bevy_mod_scripting_rhai-v0.8.0-alpha.1) - 2024-11-10 + +### Other + +- update Cargo.toml dependencies + ## [0.7.0](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_rhai-v0.6.0...bevy_mod_scripting_rhai-v0.7.0) - 2024-11-03 ### Other diff --git a/crates/languages/bevy_mod_scripting_rhai/Cargo.toml b/crates/languages/bevy_mod_scripting_rhai/Cargo.toml index 3f2c87994f..c19a9db60b 100644 --- a/crates/languages/bevy_mod_scripting_rhai/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_rhai/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_rhai" -version = "0.7.1" +version = "0.8.0-alpha.2" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" diff --git a/crates/languages/bevy_mod_scripting_rhai/src/assets.rs b/crates/languages/bevy_mod_scripting_rhai/src/assets.rs index c4d2da90cc..36b9249865 100644 --- a/crates/languages/bevy_mod_scripting_rhai/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_rhai/src/assets.rs @@ -1,5 +1,5 @@ use bevy::{ - asset::{io::Reader, Asset, AssetLoader, AsyncReadExt, LoadContext}, + asset::{io::Reader, Asset, AssetLoader, LoadContext}, reflect::TypePath, }; @@ -25,11 +25,11 @@ impl AssetLoader for RhaiLoader { type Asset = RhaiFile; type Settings = (); type Error = anyhow::Error; - async fn load<'a>( - &'a self, - reader: &'a mut Reader<'_>, - _: &'a Self::Settings, - _: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _: &Self::Settings, + _: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/crates/languages/bevy_mod_scripting_rhai_derive/Cargo.toml b/crates/languages/bevy_mod_scripting_rhai_derive/Cargo.toml index f06a35aa00..ae9005e157 100644 --- a/crates/languages/bevy_mod_scripting_rhai_derive/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_rhai_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_rhai_derive" -version = "0.7.1" +version = "0.8.0-alpha.2" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" @@ -17,7 +17,7 @@ path = "src/lib.rs" proc-macro = true [dependencies] -bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.7.1" } +bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.8.0-alpha.2" } paste = "1.0.7" syn = { version = "1.0.57", features = ["full", "fold", "extra-traits"] } quote = "1.0.8" diff --git a/crates/languages/bevy_mod_scripting_rune/CHANGELOG.md b/crates/languages/bevy_mod_scripting_rune/CHANGELOG.md index 511cdf6703..960f5d120a 100644 --- a/crates/languages/bevy_mod_scripting_rune/CHANGELOG.md +++ b/crates/languages/bevy_mod_scripting_rune/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.8.0-alpha.2](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_rune-v0.8.0-alpha.1...bevy_mod_scripting_rune-v0.8.0-alpha.2) - 2024-12-03 + +### Other + +- update Cargo.toml dependencies + +## [0.8.0-alpha.1](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_rune-v0.8.0-alpha.0...bevy_mod_scripting_rune-v0.8.0-alpha.1) - 2024-11-10 + +### Other + +- update Cargo.toml dependencies + ## [0.7.0](https://github.com/makspll/bevy_mod_scripting/compare/bevy_mod_scripting_rune-v0.6.0...bevy_mod_scripting_rune-v0.7.0) - 2024-11-03 ### Other diff --git a/crates/languages/bevy_mod_scripting_rune/Cargo.toml b/crates/languages/bevy_mod_scripting_rune/Cargo.toml index e86f4f8ff2..c3d9bef3e8 100644 --- a/crates/languages/bevy_mod_scripting_rune/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_rune/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_rune" -version = "0.7.1" +version = "0.8.0-alpha.2" edition = "2021" license = "MIT OR Apache-2.0" description = "Necessary functionality for Rune support with bevy_mod_scripting" diff --git a/crates/languages/bevy_mod_scripting_rune/src/assets.rs b/crates/languages/bevy_mod_scripting_rune/src/assets.rs index e05272272d..e5d0f96ab2 100644 --- a/crates/languages/bevy_mod_scripting_rune/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_rune/src/assets.rs @@ -1,6 +1,6 @@ use anyhow::Error; use bevy::{ - asset::{io::Reader, Asset, AssetLoader, AsyncReadExt}, + asset::{io::Reader, Asset, AssetLoader}, reflect::TypePath, }; use bevy_mod_scripting_core::prelude::*; @@ -27,22 +27,15 @@ impl AssetLoader for RuneLoader { type Settings = (); type Error = Error; - fn load<'a>( - &'a self, - reader: &'a mut Reader, - _settings: &'a (), - _load_context: &'a mut bevy::asset::LoadContext, - ) -> impl bevy::utils::ConditionalSendFuture< - Output = std::result::Result< - ::Asset, - ::Error, - >, - > { - Box::pin(async move { - let mut bytes = Vec::new(); - reader.read_to_end(&mut bytes).await?; - Ok(RuneFile { bytes }) - }) + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut bevy::asset::LoadContext<'_>, + ) -> std::result::Result { + let mut bytes = Vec::new(); + reader.read_to_end(&mut bytes).await?; + Ok(RuneFile { bytes }) } fn extensions(&self) -> &[&str] { diff --git a/crates/macro_tests/Cargo.toml b/crates/macro_tests/Cargo.toml index 969de9f57b..d8b651d323 100644 --- a/crates/macro_tests/Cargo.toml +++ b/crates/macro_tests/Cargo.toml @@ -15,7 +15,7 @@ debug = false [dev-dependencies] trybuild = "1.0" -bevy = { version = "0.14", default-features = false } +bevy = { version = "0.15.0", default-features = false } bevy_mod_scripting = { path = "../../", features = [ "lua", "lua_script_api", diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000000..e9c072897d --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +book \ No newline at end of file diff --git a/docs/book.toml b/docs/book.toml new file mode 100644 index 0000000000..dafeadc13d --- /dev/null +++ b/docs/book.toml @@ -0,0 +1,6 @@ +[book] +authors = ["makspll"] +language = "en" +multilingual = false +src = "src" +title = "Bevy Scripting" diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md new file mode 100644 index 0000000000..7390c82896 --- /dev/null +++ b/docs/src/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +- [Chapter 1](./chapter_1.md) diff --git a/docs/src/chapter_1.md b/docs/src/chapter_1.md new file mode 100644 index 0000000000..1259c54e97 --- /dev/null +++ b/docs/src/chapter_1.md @@ -0,0 +1,6 @@ +# Chapter 1 + + +## Introduction + +Welcome to the greatest documentation of all time WIP \ No newline at end of file diff --git a/examples/lua/game_of_life.rs b/examples/lua/game_of_life.rs index 11482c2fb7..994d80d91c 100644 --- a/examples/lua/game_of_life.rs +++ b/examples/lua/game_of_life.rs @@ -3,12 +3,12 @@ use std::sync::Mutex; use bevy::{ diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, + image::ImageSampler, prelude::*, reflect::Reflect, render::{ render_asset::RenderAssetUsages, render_resource::{Extent3d, TextureDimension, TextureFormat}, - texture::ImageSampler, }, window::{PrimaryWindow, WindowResized}, }; @@ -86,18 +86,15 @@ pub fn setup( let script_path = bevy_mod_scripting_lua::lua_path!("game_of_life"); - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); commands - .spawn(SpriteBundle { - texture: assets.add(image), - sprite: Sprite { - custom_size: Some(Vec2::new( - settings.display_grid_dimensions.0 as f32, - settings.display_grid_dimensions.1 as f32, - )), - color: Color::srgb(1.0, 0.388, 0.278), // TOMATO - ..Default::default() - }, + .spawn(Sprite { + image: assets.add(image), + custom_size: Some(Vec2::new( + settings.display_grid_dimensions.0 as f32, + settings.display_grid_dimensions.1 as f32, + )), + color: Color::srgb(1.0, 0.388, 0.278), // TOMATO ..Default::default() }) .insert(LifeState { @@ -156,11 +153,11 @@ pub fn sync_window_size( /// Runs after LifeState components are updated, updates their rendered representation pub fn update_rendered_state( mut assets: ResMut>, - query: Query<(&LifeState, &Handle)>, + query: Query<(&LifeState, &Sprite)>, ) { for (new_state, old_rendered_state) in query.iter() { let old_rendered_state = assets - .get_mut(old_rendered_state) + .get_mut(&old_rendered_state.image) .expect("World is not setup correctly"); old_rendered_state.data = new_state.cells.clone(); diff --git a/examples/rhai/game_of_life.rs b/examples/rhai/game_of_life.rs index aa203448be..6ed07482dd 100644 --- a/examples/rhai/game_of_life.rs +++ b/examples/rhai/game_of_life.rs @@ -1,11 +1,11 @@ use bevy::{ diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, + image::ImageSampler, prelude::*, reflect::Reflect, render::{ render_asset::RenderAssetUsages, render_resource::{Extent3d, TextureDimension, TextureFormat}, - texture::ImageSampler, }, window::{PrimaryWindow, WindowResized}, }; @@ -91,18 +91,15 @@ pub fn setup( let script_path = "scripts/game_of_life.rhai"; - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); commands - .spawn(SpriteBundle { - texture: assets.add(image), - sprite: Sprite { - custom_size: Some(Vec2::new( - settings.display_grid_dimensions.0 as f32, - settings.display_grid_dimensions.1 as f32, - )), - color: Color::srgb(1.0, 0.388, 0.278), // TOMATO - ..Default::default() - }, + .spawn(Sprite { + image: assets.add(image), + custom_size: Some(Vec2::new( + settings.display_grid_dimensions.0 as f32, + settings.display_grid_dimensions.1 as f32, + )), + color: Color::srgb(1.0, 0.388, 0.278), // TOMATO ..Default::default() }) .insert(LifeState { @@ -161,11 +158,11 @@ pub fn sync_window_size( /// Runs after LifeState components are updated, updates their rendered representation pub fn update_rendered_state( mut assets: ResMut>, - query: Query<(&LifeState, &Handle)>, + query: Query<(&LifeState, &Sprite)>, ) { for (new_state, old_rendered_state) in query.iter() { let old_rendered_state = assets - .get_mut(old_rendered_state) + .get_mut(&old_rendered_state.image) .expect("World is not setup correctly"); old_rendered_state.data = new_state.cells.clone(); diff --git a/makefile b/makefile index 74ed9a9f79..5fc3883bdd 100644 --- a/makefile +++ b/makefile @@ -21,15 +21,15 @@ PACKAGE=bevy_mod_scripting TEST_NAME= # # valgrind outputs a callgrind.out.. We can analyze this with kcachegrind # kcachegrind -NIGHTLY_VERSION=nightly-2024-05-20 -BEVY_VERSION=0.14.2 -GLAM_VERSION=0.28.0 +NIGHTLY_VERSION=nightly-2024-11-05 +BEVY_VERSION=0.15.0 +GLAM_VERSION=0.29.0 CODEGEN_PATH=${PWD}/target/codegen BEVY_PATH=${CODEGEN_PATH}/bevy GLAM_PATH=${CODEGEN_PATH}/glam OUTPUT_PATH=${CODEGEN_PATH}/output GENERATED_SRC_PATH=./crates/bevy_script_api/src/providers -GEN_BEVY_FEATURES=bevy_asset,bevy_gltf,bevy_animation,bevy_core_pipeline,bevy_ui,bevy_pbr,bevy_render,bevy_text,bevy_sprite,file_watcher,multi_threaded +GEN_BEVY_FEATURES=bevy_asset,bevy_animation,bevy_core_pipeline,bevy_ui,bevy_pbr,bevy_render,bevy_text,bevy_sprite,file_watcher,multi_threaded build_test_in_package: @cargo test --no-run --lib --workspace $(TEST_NAME) @@ -61,10 +61,10 @@ clean_bevy: cd ${BEVY_PATH} && cargo clean generate_bevy: - cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen generate --output ${OUTPUT_PATH} --template-args '{ "self_is_bevy_script_api": true}' --features ${GEN_BEVY_FEATURES} + cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen generate --output ${OUTPUT_PATH} --template-args '{ "self_is_bevy_script_api": true}' --features ${GEN_BEVY_FEATURES} -vv collect_bevy: - cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen collect --output ${OUTPUT_PATH} --template-args '{ "self_is_bevy_script_api": true}' + cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen collect --output ${OUTPUT_PATH} --template-args '{ "self_is_bevy_script_api": true}' -vv deletion_confirmation: @echo -n "This action will delete ALL files in directories: '${GENERATED_SRC_PATH}' amd ${OUTPUT_PATH} (y/N) " diff --git a/readme.md b/readme.md index fb0dc2cdc6..7e62cfd51d 100644 --- a/readme.md +++ b/readme.md @@ -41,6 +41,14 @@ The languages currently supported are as follows: |Language| Support Level | Documentation Generation | |----|----|----| |Lua|4|[Yes](https://makspll.github.io/bevy_mod_scripting_lua/latest/)| +|Lua51|4|[Yes](https://makspll.github.io/bevy_mod_scripting_lua/latest/)| +|Lua52|4|[Yes](https://makspll.github.io/bevy_mod_scripting_lua/latest/)| +|Lua53|4|[Yes](https://makspll.github.io/bevy_mod_scripting_lua/latest/)| +|Lua54|4|[Yes](https://makspll.github.io/bevy_mod_scripting_lua/latest/)| +|Luajit|4|[Yes](https://makspll.github.io/bevy_mod_scripting_lua/latest/)| +|Luajit52|4|[Yes](https://makspll.github.io/bevy_mod_scripting_lua/latest/)| +|Luau|4|[Yes](https://makspll.github.io/bevy_mod_scripting_lua/latest/)| +|Teal|4|[Yes](https://makspll.github.io/bevy_mod_scripting_lua/latest/)| |Rhai|2|No| |Rune|1|No| @@ -264,6 +272,7 @@ To see more complex applications of this library have a look at the examples: - [generating statically typed lua wrappers + ReflectReference system](examples/wrappers.rs) - [lua - documentation generation + lua static typing](examples/lua/documentation_gen.rs) - [lua - bevy console integration](examples/lua/console_integration.rs) +- [lua - dynamic queryies](examples/lua/dynamic_queries.rs) - [rhai - bevy console integration](examples/rhai/console_integration.rs) - [lua - game of life with teal](examples/lua/game_of_life.rs) - [rhai - game of life](examples/rhai/game_of_life.rs)