From c2c3bda9b24497d334a1e97139a5e7bf3389bb15 Mon Sep 17 00:00:00 2001 From: Maksymilian Mozolewski Date: Sat, 7 Sep 2024 21:23:04 +0100 Subject: [PATCH] Migrate to bevy 0.14 (#127) * chore: First pass. * Pin bevy to 0.14.2 and migrate rhai asset loader future * roll back nightly version to try generating with it * typo * fix stack overflow and improve logging in bootstrapping, build bootstrap into nearest target * bump rust version for codegen * typo * fix issues with file loader * generate new providers * add uuid dependency * ignore TypeId as a proxy * re-generate bevy_reflect * fix missing GetTypeRegistration bounds (this is good to have anyway) * fix compilation errors in examples * add wsl exports * formatting * fix clippy warnings * more clippy fixes * fix macro tests * fix macro test --------- Co-authored-by: Shane Celis --- .github/workflows/bevy_api_gen.yml | 10 +- Cargo.toml | 12 +- check.sh | 6 +- crates/bevy_api_gen/Cargo.bootstrap.toml | 8 +- crates/bevy_api_gen/Cargo.toml | 4 +- crates/bevy_api_gen/readme.md | 14 +- crates/bevy_api_gen/rust-toolchain.toml | 2 +- crates/bevy_api_gen/src/args.rs | 1 + crates/bevy_api_gen/src/bin/main.rs | 99 +- crates/bevy_api_gen/src/callback.rs | 2 +- crates/bevy_api_gen/src/feature_graph.rs | 41 +- .../bevy_api_gen/src/modifying_file_loader.rs | 21 +- .../bevy_api_gen/src/passes/cache_traits.rs | 5 - .../src/passes/find_methods_and_fields.rs | 4 +- .../src/passes/find_reflect_types.rs | 3 +- crates/bevy_mod_scripting_common/src/input.rs | 4 + crates/bevy_mod_scripting_core/src/lib.rs | 4 +- crates/bevy_script_api/Cargo.toml | 3 +- crates/bevy_script_api/src/common/bevy/mod.rs | 3 +- crates/bevy_script_api/src/common/std.rs | 10 +- crates/bevy_script_api/src/lua/mod.rs | 2 +- crates/bevy_script_api/src/lua/std.rs | 18 +- crates/bevy_script_api/src/lua/util.rs | 10 + .../src/providers/bevy_core.rs | 12 +- .../bevy_script_api/src/providers/bevy_ecs.rs | 141 +- .../src/providers/bevy_input.rs | 952 +- .../src/providers/bevy_math.rs | 4900 ++++ .../src/providers/bevy_reflect.rs | 19996 ++++++---------- .../src/providers/bevy_time.rs | 48 +- .../src/providers/bevy_transform.rs | 302 +- .../src/providers/bevy_window.rs | 666 +- crates/bevy_script_api/src/providers/mod.rs | 4 + crates/bevy_script_api/src/rhai/mod.rs | 2 +- crates/bevy_script_api/src/rhai/std.rs | 23 +- .../bevy_mod_scripting_lua/src/assets.rs | 7 +- .../bevy_mod_scripting_lua_derive/Cargo.toml | 2 +- .../bevy_mod_scripting_lua_derive/src/arg.rs | 8 +- .../src/function.rs | 3 +- .../bevy_mod_scripting_lua_derive/src/lib.rs | 4 +- .../src/signature.rs | 6 +- .../bevy_mod_scripting_rhai/src/assets.rs | 16 +- .../bevy_mod_scripting_rune/src/assets.rs | 7 +- crates/macro_tests/Cargo.toml | 2 +- .../references/non-proxy-reference.stderr | 2 +- .../output-with-proxy-reference.stderr | 8 +- .../fail/simple/invalid-argument-count.stderr | 6 +- examples/lua/bevy_api.rs | 2 +- examples/lua/console_integration.rs | 4 +- examples/lua/game_of_life.rs | 2 +- examples/rhai/bevy_api.rs | 2 +- examples/rhai/console_integration.rs | 4 +- examples/rhai/game_of_life.rs | 2 +- examples/rune/event_recipients.rs | 2 +- examples/rune/minimal.rs | 2 +- examples/wrappers.rs | 2 +- makefile | 11 +- readme.md | 15 +- wsl.sh | 3 + 58 files changed, 14252 insertions(+), 13202 deletions(-) create mode 100644 crates/bevy_script_api/src/providers/bevy_math.rs create mode 100644 wsl.sh diff --git a/.github/workflows/bevy_api_gen.yml b/.github/workflows/bevy_api_gen.yml index 3c34eaec..02412717 100644 --- a/.github/workflows/bevy_api_gen.yml +++ b/.github/workflows/bevy_api_gen.yml @@ -27,7 +27,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2024-01-24 + toolchain: nightly-2024-05-20 override: true - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 @@ -54,7 +54,7 @@ jobs: with: profile: minimal components: rustfmt - toolchain: nightly-2024-01-24 + toolchain: nightly-2024-05-20 override: true - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 @@ -77,7 +77,7 @@ jobs: rm -rf crates - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2024-01-24 + toolchain: nightly-2024-05-20 components: clippy override: true - name: Rust Cache @@ -100,7 +100,7 @@ jobs: rm -rf crates - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2024-01-24 + toolchain: nightly-2024-05-20 override: true - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 @@ -122,7 +122,7 @@ jobs: rm -rf crates - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2024-01-24 + toolchain: nightly-2024-05-20 override: true - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 diff --git a/Cargo.toml b/Cargo.toml index b1ae0117..2af7bbd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,7 @@ bevy_script_api = { path = "crates/bevy_script_api", version = "0.6.0", optional [workspace.dependencies] -bevy = { version = "=0.13.1", default-features = false } +bevy = { version = "0.14.2", default-features = false } bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.6.0" } bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.6.0" } @@ -78,7 +78,7 @@ bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version bevy = { workspace = true, default-features = true } clap = { version = "4.1", features = ["derive"] } rand = "0.8.5" -bevy_console = "0.11.1" +bevy_console = "0.12" rhai-rand = "0.1" [workspace] @@ -118,7 +118,7 @@ required-features = [ "lua54", "lua_script_api", "bevy/file_watcher", - "bevy/multi-threaded", + "bevy/multi_threaded", ] [[example]] @@ -128,7 +128,7 @@ required-features = [ "rhai", "rhai_script_api", "bevy/file_watcher", - "bevy/multi-threaded", + "bevy/multi_threaded", ] [[example]] @@ -143,7 +143,7 @@ required-features = [ "lua54", "lua_script_api", "bevy/file_watcher", - "bevy/multi-threaded", + "bevy/multi_threaded", ] [[example]] @@ -153,7 +153,7 @@ required-features = [ "rhai", "rhai_script_api", "bevy/file_watcher", - "bevy/multi-threaded", + "bevy/multi_threaded", ] [[example]] diff --git a/check.sh b/check.sh index b7f544a8..c731dd4c 100755 --- a/check.sh +++ b/check.sh @@ -4,7 +4,7 @@ CURRENT_DIR=$(basename "$PWD") if [[ "$CURRENT_DIR" == "bevy_api_gen" ]]; then - cargo clippy --all-targets --message-format=json + cargo +nightly-2024-05-20 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 \ No newline at end of file + 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.bootstrap.toml b/crates/bevy_api_gen/Cargo.bootstrap.toml index b73cb76e..74afa486 100644 --- a/crates/bevy_api_gen/Cargo.bootstrap.toml +++ b/crates/bevy_api_gen/Cargo.bootstrap.toml @@ -6,6 +6,12 @@ edition = "2021" [dependencies] mlua = { version = "0.9.2", features = ["lua54", "vendored", "send", "macros"] } -bevy_reflect = { version = "0.13.1", features = ["bevy", "bevy_math"] } +bevy_reflect = { version = "0.14", features = [ + "bevy", + "glam", + "petgraph", + "smallvec", + "uuid", +] } [workspace] diff --git a/crates/bevy_api_gen/Cargo.toml b/crates/bevy_api_gen/Cargo.toml index ab42559b..8a06e6f3 100644 --- a/crates/bevy_api_gen/Cargo.toml +++ b/crates/bevy_api_gen/Cargo.toml @@ -37,13 +37,13 @@ source = "discover" rustc_private = true [rust-analyzer.check] -overrideCommand = ["cargo", "+nightly-2024-01-24", "a", "--message-format=json"] +overrideCommand = ["cargo", "+nightly-2024-05-20", "a", "--message-format=json"] [dependencies] log = "0.4" env_logger = "0.11" -rustc_plugin = "=0.9.0-nightly-2024-01-24" +rustc_plugin = "=0.10.0-nightly-2024-05-20" indexmap = "2" tempdir = "0.3" cargo_metadata = "0.18" diff --git a/crates/bevy_api_gen/readme.md b/crates/bevy_api_gen/readme.md index 0831b6fc..d8fe50e5 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-01-24 install bevy_api_gen +cargo +nightly-2024-05-20 install bevy_api_gen ``` # Usage @@ -18,17 +18,17 @@ cargo +nightly-2024-01-24 install bevy_api_gen To run the main codegen process, use the following command: ```bash -cargo +nightly-2024-01-24 bevy-api-gen generate +cargo +nightly-2024-05-20 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-01-24/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-05-20/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-01-24 bevy-api-gen collect +cargo +nightly-2024-05-20 bevy-api-gen collect ``` ## List Types @@ -36,7 +36,7 @@ cargo +nightly-2024-01-24 bevy-api-gen collect To see a list of all `Reflect` implementing types in your workspace run: ```bash -cargo +nightly-2024-01-24 bevy-api-gen list-types > all_types.txt +cargo +nightly-2024-05-20 bevy-api-gen list-types > all_types.txt ``` ## List Templates @@ -44,7 +44,7 @@ cargo +nightly-2024-01-24 bevy-api-gen list-types > all_types.txt To see the list of all templates which you can override use: ```bash -cargo +nightly-2024-01-24 bevy-api-gen list-templates +cargo +nightly-2024-05-20 bevy-api-gen list-templates ``` ## Print Template @@ -52,5 +52,5 @@ cargo +nightly-2024-01-24 bevy-api-gen list-templates You can also print any of the templates to stdout: ```bash -cargo +nightly-2024-01-24 bevy-api-gen print item.tera +cargo +nightly-2024-05-20 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 d5b2ac7b..2a12ab9a 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-01-24" +channel = "nightly-2024-05-20" diff --git a/crates/bevy_api_gen/src/args.rs b/crates/bevy_api_gen/src/args.rs index 15e0d3f8..848d0a93 100644 --- a/crates/bevy_api_gen/src/args.rs +++ b/crates/bevy_api_gen/src/args.rs @@ -104,6 +104,7 @@ impl Verbosity { fn default_ignored_types() -> String { [ + "std::any::TypeId", "bevy_reflect::DynamicArray", "bevy_reflect::DynamicList", "bevy_reflect::DynamicMap", diff --git a/crates/bevy_api_gen/src/bin/main.rs b/crates/bevy_api_gen/src/bin/main.rs index 81ae80b7..626e1169 100644 --- a/crates/bevy_api_gen/src/bin/main.rs +++ b/crates/bevy_api_gen/src/bin/main.rs @@ -2,15 +2,15 @@ use std::{ collections::HashMap, env, fs::{create_dir_all, File}, - io::Write, - path::Path, + io::{BufRead, Write}, + path::{Path, PathBuf}, process::{Command, Stdio}, }; use bevy_api_gen::*; use cargo_metadata::camino::Utf8Path; use clap::Parser; -use log::{debug, info}; +use log::{debug, error, info}; use strum::VariantNames; use tera::Context; @@ -25,19 +25,34 @@ fn main() { } env_logger::init(); + info!("Computing crate metadata"); let metadata = cargo_metadata::MetadataCommand::new() .no_deps() .other_options(["--all-features".to_string(), "--offline".to_string()]) .exec() .unwrap(); + let crates = metadata .workspace_packages() .iter() .map(|p| p.name.to_owned()) .collect::>(); + + info!("Computing active features"); let include_crates = match (&args.workspace_root, args.cmd.is_generate()) { (Some(root), true) => { let feature_graph = FeatureGraph::from_metadata(&metadata, root); + info!( + "Using workspace root: {}, found {} crates", + feature_graph.workspace_root, + feature_graph.crates.len() + ); + + info!( + "Computing all transitive dependencies for enabled top-level features: {}", + args.features.join(",") + ); + let dependencies = feature_graph .dependencies_for_features(args.features.as_ref(), !args.no_default_features) .into_iter() @@ -52,6 +67,8 @@ fn main() { let plugin_subdir = format!("plugin-{}", env!("RUSTC_CHANNEL")); let plugin_target_dir = metadata.target_directory.join(plugin_subdir); + info!("Computing wokrspace metadata"); + // inform the deps about the workspace crates, this is going to be useful when working with meta files as we will be able to // know when to panic if a crate is not found // it's also useful to pass around the output directory for our Args default values to be able to compute them @@ -132,14 +149,13 @@ fn main() { _ => {} } - let temp_dir = tempdir::TempDir::new("bevy_api_gen_bootstrap") - .expect("Error occured when trying to acquire temp file"); + let temp_dir = find_bootstrap_dir(); - debug!("Temporary directory: {}", &temp_dir.path().display()); + debug!("Bootstrap directory: {}", &temp_dir.as_path().display()); - write_bootstrap_files(temp_dir.path()); + write_bootstrap_files(temp_dir.as_path()); - let bootstrap_rlibs = build_bootstrap(temp_dir.path(), &plugin_target_dir.join("bootstrap")); + let bootstrap_rlibs = build_bootstrap(temp_dir.as_path(), &plugin_target_dir.join("bootstrap")); if bootstrap_rlibs.len() == BOOTSTRAP_DEPS.len() { let extern_args = bootstrap_rlibs @@ -195,20 +211,50 @@ fn build_bootstrap( let mut cmd = Command::new("cargo") .current_dir(temp_dir) .stdout(Stdio::piped()) + .stderr(Stdio::piped()) .args(["build", "--message-format=json"]) .spawn() .unwrap(); + info!( + "cd {} && cargo build --message-format=json", + temp_dir.display() + ); + let reader = std::io::BufReader::new(cmd.stdout.take().unwrap()); + let err_reader = std::io::BufReader::new(cmd.stderr.take().unwrap()); std::fs::create_dir_all(cache_dir).unwrap(); let mut bootstrap_rlibs = HashMap::with_capacity(BOOTSTRAP_DEPS.len()); for msg in cargo_metadata::Message::parse_stream(reader) { - if let cargo_metadata::Message::CompilerArtifact(artifact) = msg.unwrap() { + let msg = msg.unwrap(); + if let cargo_metadata::Message::CompilerArtifact(artifact) = msg { for artifact in artifact.filenames.into_iter() { process_artifact(artifact, &mut bootstrap_rlibs); } + } else { + match msg { + cargo_metadata::Message::BuildFinished(finished) => { + if !finished.success { + error!("Bootstrapping crate failed to build artifact"); + } + } + cargo_metadata::Message::TextLine(t) => { + info!("{t}"); + } + cargo_metadata::Message::CompilerMessage(msg) => { + info!("{msg}"); + } + _ => {} + } + } + } + for msg in err_reader.lines() { + if let Ok(line) = msg { + info!("{line}"); + } else { + panic!("Failed to read cargo stderr"); } } @@ -224,10 +270,17 @@ fn build_bootstrap( std::fs::copy(path, dest).unwrap(); } } + match cmd.wait() { + Ok(status) => { + if !status.success() { + panic!("Building bootstrap crate returned a failure status code"); + } + } + Err(e) => { + panic!("Failed to wait on cargo build process: {}", e); + } + } - if !cmd.wait().unwrap().success() { - panic!("Building bootstrap crate returned a failure status code"); - }; bootstrap_rlibs } @@ -248,6 +301,28 @@ fn process_artifact( } } +/// finds best location for bootstrapping crate +/// this will be the nearest target/bevy_api_gen_bootstrap directory +fn find_bootstrap_dir() -> PathBuf { + let mut path = env::current_dir().unwrap(); + loop { + if path.join("target").exists() { + break; + } else if let Some(parent) = path.parent() { + path = parent.to_path_buf(); + } else { + panic!("Could not find `target` directory"); + } + } + + path.push("target"); + path.push("bevy_api_gen_bootstrap"); + + // create all the directories + create_dir_all(&path).unwrap(); + path +} + /// Generate bootstrapping crate files fn write_bootstrap_files(path: &Path) { // write manifest file 'Cargo.toml' diff --git a/crates/bevy_api_gen/src/callback.rs b/crates/bevy_api_gen/src/callback.rs index 6174de20..a762ed76 100644 --- a/crates/bevy_api_gen/src/callback.rs +++ b/crates/bevy_api_gen/src/callback.rs @@ -42,7 +42,7 @@ impl rustc_driver::Callbacks for BevyAnalyzerCallbacks { .. } = &self.args.cmd { - templates_dir = templates.to_owned(); + templates.clone_into(&mut templates_dir); if let Some(meta_output) = meta_output { meta_dirs.push(meta_output.to_owned()) }; diff --git a/crates/bevy_api_gen/src/feature_graph.rs b/crates/bevy_api_gen/src/feature_graph.rs index 33b491ee..4e08c29b 100644 --- a/crates/bevy_api_gen/src/feature_graph.rs +++ b/crates/bevy_api_gen/src/feature_graph.rs @@ -1,12 +1,14 @@ use std::collections::{HashMap, HashSet}; -use cargo_metadata::{Metadata, Package}; +use cargo_metadata::{DependencyKind, Metadata, Package}; use itertools::{Either, Itertools}; +use log::debug; #[derive(Clone, Debug)] pub enum FeatureEffect { /// A feature which enables another feature /// in a dependency + /// if enable_optional is true, the dependency may not itself be enabled in which case the feature is not enabled EnableDepFeature { feature: String, dependency: String, @@ -53,8 +55,8 @@ pub enum Depdenency { #[derive(Debug)] pub struct FeatureGraph { - workspace_root: String, - crates: Vec, + pub workspace_root: String, + pub crates: Vec, } impl FeatureGraph { @@ -72,7 +74,7 @@ impl FeatureGraph { .find(|c| c.name == self.workspace_root) .unwrap(); let mut buffer = Default::default(); - self.dependencies_for_features_on_crate(root, features, include_default, &mut buffer); + self.dependencies_for_features_on_crate(root, features, include_default, &mut buffer, 0); buffer.iter().map(|c| c.name.as_str()).collect() } @@ -83,7 +85,18 @@ impl FeatureGraph { features: &[String], include_default: bool, buffer: &mut HashSet<&'a Crate>, + depth: usize, ) { + let log_prefix = "|".to_owned() + &"-".repeat(depth); + debug!( + "{log_prefix}Processing dependencies for crate: `{}` with features: {}", + crate_.name, + features.join(", ") + ); + if depth > 30 { + panic!("Recursion depth exceeded"); + } + let active_features = features .iter() .map(|f| { @@ -106,6 +119,7 @@ impl FeatureGraph { dependency, enable_optional, } => { + // we ignore optional dependencies's features, is this what we want to do? if *enable_optional { deps.entry(self.crates.iter().find(|c| c.name == *dependency).unwrap()) .or_default() @@ -129,10 +143,26 @@ impl FeatureGraph { })); // repeat for all dependencies recursively + // we also ignore optional dependencies here, again is this what we want to do? I can't remember for (dep, features) in deps.iter() { + debug!( + "{log_prefix}Adding dependency: {} with features {:?}", + dep.name, features + ); buffer.insert(dep); - self.dependencies_for_features_on_crate(dep, features, include_default, buffer); + self.dependencies_for_features_on_crate( + dep, + features, + include_default, + buffer, + depth + 1, + ); } + + debug!( + "{log_prefix}Finished processing dependencies for crate: `{}`", + crate_.name + ); } /// "flattens" feature effects to a list of effects based on the selected active features, features which enable other features are expanded until @@ -182,6 +212,7 @@ impl FeatureGraph { let (optional_dependencies, other_dependencies) = meta .dependencies .iter() + .filter(|d| d.kind == DependencyKind::Normal) // dev dependencies can introduce weird cycles, and we don't care about them anyway .map(|f| (f.name.clone(), f.optional)) .partition_map(|(name, opt)| { if opt { diff --git a/crates/bevy_api_gen/src/modifying_file_loader.rs b/crates/bevy_api_gen/src/modifying_file_loader.rs index 0f492192..a8c01d85 100644 --- a/crates/bevy_api_gen/src/modifying_file_loader.rs +++ b/crates/bevy_api_gen/src/modifying_file_loader.rs @@ -21,12 +21,23 @@ impl FileLoader for ModifyingFileLoader { path.to_str().unwrap() ); RealFileLoader.read_file(path).map(|mut f| { - if !f.contains("extern crate mlua") { - f.push_str("#[allow(unused_extern_crates)] extern crate mlua;"); - } - if !f.contains("extern crate bevy_reflect") { - f.push_str("#[allow(unused_extern_crates)] extern crate bevy_reflect;"); + // we make it pub so in case we are re-exporting this crate we won't run into private re-export issues + + for crate_ in &["bevy_reflect", "mlua"] { + if !f.contains(&format!("extern crate {crate_}")) { + if f.contains(&format!("pub use {crate_}")) { + f.push_str(&format!( + "#[allow(unused_extern_crates)] pub extern crate {crate_};" + )); + } else { + // this causes issues in proc macros so let's make it private where we can + f.push_str(&format!( + "#[allow(unused_extern_crates)] extern crate {crate_};" + )); + } + } } + f }) } else { diff --git a/crates/bevy_api_gen/src/passes/cache_traits.rs b/crates/bevy_api_gen/src/passes/cache_traits.rs index b4e5cf01..bdbd9568 100644 --- a/crates/bevy_api_gen/src/passes/cache_traits.rs +++ b/crates/bevy_api_gen/src/passes/cache_traits.rs @@ -31,11 +31,6 @@ pub(crate) fn cache_traits(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool { ctxt.cached_traits .std_source_traits .insert(def_path_str.to_string(), trait_did); - } else if STD_SOURCE_TRAITS.contains(&def_path_str.as_str()) { - trace!("found misc trait def id: {trait_did:?}"); - ctxt.cached_traits - .std_source_traits - .insert(def_path_str.to_string(), trait_did); } } 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 9046dadd..ab016de1 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 @@ -3,7 +3,7 @@ use log::{info, trace}; use rustc_ast::Attribute; use rustc_hir::{ def_id::{DefId, LOCAL_CRATE}, - Unsafety, + Safety, }; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::ty::{AdtKind, AssocKind, FieldDef, FnSig, ParamEnv, Ty, TyCtxt, TyKind}; @@ -135,7 +135,7 @@ pub(crate) fn find_methods_and_fields(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> } }; - let is_unsafe = sig.unsafety == Unsafety::Unsafe; + let is_unsafe = sig.safety == Safety::Unsafe; if trait_did.is_none() && !ctxt.tcx.visibility(fn_did).is_public() { log::info!( diff --git a/crates/bevy_api_gen/src/passes/find_reflect_types.rs b/crates/bevy_api_gen/src/passes/find_reflect_types.rs index 2f9b5a7b..f808922c 100644 --- a/crates/bevy_api_gen/src/passes/find_reflect_types.rs +++ b/crates/bevy_api_gen/src/passes/find_reflect_types.rs @@ -44,7 +44,8 @@ pub(crate) fn find_reflect_types(ctxt: &mut BevyCtxt<'_>, args: &Args) -> bool { // only non parametrized simple types are allowed, i.e. "MyStruct" is allowed but "MyStruct" isn't generics.count() == 0 && self_ty.def().is_some_and(|did| { - if ignored_types.contains(&format!("{}::{}",ctxt.tcx.crate_name(LOCAL_CRATE),ctxt.tcx.item_name(did))) { + let short_form = format!("{}::{}",ctxt.tcx.crate_name(LOCAL_CRATE),ctxt.tcx.item_name(did)); + if ignored_types.contains(&short_form) || ignored_types.contains(&tcx.def_path_str(did)) { info!("Ignoring type: {:?}", tcx.def_path_str(did)); return false; }; diff --git a/crates/bevy_mod_scripting_common/src/input.rs b/crates/bevy_mod_scripting_common/src/input.rs index 57aaac37..4ba284dd 100644 --- a/crates/bevy_mod_scripting_common/src/input.rs +++ b/crates/bevy_mod_scripting_common/src/input.rs @@ -1,3 +1,4 @@ +#![allow(clippy::manual_unwrap_or_default)] // from darling use darling::{util::Flag, FromDeriveInput, FromMeta}; use proc_macro2::Ident; use quote::format_ident; @@ -94,6 +95,7 @@ pub struct ProxyType { /// - Result /// - Vec /// - Tuple +/// /// This type helps us destructure these patterns and unwrap/wrap proxies fully without dealing with the full syn::Type enum #[derive(Debug, Clone)] pub enum SimpleType { @@ -537,6 +539,8 @@ 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/src/lib.rs b/crates/bevy_mod_scripting_core/src/lib.rs index 617571c8..2022dad3 100644 --- a/crates/bevy_mod_scripting_core/src/lib.rs +++ b/crates/bevy_mod_scripting_core/src/lib.rs @@ -57,7 +57,7 @@ impl GenDocumentation for App { #[cfg(any(debug_assertions, feature = "doc_always"))] { info!("Generating documentation"); - let w = &mut self.world; + let w = &mut self.world_mut(); let providers: &APIProviders = w.resource(); if let Err(e) = providers.gen_all() { error!("{}", e); @@ -137,7 +137,7 @@ impl AddScriptApiProvider for App { >, ) -> &mut Self { provider.register_with_app(self); - let w = &mut self.world; + let w = &mut self.world_mut(); let providers: &mut APIProviders = &mut w.resource_mut(); providers.providers.push(provider); self diff --git a/crates/bevy_script_api/Cargo.toml b/crates/bevy_script_api/Cargo.toml index 4f069e48..e50521fd 100644 --- a/crates/bevy_script_api/Cargo.toml +++ b/crates/bevy_script_api/Cargo.toml @@ -27,8 +27,9 @@ bevy = { workspace = true, default-features = false, features = [ "bevy_text", "bevy_sprite", "file_watcher", - "multi-threaded", + "multi_threaded", ] } +uuid = "1.10" bevy_mod_scripting_core = { workspace = true } parking_lot = "0.12.1" paste = "1.0.7" diff --git a/crates/bevy_script_api/src/common/bevy/mod.rs b/crates/bevy_script_api/src/common/bevy/mod.rs index bb5bb7d2..ba45a35b 100644 --- a/crates/bevy_script_api/src/common/bevy/mod.rs +++ b/crates/bevy_script_api/src/common/bevy/mod.rs @@ -4,8 +4,7 @@ use bevy::{ ecs::{ component::ComponentId, query::QueryBuilder, - system::Command, - world::{EntityRef, World}, + world::{Command, EntityRef, World}, }, prelude::{ AppTypeRegistry, BuildWorldChildren, Children, DespawnChildrenRecursive, DespawnRecursive, diff --git a/crates/bevy_script_api/src/common/std.rs b/crates/bevy_script_api/src/common/std.rs index dcf85073..0f4c929c 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, TypePath}; +use bevy::reflect::{FromReflect, GetTypeRegistration, TypePath}; use crate::{error::ReflectionError, ReflectReference, ValueIndex}; @@ -26,7 +26,9 @@ impl std::fmt::Debug for ScriptVec { } } -impl std::fmt::Display for ScriptVec { +impl std::fmt::Display + for ScriptVec +{ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let str = self .ref_ @@ -39,7 +41,7 @@ impl std::fmt::Display for Script } } -impl ScriptVec { +impl ScriptVec { pub fn new_ref(ref_: ReflectReference) -> Self { Self { ref_, @@ -116,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/mod.rs b/crates/bevy_script_api/src/lua/mod.rs index 08bcb30b..5338fb9c 100644 --- a/crates/bevy_script_api/src/lua/mod.rs +++ b/crates/bevy_script_api/src/lua/mod.rs @@ -42,7 +42,7 @@ impl RegisterForeignLuaType for App { &mut self, ) -> &mut Self { { - let registry = self.world.resource_mut::(); + let registry = self.world_mut().resource_mut::(); let mut registry = registry.write(); let user_data = >::from_type(); diff --git a/crates/bevy_script_api/src/lua/std.rs b/crates/bevy_script_api/src/lua/std.rs index fc36faec..6dddbe93 100644 --- a/crates/bevy_script_api/src/lua/std.rs +++ b/crates/bevy_script_api/src/lua/std.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use bevy::reflect::FromReflect; use bevy::reflect::Reflect; -use bevy::reflect::TypePath; +use bevy::reflect::{GetTypeRegistration, TypePath}; use bevy_mod_scripting_lua::tealr; use bevy_mod_scripting_lua::tealr::ToTypename; @@ -99,8 +99,15 @@ impl<'lua> IntoLuaProxy<'lua> for String { } } -impl FromLuaProxy<'a> + Clone> - LuaProxyable for Option +impl< + T: LuaProxyable + + Reflect + + FromReflect + + GetTypeRegistration + + TypePath + + for<'a> FromLuaProxy<'a> + + Clone, + > LuaProxyable for Option { fn ref_to_lua(self_: ReflectReference, lua: &Lua) -> mlua::Result { self_.get_typed(|s: &Option| match s { @@ -236,6 +243,7 @@ pub type LuaVec = ScriptVec; impl< T: ToTypename + FromReflect + + GetTypeRegistration + TypePath + LuaProxyable + for<'a> FromLuaProxy<'a> @@ -263,6 +271,7 @@ impl ToTypename for LuaVec { impl< T: ToTypename + FromReflect + + GetTypeRegistration + TypePath + LuaProxyable + for<'a> FromLuaProxy<'a> @@ -282,6 +291,7 @@ impl< impl< T: ToTypename + FromReflect + + GetTypeRegistration + TypePath + LuaProxyable + for<'a> FromLuaProxy<'a> @@ -371,6 +381,7 @@ impl< impl< T: ToTypename + FromReflect + + GetTypeRegistration + TypePath + LuaProxyable + for<'a> FromLuaProxy<'a> @@ -432,6 +443,7 @@ impl< + for<'a> IntoLuaProxy<'a> + Clone + FromReflect + + GetTypeRegistration + TypePath + LuaProxyable + std::fmt::Debug, diff --git a/crates/bevy_script_api/src/lua/util.rs b/crates/bevy_script_api/src/lua/util.rs index 1221e2e9..2a96a3e5 100644 --- a/crates/bevy_script_api/src/lua/util.rs +++ b/crates/bevy_script_api/src/lua/util.rs @@ -299,6 +299,10 @@ 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> { + panic!("This should never be called, I am a dummy implementation"); + } + fn into_any(self: Box) -> Box { panic!("This should never be called, I am a dummy implementation"); } @@ -358,6 +362,12 @@ macro_rules! impl_tealr_generic{ } } + impl ::bevy::reflect::GetTypeRegistration for $name { + fn get_type_registration() -> bevy::reflect::TypeRegistration { + panic!("This should never be called, I am a dummy implementation"); + } + } + $crate::impl_tealr_type!($name); $crate::impl_from_lua_with_clone!($name); } diff --git a/crates/bevy_script_api/src/providers/bevy_core.rs b/crates/bevy_script_api/src/providers/bevy_core.rs index f205ff73..762e6fb7 100644 --- a/crates/bevy_script_api/src/providers/bevy_core.rs +++ b/crates/bevy_script_api/src/providers/bevy_core.rs @@ -14,12 +14,6 @@ use bevy_script_api::{ remote = "bevy::core::prelude::Name", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::core::prelude::Name; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -28,6 +22,12 @@ use bevy_script_api::{ )] fn eq(&self, #[proxy] other: &name::Name) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::core::prelude::Name; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] diff --git a/crates/bevy_script_api/src/providers/bevy_ecs.rs b/crates/bevy_script_api/src/providers/bevy_ecs.rs index a05a4b0a..465b5fa8 100644 --- a/crates/bevy_script_api/src/providers/bevy_ecs.rs +++ b/crates/bevy_script_api/src/providers/bevy_ecs.rs @@ -21,12 +21,6 @@ use bevy_script_api::{ )] fn eq(&self, #[proxy] other: &entity::Entity) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::entity::Entity; - "#, r#" /// Creates a new entity ID with the specified `index` and a generation of 1. @@ -81,16 +75,31 @@ use bevy_script_api::{ #[lua(kind = "Method")] fn generation(self) -> u32; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::entity::Entity; + "#, 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[])] +struct OnAdd {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy(derive(), remote = "bevy::ecs::world::OnInsert", functions[])] +struct OnInsert {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy(derive(), remote = "bevy::ecs::world::OnRemove", functions[])] +struct OnRemove {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::ecs::component::ComponentId", @@ -109,12 +118,6 @@ struct Entity {} #[lua(kind = "Method")] fn index(self) -> usize; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" @@ -132,6 +135,12 @@ struct Entity {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::ecs::component::ComponentId; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -147,14 +156,19 @@ 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; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &component::Tick) -> bool; "#, 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::ecs::component::Tick; "#, r#" @@ -194,13 +208,8 @@ struct ComponentId(); "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &component::Tick) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -222,7 +231,8 @@ struct Tick {} "#, r#" -/// Returns `true` if the component or resource was added after the system last ran. +/// Returns `true` if the component or resource was added after the system last ran +/// (or the system is running for the first time). #[lua(kind = "Method")] fn is_added( @@ -235,7 +245,8 @@ struct Tick {} "#, r#" -/// Returns `true` if the component or resource was added or mutably dereferenced after the system last ran. +/// Returns `true` if the component or resource was added or mutably dereferenced after the system last ran +/// (or the system is running for the first time). #[lua(kind = "Method")] fn is_changed( @@ -287,6 +298,66 @@ fn index(&self) -> String { )] struct ComponentTicks {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::ecs::identifier::Identifier", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + 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`]. + + #[lua(kind = "Method")] + fn low(self) -> u32; + +"#, + r#" +/// Returns the masked value of the high segment of the [`Identifier`]. +/// Does not include the flag bits. + + #[lua(kind = "Method")] + fn masked_high(self) -> u32; + +"#, + r#" +/// Convert the [`Identifier`] into a `u64`. + + #[lua(kind = "Method")] + fn to_bits(self) -> u64; + +"#, + r#" +/// Convert a `u64` into an [`Identifier`]. +/// # Panics +/// This method will likely panic if given `u64` values that did not come from [`Identifier::to_bits`]. + + #[lua(kind = "Function", output(proxy))] + fn from_bits(value: u64) -> bevy::ecs::identifier::Identifier; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Identifier {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::ecs::entity::EntityHash", @@ -320,6 +391,11 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { "Tick", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, )?; + instances + .add_instance( + "Identifier", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; Ok(()) } } @@ -349,6 +425,9 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider { .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, >() + .process_type::() + .process_type::() + .process_type::() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< @@ -360,6 +439,12 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider { bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, >() .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaIdentifier, + >, + >() .process_type::() }, ), @@ -382,9 +467,13 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider { } 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::(); } } diff --git a/crates/bevy_script_api/src/providers/bevy_input.rs b/crates/bevy_script_api/src/providers/bevy_input.rs index 14f70d41..d06224cc 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_math::*; extern crate self as bevy_script_api; use bevy_script_api::{ lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, @@ -13,16 +14,15 @@ use bevy_script_api::{ derive(clone), remote = "bevy::input::gamepad::Gamepad", functions[r#" -/// Creates a new [`Gamepad`]. - #[lua(kind = "Function", output(proxy))] - fn new(id: usize) -> bevy::input::gamepad::Gamepad; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, 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::gamepad::Gamepad; "#, r#" @@ -37,9 +37,10 @@ use bevy_script_api::{ "#, r#" +/// Creates a new [`Gamepad`]. - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::Gamepad; + #[lua(kind = "Function", output(proxy))] + fn new(id: usize) -> bevy::input::gamepad::Gamepad; "#, r#" @@ -58,18 +59,6 @@ struct Gamepad { 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#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -99,6 +88,18 @@ struct Gamepad { axis_type: bevy::input::gamepad::GamepadAxisType, ) -> bevy::input::gamepad::GamepadAxis; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadAxis; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -119,6 +120,12 @@ struct GamepadAxis { remote = "bevy::input::gamepad::GamepadAxisType", 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", @@ -133,12 +140,6 @@ struct GamepadAxis { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::gamepad::GamepadAxisType; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -165,14 +166,14 @@ struct GamepadAxisType {} "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButton; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, 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::gamepad::GamepadButton; "#, r#" @@ -215,17 +216,6 @@ struct GamepadButton { remote = "bevy::input::gamepad::GamepadButtonType", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadButtonType) -> bool; - -"#, - r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::gamepad::GamepadButtonType; @@ -235,6 +225,17 @@ struct GamepadButton { #[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; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -250,8 +251,8 @@ struct GamepadButtonType {} remote = "bevy::input::keyboard::KeyCode", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::KeyCode; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -267,8 +268,8 @@ struct GamepadButtonType {} "#, 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::KeyCode; "#, r#" @@ -285,6 +286,12 @@ 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", @@ -293,12 +300,6 @@ 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#" @@ -320,6 +321,12 @@ struct MouseButton {} remote = "bevy::input::touch::TouchInput", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touch::TouchInput; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -328,12 +335,6 @@ struct MouseButton {} )] fn eq(&self, #[proxy] other: &touch::TouchInput) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touch::TouchInput; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -355,9 +356,15 @@ struct TouchInput { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::keyboard::Key", + 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) -> (); @@ -370,13 +377,7 @@ struct TouchInput { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &keyboard::Key) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::Key; + fn eq(&self, #[proxy] other: &keyboard::KeyboardFocusLost) -> bool; "#, r#" @@ -386,7 +387,7 @@ fn index(&self) -> String { } "#] )] -struct Key {} +struct KeyboardFocusLost {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), @@ -404,14 +405,14 @@ struct Key {} "#, 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#" - #[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#" @@ -434,17 +435,17 @@ struct KeyboardInput { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::keyboard::NativeKey", + remote = "bevy::input::mouse::MouseButtonInput", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::NativeKey; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, 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::mouse::MouseButtonInput; "#, r#" @@ -455,7 +456,7 @@ struct KeyboardInput { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &keyboard::NativeKey) -> bool; + fn eq(&self, #[proxy] other: &mouse::MouseButtonInput) -> bool; "#, r#" @@ -465,32 +466,33 @@ fn index(&self) -> String { } "#] )] -struct NativeKey {} +struct MouseButtonInput { + #[lua(output(proxy))] + button: bevy::input::mouse::MouseButton, + #[lua(output(proxy))] + state: bevy::input::ButtonState, + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::keyboard::NativeKeyCode", + remote = "bevy::input::mouse::MouseMotion", 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", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &keyboard::NativeKeyCode) -> bool; + fn eq(&self, #[proxy] other: &mouse::MouseMotion) -> bool; "#, 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::mouse::MouseMotion; "#, r#" @@ -500,15 +502,18 @@ fn index(&self) -> String { } "#] )] -struct NativeKeyCode {} +struct MouseMotion { + #[lua(output(proxy))] + delta: bevy::math::Vec2, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::mouse::MouseButtonInput", + remote = "bevy::input::mouse::MouseWheel", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseButtonInput; + fn clone(&self) -> bevy::input::mouse::MouseWheel; "#, r#" @@ -519,13 +524,7 @@ struct NativeKeyCode {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &mouse::MouseButtonInput) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + fn eq(&self, #[proxy] other: &mouse::MouseWheel) -> bool; "#, r#" @@ -535,22 +534,22 @@ fn index(&self) -> String { } "#] )] -struct MouseButtonInput { - #[lua(output(proxy))] - button: bevy::input::mouse::MouseButton, +struct MouseWheel { #[lua(output(proxy))] - state: bevy::input::ButtonState, + unit: bevy::input::mouse::MouseScrollUnit, + x: f32, + y: f32, #[lua(output(proxy))] window: bevy::ecs::entity::Entity, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::mouse::MouseMotion", + remote = "bevy::input::gamepad::GamepadAxisChangedEvent", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseMotion; + fn clone(&self) -> bevy::input::gamepad::GamepadAxisChangedEvent; "#, r#" @@ -561,7 +560,20 @@ struct MouseButtonInput { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &mouse::MouseMotion) -> bool; + fn eq(&self, #[proxy] other: &gamepad::GamepadAxisChangedEvent) -> bool; + +"#, + r#" +/// Creates a [`GamepadAxisChangedEvent`]. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::input::gamepad::Gamepad, + #[proxy] + axis_type: bevy::input::gamepad::GamepadAxisType, + value: f32, + ) -> bevy::input::gamepad::GamepadAxisChangedEvent; "#, r#" @@ -571,35 +583,45 @@ fn index(&self) -> String { } "#] )] -struct MouseMotion { +struct GamepadAxisChangedEvent { #[lua(output(proxy))] - delta: bevy::math::Vec2, + gamepad: bevy::input::gamepad::Gamepad, + #[lua(output(proxy))] + axis_type: bevy::input::gamepad::GamepadAxisType, + value: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::mouse::MouseScrollUnit", + remote = "bevy::input::gamepad::GamepadButtonChangedEvent", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadButtonChangedEvent; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", composite = "eq", metamethod = "Eq", )] - 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; + fn eq(&self, #[proxy] other: &gamepad::GamepadButtonChangedEvent) -> bool; "#, r#" +/// Creates a [`GamepadButtonChangedEvent`]. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[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#" @@ -609,15 +631,27 @@ fn index(&self) -> String { } "#] )] -struct MouseScrollUnit {} +struct GamepadButtonChangedEvent { + #[lua(output(proxy))] + gamepad: bevy::input::gamepad::Gamepad, + #[lua(output(proxy))] + button_type: bevy::input::gamepad::GamepadButtonType, + value: f32, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::mouse::MouseWheel", + remote = "bevy::input::gamepad::GamepadButtonInput", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseWheel; + fn clone(&self) -> bevy::input::gamepad::GamepadButtonInput; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -628,7 +662,7 @@ struct MouseScrollUnit {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &mouse::MouseWheel) -> bool; + fn eq(&self, #[proxy] other: &gamepad::GamepadButtonInput) -> bool; "#, r#" @@ -638,22 +672,20 @@ fn index(&self) -> String { } "#] )] -struct MouseWheel { +struct GamepadButtonInput { #[lua(output(proxy))] - unit: bevy::input::mouse::MouseScrollUnit, - x: f32, - y: f32, + button: bevy::input::gamepad::GamepadButton, #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, + state: bevy::input::ButtonState, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::touch::ForceTouch", + remote = "bevy::input::gamepad::GamepadConnectionEvent", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touch::ForceTouch; + fn clone(&self) -> bevy::input::gamepad::GamepadConnectionEvent; "#, r#" @@ -664,7 +696,33 @@ struct MouseWheel { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &touch::ForceTouch) -> bool; + fn eq(&self, #[proxy] other: &gamepad::GamepadConnectionEvent) -> bool; + +"#, + r#" +/// Creates a [`GamepadConnectionEvent`]. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::input::gamepad::Gamepad, + #[proxy] + connection: bevy::input::gamepad::GamepadConnection, + ) -> bevy::input::gamepad::GamepadConnectionEvent; + +"#, + r#" +/// Is the gamepad connected? + + #[lua(kind = "Method")] + fn connected(&self) -> bool; + +"#, + r#" +/// Is the gamepad disconnected? + + #[lua(kind = "Method")] + fn disconnected(&self) -> bool; "#, r#" @@ -674,32 +732,82 @@ fn index(&self) -> String { } "#] )] -struct ForceTouch {} +struct GamepadConnectionEvent { + #[lua(output(proxy))] + gamepad: bevy::input::gamepad::Gamepad, + #[lua(output(proxy))] + connection: bevy::input::gamepad::GamepadConnection, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::touch::TouchPhase", + remote = "bevy::input::gamepad::GamepadEvent", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadEvent; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &touch::TouchPhase) -> bool; + fn eq(&self, #[proxy] other: &gamepad::GamepadEvent) -> bool; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct GamepadEvent {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "bevy::input::gamepad::GamepadSettings", + functions[r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +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), + remote = "bevy::input::gestures::PinchGesture", + functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touch::TouchPhase; + fn clone(&self) -> bevy::input::gestures::PinchGesture; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gestures::PinchGesture) -> bool; "#, r#" @@ -709,11 +817,11 @@ fn index(&self) -> String { } "#] )] -struct TouchPhase {} +struct PinchGesture(f32); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::touchpad::TouchpadMagnify", + remote = "bevy::input::gestures::RotationGesture", functions[r#" #[lua( @@ -722,13 +830,13 @@ struct TouchPhase {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &touchpad::TouchpadMagnify) -> bool; + fn eq(&self, #[proxy] other: &gestures::RotationGesture) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touchpad::TouchpadMagnify; + fn clone(&self) -> bevy::input::gestures::RotationGesture; "#, r#" @@ -738,11 +846,11 @@ fn index(&self) -> String { } "#] )] -struct TouchpadMagnify(f32); +struct RotationGesture(f32); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::touchpad::TouchpadRotate", + remote = "bevy::input::gestures::DoubleTapGesture", functions[r#" #[lua( @@ -751,13 +859,42 @@ struct TouchpadMagnify(f32); composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &touchpad::TouchpadRotate) -> bool; + fn eq(&self, #[proxy] other: &gestures::DoubleTapGesture) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touchpad::TouchpadRotate; + fn clone(&self) -> bevy::input::gestures::DoubleTapGesture; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct DoubleTapGesture {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + 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", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gestures::PanGesture) -> bool; "#, r#" @@ -767,7 +904,152 @@ fn index(&self) -> String { } "#] )] -struct TouchpadRotate(f32); +struct PanGesture(#[lua(output(proxy))] bevy::math::Vec2); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + 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) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &ButtonState) -> bool; + +"#, + r#" +/// Is this button pressed? + + #[lua(kind = "Method")] + fn is_pressed(&self) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct ButtonState {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::gamepad::GamepadInfo", + 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; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadInfo; + +"#, + 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. + + #[lua(kind = "Method")] + fn is_pressed(&self, value: f32) -> bool; + +"#, + r#" +/// Returns `true` if the button is released. +/// A button is considered released if the `value` passed is lower than or equal to the release threshold. + + #[lua(kind = "Method")] + fn is_released(&self, value: f32) -> bool; + +"#, + r#" +/// Get the button input threshold above which the button is considered pressed. + + #[lua(kind = "Method")] + fn press_threshold(&self) -> f32; + +"#, + r#" +/// Try to set the button input threshold above which the button is considered pressed. +/// If the value passed is outside the range [release threshold..=1.0], the value will not be changed. +/// Returns the new value of the press threshold. + + #[lua(kind = "MutatingMethod")] + fn set_press_threshold(&mut self, value: f32) -> f32; + +"#, + r#" +/// Get the button input threshold below which the button is considered released. + + #[lua(kind = "Method")] + fn release_threshold(&self) -> f32; + +"#, + r#" +/// Try to set the button input threshold below which the button is considered released. If the +/// value passed is outside the range [0.0..=press threshold], the value will not be changed. +/// Returns the new value of the release threshold. + + #[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")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct ButtonSettings {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), @@ -902,138 +1184,26 @@ fn index(&self) -> String { )] struct AxisSettings {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - 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. - - #[lua(kind = "Method")] - fn filter( - &self, - new_value: f32, - old_value: std::option::Option, - ) -> std::option::Option; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct ButtonAxisSettings { - high: f32, - low: f32, - threshold: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::ButtonSettings", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::ButtonSettings; - -"#, - 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. - - #[lua(kind = "Method")] - fn is_pressed(&self, value: f32) -> bool; - -"#, - r#" -/// Returns `true` if the button is released. -/// A button is considered released if the `value` passed is lower than or equal to the release threshold. - - #[lua(kind = "Method")] - fn is_released(&self, value: f32) -> bool; - -"#, - r#" -/// Get the button input threshold above which the button is considered pressed. - - #[lua(kind = "Method")] - fn press_threshold(&self) -> f32; - -"#, - r#" -/// Try to set the button input threshold above which the button is considered pressed. -/// If the value passed is outside the range [release threshold..=1.0], the value will not be changed. -/// Returns the new value of the press threshold. - - #[lua(kind = "MutatingMethod")] - fn set_press_threshold(&mut self, value: f32) -> f32; - -"#, - r#" -/// Get the button input threshold below which the button is considered released. - - #[lua(kind = "Method")] - fn release_threshold(&self) -> f32; - -"#, - r#" -/// Try to set the button input threshold below which the button is considered released. If the -/// value passed is outside the range [0.0..=press threshold], the value will not be changed. -/// Returns the new value of the release threshold. - - #[lua(kind = "MutatingMethod")] - fn set_release_threshold(&mut self, value: f32) -> f32; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct ButtonSettings {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadAxisChangedEvent", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadAxisChangedEvent) -> bool; - -"#, - r#" +#[proxy( + derive(clone), + remote = "bevy::input::gamepad::ButtonAxisSettings", + functions[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. - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadAxisChangedEvent; + #[lua(kind = "Method")] + fn filter( + &self, + new_value: f32, + old_value: std::option::Option, + ) -> std::option::Option; "#, r#" -/// Creates a [`GamepadAxisChangedEvent`]. - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - axis_type: bevy::input::gamepad::GamepadAxisType, - value: f32, - ) -> bevy::input::gamepad::GamepadAxisChangedEvent; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::ButtonAxisSettings; "#, r#" @@ -1043,21 +1213,19 @@ fn index(&self) -> String { } "#] )] -struct GamepadAxisChangedEvent { - #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] - axis_type: bevy::input::gamepad::GamepadAxisType, - value: f32, +struct ButtonAxisSettings { + high: f32, + low: f32, + threshold: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadButtonChangedEvent", + remote = "bevy::input::gamepad::GamepadConnection", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonChangedEvent; + fn clone(&self) -> bevy::input::gamepad::GamepadConnection; "#, r#" @@ -1068,20 +1236,7 @@ struct GamepadAxisChangedEvent { composite = "eq", metamethod = "Eq", )] - 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; + fn eq(&self, #[proxy] other: &gamepad::GamepadConnection) -> bool; "#, r#" @@ -1091,38 +1246,32 @@ fn index(&self) -> String { } "#] )] -struct GamepadButtonChangedEvent { - #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] - button_type: bevy::input::gamepad::GamepadButtonType, - value: f32, -} +struct GamepadConnection {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadButtonInput", + 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", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadButtonInput) -> bool; + 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#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonInput; + fn clone(&self) -> bevy::input::keyboard::Key; "#, r#" @@ -1132,20 +1281,15 @@ fn index(&self) -> String { } "#] )] -struct GamepadButtonInput { - #[lua(output(proxy))] - button: bevy::input::gamepad::GamepadButton, - #[lua(output(proxy))] - state: bevy::input::ButtonState, -} +struct Key {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadConnection", + remote = "bevy::input::keyboard::NativeKeyCode", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadConnection; + fn clone(&self) -> bevy::input::keyboard::NativeKeyCode; "#, r#" @@ -1156,7 +1300,13 @@ struct GamepadButtonInput { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadConnection) -> bool; + fn eq(&self, #[proxy] other: &keyboard::NativeKeyCode) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -1166,52 +1316,32 @@ fn index(&self) -> String { } "#] )] -struct GamepadConnection {} +struct NativeKeyCode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadConnectionEvent", + remote = "bevy::input::keyboard::NativeKey", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::NativeKey; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadConnectionEvent) -> bool; - -"#, - r#" -/// Creates a [`GamepadConnectionEvent`]. - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - connection: bevy::input::gamepad::GamepadConnection, - ) -> bevy::input::gamepad::GamepadConnectionEvent; - -"#, - r#" -/// Is the gamepad connected? - - #[lua(kind = "Method")] - fn connected(&self) -> bool; - -"#, - r#" -/// Is the gamepad disconnected? - - #[lua(kind = "Method")] - fn disconnected(&self) -> bool; + fn eq(&self, #[proxy] other: &keyboard::NativeKey) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadConnectionEvent; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -1221,31 +1351,32 @@ fn index(&self) -> String { } "#] )] -struct GamepadConnectionEvent { - #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] - connection: bevy::input::gamepad::GamepadConnection, -} +struct NativeKey {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadEvent", + remote = "bevy::input::mouse::MouseScrollUnit", 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::GamepadEvent) -> bool; + fn eq(&self, #[proxy] other: &mouse::MouseScrollUnit) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadEvent; + fn clone(&self) -> bevy::input::mouse::MouseScrollUnit; "#, r#" @@ -1255,41 +1386,12 @@ fn index(&self) -> String { } "#] )] -struct GamepadEvent {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(), - remote = "bevy::input::gamepad::GamepadSettings", - functions[r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -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, -} +struct MouseScrollUnit {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::ButtonState", + remote = "bevy::input::touch::TouchPhase", functions[r#" -/// Is this button pressed? - - #[lua(kind = "Method")] - fn is_pressed(&self) -> bool; - -"#, - r#" #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); @@ -1303,13 +1405,13 @@ struct GamepadSettings { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &ButtonState) -> bool; + fn eq(&self, #[proxy] other: &touch::TouchPhase) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::ButtonState; + fn clone(&self) -> bevy::input::touch::TouchPhase; "#, r#" @@ -1319,11 +1421,11 @@ fn index(&self) -> String { } "#] )] -struct ButtonState {} +struct TouchPhase {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadInfo", + remote = "bevy::input::touch::ForceTouch", functions[r#" #[lua( @@ -1332,19 +1434,13 @@ struct ButtonState {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadInfo) -> bool; + fn eq(&self, #[proxy] other: &touch::ForceTouch) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadInfo; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + fn clone(&self) -> bevy::input::touch::ForceTouch; "#, r#" @@ -1354,9 +1450,7 @@ fn index(&self) -> String { } "#] )] -struct GamepadInfo { - name: std::string::String, -} +struct ForceTouch {} #[derive(Default)] pub(crate) struct Globals; impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { @@ -1448,21 +1542,11 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { .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< @@ -1476,7 +1560,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { >, >() .process_type::() - .process_type::() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< @@ -1485,8 +1568,22 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { >() .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::() }, ), ) @@ -1515,31 +1612,34 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { 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::< bevy::input::gamepad::GamepadButtonChangedEvent, >(); 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/bevy_math.rs b/crates/bevy_script_api/src/providers/bevy_math.rs new file mode 100644 index 00000000..461fb0b5 --- /dev/null +++ b/crates/bevy_script_api/src/providers/bevy_math.rs @@ -0,0 +1,4900 @@ +// @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_reflect::*; +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::math::CompassOctant", + 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::math::CompassOctant; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &compass::CompassOctant) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct CompassOctant {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::CompassQuadrant", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &compass::CompassQuadrant) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::CompassQuadrant; + +"#, + 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 CompassQuadrant {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::AspectRatio", + functions[r#" +/// Create a new `AspectRatio` from a given `width` and `height`. + + #[lua(kind = "Function", output(proxy))] + fn new(width: f32, height: f32) -> bevy::math::AspectRatio; + +"#, + r#" +/// Create a new `AspectRatio` from a given amount of `x` pixels and `y` pixels. + + #[lua(kind = "Function", output(proxy))] + fn from_pixels(x: u32, y: u32) -> bevy::math::AspectRatio; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::AspectRatio; + +"#, + 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::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, + ) -> bevy::math::Ray2d; + +"#, + r#" +/// Get a point at a given distance along the ray + + #[lua(kind = "Method", output(proxy))] + fn get_point(&self, distance: f32) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Get the distance to a plane if the ray intersects it + + #[lua(kind = "Method")] + fn intersect_plane( + &self, + #[proxy] + plane_origin: bevy::math::prelude::Vec2, + #[proxy] + plane: bevy::math::primitives::Plane2d, + ) -> std::option::Option; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &ray::Ray2d) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::Ray2d; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Ray2d { + #[lua(output(proxy))] + origin: bevy::math::prelude::Vec2, + #[lua(output(proxy))] + direction: bevy::math::prelude::Dir2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + 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", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &ray::Ray3d) -> bool; + +"#, + 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, + ) -> bevy::math::Ray3d; + +"#, + r#" +/// Get a point at a given distance along the ray + + #[lua(kind = "Method", output(proxy))] + fn get_point(&self, distance: f32) -> bevy::math::prelude::Vec3; + +"#, + r#" +/// Get the distance to a plane if the ray intersects it + + #[lua(kind = "Method")] + fn intersect_plane( + &self, + #[proxy] + plane_origin: bevy::math::prelude::Vec3, + #[proxy] + plane: bevy::math::primitives::InfinitePlane3d, + ) -> std::option::Option; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Ray3d { + #[lua(output(proxy))] + origin: bevy::math::prelude::Vec3, + #[lua(output(proxy))] + direction: bevy::math::prelude::Dir3, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Rot2", + functions[r#" +/// Rotates a [`Vec2`] by a [`Rot2`]. + + #[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#" +/// Rotates the [`Dir2`] using a [`Rot2`]. + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + 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; + +"#, + r#" +/// Creates a [`Rot2`] from a counterclockwise angle in radians. + + #[lua(kind = "Function", output(proxy))] + fn radians(radians: f32) -> bevy::math::Rot2; + +"#, + r#" +/// Creates a [`Rot2`] from a counterclockwise angle in degrees. + + #[lua(kind = "Function", output(proxy))] + fn degrees(degrees: f32) -> bevy::math::Rot2; + +"#, + r#" +/// Creates a [`Rot2`] from the sine and cosine of an angle in radians. +/// The rotation is only valid if `sin * sin + cos * cos == 1.0`. +/// # Panics +/// Panics if `sin * sin + cos * cos != 1.0` when the `glam_assert` feature is enabled. + + #[lua(kind = "Function", output(proxy))] + fn from_sin_cos(sin: f32, cos: f32) -> bevy::math::Rot2; + +"#, + r#" +/// Returns the rotation in radians in the `(-pi, pi]` range. + + #[lua(kind = "Method")] + fn as_radians(self) -> f32; + +"#, + r#" +/// Returns the rotation in degrees in the `(-180, 180]` range. + + #[lua(kind = "Method")] + fn as_degrees(self) -> f32; + +"#, + r#" +/// Returns the sine and cosine of the rotation angle in radians. + + #[lua(kind = "Method")] + fn sin_cos(self) -> (f32, f32); + +"#, + r#" +/// Computes the length or norm of the complex number used to represent the rotation. +/// The length is typically expected to be `1.0`. Unexpectedly denormalized rotations +/// can be a result of incorrect construction or floating point error caused by +/// successive operations. + + #[lua(kind = "Method")] + fn length(self) -> f32; + +"#, + r#" +/// Computes the squared length or norm of the complex number used to represent the rotation. +/// This is generally faster than [`Rot2::length()`], as it avoids a square +/// root operation. +/// The length is typically expected to be `1.0`. Unexpectedly denormalized rotations +/// can be a result of incorrect construction or floating point error caused by +/// successive operations. + + #[lua(kind = "Method")] + fn length_squared(self) -> f32; + +"#, + r#" +/// Computes `1.0 / self.length()`. +/// For valid results, `self` must _not_ have a length of zero. + + #[lua(kind = "Method")] + fn length_recip(self) -> f32; + +"#, + r#" +/// Returns `self` with a length of `1.0`. +/// Note that [`Rot2`] should typically already be normalized by design. +/// Manual normalization is only needed when successive operations result in +/// accumulated floating point error, or if the rotation was constructed +/// with invalid values. +/// # Panics +/// Panics if `self` has a length of zero, NaN, or infinity when debug assertions are enabled. + + #[lua(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::Rot2; + +"#, + r#" +/// Returns `true` if the rotation is neither infinite nor NaN. + + #[lua(kind = "Method")] + fn is_finite(self) -> bool; + +"#, + r#" +/// Returns `true` if the rotation is NaN. + + #[lua(kind = "Method")] + fn is_nan(self) -> bool; + +"#, + r#" +/// Returns whether `self` has a length of `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. + + #[lua(kind = "Method")] + fn is_normalized(self) -> bool; + +"#, + r#" +/// Returns `true` if the rotation is near [`Rot2::IDENTITY`]. + + #[lua(kind = "Method")] + fn is_near_identity(self) -> bool; + +"#, + r#" +/// Returns the angle in radians needed to make `self` and `other` coincide. + + #[lua(kind = "Method")] + fn angle_between(self, #[proxy] other: bevy::math::Rot2) -> f32; + +"#, + r#" +/// Returns the inverse of the rotation. This is also the conjugate +/// of the unit complex number representing the rotation. + + #[lua(kind = "Method", output(proxy))] + fn inverse(self) -> bevy::math::Rot2; + +"#, + r#" +/// Performs a linear interpolation between `self` and `rhs` based on +/// the value `s`, and normalizes the rotation afterwards. +/// When `s == 0.0`, the result will be equal to `self`. +/// When `s == 1.0`, the result will be equal to `rhs`. +/// This is slightly more efficient than [`slerp`](Self::slerp), and produces a similar result +/// when the difference between the two rotations is small. At larger differences, +/// the result resembles a kind of ease-in-out effect. +/// If you would like the angular velocity to remain constant, consider using [`slerp`](Self::slerp) instead. +/// # Details +/// `nlerp` corresponds to computing an angle for a point at position `s` on a line drawn +/// between the endpoints of the arc formed by `self` and `rhs` on a unit circle, +/// and normalizing the result afterwards. +/// Note that if the angles are opposite like 0 and π, the line will pass through the origin, +/// and the resulting angle will always be either `self` or `rhs` depending on `s`. +/// If `s` happens to be `0.5` in this case, a valid rotation cannot be computed, and `self` +/// will be returned as a fallback. +/// # Example +/// ``` +/// # use bevy_math::Rot2; +/// # +/// let rot1 = Rot2::IDENTITY; +/// let rot2 = Rot2::degrees(135.0); +/// let result1 = rot1.nlerp(rot2, 1.0 / 3.0); +/// assert_eq!(result1.as_degrees(), 28.675055); +/// let result2 = rot1.nlerp(rot2, 0.5); +/// assert_eq!(result2.as_degrees(), 67.5); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn nlerp(self, #[proxy] end: bevy::math::Rot2, s: f32) -> bevy::math::Rot2; + +"#, + r#" +/// Performs a spherical linear interpolation between `self` and `end` +/// based on the value `s`. +/// This corresponds to interpolating between the two angles at a constant angular velocity. +/// When `s == 0.0`, the result will be equal to `self`. +/// When `s == 1.0`, the result will be equal to `rhs`. +/// If you would like the rotation to have a kind of ease-in-out effect, consider +/// using the slightly more efficient [`nlerp`](Self::nlerp) instead. +/// # Example +/// ``` +/// # use bevy_math::Rot2; +/// # +/// let rot1 = Rot2::IDENTITY; +/// let rot2 = Rot2::degrees(135.0); +/// let result1 = rot1.slerp(rot2, 1.0 / 3.0); +/// assert_eq!(result1.as_degrees(), 45.0); +/// let result2 = rot1.slerp(rot2, 0.5); +/// assert_eq!(result2.as_degrees(), 67.5); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn slerp(self, #[proxy] end: bevy::math::Rot2, s: f32) -> bevy::math::Rot2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Rot2) -> bevy::math::Rot2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &rotation2d::Rot2) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Rot2 { + cos: f32, + sin: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::prelude::Dir2", + functions[r#" +/// Create a [`Dir2`] from a [`Vec2`] that is already normalized. +/// # Warning +/// `value` must be normalized, i.e its length must be `1.0`. + + #[lua(kind = "Function", output(proxy))] + fn new_unchecked( + #[proxy] + value: bevy::math::prelude::Vec2, + ) -> bevy::math::prelude::Dir2; + +"#, + r#" +/// Returns the inner [`Vec2`] + + #[lua(kind = "Method", output(proxy))] + fn as_vec2(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Performs a spherical linear interpolation between `self` and `rhs` +/// based on the value `s`. +/// This corresponds to interpolating between the two directions at a constant angular velocity. +/// When `s == 0.0`, the result will be equal to `self`. +/// When `s == 1.0`, the result will be equal to `rhs`. +/// # Example +/// ``` +/// # use bevy_math::Dir2; +/// # use approx::{assert_relative_eq, RelativeEq}; +/// # +/// let dir1 = Dir2::X; +/// let dir2 = Dir2::Y; +/// let result1 = dir1.slerp(dir2, 1.0 / 3.0); +/// assert_relative_eq!(result1, Dir2::from_xy(0.75_f32.sqrt(), 0.5).unwrap()); +/// let result2 = dir1.slerp(dir2, 0.5); +/// assert_relative_eq!(result2, Dir2::from_xy(0.5_f32.sqrt(), 0.5_f32.sqrt()).unwrap()); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn slerp( + self, + #[proxy] + rhs: bevy::math::prelude::Dir2, + s: f32, + ) -> bevy::math::prelude::Dir2; + +"#, + r#" +/// Get the rotation that rotates this direction to `other`. + + #[lua(kind = "Method", output(proxy))] + fn rotation_to(self, #[proxy] other: bevy::math::prelude::Dir2) -> bevy::math::Rot2; + +"#, + r#" +/// Get the rotation that rotates `other` to this direction. + + #[lua(kind = "Method", output(proxy))] + fn rotation_from( + self, + #[proxy] + other: bevy::math::prelude::Dir2, + ) -> bevy::math::Rot2; + +"#, + r#" +/// Get the rotation that rotates the X-axis to this direction. + + #[lua(kind = "Method", output(proxy))] + fn rotation_from_x(self) -> bevy::math::Rot2; + +"#, + r#" +/// Get the rotation that rotates this direction to the X-axis. + + #[lua(kind = "Method", output(proxy))] + fn rotation_to_x(self) -> bevy::math::Rot2; + +"#, + r#" +/// Get the rotation that rotates the Y-axis to this direction. + + #[lua(kind = "Method", output(proxy))] + fn rotation_from_y(self) -> bevy::math::Rot2; + +"#, + r#" +/// Get the rotation that rotates this direction to the Y-axis. + + #[lua(kind = "Method", output(proxy))] + fn rotation_to_y(self) -> bevy::math::Rot2; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::prelude::Dir2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::prelude::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &direction::Dir2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::prelude::Dir2; + +"#, + 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", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::prelude::Dir3; + +"#, + r#" +/// Create a [`Dir3`] from a [`Vec3`] that is already normalized. +/// # Warning +/// `value` must be normalized, i.e its length must be `1.0`. + + #[lua(kind = "Function", output(proxy))] + fn new_unchecked( + #[proxy] + value: bevy::math::prelude::Vec3, + ) -> bevy::math::prelude::Dir3; + +"#, + r#" +/// Returns the inner [`Vec3`] + + #[lua(kind = "Method", output(proxy))] + fn as_vec3(&self) -> bevy::math::prelude::Vec3; + +"#, + r#" +/// Performs a spherical linear interpolation between `self` and `rhs` +/// based on the value `s`. +/// This corresponds to interpolating between the two directions at a constant angular velocity. +/// When `s == 0.0`, the result will be equal to `self`. +/// When `s == 1.0`, the result will be equal to `rhs`. +/// # Example +/// ``` +/// # use bevy_math::Dir3; +/// # use approx::{assert_relative_eq, RelativeEq}; +/// # +/// let dir1 = Dir3::X; +/// let dir2 = Dir3::Y; +/// let result1 = dir1.slerp(dir2, 1.0 / 3.0); +/// assert_relative_eq!( +/// result1, +/// Dir3::from_xyz(0.75_f32.sqrt(), 0.5, 0.0).unwrap(), +/// epsilon = 0.000001 +/// ); +/// let result2 = dir1.slerp(dir2, 0.5); +/// assert_relative_eq!(result2, Dir3::from_xyz(0.5_f32.sqrt(), 0.5_f32.sqrt(), 0.0).unwrap()); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn slerp( + self, + #[proxy] + rhs: bevy::math::prelude::Dir3, + s: f32, + ) -> bevy::math::prelude::Dir3; + +"#, + 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", + 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; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Dir3(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::prelude::Dir3A", + functions[r#" + + #[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; + +"#, + 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(kind = "Function", output(proxy))] + fn new_unchecked(#[proxy] value: bevy::math::Vec3A) -> bevy::math::prelude::Dir3A; + +"#, + r#" +/// Returns the inner [`Vec3A`] + + #[lua(kind = "Method", output(proxy))] + fn as_vec3a(&self) -> bevy::math::Vec3A; + +"#, + r#" +/// Performs a spherical linear interpolation between `self` and `rhs` +/// based on the value `s`. +/// This corresponds to interpolating between the two directions at a constant angular velocity. +/// When `s == 0.0`, the result will be equal to `self`. +/// When `s == 1.0`, the result will be equal to `rhs`. +/// # Example +/// ``` +/// # use bevy_math::Dir3A; +/// # use approx::{assert_relative_eq, RelativeEq}; +/// # +/// let dir1 = Dir3A::X; +/// let dir2 = Dir3A::Y; +/// let result1 = dir1.slerp(dir2, 1.0 / 3.0); +/// assert_relative_eq!( +/// result1, +/// Dir3A::from_xyz(0.75_f32.sqrt(), 0.5, 0.0).unwrap(), +/// epsilon = 0.000001 +/// ); +/// let result2 = dir1.slerp(dir2, 0.5); +/// assert_relative_eq!(result2, Dir3A::from_xyz(0.5_f32.sqrt(), 0.5_f32.sqrt(), 0.0).unwrap()); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn slerp( + self, + #[proxy] + rhs: bevy::math::prelude::Dir3A, + s: f32, + ) -> bevy::math::prelude::Dir3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::prelude::Dir3A; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Dir3A(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::prelude::IRect", + functions[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. +/// # Examples +/// ``` +/// # use bevy_math::IRect; +/// let r = IRect::new(0, 4, 10, 6); // w=10 h=2 +/// let r = IRect::new(2, 3, 5, -1); // w=3 h=4 +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(x0: i32, y0: i32, x1: i32, y1: i32) -> bevy::math::prelude::IRect; + +"#, + 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. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// // Unit rect from [0,0] to [1,1] +/// let r = IRect::from_corners(IVec2::ZERO, IVec2::ONE); // w=1 h=1 +/// // Same; the points do not need to be ordered +/// let r = IRect::from_corners(IVec2::ONE, IVec2::ZERO); // w=1 h=1 +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_corners( + #[proxy] + p0: bevy::math::prelude::IVec2, + #[proxy] + p1: bevy::math::prelude::IVec2, + ) -> bevy::math::prelude::IRect; + +"#, + r#" +/// Create a new rectangle from its center and size. +/// # Rounding Behaviour +/// 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. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::from_center_size(IVec2::ZERO, IVec2::new(3, 2)); // w=2 h=2 +/// assert_eq!(r.min, IVec2::splat(-1)); +/// assert_eq!(r.max, IVec2::splat(1)); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_center_size( + #[proxy] + origin: bevy::math::prelude::IVec2, + #[proxy] + size: bevy::math::prelude::IVec2, + ) -> bevy::math::prelude::IRect; + +"#, + r#" +/// Create a new rectangle from its center and half-size. +/// # Panics +/// This method panics if any of the components of the half-size is negative. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::from_center_half_size(IVec2::ZERO, IVec2::ONE); // w=2 h=2 +/// assert_eq!(r.min, IVec2::splat(-1)); +/// assert_eq!(r.max, IVec2::splat(1)); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_center_half_size( + #[proxy] + origin: bevy::math::prelude::IVec2, + #[proxy] + half_size: bevy::math::prelude::IVec2, + ) -> bevy::math::prelude::IRect; + +"#, + r#" +/// Check if the rectangle is empty. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::from_corners(IVec2::ZERO, IVec2::new(0, 1)); // w=0 h=1 +/// assert!(r.is_empty()); +/// ``` + + #[lua(kind = "Method")] + fn is_empty(&self) -> bool; + +"#, + r#" +/// Rectangle width (max.x - min.x). +/// # Examples +/// ``` +/// # use bevy_math::IRect; +/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// assert_eq!(r.width(), 5); +/// ``` + + #[lua(kind = "Method")] + fn width(&self) -> i32; + +"#, + r#" +/// Rectangle height (max.y - min.y). +/// # Examples +/// ``` +/// # use bevy_math::IRect; +/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// assert_eq!(r.height(), 1); +/// ``` + + #[lua(kind = "Method")] + fn height(&self) -> i32; + +"#, + r#" +/// Rectangle size. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// assert_eq!(r.size(), IVec2::new(5, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn size(&self) -> bevy::math::prelude::IVec2; + +"#, + r#" +/// Rectangle half-size. +/// # Rounding Behaviour +/// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::new(0, 0, 4, 3); // w=4 h=3 +/// assert_eq!(r.half_size(), IVec2::new(2, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn half_size(&self) -> bevy::math::prelude::IVec2; + +"#, + r#" +/// The center point of the rectangle. +/// # Rounding Behaviour +/// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::new(0, 0, 5, 2); // w=5 h=2 +/// assert_eq!(r.center(), IVec2::new(2, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn center(&self) -> bevy::math::prelude::IVec2; + +"#, + r#" +/// Check if a point lies within this rectangle, inclusive of its edges. +/// # Examples +/// ``` +/// # use bevy_math::IRect; +/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// assert!(r.contains(r.center())); +/// assert!(r.contains(r.min)); +/// assert!(r.contains(r.max)); +/// ``` + + #[lua(kind = "Method")] + fn contains(&self, #[proxy] point: bevy::math::prelude::IVec2) -> bool; + +"#, + r#" +/// Build a new rectangle formed of the union of this rectangle and another rectangle. +/// The union is the smallest rectangle enclosing both rectangles. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r1 = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// let r2 = IRect::new(1, -1, 3, 3); // w=2 h=4 +/// let r = r1.union(r2); +/// assert_eq!(r.min, IVec2::new(0, -1)); +/// assert_eq!(r.max, IVec2::new(5, 3)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn union( + &self, + #[proxy] + other: bevy::math::prelude::IRect, + ) -> bevy::math::prelude::IRect; + +"#, + r#" +/// Build a new rectangle formed of the union of this rectangle and a point. +/// The union is the smallest rectangle enclosing both the rectangle and the point. If the +/// point is already inside the rectangle, this method returns a copy of the rectangle. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// let u = r.union_point(IVec2::new(3, 6)); +/// assert_eq!(u.min, IVec2::ZERO); +/// assert_eq!(u.max, IVec2::new(5, 6)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn union_point( + &self, + #[proxy] + other: bevy::math::prelude::IVec2, + ) -> bevy::math::prelude::IRect; + +"#, + r#" +/// Build a new rectangle formed of the intersection of this rectangle and another rectangle. +/// The intersection is the largest rectangle enclosed in both rectangles. If the intersection +/// is empty, this method returns an empty rectangle ([`IRect::is_empty()`] returns `true`), but +/// the actual values of [`IRect::min`] and [`IRect::max`] are implementation-dependent. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r1 = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// let r2 = IRect::new(1, -1, 3, 3); // w=2 h=4 +/// let r = r1.intersect(r2); +/// assert_eq!(r.min, IVec2::new(1, 0)); +/// assert_eq!(r.max, IVec2::new(3, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn intersect( + &self, + #[proxy] + other: bevy::math::prelude::IRect, + ) -> bevy::math::prelude::IRect; + +"#, + r#" +/// Create a new rectangle by expanding it evenly on all sides. +/// A positive expansion value produces a larger rectangle, +/// while a negative expansion value produces a smaller rectangle. +/// If this would result in zero or negative width or height, [`IRect::EMPTY`] is returned instead. +/// # Examples +/// ``` +/// # use bevy_math::{IRect, IVec2}; +/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 +/// let r2 = r.inflate(3); // w=11 h=7 +/// assert_eq!(r2.min, IVec2::splat(-3)); +/// assert_eq!(r2.max, IVec2::new(8, 4)); +/// let r = IRect::new(0, -1, 4, 3); // w=4 h=4 +/// let r2 = r.inflate(-1); // w=2 h=2 +/// assert_eq!(r2.min, IVec2::new(1, 0)); +/// assert_eq!(r2.max, IVec2::new(3, 2)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn inflate(&self, expansion: i32) -> bevy::math::prelude::IRect; + +"#, + r#" +/// Returns self as [`Rect`] (f32) + + #[lua(kind = "Method", output(proxy))] + fn as_rect(&self) -> bevy::math::prelude::Rect; + +"#, + r#" +/// Returns self as [`URect`] (u32) + + #[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")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct IRect { + #[lua(output(proxy))] + min: bevy::math::prelude::IVec2, + #[lua(output(proxy))] + max: bevy::math::prelude::IVec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::prelude::Rect", + functions[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. +/// # Examples +/// ``` +/// # use bevy_math::Rect; +/// let r = Rect::new(0., 4., 10., 6.); // w=10 h=2 +/// let r = Rect::new(2., 3., 5., -1.); // w=3 h=4 +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(x0: f32, y0: f32, x1: f32, y1: f32) -> bevy::math::prelude::Rect; + +"#, + 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. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// // Unit rect from [0,0] to [1,1] +/// let r = Rect::from_corners(Vec2::ZERO, Vec2::ONE); // w=1 h=1 +/// // Same; the points do not need to be ordered +/// let r = Rect::from_corners(Vec2::ONE, Vec2::ZERO); // w=1 h=1 +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_corners( + #[proxy] + p0: bevy::math::prelude::Vec2, + #[proxy] + p1: bevy::math::prelude::Vec2, + ) -> bevy::math::prelude::Rect; + +"#, + r#" +/// Create a new rectangle from its center and size. +/// # Panics +/// This method panics if any of the components of the size is negative. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// let r = Rect::from_center_size(Vec2::ZERO, Vec2::ONE); // w=1 h=1 +/// assert!(r.min.abs_diff_eq(Vec2::splat(-0.5), 1e-5)); +/// assert!(r.max.abs_diff_eq(Vec2::splat(0.5), 1e-5)); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_center_size( + #[proxy] + origin: bevy::math::prelude::Vec2, + #[proxy] + size: bevy::math::prelude::Vec2, + ) -> bevy::math::prelude::Rect; + +"#, + r#" +/// Create a new rectangle from its center and half-size. +/// # Panics +/// This method panics if any of the components of the half-size is negative. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// let r = Rect::from_center_half_size(Vec2::ZERO, Vec2::ONE); // w=2 h=2 +/// assert!(r.min.abs_diff_eq(Vec2::splat(-1.), 1e-5)); +/// assert!(r.max.abs_diff_eq(Vec2::splat(1.), 1e-5)); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_center_half_size( + #[proxy] + origin: bevy::math::prelude::Vec2, + #[proxy] + half_size: bevy::math::prelude::Vec2, + ) -> bevy::math::prelude::Rect; + +"#, + r#" +/// Check if the rectangle is empty. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// let r = Rect::from_corners(Vec2::ZERO, Vec2::new(0., 1.)); // w=0 h=1 +/// assert!(r.is_empty()); +/// ``` + + #[lua(kind = "Method")] + fn is_empty(&self) -> bool; + +"#, + r#" +/// Rectangle width (max.x - min.x). +/// # Examples +/// ``` +/// # use bevy_math::Rect; +/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 +/// assert!((r.width() - 5.).abs() <= 1e-5); +/// ``` + + #[lua(kind = "Method")] + fn width(&self) -> f32; + +"#, + r#" +/// Rectangle height (max.y - min.y). +/// # Examples +/// ``` +/// # use bevy_math::Rect; +/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 +/// assert!((r.height() - 1.).abs() <= 1e-5); +/// ``` + + #[lua(kind = "Method")] + fn height(&self) -> f32; + +"#, + r#" +/// Rectangle size. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 +/// assert!(r.size().abs_diff_eq(Vec2::new(5., 1.), 1e-5)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn size(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Rectangle half-size. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 +/// assert!(r.half_size().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn half_size(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// The center point of the rectangle. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 +/// assert!(r.center().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn center(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Check if a point lies within this rectangle, inclusive of its edges. +/// # Examples +/// ``` +/// # use bevy_math::Rect; +/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 +/// assert!(r.contains(r.center())); +/// assert!(r.contains(r.min)); +/// assert!(r.contains(r.max)); +/// ``` + + #[lua(kind = "Method")] + fn contains(&self, #[proxy] point: bevy::math::prelude::Vec2) -> bool; + +"#, + r#" +/// Build a new rectangle formed of the union of this rectangle and another rectangle. +/// The union is the smallest rectangle enclosing both rectangles. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// let r1 = Rect::new(0., 0., 5., 1.); // w=5 h=1 +/// let r2 = Rect::new(1., -1., 3., 3.); // w=2 h=4 +/// let r = r1.union(r2); +/// assert!(r.min.abs_diff_eq(Vec2::new(0., -1.), 1e-5)); +/// assert!(r.max.abs_diff_eq(Vec2::new(5., 3.), 1e-5)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn union( + &self, + #[proxy] + other: bevy::math::prelude::Rect, + ) -> bevy::math::prelude::Rect; + +"#, + r#" +/// Build a new rectangle formed of the union of this rectangle and a point. +/// The union is the smallest rectangle enclosing both the rectangle and the point. If the +/// point is already inside the rectangle, this method returns a copy of the rectangle. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 +/// let u = r.union_point(Vec2::new(3., 6.)); +/// assert!(u.min.abs_diff_eq(Vec2::ZERO, 1e-5)); +/// assert!(u.max.abs_diff_eq(Vec2::new(5., 6.), 1e-5)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn union_point( + &self, + #[proxy] + other: bevy::math::prelude::Vec2, + ) -> bevy::math::prelude::Rect; + +"#, + r#" +/// Build a new rectangle formed of the intersection of this rectangle and another rectangle. +/// The intersection is the largest rectangle enclosed in both rectangles. If the intersection +/// is empty, this method returns an empty rectangle ([`Rect::is_empty()`] returns `true`), but +/// the actual values of [`Rect::min`] and [`Rect::max`] are implementation-dependent. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// let r1 = Rect::new(0., 0., 5., 1.); // w=5 h=1 +/// let r2 = Rect::new(1., -1., 3., 3.); // w=2 h=4 +/// let r = r1.intersect(r2); +/// assert!(r.min.abs_diff_eq(Vec2::new(1., 0.), 1e-5)); +/// assert!(r.max.abs_diff_eq(Vec2::new(3., 1.), 1e-5)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn intersect( + &self, + #[proxy] + other: bevy::math::prelude::Rect, + ) -> bevy::math::prelude::Rect; + +"#, + r#" +/// Create a new rectangle by expanding it evenly on all sides. +/// A positive expansion value produces a larger rectangle, +/// while a negative expansion value produces a smaller rectangle. +/// If this would result in zero or negative width or height, [`Rect::EMPTY`] is returned instead. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 +/// let r2 = r.inflate(3.); // w=11 h=7 +/// assert!(r2.min.abs_diff_eq(Vec2::splat(-3.), 1e-5)); +/// assert!(r2.max.abs_diff_eq(Vec2::new(8., 4.), 1e-5)); +/// let r = Rect::new(0., -1., 6., 7.); // w=6 h=8 +/// let r2 = r.inflate(-2.); // w=11 h=7 +/// assert!(r2.min.abs_diff_eq(Vec2::new(2., 1.), 1e-5)); +/// assert!(r2.max.abs_diff_eq(Vec2::new(4., 5.), 1e-5)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn inflate(&self, expansion: f32) -> bevy::math::prelude::Rect; + +"#, + r#" +/// Build a new rectangle from this one with its coordinates expressed +/// relative to `other` in a normalized ([0..1] x [0..1]) coordinate system. +/// # Examples +/// ``` +/// # use bevy_math::{Rect, Vec2}; +/// let r = Rect::new(2., 3., 4., 6.); +/// let s = Rect::new(0., 0., 10., 10.); +/// let n = r.normalize(s); +/// assert_eq!(n.min.x, 0.2); +/// assert_eq!(n.min.y, 0.3); +/// assert_eq!(n.max.x, 0.4); +/// assert_eq!(n.max.y, 0.6); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn normalize( + &self, + #[proxy] + other: bevy::math::prelude::Rect, + ) -> bevy::math::prelude::Rect; + +"#, + r#" +/// Returns self as [`IRect`] (i32) + + #[lua(kind = "Method", output(proxy))] + fn as_irect(&self) -> bevy::math::prelude::IRect; + +"#, + r#" +/// Returns self as [`URect`] (u32) + + #[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")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Rect { + #[lua(output(proxy))] + min: bevy::math::prelude::Vec2, + #[lua(output(proxy))] + max: bevy::math::prelude::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::prelude::URect", + functions[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. +/// # Examples +/// ``` +/// # use bevy_math::URect; +/// let r = URect::new(0, 4, 10, 6); // w=10 h=2 +/// let r = URect::new(2, 4, 5, 0); // w=3 h=4 +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn new(x0: u32, y0: u32, x1: u32, y1: u32) -> bevy::math::prelude::URect; + +"#, + 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. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// // Unit rect from [0,0] to [1,1] +/// let r = URect::from_corners(UVec2::ZERO, UVec2::ONE); // w=1 h=1 +/// // Same; the points do not need to be ordered +/// let r = URect::from_corners(UVec2::ONE, UVec2::ZERO); // w=1 h=1 +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_corners( + #[proxy] + p0: bevy::math::prelude::UVec2, + #[proxy] + p1: bevy::math::prelude::UVec2, + ) -> bevy::math::prelude::URect; + +"#, + r#" +/// Create a new rectangle from its center and size. +/// # Rounding Behaviour +/// 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. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::from_center_size(UVec2::ONE, UVec2::splat(2)); // w=2 h=2 +/// assert_eq!(r.min, UVec2::splat(0)); +/// assert_eq!(r.max, UVec2::splat(2)); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_center_size( + #[proxy] + origin: bevy::math::prelude::UVec2, + #[proxy] + size: bevy::math::prelude::UVec2, + ) -> bevy::math::prelude::URect; + +"#, + r#" +/// Create a new rectangle from its center and half-size. +/// # Panics +/// This method panics if any of the components of the half-size is negative or if `origin - half_size` results in any negatives. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::from_center_half_size(UVec2::ONE, UVec2::ONE); // w=2 h=2 +/// assert_eq!(r.min, UVec2::splat(0)); +/// assert_eq!(r.max, UVec2::splat(2)); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn from_center_half_size( + #[proxy] + origin: bevy::math::prelude::UVec2, + #[proxy] + half_size: bevy::math::prelude::UVec2, + ) -> bevy::math::prelude::URect; + +"#, + r#" +/// Check if the rectangle is empty. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::from_corners(UVec2::ZERO, UVec2::new(0, 1)); // w=0 h=1 +/// assert!(r.is_empty()); +/// ``` + + #[lua(kind = "Method")] + fn is_empty(&self) -> bool; + +"#, + r#" +/// Rectangle width (max.x - min.x). +/// # Examples +/// ``` +/// # use bevy_math::URect; +/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 +/// assert_eq!(r.width(), 5); +/// ``` + + #[lua(kind = "Method")] + fn width(&self) -> u32; + +"#, + r#" +/// Rectangle height (max.y - min.y). +/// # Examples +/// ``` +/// # use bevy_math::URect; +/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 +/// assert_eq!(r.height(), 1); +/// ``` + + #[lua(kind = "Method")] + fn height(&self) -> u32; + +"#, + r#" +/// Rectangle size. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 +/// assert_eq!(r.size(), UVec2::new(5, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn size(&self) -> bevy::math::prelude::UVec2; + +"#, + r#" +/// Rectangle half-size. +/// # Rounding Behaviour +/// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::new(0, 0, 4, 2); // w=4 h=2 +/// assert_eq!(r.half_size(), UVec2::new(2, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn half_size(&self) -> bevy::math::prelude::UVec2; + +"#, + r#" +/// The center point of the rectangle. +/// # Rounding Behaviour +/// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::new(0, 0, 4, 2); // w=4 h=2 +/// assert_eq!(r.center(), UVec2::new(2, 1)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn center(&self) -> bevy::math::prelude::UVec2; + +"#, + r#" +/// Check if a point lies within this rectangle, inclusive of its edges. +/// # Examples +/// ``` +/// # use bevy_math::URect; +/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 +/// assert!(r.contains(r.center())); +/// assert!(r.contains(r.min)); +/// assert!(r.contains(r.max)); +/// ``` + + #[lua(kind = "Method")] + fn contains(&self, #[proxy] point: bevy::math::prelude::UVec2) -> bool; + +"#, + r#" +/// Build a new rectangle formed of the union of this rectangle and another rectangle. +/// The union is the smallest rectangle enclosing both rectangles. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r1 = URect::new(0, 0, 5, 1); // w=5 h=1 +/// let r2 = URect::new(1, 0, 3, 8); // w=2 h=4 +/// let r = r1.union(r2); +/// assert_eq!(r.min, UVec2::new(0, 0)); +/// assert_eq!(r.max, UVec2::new(5, 8)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn union( + &self, + #[proxy] + other: bevy::math::prelude::URect, + ) -> bevy::math::prelude::URect; + +"#, + r#" +/// Build a new rectangle formed of the union of this rectangle and a point. +/// The union is the smallest rectangle enclosing both the rectangle and the point. If the +/// point is already inside the rectangle, this method returns a copy of the rectangle. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 +/// let u = r.union_point(UVec2::new(3, 6)); +/// assert_eq!(u.min, UVec2::ZERO); +/// assert_eq!(u.max, UVec2::new(5, 6)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn union_point( + &self, + #[proxy] + other: bevy::math::prelude::UVec2, + ) -> bevy::math::prelude::URect; + +"#, + r#" +/// Build a new rectangle formed of the intersection of this rectangle and another rectangle. +/// The intersection is the largest rectangle enclosed in both rectangles. If the intersection +/// is empty, this method returns an empty rectangle ([`URect::is_empty()`] returns `true`), but +/// the actual values of [`URect::min`] and [`URect::max`] are implementation-dependent. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r1 = URect::new(0, 0, 2, 2); // w=2 h=2 +/// let r2 = URect::new(1, 1, 3, 3); // w=2 h=2 +/// let r = r1.intersect(r2); +/// assert_eq!(r.min, UVec2::new(1, 1)); +/// assert_eq!(r.max, UVec2::new(2, 2)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn intersect( + &self, + #[proxy] + other: bevy::math::prelude::URect, + ) -> bevy::math::prelude::URect; + +"#, + r#" +/// Create a new rectangle by expanding it evenly on all sides. +/// A positive expansion value produces a larger rectangle, +/// while a negative expansion value produces a smaller rectangle. +/// If this would result in zero width or height, [`URect::EMPTY`] is returned instead. +/// # Examples +/// ``` +/// # use bevy_math::{URect, UVec2}; +/// let r = URect::new(4, 4, 6, 6); // w=2 h=2 +/// let r2 = r.inflate(1); // w=4 h=4 +/// assert_eq!(r2.min, UVec2::splat(3)); +/// assert_eq!(r2.max, UVec2::splat(7)); +/// let r = URect::new(4, 4, 8, 8); // w=4 h=4 +/// let r2 = r.inflate(-1); // w=2 h=2 +/// assert_eq!(r2.min, UVec2::splat(5)); +/// assert_eq!(r2.max, UVec2::splat(7)); +/// ``` + + #[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; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::prelude::URect; + +"#, + 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 URect { + #[lua(output(proxy))] + min: bevy::math::prelude::UVec2, + #[lua(output(proxy))] + max: bevy::math::prelude::UVec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy(derive(), remote = "bevy::math::Affine3", functions[])] +struct Affine3 { + #[lua(output(proxy))] + matrix3: bevy::math::prelude::Mat3, + #[lua(output(proxy))] + translation: bevy::math::prelude::Vec3, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::bounding::Aabb2d", + functions[r#" +/// Constructs an AABB from its center and half-size. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + center: bevy::math::prelude::Vec2, + #[proxy] + half_size: bevy::math::prelude::Vec2, + ) -> bevy::math::bounding::Aabb2d; + +"#, + r#" +/// Computes the smallest [`BoundingCircle`] containing this [`Aabb2d`]. + + #[lua(kind = "Method", output(proxy))] + fn bounding_circle(&self) -> bevy::math::bounding::BoundingCircle; + +"#, + r#" +/// Finds the point on the AABB that is closest to the given `point`. +/// If the point is outside the AABB, the returned point will be on the perimeter of the AABB. +/// Otherwise, it will be inside the AABB and returned as is. + + #[lua(kind = "Method", output(proxy))] + fn closest_point( + &self, + #[proxy] + 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")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Aabb2d { + #[lua(output(proxy))] + min: bevy::math::prelude::Vec2, + #[lua(output(proxy))] + max: bevy::math::prelude::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + 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))] + fn new( + #[proxy] + center: bevy::math::prelude::Vec2, + radius: f32, + ) -> bevy::math::bounding::BoundingCircle; + +"#, + r#" +/// Get the radius of the bounding circle + + #[lua(kind = "Method")] + fn radius(&self) -> f32; + +"#, + r#" +/// Computes the smallest [`Aabb2d`] containing this [`BoundingCircle`]. + + #[lua(kind = "Method", output(proxy))] + fn aabb_2d(&self) -> bevy::math::bounding::Aabb2d; + +"#, + r#" +/// Finds the point on the bounding 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#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct BoundingCircle { + #[lua(output(proxy))] + center: bevy::math::prelude::Vec2, + #[lua(output(proxy))] + circle: bevy::math::primitives::Circle, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Circle", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Circle; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Circle) -> bool; + +"#, + 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#" +#[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::Arc2d", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Arc2d; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Arc2d) -> bool; + +"#, + r#" +/// Create a new [`Arc2d`] from a `radius` and a `half_angle` + + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32, half_angle: f32) -> bevy::math::primitives::Arc2d; + +"#, + r#" +/// Create a new [`Arc2d`] from a `radius` and an `angle` in radians + + #[lua(kind = "Function", output(proxy))] + fn from_radians(radius: f32, angle: f32) -> bevy::math::primitives::Arc2d; + +"#, + r#" +/// Create a new [`Arc2d`] from a `radius` and an `angle` in degrees. + + #[lua(kind = "Function", output(proxy))] + fn from_degrees(radius: f32, angle: f32) -> bevy::math::primitives::Arc2d; + +"#, + r#" +/// Create a new [`Arc2d`] from a `radius` and a `fraction` of a single turn. +/// For instance, `0.5` turns is a semicircle. + + #[lua(kind = "Function", output(proxy))] + fn from_turns(radius: f32, fraction: f32) -> bevy::math::primitives::Arc2d; + +"#, + r#" +/// Get the angle of the arc + + #[lua(kind = "Method")] + fn angle(&self) -> f32; + +"#, + r#" +/// Get the length of the arc + + #[lua(kind = "Method")] + fn length(&self) -> f32; + +"#, + r#" +/// Get the right-hand end point of the arc + + #[lua(kind = "Method", output(proxy))] + fn right_endpoint(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Get the left-hand end point of the arc + + #[lua(kind = "Method", output(proxy))] + fn left_endpoint(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Get the midpoint of the arc + + #[lua(kind = "Method", output(proxy))] + fn midpoint(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Get half the distance between the endpoints (half the length of the chord) + + #[lua(kind = "Method")] + fn half_chord_length(&self) -> f32; + +"#, + r#" +/// Get the distance between the endpoints (the length of the chord) + + #[lua(kind = "Method")] + fn chord_length(&self) -> f32; + +"#, + r#" +/// Get the midpoint of the two endpoints (the midpoint of the chord) + + #[lua(kind = "Method", output(proxy))] + fn chord_midpoint(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Get the length of the apothem of this arc, that is, +/// the distance from the center of the circle to the midpoint of the chord, in the direction of the midpoint of the arc. +/// Equivalently, the [`radius`](Self::radius) minus the [`sagitta`](Self::sagitta). +/// Note that for a [`major`](Self::is_major) arc, the apothem will be negative. + + #[lua(kind = "Method")] + fn apothem(&self) -> f32; + +"#, + r#" +/// Get the length of the sagitta of this arc, that is, +/// the length of the line between the midpoints of the arc and its chord. +/// Equivalently, the height of the triangle whose base is the chord and whose apex is the midpoint of the arc. +/// The sagitta is also the sum of the [`radius`](Self::radius) and the [`apothem`](Self::apothem). + + #[lua(kind = "Method")] + fn sagitta(&self) -> f32; + +"#, + r#" +/// Produces true if the arc is at most half a circle. +/// **Note:** This is not the negation of [`is_major`](Self::is_major): an exact semicircle is both major and minor. + + #[lua(kind = "Method")] + fn is_minor(&self) -> bool; + +"#, + r#" +/// Produces true if the arc is at least half a circle. +/// **Note:** This is not the negation of [`is_minor`](Self::is_minor): an exact semicircle is both major and minor. + + #[lua(kind = "Method")] + fn is_major(&self) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Arc2d { + radius: f32, + half_angle: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Capsule2d", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Capsule2d) -> bool; + +"#, + r#" +/// Create a new `Capsule2d` from a radius and length + + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule2d; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Capsule2d; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Capsule2d { + radius: f32, + half_length: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + 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))] + fn new(radius: f32, angle: f32) -> bevy::math::primitives::CircularSector; + +"#, + r#" +/// Create a new [`CircularSector`] from a `radius` and an `angle` in radians. + + #[lua(kind = "Function", output(proxy))] + fn from_radians(radius: f32, angle: f32) -> bevy::math::primitives::CircularSector; + +"#, + r#" +/// Create a new [`CircularSector`] from a `radius` and an `angle` in degrees. + + #[lua(kind = "Function", output(proxy))] + fn from_degrees(radius: f32, angle: f32) -> bevy::math::primitives::CircularSector; + +"#, + r#" +/// Create a new [`CircularSector`] from a `radius` and a number of `turns` of a circle. +/// For instance, `0.5` turns is a semicircle. + + #[lua(kind = "Function", output(proxy))] + fn from_turns(radius: f32, fraction: f32) -> bevy::math::primitives::CircularSector; + +"#, + r#" +/// Get half the angle of the sector + + #[lua(kind = "Method")] + fn half_angle(&self) -> f32; + +"#, + r#" +/// Get the angle of the sector + + #[lua(kind = "Method")] + fn angle(&self) -> f32; + +"#, + r#" +/// Get the radius of the sector + + #[lua(kind = "Method")] + fn radius(&self) -> f32; + +"#, + r#" +/// Get the length of the arc defining the sector + + #[lua(kind = "Method")] + fn arc_length(&self) -> f32; + +"#, + r#" +/// Get half the length of the chord defined by the sector +/// See [`Arc2d::half_chord_length`] + + #[lua(kind = "Method")] + fn half_chord_length(&self) -> f32; + +"#, + r#" +/// Get the length of the chord defined by the sector +/// See [`Arc2d::chord_length`] + + #[lua(kind = "Method")] + fn chord_length(&self) -> f32; + +"#, + r#" +/// Get the midpoint of the chord defined by the sector +/// See [`Arc2d::chord_midpoint`] + + #[lua(kind = "Method", output(proxy))] + fn chord_midpoint(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Get the length of the apothem of this sector +/// See [`Arc2d::apothem`] + + #[lua(kind = "Method")] + fn apothem(&self) -> f32; + +"#, + r#" +/// Get the length of the sagitta of this sector +/// See [`Arc2d::sagitta`] + + #[lua(kind = "Method")] + fn sagitta(&self) -> f32; + +"#, + r#" +/// Returns the area of this sector + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct CircularSector { + #[lua(output(proxy))] + arc: bevy::math::primitives::Arc2d, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + 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))] + fn new(radius: f32, angle: f32) -> bevy::math::primitives::CircularSegment; + +"#, + r#" +/// Create a new [`CircularSegment`] from a `radius` and an `angle` in radians. + + #[lua(kind = "Function", output(proxy))] + fn from_radians(radius: f32, angle: f32) -> bevy::math::primitives::CircularSegment; + +"#, + r#" +/// Create a new [`CircularSegment`] from a `radius` and an `angle` in degrees. + + #[lua(kind = "Function", output(proxy))] + fn from_degrees(radius: f32, angle: f32) -> bevy::math::primitives::CircularSegment; + +"#, + r#" +/// Create a new [`CircularSegment`] from a `radius` and a number of `turns` of a circle. +/// For instance, `0.5` turns is a semicircle. + + #[lua(kind = "Function", output(proxy))] + fn from_turns(radius: f32, fraction: f32) -> bevy::math::primitives::CircularSegment; + +"#, + r#" +/// Get the half-angle of the segment + + #[lua(kind = "Method")] + fn half_angle(&self) -> f32; + +"#, + r#" +/// Get the angle of the segment + + #[lua(kind = "Method")] + fn angle(&self) -> f32; + +"#, + r#" +/// Get the radius of the segment + + #[lua(kind = "Method")] + fn radius(&self) -> f32; + +"#, + r#" +/// Get the length of the arc defining the segment + + #[lua(kind = "Method")] + fn arc_length(&self) -> f32; + +"#, + r#" +/// Get half the length of the segment's base, also known as its chord + + #[lua(kind = "Method")] + fn half_chord_length(&self) -> f32; + +"#, + r#" +/// Get the length of the segment's base, also known as its chord + + #[lua(kind = "Method")] + fn chord_length(&self) -> f32; + +"#, + r#" +/// Get the midpoint of the segment's base, also known as its chord + + #[lua(kind = "Method", output(proxy))] + fn chord_midpoint(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Get the length of the apothem of this segment, +/// which is the signed distance between the segment and the center of its circle +/// See [`Arc2d::apothem`] + + #[lua(kind = "Method")] + fn apothem(&self) -> f32; + +"#, + r#" +/// Get the length of the sagitta of this segment, also known as its height +/// See [`Arc2d::sagitta`] + + #[lua(kind = "Method")] + fn sagitta(&self) -> f32; + +"#, + r#" +/// Returns the area of this segment + + #[lua(kind = "Method")] + fn area(&self) -> f32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct CircularSegment { + #[lua(output(proxy))] + arc: bevy::math::primitives::Arc2d, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + 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. + + #[lua(kind = "Function", output(proxy))] + fn new(half_width: f32, half_height: f32) -> bevy::math::primitives::Ellipse; + +"#, + r#" +/// Create a new `Ellipse` from a given full size. +/// `size.x` is the diameter along the X axis, and `size.y` is the diameter along the Y axis. + + #[lua(kind = "Function", output(proxy))] + fn from_size( + #[proxy] + size: bevy::math::prelude::Vec2, + ) -> bevy::math::primitives::Ellipse; + +"#, + r#" +/// Returns the [eccentricity](https://en.wikipedia.org/wiki/Eccentricity_(mathematics)) of the ellipse. +/// It can be thought of as a measure of how "stretched" or elongated the ellipse is. +/// The value should be in the range [0, 1), where 0 represents a circle, and 1 represents a parabola. + + #[lua(kind = "Method")] + fn eccentricity(&self) -> f32; + +"#, + r#" +/// Get the focal length of the ellipse. This corresponds to the distance between one of the foci and the center of the ellipse. +/// The focal length of an ellipse is related to its eccentricity by `eccentricity = focal_length / semi_major` + + #[lua(kind = "Method")] + fn focal_length(&self) -> f32; + +"#, + r#" +/// Returns the length of the semi-major axis. This corresponds to the longest radius of the ellipse. + + #[lua(kind = "Method")] + fn semi_major(&self) -> f32; + +"#, + r#" +/// Returns the length of the semi-minor axis. This corresponds to the shortest radius of the ellipse. + + #[lua(kind = "Method")] + fn semi_minor(&self) -> f32; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Ellipse; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Ellipse { + #[lua(output(proxy))] + half_size: bevy::math::prelude::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + 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", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Line2d) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Line2d { + #[lua(output(proxy))] + direction: bevy::math::prelude::Dir2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Plane2d", + functions[r#" +/// Create a new `Plane2d` from a normal +/// # Panics +/// Panics if the given `normal` is zero (or very close to zero), or non-finite. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + 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#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Plane2d; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Plane2d { + #[lua(output(proxy))] + normal: bevy::math::prelude::Dir2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Rectangle", + functions[r#" +/// Create a new `Rectangle` from a full width and height + + #[lua(kind = "Function", output(proxy))] + fn new(width: f32, height: f32) -> bevy::math::primitives::Rectangle; + +"#, + r#" +/// Create a new `Rectangle` from a given full size + + #[lua(kind = "Function", output(proxy))] + fn from_size( + #[proxy] + size: bevy::math::prelude::Vec2, + ) -> bevy::math::primitives::Rectangle; + +"#, + r#" +/// Create a new `Rectangle` from two corner points + + #[lua(kind = "Function", output(proxy))] + fn from_corners( + #[proxy] + point1: bevy::math::prelude::Vec2, + #[proxy] + point2: bevy::math::prelude::Vec2, + ) -> bevy::math::primitives::Rectangle; + +"#, + r#" +/// Create a `Rectangle` from a single length. +/// The resulting `Rectangle` will be the same size in every direction. + + #[lua(kind = "Function", output(proxy))] + fn from_length(length: f32) -> bevy::math::primitives::Rectangle; + +"#, + r#" +/// Get the size of the rectangle + + #[lua(kind = "Method", output(proxy))] + fn size(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Finds the point on the rectangle that is closest to the given `point`. +/// If the point is outside the rectangle, the returned point will be on the perimeter of the rectangle. +/// Otherwise, it will be inside the rectangle and returned as is. + + #[lua(kind = "Method", output(proxy))] + fn closest_point( + &self, + #[proxy] + 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#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Rectangle; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Rectangle { + #[lua(output(proxy))] + half_size: bevy::math::prelude::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::RegularPolygon", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::RegularPolygon; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::RegularPolygon) -> bool; + +"#, + r#" +/// Create a new `RegularPolygon` +/// from the radius of the circumcircle and a number of sides +/// # Panics +/// Panics if `circumradius` is negative + + #[lua(kind = "Function", output(proxy))] + fn new(circumradius: f32, sides: usize) -> bevy::math::primitives::RegularPolygon; + +"#, + r#" +/// Get the radius of the circumcircle on which all vertices +/// of the regular polygon lie + + #[lua(kind = "Method")] + fn circumradius(&self) -> f32; + +"#, + r#" +/// Get the inradius or apothem of the regular polygon. +/// This is the radius of the largest circle that can +/// be drawn within the polygon + + #[lua(kind = "Method")] + fn inradius(&self) -> f32; + +"#, + r#" +/// Get the length of one side of the regular polygon + + #[lua(kind = "Method")] + fn side_length(&self) -> f32; + +"#, + r#" +/// Get the internal angle of the regular polygon in degrees. +/// This is the angle formed by two adjacent sides with points +/// within the angle being in the interior of the polygon + + #[lua(kind = "Method")] + fn internal_angle_degrees(&self) -> f32; + +"#, + r#" +/// Get the internal angle of the regular polygon in radians. +/// This is the angle formed by two adjacent sides with points +/// within the angle being in the interior of the polygon + + #[lua(kind = "Method")] + fn internal_angle_radians(&self) -> f32; + +"#, + r#" +/// Get the external angle of the regular polygon in degrees. +/// This is the angle formed by two adjacent sides with points +/// within the angle being in the exterior of the polygon + + #[lua(kind = "Method")] + fn external_angle_degrees(&self) -> f32; + +"#, + r#" +/// Get the external angle of the regular polygon in radians. +/// This is the angle formed by two adjacent sides with points +/// within the angle being in the exterior of the polygon + + #[lua(kind = "Method")] + fn external_angle_radians(&self) -> f32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct RegularPolygon { + #[lua(output(proxy))] + circumcircle: bevy::math::primitives::Circle, + sides: usize, +} +#[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))] + fn new( + horizontal_diagonal: f32, + vertical_diagonal: f32, + ) -> bevy::math::primitives::Rhombus; + +"#, + r#" +/// Create a new `Rhombus` from a side length with all inner angles equal. + + #[lua(kind = "Function", output(proxy))] + fn from_side(side: f32) -> bevy::math::primitives::Rhombus; + +"#, + r#" +/// Create a new `Rhombus` from a given inradius with all inner angles equal. + + #[lua(kind = "Function", output(proxy))] + fn from_inradius(inradius: f32) -> bevy::math::primitives::Rhombus; + +"#, + r#" +/// Get the length of each side of the rhombus + + #[lua(kind = "Method")] + fn side(&self) -> f32; + +"#, + r#" +/// Get the radius of the circumcircle on which all vertices +/// of the rhombus lie + + #[lua(kind = "Method")] + fn circumradius(&self) -> f32; + +"#, + r#" +/// Get the radius of the largest circle that can +/// be drawn within the rhombus + + #[lua(kind = "Method")] + fn inradius(&self) -> f32; + +"#, + r#" +/// Finds the point on the rhombus that is closest to the given `point`. +/// If the point is outside the rhombus, the returned point will be on the perimeter of the rhombus. +/// Otherwise, it will be inside the rhombus and returned as is. + + #[lua(kind = "Method", output(proxy))] + fn closest_point( + &self, + #[proxy] + point: bevy::math::prelude::Vec2, + ) -> bevy::math::prelude::Vec2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Rhombus { + #[lua(output(proxy))] + half_diagonals: bevy::math::prelude::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Segment2d", + functions[r#" +/// Create a new `Segment2d` from a direction and full length of the segment + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + direction: bevy::math::prelude::Dir2, + length: f32, + ) -> bevy::math::primitives::Segment2d; + +"#, + r#" +/// Get the position of the first point on the line segment + + #[lua(kind = "Method", output(proxy))] + fn point1(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Get the position of the second point on the line segment + + #[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")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Segment2d { + #[lua(output(proxy))] + direction: bevy::math::prelude::Dir2, + half_length: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Triangle2d", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Triangle2d; + +"#, + r#" +/// Create a new `Triangle2d` from points `a`, `b`, and `c` + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + a: bevy::math::prelude::Vec2, + #[proxy] + b: bevy::math::prelude::Vec2, + #[proxy] + c: bevy::math::prelude::Vec2, + ) -> bevy::math::primitives::Triangle2d; + +"#, + r#" +/// Checks if the triangle is degenerate, meaning it has zero area. +/// A triangle is degenerate if the cross product of the vectors `ab` and `ac` has a length less than `10e-7`. +/// This indicates that the three vertices are collinear or nearly collinear. + + #[lua(kind = "Method")] + fn is_degenerate(&self) -> bool; + +"#, + r#" +/// Checks if the triangle is acute, meaning all angles are less than 90 degrees + + #[lua(kind = "Method")] + fn is_acute(&self) -> bool; + +"#, + r#" +/// Checks if the triangle is obtuse, meaning one angle is greater than 90 degrees + + #[lua(kind = "Method")] + fn is_obtuse(&self) -> bool; + +"#, + r#" +/// Reverse the [`WindingOrder`] of the triangle +/// by swapping the first and last vertices. + + #[lua(kind = "MutatingMethod")] + fn reverse(&mut self) -> (); + +"#, + r#" +/// This triangle but reversed. + + #[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")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Triangle2d { + vertices: ReflectedValue, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::bounding::Aabb3d", + functions[r#" +/// Computes the smallest [`BoundingSphere`] containing this [`Aabb3d`]. + + #[lua(kind = "Method", output(proxy))] + fn bounding_sphere(&self) -> bevy::math::bounding::BoundingSphere; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::Aabb3d; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Aabb3d { + #[lua(output(proxy))] + min: bevy::math::Vec3A, + #[lua(output(proxy))] + max: bevy::math::Vec3A, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::bounding::BoundingSphere", + functions[r#" +/// Get the radius of the bounding sphere + + #[lua(kind = "Method")] + fn radius(&self) -> f32; + +"#, + r#" +/// Computes the smallest [`Aabb3d`] containing this [`BoundingSphere`]. + + #[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")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct BoundingSphere { + #[lua(output(proxy))] + center: bevy::math::Vec3A, + #[lua(output(proxy))] + sphere: bevy::math::primitives::Sphere, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Sphere", + functions[r#" +/// Create a new [`Sphere`] from a `radius` + + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32) -> bevy::math::primitives::Sphere; + +"#, + r#" +/// Get the diameter of the sphere + + #[lua(kind = "Method")] + fn diameter(&self) -> f32; + +"#, + r#" +/// Finds the point on the sphere that is closest to the given `point`. +/// If the point is outside the sphere, the returned point will be on the surface of the sphere. +/// Otherwise, it will be inside the sphere and returned as is. + + #[lua(kind = "Method", output(proxy))] + fn closest_point( + &self, + #[proxy] + 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#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Sphere; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Sphere { + radius: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Cuboid", + functions[r#" +/// Create a new `Cuboid` from a full x, y, and z length + + #[lua(kind = "Function", output(proxy))] + fn new( + x_length: f32, + y_length: f32, + z_length: f32, + ) -> bevy::math::primitives::Cuboid; + +"#, + r#" +/// Create a new `Cuboid` from a given full size + + #[lua(kind = "Function", output(proxy))] + fn from_size( + #[proxy] + size: bevy::math::prelude::Vec3, + ) -> bevy::math::primitives::Cuboid; + +"#, + r#" +/// Create a new `Cuboid` from two corner points + + #[lua(kind = "Function", output(proxy))] + fn from_corners( + #[proxy] + point1: bevy::math::prelude::Vec3, + #[proxy] + point2: bevy::math::prelude::Vec3, + ) -> bevy::math::primitives::Cuboid; + +"#, + r#" +/// Create a `Cuboid` from a single length. +/// The resulting `Cuboid` will be the same size in every direction. + + #[lua(kind = "Function", output(proxy))] + fn from_length(length: f32) -> bevy::math::primitives::Cuboid; + +"#, + r#" +/// Get the size of the cuboid + + #[lua(kind = "Method", output(proxy))] + fn size(&self) -> bevy::math::prelude::Vec3; + +"#, + r#" +/// Finds the point on the cuboid that is closest to the given `point`. +/// If the point is outside the cuboid, the returned point will be on the surface of the cuboid. +/// Otherwise, it will be inside the cuboid and returned as is. + + #[lua(kind = "Method", output(proxy))] + fn closest_point( + &self, + #[proxy] + 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::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")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Cuboid { + #[lua(output(proxy))] + half_size: bevy::math::prelude::Vec3, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Cylinder", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + 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 + + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32, height: f32) -> bevy::math::primitives::Cylinder; + +"#, + r#" +/// Get the base of the cylinder as a [`Circle`] + + #[lua(kind = "Method", output(proxy))] + fn base(&self) -> bevy::math::primitives::Circle; + +"#, + r#" +/// Get the surface area of the side of the cylinder, +/// also known as the lateral area + + #[lua(kind = "Method")] + fn lateral_area(&self) -> f32; + +"#, + r#" +/// Get the surface area of one base of the cylinder + + #[lua(kind = "Method")] + fn base_area(&self) -> f32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Cylinder { + radius: f32, + half_height: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + 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))] + fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule3d; + +"#, + r#" +/// Get the part connecting the hemispherical ends +/// of the capsule as a [`Cylinder`] + + #[lua(kind = "Method", output(proxy))] + fn to_cylinder(&self) -> bevy::math::primitives::Cylinder; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Capsule3d; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Capsule3d { + radius: f32, + half_length: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Cone", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::Cone) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Cone; + +"#, + r#" +/// Get the base of the cone as a [`Circle`] + + #[lua(kind = "Method", output(proxy))] + fn base(&self) -> bevy::math::primitives::Circle; + +"#, + r#" +/// Get the slant height of the cone, the length of the line segment +/// connecting a point on the base to the apex + + #[lua(kind = "Method")] + fn slant_height(&self) -> f32; + +"#, + r#" +/// Get the surface area of the side of the cone, +/// also known as the lateral area + + #[lua(kind = "Method")] + fn lateral_area(&self) -> f32; + +"#, + r#" +/// Get the surface area of the base of the cone + + #[lua(kind = "Method")] + fn base_area(&self) -> f32; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Cone { + radius: f32, + height: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::ConicalFrustum", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::ConicalFrustum; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::ConicalFrustum) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct ConicalFrustum { + radius_top: f32, + radius_bottom: f32, + height: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::InfinitePlane3d", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::InfinitePlane3d; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::InfinitePlane3d) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct InfinitePlane3d { + #[lua(output(proxy))] + normal: bevy::math::prelude::Dir3, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Line3d", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Line3d; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::Line3d) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Line3d { + #[lua(output(proxy))] + direction: bevy::math::prelude::Dir3, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Segment3d", + functions[r#" +/// Create a new `Segment3d` from a direction and full length of the segment + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + direction: bevy::math::prelude::Dir3, + length: f32, + ) -> bevy::math::primitives::Segment3d; + +"#, + r#" +/// Get the position of the first point on the line segment + + #[lua(kind = "Method", output(proxy))] + fn point1(&self) -> bevy::math::prelude::Vec3; + +"#, + r#" +/// Get the position of the second point on the line segment + + #[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#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::Segment3d) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Segment3d { + #[lua(output(proxy))] + direction: bevy::math::prelude::Dir3, + half_length: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Torus", + functions[r#" +/// Create a new `Torus` from an inner and outer radius. +/// The inner radius is the radius of the hole, and the outer radius +/// is the radius of the entire object + + #[lua(kind = "Function", output(proxy))] + fn new(inner_radius: f32, outer_radius: f32) -> bevy::math::primitives::Torus; + +"#, + r#" +/// Get the inner radius of the torus. +/// For a ring torus, this corresponds to the radius of the hole, +/// or `major_radius - minor_radius` + + #[lua(kind = "Method")] + fn inner_radius(&self) -> f32; + +"#, + r#" +/// Get the outer radius of the torus. +/// This corresponds to the overall radius of the entire object, +/// or `major_radius + minor_radius` + + #[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#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::Torus) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Torus { + minor_radius: f32, + major_radius: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + 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))] + fn new( + #[proxy] + a: bevy::math::prelude::Vec3, + #[proxy] + b: bevy::math::prelude::Vec3, + #[proxy] + c: bevy::math::prelude::Vec3, + ) -> bevy::math::primitives::Triangle3d; + +"#, + r#" +/// Checks if the triangle is degenerate, meaning it has zero area. +/// A triangle is degenerate if the cross product of the vectors `ab` and `ac` has a length less than `10e-7`. +/// This indicates that the three vertices are collinear or nearly collinear. + + #[lua(kind = "Method")] + fn is_degenerate(&self) -> bool; + +"#, + r#" +/// Checks if the triangle is acute, meaning all angles are less than 90 degrees + + #[lua(kind = "Method")] + fn is_acute(&self) -> bool; + +"#, + r#" +/// Checks if the triangle is obtuse, meaning one angle is greater than 90 degrees + + #[lua(kind = "Method")] + fn is_obtuse(&self) -> bool; + +"#, + r#" +/// Reverse the triangle by swapping the first and last vertices. + + #[lua(kind = "MutatingMethod")] + fn reverse(&mut self) -> (); + +"#, + r#" +/// This triangle but reversed. + + #[lua(kind = "Method", output(proxy))] + fn reversed(self) -> bevy::math::primitives::Triangle3d; + +"#, + r#" +/// Get the centroid of the triangle. +/// This function finds the geometric center of the triangle by averaging the vertices: +/// `centroid = (a + b + c) / 3`. + + #[lua(kind = "Method", output(proxy))] + fn centroid(&self) -> bevy::math::prelude::Vec3; + +"#, + r#" +/// Get the circumcenter of the triangle. + + #[lua(kind = "Method", output(proxy))] + fn circumcenter(&self) -> bevy::math::prelude::Vec3; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Triangle3d { + vertices: ReflectedValue, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::bounding::RayCast2d", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::RayCast2d; + +"#, + r#" +/// Construct a [`RayCast2d`] from an origin, [`Dir2`], and max distance. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + origin: bevy::math::prelude::Vec2, + #[proxy] + direction: bevy::math::prelude::Dir2, + max: f32, + ) -> bevy::math::bounding::RayCast2d; + +"#, + r#" +/// Construct a [`RayCast2d`] from a [`Ray2d`] and max distance. + + #[lua(kind = "Function", output(proxy))] + fn from_ray( + #[proxy] + ray: bevy::math::Ray2d, + max: f32, + ) -> bevy::math::bounding::RayCast2d; + +"#, + r#" +/// Get the cached multiplicative inverse of the direction of the ray. + + #[lua(kind = "Method", output(proxy))] + fn direction_recip(&self) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Get the distance of an intersection with an [`Aabb2d`], if any. + + #[lua(kind = "Method")] + fn aabb_intersection_at( + &self, + #[proxy] + aabb: &bounding::bounded2d::Aabb2d, + ) -> std::option::Option; + +"#, + r#" +/// Get the distance of an intersection with a [`BoundingCircle`], if any. + + #[lua(kind = "Method")] + fn circle_intersection_at( + &self, + #[proxy] + circle: &bounding::bounded2d::BoundingCircle, + ) -> std::option::Option; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct RayCast2d { + #[lua(output(proxy))] + ray: bevy::math::Ray2d, + max: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + 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))] + fn new( + #[proxy] + aabb: bevy::math::bounding::Aabb2d, + #[proxy] + origin: bevy::math::prelude::Vec2, + #[proxy] + direction: bevy::math::prelude::Dir2, + max: f32, + ) -> bevy::math::bounding::AabbCast2d; + +"#, + r#" +/// Construct an [`AabbCast2d`] from an [`Aabb2d`], [`Ray2d`], and max distance. + + #[lua(kind = "Function", output(proxy))] + fn from_ray( + #[proxy] + aabb: bevy::math::bounding::Aabb2d, + #[proxy] + ray: bevy::math::Ray2d, + max: f32, + ) -> bevy::math::bounding::AabbCast2d; + +"#, + r#" +/// Get the distance at which the [`Aabb2d`]s collide, if at all. + + #[lua(kind = "Method")] + fn aabb_collision_at( + &self, + #[proxy] + aabb: bevy::math::bounding::Aabb2d, + ) -> std::option::Option; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AabbCast2d { + #[lua(output(proxy))] + ray: bevy::math::bounding::RayCast2d, + #[lua(output(proxy))] + aabb: bevy::math::bounding::Aabb2d, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::bounding::BoundingCircleCast", + functions[r#" +/// Construct a [`BoundingCircleCast`] from a [`BoundingCircle`], origin, [`Dir2`], and max distance. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + circle: bevy::math::bounding::BoundingCircle, + #[proxy] + origin: bevy::math::prelude::Vec2, + #[proxy] + direction: bevy::math::prelude::Dir2, + max: f32, + ) -> bevy::math::bounding::BoundingCircleCast; + +"#, + r#" +/// Construct a [`BoundingCircleCast`] from a [`BoundingCircle`], [`Ray2d`], and max distance. + + #[lua(kind = "Function", output(proxy))] + fn from_ray( + #[proxy] + circle: bevy::math::bounding::BoundingCircle, + #[proxy] + ray: bevy::math::Ray2d, + max: f32, + ) -> bevy::math::bounding::BoundingCircleCast; + +"#, + r#" +/// Get the distance at which the [`BoundingCircle`]s collide, if at all. + + #[lua(kind = "Method")] + fn circle_collision_at( + &self, + #[proxy] + circle: bevy::math::bounding::BoundingCircle, + ) -> std::option::Option; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::BoundingCircleCast; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct BoundingCircleCast { + #[lua(output(proxy))] + ray: bevy::math::bounding::RayCast2d, + #[lua(output(proxy))] + circle: bevy::math::bounding::BoundingCircle, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::bounding::RayCast3d", + functions[r#" +/// Construct a [`RayCast3d`] from a [`Ray3d`] and max distance. + + #[lua(kind = "Function", output(proxy))] + fn from_ray( + #[proxy] + ray: bevy::math::Ray3d, + max: f32, + ) -> bevy::math::bounding::RayCast3d; + +"#, + r#" +/// Get the cached multiplicative inverse of the direction of the ray. + + #[lua(kind = "Method", output(proxy))] + fn direction_recip(&self) -> bevy::math::Vec3A; + +"#, + r#" +/// Get the distance of an intersection with an [`Aabb3d`], if any. + + #[lua(kind = "Method")] + fn aabb_intersection_at( + &self, + #[proxy] + aabb: &bounding::bounded3d::Aabb3d, + ) -> std::option::Option; + +"#, + r#" +/// Get the distance of an intersection with a [`BoundingSphere`], if any. + + #[lua(kind = "Method")] + fn sphere_intersection_at( + &self, + #[proxy] + 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")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct RayCast3d { + #[lua(output(proxy))] + origin: bevy::math::Vec3A, + #[lua(output(proxy))] + direction: bevy::math::prelude::Dir3A, + max: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::bounding::AabbCast3d", + functions[r#" +/// Construct an [`AabbCast3d`] from an [`Aabb3d`], [`Ray3d`], and max distance. + + #[lua(kind = "Function", output(proxy))] + fn from_ray( + #[proxy] + aabb: bevy::math::bounding::Aabb3d, + #[proxy] + ray: bevy::math::Ray3d, + max: f32, + ) -> bevy::math::bounding::AabbCast3d; + +"#, + r#" +/// Get the distance at which the [`Aabb3d`]s collide, if at all. + + #[lua(kind = "Method")] + fn aabb_collision_at( + &self, + #[proxy] + aabb: bevy::math::bounding::Aabb3d, + ) -> std::option::Option; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::AabbCast3d; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AabbCast3d { + #[lua(output(proxy))] + ray: bevy::math::bounding::RayCast3d, + #[lua(output(proxy))] + aabb: bevy::math::bounding::Aabb3d, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::bounding::BoundingSphereCast", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::BoundingSphereCast; + +"#, + r#" +/// Construct a [`BoundingSphereCast`] from a [`BoundingSphere`], [`Ray3d`], and max distance. + + #[lua(kind = "Function", output(proxy))] + fn from_ray( + #[proxy] + sphere: bevy::math::bounding::BoundingSphere, + #[proxy] + ray: bevy::math::Ray3d, + max: f32, + ) -> bevy::math::bounding::BoundingSphereCast; + +"#, + r#" +/// Get the distance at which the [`BoundingSphere`]s collide, if at all. + + #[lua(kind = "Method")] + fn sphere_collision_at( + &self, + #[proxy] + sphere: bevy::math::bounding::BoundingSphere, + ) -> std::option::Option; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct BoundingSphereCast { + #[lua(output(proxy))] + ray: bevy::math::bounding::RayCast3d, + #[lua(output(proxy))] + sphere: bevy::math::bounding::BoundingSphere, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::FloatOrd", + functions[r#" + + #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] + fn lt(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] + fn le(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] + fn gt(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] + fn ge(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::FloatOrd; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::FloatOrd; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct FloatOrd(f32); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Annulus", + 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; + +"#, + r#" +/// Get the diameter of the annulus + + #[lua(kind = "Method")] + fn diameter(&self) -> f32; + +"#, + r#" +/// 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( + &self, + #[proxy] + 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::primitives::Annulus; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Annulus) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +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( + 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. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + normal: bevy::math::prelude::Vec3, + #[proxy] + half_size: bevy::math::prelude::Vec2, + ) -> bevy::math::primitives::Plane3d; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Plane3d; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Plane3d { + #[lua(output(proxy))] + normal: bevy::math::prelude::Dir3, + #[lua(output(proxy))] + half_size: bevy::math::prelude::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + 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; + +"#, + r#" +/// Create a new [`Tetrahedron`] from points `a`, `b`, `c` and `d`. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + a: bevy::math::prelude::Vec3, + #[proxy] + b: bevy::math::prelude::Vec3, + #[proxy] + c: bevy::math::prelude::Vec3, + #[proxy] + d: bevy::math::prelude::Vec3, + ) -> bevy::math::primitives::Tetrahedron; + +"#, + r#" +/// Get the signed volume of the tetrahedron. +/// If it's negative, the normal vector of the face defined by +/// the first three points using the right-hand rule points +/// away from the fourth vertex. + + #[lua(kind = "Method")] + fn signed_volume(&self) -> f32; + +"#, + r#" +/// Get the centroid of the tetrahedron. +/// This function finds the geometric center of the tetrahedron +/// by averaging the vertices: `centroid = (a + b + c + d) / 4`. + + #[lua(kind = "Method", output(proxy))] + fn centroid(&self) -> bevy::math::prelude::Vec3; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Tetrahedron { + vertices: ReflectedValue, +} +#[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( + "AspectRatio", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Ray2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Ray3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Rot2", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Dir2", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Dir3", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Dir3A", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "IRect", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Rect", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "URect", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Aabb2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "BoundingCircle", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaBoundingCircle, + >::new, + )?; + instances + .add_instance( + "Circle", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Arc2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Capsule2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "CircularSector", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaCircularSector, + >::new, + )?; + instances + .add_instance( + "CircularSegment", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaCircularSegment, + >::new, + )?; + instances + .add_instance( + "Ellipse", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Plane2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Rectangle", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "RegularPolygon", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaRegularPolygon, + >::new, + )?; + instances + .add_instance( + "Rhombus", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Segment2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Triangle2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Sphere", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Cuboid", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Cylinder", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Capsule3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Segment3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Torus", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Triangle3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "RayCast2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AabbCast2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "BoundingCircleCast", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaBoundingCircleCast, + >::new, + )?; + instances + .add_instance( + "RayCast3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AabbCast3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "BoundingSphereCast", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaBoundingSphereCast, + >::new, + )?; + instances + .add_instance( + "Annulus", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Plane3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Tetrahedron", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + Ok(()) + } +} +pub struct BevyMathAPIProvider; +impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { + 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( + "BevyMathAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAspectRatio, + >, + >() + .process_type::() + .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, + >() + .process_type::() + .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, + >() + .process_type::() + .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, + >() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaBoundingCircle, + >, + >() + .process_type::() + .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< + LuaCapsule2d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaCircularSector, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaCircularSegment, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaRectangle, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaRegularPolygon, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaSegment2d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaTriangle2d, + >, + >() + .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, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaCylinder, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaCapsule3d, + >, + >() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaSegment3d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaTriangle3d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaRayCast2d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAabbCast2d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaBoundingCircleCast, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaRayCast3d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAabbCast3d, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaBoundingSphereCast, + >, + >() + .process_type::() + .process_type::() + .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< + LuaTetrahedron, + >, + >() + }, + ), + ) + } + 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::(); + 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::(); + 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_reflect.rs b/crates/bevy_script_api/src/providers/bevy_reflect.rs index 2af5976c..357cd406 100644 --- a/crates/bevy_script_api/src/providers/bevy_reflect.rs +++ b/crates/bevy_script_api/src/providers/bevy_reflect.rs @@ -11,81 +11,6 @@ use bevy_script_api::{ derive(clone), remote = "bevy::utils::Duration", functions[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; - -"#, - 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::utils::Duration; - -"#, - 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 = "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#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::utils::Duration; - -"#, - 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 @@ -147,6 +72,10 @@ use bevy_script_api::{ "#, r#" /// Creates a new `Duration` from the specified number of nanoseconds. +/// Note: Using this on the return value of `as_nanos()` might cause unexpected behavior: +/// `as_nanos()` returns a u128, and can return values that do not fit in u64, e.g. 585 years. +/// Instead, consider using the pattern `Duration::new(d.as_secs(), d.subsec_nanos())` +/// if you cannot copy/clone the Duration directly. /// # Examples /// ``` /// use std::time::Duration; @@ -494,21 +423,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#" -/// # 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. + + #[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", @@ -517,7 +443,47 @@ struct Duration {} composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; + fn add(self, #[proxy] rhs: bevy::utils::Duration) -> 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::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::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u32) -> bevy::utils::Duration; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -528,13 +494,29 @@ struct Duration {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &bevy_utils::Instant) -> bool; + fn eq(&self, #[proxy] other: &bevy_utils::Duration) -> 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 = "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::utils::Instant; "#, r#" @@ -551,12 +533,23 @@ struct Duration {} "#, r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +/// # 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. + #[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::utils::Instant; + fn add(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; "#, r#" @@ -575,7 +568,7 @@ struct Duration {} /// 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 `earlier` was later than `self`. Currently this +/// Previous Rust versions panicked when `earlier` was later than `self`. Currently this /// method saturates. Future versions may reintroduce the panic in some circumstances. /// See [Monotonicity]. /// [Monotonicity]: Instant#monotonicity @@ -623,7 +616,7 @@ struct Duration {} r#" /// Returns the amount of time elapsed since this instant. /// # Panics -/// Previous rust versions panicked when the current time was earlier than self. Currently this +/// Previous Rust versions panicked when the current time was earlier than self. Currently this /// method returns a Duration of zero in that case. Future versions may reintroduce the panic. /// See [Monotonicity]. /// [Monotonicity]: Instant#monotonicity @@ -645,7 +638,7 @@ struct Duration {} /// 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 +/// 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 @@ -659,6 +652,17 @@ struct Duration {} )] fn sub(self, #[proxy] other: bevy::utils::Instant) -> bevy::utils::Duration; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_utils::Instant) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -671,7 +675,7 @@ struct Instant(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "std::num::NonZeroI128", + remote = "std::path::PathBuf", functions[r#" #[lua( @@ -679,327 +683,223 @@ struct Instant(); kind = "Method", output(proxy), )] - fn clone(&self) -> std::num::NonZeroI128; + fn clone(&self) -> std::path::PathBuf; "#, r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. +/// 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(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: i128) -> std::num::NonZeroI128; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "MutatingMethod", + )] + fn clone_from(&mut self, #[proxy] source: &std::path::PathBuf) -> (); "#, r#" -/// Returns the value as a primitive type. +/// Allocates an empty `PathBuf`. +/// # Examples +/// ``` +/// use std::path::PathBuf; +/// let path = PathBuf::new(); +/// ``` - #[lua(kind = "Method")] - fn get(self) -> i128; + #[lua(kind = "Function", output(proxy))] + fn new() -> std::path::PathBuf; "#, r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// Creates a new `PathBuf` with a given capacity used to create the +/// internal [`OsString`]. See [`with_capacity`] defined on [`OsString`]. /// # Examples -/// Basic usage: /// ``` -///let n = std::num::NonZeroI128::new(-1i128).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); +/// use std::path::PathBuf; +/// let mut path = PathBuf::with_capacity(10); +/// let capacity = path.capacity(); +/// // This push is done without reallocating +/// path.push(r"C:\"); +/// assert_eq!(capacity, path.capacity()); /// ``` +/// [`with_capacity`]: OsString::with_capacity - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; + #[lua(kind = "Function", output(proxy))] + fn with_capacity(capacity: usize) -> std::path::PathBuf; "#, r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. +/// Truncates `self` to [`self.parent`]. +/// Returns `false` and does nothing if [`self.parent`] is [`None`]. +/// Otherwise, returns `true`. +/// [`self.parent`]: Path::parent /// # Examples -/// Basic usage: /// ``` -///let n = std::num::NonZeroI128::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); +/// use std::path::{Path, PathBuf}; +/// let mut p = PathBuf::from("/spirited/away.rs"); +/// p.pop(); +/// assert_eq!(Path::new("/spirited"), p); +/// p.pop(); +/// assert_eq!(Path::new("/"), p); /// ``` - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; + #[lua(kind = "MutatingMethod")] + fn pop(&mut self) -> bool; "#, r#" -/// Computes the absolute value of self. -///See [`i128::abs`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI128::new(1)?; -///let neg = NonZeroI128::new(-1)?; -/// assert_eq!(pos, pos.abs()); -/// assert_eq!(pos, neg.abs()); -/// # Some(()) -/// # } -/// ``` +/// Invokes [`capacity`] on the underlying instance of [`OsString`]. +/// [`capacity`]: OsString::capacity - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> std::num::NonZeroI128; + #[lua(kind = "Method")] + fn capacity(&self) -> usize; "#, r#" -/// Saturating absolute value, see -///[`i128::saturating_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI128::new(1)?; -///let neg = NonZeroI128::new(-1)?; -///let min = NonZeroI128::new(i128::MIN)?; -///let min_plus = NonZeroI128::new(i128::MIN + 1)?; -///let max = NonZeroI128::new(i128::MAX)?; -/// assert_eq!(pos, pos.saturating_abs()); -/// assert_eq!(pos, neg.saturating_abs()); -/// assert_eq!(max, min.saturating_abs()); -/// assert_eq!(max, min_plus.saturating_abs()); -/// # Some(()) -/// # } -/// ``` +/// Invokes [`clear`] on the underlying instance of [`OsString`]. +/// [`clear`]: OsString::clear - #[lua(kind = "Method", output(proxy))] - fn saturating_abs(self) -> std::num::NonZeroI128; + #[lua(kind = "MutatingMethod")] + fn clear(&mut self) -> (); "#, r#" -/// Wrapping absolute value, see -///[`i128::wrapping_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI128::new(1)?; -///let neg = NonZeroI128::new(-1)?; -///let min = NonZeroI128::new(i128::MIN)?; -///# let max = NonZeroI128::new(i128::MAX)?; -/// assert_eq!(pos, pos.wrapping_abs()); -/// assert_eq!(pos, neg.wrapping_abs()); -/// assert_eq!(min, min.wrapping_abs()); -/// assert_eq!(max, (-max).wrapping_abs()); -/// # Some(()) -/// # } -/// ``` +/// Invokes [`reserve`] on the underlying instance of [`OsString`]. +/// [`reserve`]: OsString::reserve - #[lua(kind = "Method", output(proxy))] - fn wrapping_abs(self) -> std::num::NonZeroI128; + #[lua(kind = "MutatingMethod")] + fn reserve(&mut self, additional: usize) -> (); "#, r#" -/// Computes the absolute value of self -/// without any wrapping or panicking. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -///# use std::num::NonZeroU128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let u_pos = NonZeroU128::new(1)?; -///let i_pos = NonZeroI128::new(1)?; -///let i_neg = NonZeroI128::new(-1)?; -///let i_min = NonZeroI128::new(i128::MIN)?; -///let u_max = NonZeroU128::new(u128::MAX / 2 + 1)?; -/// assert_eq!(u_pos, i_pos.unsigned_abs()); -/// assert_eq!(u_pos, i_neg.unsigned_abs()); -/// assert_eq!(u_max, i_min.unsigned_abs()); -/// # Some(()) -/// # } -/// ``` +/// Invokes [`reserve_exact`] on the underlying instance of [`OsString`]. +/// [`reserve_exact`]: OsString::reserve_exact - #[lua(kind = "Method", output(proxy))] - fn unsigned_abs(self) -> std::num::NonZeroU128; + #[lua(kind = "MutatingMethod")] + fn reserve_exact(&mut self, additional: usize) -> (); "#, r#" -/// Returns `true` if `self` is positive and `false` if the -/// number is negative. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI128::new(5)?; -///let neg_five = NonZeroI128::new(-5)?; -/// assert!(pos_five.is_positive()); -/// assert!(!neg_five.is_positive()); -/// # Some(()) -/// # } -/// ``` +/// Invokes [`shrink_to_fit`] on the underlying instance of [`OsString`]. +/// [`shrink_to_fit`]: OsString::shrink_to_fit - #[lua(kind = "Method")] - fn is_positive(self) -> bool; + #[lua(kind = "MutatingMethod")] + fn shrink_to_fit(&mut self) -> (); "#, r#" -/// Returns `true` if `self` is negative and `false` if the -/// number is positive. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI128::new(5)?; -///let neg_five = NonZeroI128::new(-5)?; -/// assert!(neg_five.is_negative()); -/// assert!(!pos_five.is_negative()); -/// # Some(()) -/// # } -/// ``` +/// Invokes [`shrink_to`] on the underlying instance of [`OsString`]. +/// [`shrink_to`]: OsString::shrink_to - #[lua(kind = "Method")] - fn is_negative(self) -> bool; + #[lua(kind = "MutatingMethod")] + fn shrink_to(&mut self, min_capacity: usize) -> (); "#, r#" -/// Saturating negation. Computes `-self`, -///returning [`NonZeroI128::MAX`] -///if `self == NonZeroI128::MIN` -/// instead of overflowing. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI128::new(5)?; -///let neg_five = NonZeroI128::new(-5)?; -///let min = NonZeroI128::new(i128::MIN)?; -///let min_plus_one = NonZeroI128::new(i128::MIN + 1)?; -///let max = NonZeroI128::new(i128::MAX)?; -/// assert_eq!(pos_five.saturating_neg(), neg_five); -/// assert_eq!(min.saturating_neg(), max); -/// assert_eq!(max.saturating_neg(), min_plus_one); -/// # Some(()) -/// # } -/// ``` - #[lua(kind = "Method", output(proxy))] - fn saturating_neg(self) -> std::num::NonZeroI128; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::path::PathBuf) -> bool; "#, r#" -/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary -/// of the type. -///See [`i128::wrapping_neg`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI128::new(5)?; -///let neg_five = NonZeroI128::new(-5)?; -///let min = NonZeroI128::new(i128::MIN)?; -/// assert_eq!(pos_five.wrapping_neg(), neg_five); -/// assert_eq!(min.wrapping_neg(), min); -/// # Some(()) -/// # } -/// ``` +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct PathBuf {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "std::ops::RangeFull", + functions[r#" - #[lua(kind = "Method", output(proxy))] - fn wrapping_neg(self) -> std::num::NonZeroI128; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroI128::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroI128::new(2)?; -///let four = NonZeroI128::new(4)?; -///let max = NonZeroI128::new(i128::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroI128, - ) -> std::num::NonZeroI128; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &std::ops::RangeFull) -> bool; "#, r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroI128::MIN`] or [`NonZeroI128::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroI128::new(3)?; -///let twenty_seven = NonZeroI128::new(27)?; -///let max = NonZeroI128::new(i128::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI128; + #[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")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct RangeFull {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Quat", + functions[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: &std::num::NonZeroI128) -> bool; + fn neg(self) -> bevy::math::Quat; "#, r#" +/// Multiplies a quaternion by a scalar value. +/// The product is not guaranteed to be normalized. #[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) -> std::num::NonZeroI128; + fn mul(self, rhs: f32) -> bevy::math::Quat; "#, 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::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[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#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct NonZeroI128(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroI16", - functions[r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -1007,965 +907,465 @@ struct NonZeroI128(); composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &std::num::NonZeroI16) -> bool; + fn eq(&self, #[proxy] rhs: &glam::Quat) -> bool; "#, 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) -> std::num::NonZeroI16; + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, 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::Quat; "#, r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. +/// Creates a new rotation quaternion. +/// This should generally not be called manually unless you know what you are doing. +/// Use one of the other constructors instead such as `identity` or `from_axis_angle`. +/// `from_xyzw` is mostly used by unit tests and `serde` deserialization. +/// # Preconditions +/// This function does not check if the input is normalized, it is up to the user to +/// provide normalized input or to normalized the resulting quaternion. #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: i16) -> std::num::NonZeroI16; + fn from_xyzw(x: f32, y: f32, z: f32, w: f32) -> bevy::math::Quat; "#, r#" -/// Returns the value as a primitive type. +/// Creates a rotation quaternion from an array. +/// # Preconditions +/// This function does not check if the input is normalized, it is up to the user to +/// provide normalized input or to normalized the resulting quaternion. - #[lua(kind = "Method")] - fn get(self) -> i16; + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f32; 4]) -> bevy::math::Quat; "#, r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI16::new(-1i16).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` +/// Creates a new rotation quaternion from a 4D vector. +/// # Preconditions +/// This function does not check if the input is normalized, it is up to the user to +/// provide normalized input or to normalized the resulting quaternion. - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; + #[lua(kind = "Function", output(proxy))] + fn from_vec4(#[proxy] v: bevy::math::Vec4) -> bevy::math::Quat; "#, r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI16::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` +/// Create a quaternion for a normalized rotation `axis` and `angle` (in radians). +/// The axis must be a unit vector. +/// # Panics +/// Will panic if `axis` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; + #[lua(kind = "Function", output(proxy))] + fn from_axis_angle(#[proxy] axis: bevy::math::Vec3, angle: f32) -> bevy::math::Quat; "#, r#" -/// Computes the absolute value of self. -///See [`i16::abs`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI16::new(1)?; -///let neg = NonZeroI16::new(-1)?; -/// assert_eq!(pos, pos.abs()); -/// assert_eq!(pos, neg.abs()); -/// # Some(()) -/// # } -/// ``` +/// Create a quaternion that rotates `v.length()` radians around `v.normalize()`. +/// `from_scaled_axis(Vec3::ZERO)` results in the identity quaternion. - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> std::num::NonZeroI16; + #[lua(kind = "Function", output(proxy))] + fn from_scaled_axis(#[proxy] v: bevy::math::Vec3) -> bevy::math::Quat; "#, r#" -/// Saturating absolute value, see -///[`i16::saturating_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI16::new(1)?; -///let neg = NonZeroI16::new(-1)?; -///let min = NonZeroI16::new(i16::MIN)?; -///let min_plus = NonZeroI16::new(i16::MIN + 1)?; -///let max = NonZeroI16::new(i16::MAX)?; -/// assert_eq!(pos, pos.saturating_abs()); -/// assert_eq!(pos, neg.saturating_abs()); -/// assert_eq!(max, min.saturating_abs()); -/// assert_eq!(max, min_plus.saturating_abs()); -/// # Some(()) -/// # } -/// ``` +/// Creates a quaternion from the `angle` (in radians) around the x axis. - #[lua(kind = "Method", output(proxy))] - fn saturating_abs(self) -> std::num::NonZeroI16; + #[lua(kind = "Function", output(proxy))] + fn from_rotation_x(angle: f32) -> bevy::math::Quat; "#, r#" -/// Wrapping absolute value, see -///[`i16::wrapping_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI16::new(1)?; -///let neg = NonZeroI16::new(-1)?; -///let min = NonZeroI16::new(i16::MIN)?; -///# let max = NonZeroI16::new(i16::MAX)?; -/// assert_eq!(pos, pos.wrapping_abs()); -/// assert_eq!(pos, neg.wrapping_abs()); -/// assert_eq!(min, min.wrapping_abs()); -/// assert_eq!(max, (-max).wrapping_abs()); -/// # Some(()) -/// # } -/// ``` +/// Creates a quaternion from the `angle` (in radians) around the y axis. - #[lua(kind = "Method", output(proxy))] - fn wrapping_abs(self) -> std::num::NonZeroI16; + #[lua(kind = "Function", output(proxy))] + fn from_rotation_y(angle: f32) -> bevy::math::Quat; "#, r#" -/// Computes the absolute value of self -/// without any wrapping or panicking. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -///# use std::num::NonZeroU16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let u_pos = NonZeroU16::new(1)?; -///let i_pos = NonZeroI16::new(1)?; -///let i_neg = NonZeroI16::new(-1)?; -///let i_min = NonZeroI16::new(i16::MIN)?; -///let u_max = NonZeroU16::new(u16::MAX / 2 + 1)?; -/// assert_eq!(u_pos, i_pos.unsigned_abs()); -/// assert_eq!(u_pos, i_neg.unsigned_abs()); -/// assert_eq!(u_max, i_min.unsigned_abs()); -/// # Some(()) -/// # } -/// ``` +/// Creates a quaternion from the `angle` (in radians) around the z axis. - #[lua(kind = "Method", output(proxy))] - fn unsigned_abs(self) -> std::num::NonZeroU16; + #[lua(kind = "Function", output(proxy))] + fn from_rotation_z(angle: f32) -> bevy::math::Quat; "#, r#" -/// Returns `true` if `self` is positive and `false` if the -/// number is negative. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI16::new(5)?; -///let neg_five = NonZeroI16::new(-5)?; -/// assert!(pos_five.is_positive()); -/// assert!(!neg_five.is_positive()); -/// # Some(()) -/// # } -/// ``` +/// Creates a quaternion from the given Euler rotation sequence and the angles (in radians). - #[lua(kind = "Method")] - fn is_positive(self) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_euler( + #[proxy] + euler: bevy::math::EulerRot, + a: f32, + b: f32, + c: f32, + ) -> bevy::math::Quat; "#, r#" -/// Returns `true` if `self` is negative and `false` if the -/// number is positive. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI16::new(5)?; -///let neg_five = NonZeroI16::new(-5)?; -/// assert!(neg_five.is_negative()); -/// assert!(!pos_five.is_negative()); -/// # Some(()) -/// # } -/// ``` +/// Creates a quaternion from a 3x3 rotation matrix. - #[lua(kind = "Method")] - fn is_negative(self) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_mat3(#[proxy] mat: &glam::Mat3) -> bevy::math::Quat; "#, r#" -/// Saturating negation. Computes `-self`, -///returning [`NonZeroI16::MAX`] -///if `self == NonZeroI16::MIN` -/// instead of overflowing. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI16::new(5)?; -///let neg_five = NonZeroI16::new(-5)?; -///let min = NonZeroI16::new(i16::MIN)?; -///let min_plus_one = NonZeroI16::new(i16::MIN + 1)?; -///let max = NonZeroI16::new(i16::MAX)?; -/// assert_eq!(pos_five.saturating_neg(), neg_five); -/// assert_eq!(min.saturating_neg(), max); -/// assert_eq!(max.saturating_neg(), min_plus_one); -/// # Some(()) -/// # } -/// ``` +/// Creates a quaternion from a 3x3 SIMD aligned rotation matrix. - #[lua(kind = "Method", output(proxy))] - fn saturating_neg(self) -> std::num::NonZeroI16; + #[lua(kind = "Function", output(proxy))] + fn from_mat3a(#[proxy] mat: &glam::Mat3A) -> bevy::math::Quat; "#, r#" -/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary -/// of the type. -///See [`i16::wrapping_neg`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI16::new(5)?; -///let neg_five = NonZeroI16::new(-5)?; -///let min = NonZeroI16::new(i16::MIN)?; -/// assert_eq!(pos_five.wrapping_neg(), neg_five); -/// assert_eq!(min.wrapping_neg(), min); -/// # Some(()) -/// # } -/// ``` +/// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. - #[lua(kind = "Method", output(proxy))] - fn wrapping_neg(self) -> std::num::NonZeroI16; + #[lua(kind = "Function", output(proxy))] + fn from_mat4(#[proxy] mat: &glam::Mat4) -> bevy::math::Quat; "#, r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroI16::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroI16::new(2)?; -///let four = NonZeroI16::new(4)?; -///let max = NonZeroI16::new(i16::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` +/// Gets the minimal rotation for transforming `from` to `to`. The rotation is in the +/// plane spanned by the two vectors. Will rotate at most 180 degrees. +/// The inputs must be unit vectors. +/// `from_rotation_arc(from, to) * from ≈ to`. +/// For near-singular cases (from≈to and from≈-to) the current implementation +/// is only accurate to about 0.001 (for `f32`). +/// # Panics +/// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, + #[lua(kind = "Function", output(proxy))] + fn from_rotation_arc( #[proxy] - other: std::num::NonZeroI16, - ) -> std::num::NonZeroI16; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroI16::MIN`] or [`NonZeroI16::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroI16::new(3)?; -///let twenty_seven = NonZeroI16::new(27)?; -///let max = NonZeroI16::new(i16::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI16; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> std::num::NonZeroI16; + from: bevy::math::Vec3, + #[proxy] + to: bevy::math::Vec3, + ) -> bevy::math::Quat; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct NonZeroI16(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroI32", - functions[r#" +/// Gets the minimal rotation for transforming `from` to either `to` or `-to`. This means +/// that the resulting quaternion will rotate `from` so that it is colinear with `to`. +/// The rotation is in the plane spanned by the two vectors. Will rotate at most 90 +/// degrees. +/// The inputs must be unit vectors. +/// `to.dot(from_rotation_arc_colinear(from, to) * from).abs() ≈ 1`. +/// # Panics +/// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> std::num::NonZeroI32; + #[lua(kind = "Function", output(proxy))] + fn from_rotation_arc_colinear( + #[proxy] + from: bevy::math::Vec3, + #[proxy] + to: bevy::math::Vec3, + ) -> bevy::math::Quat; "#, r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. +/// Gets the minimal rotation for transforming `from` to `to`. The resulting rotation is +/// around the z axis. Will rotate at most 180 degrees. +/// The inputs must be unit vectors. +/// `from_rotation_arc_2d(from, to) * from ≈ to`. +/// For near-singular cases (from≈to and from≈-to) the current implementation +/// is only accurate to about 0.001 (for `f32`). +/// # Panics +/// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: i32) -> std::num::NonZeroI32; + fn from_rotation_arc_2d( + #[proxy] + from: bevy::math::Vec2, + #[proxy] + to: bevy::math::Vec2, + ) -> bevy::math::Quat; "#, r#" -/// Returns the value as a primitive type. +/// Returns the rotation axis scaled by the rotation in radians. - #[lua(kind = "Method")] - fn get(self) -> i32; + #[lua(kind = "Method", output(proxy))] + fn to_scaled_axis(self) -> bevy::math::Vec3; "#, r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI32::new(-1i32).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` +/// Returns the rotation angles for the given euler rotation sequence. #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; + fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f32, f32, f32); "#, r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI32::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` +/// `[x, y, z, w]` #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; - -"#, - r#" -/// Computes the absolute value of self. -///See [`i32::abs`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI32::new(1)?; -///let neg = NonZeroI32::new(-1)?; -/// assert_eq!(pos, pos.abs()); -/// assert_eq!(pos, neg.abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> std::num::NonZeroI32; + fn to_array(&self) -> [f32; 4]; "#, r#" -/// Saturating absolute value, see -///[`i32::saturating_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI32::new(1)?; -///let neg = NonZeroI32::new(-1)?; -///let min = NonZeroI32::new(i32::MIN)?; -///let min_plus = NonZeroI32::new(i32::MIN + 1)?; -///let max = NonZeroI32::new(i32::MAX)?; -/// assert_eq!(pos, pos.saturating_abs()); -/// assert_eq!(pos, neg.saturating_abs()); -/// assert_eq!(max, min.saturating_abs()); -/// assert_eq!(max, min_plus.saturating_abs()); -/// # Some(()) -/// # } -/// ``` +/// Returns the vector part of the quaternion. #[lua(kind = "Method", output(proxy))] - fn saturating_abs(self) -> std::num::NonZeroI32; + fn xyz(self) -> bevy::math::Vec3; "#, r#" -/// Wrapping absolute value, see -///[`i32::wrapping_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI32::new(1)?; -///let neg = NonZeroI32::new(-1)?; -///let min = NonZeroI32::new(i32::MIN)?; -///# let max = NonZeroI32::new(i32::MAX)?; -/// assert_eq!(pos, pos.wrapping_abs()); -/// assert_eq!(pos, neg.wrapping_abs()); -/// assert_eq!(min, min.wrapping_abs()); -/// assert_eq!(max, (-max).wrapping_abs()); -/// # Some(()) -/// # } -/// ``` +/// Returns the quaternion conjugate of `self`. For a unit quaternion the +/// conjugate is also the inverse. #[lua(kind = "Method", output(proxy))] - fn wrapping_abs(self) -> std::num::NonZeroI32; + fn conjugate(self) -> bevy::math::Quat; "#, r#" -/// Computes the absolute value of self -/// without any wrapping or panicking. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -///# use std::num::NonZeroU32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let u_pos = NonZeroU32::new(1)?; -///let i_pos = NonZeroI32::new(1)?; -///let i_neg = NonZeroI32::new(-1)?; -///let i_min = NonZeroI32::new(i32::MIN)?; -///let u_max = NonZeroU32::new(u32::MAX / 2 + 1)?; -/// assert_eq!(u_pos, i_pos.unsigned_abs()); -/// assert_eq!(u_pos, i_neg.unsigned_abs()); -/// assert_eq!(u_max, i_min.unsigned_abs()); -/// # Some(()) -/// # } -/// ``` +/// Returns the inverse of a normalized quaternion. +/// Typically quaternion inverse returns the conjugate of a normalized quaternion. +/// Because `self` is assumed to already be unit length this method *does not* normalize +/// before returning the conjugate. +/// # Panics +/// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn unsigned_abs(self) -> std::num::NonZeroU32; + fn inverse(self) -> bevy::math::Quat; "#, r#" -/// Returns `true` if `self` is positive and `false` if the -/// number is negative. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI32::new(5)?; -///let neg_five = NonZeroI32::new(-5)?; -/// assert!(pos_five.is_positive()); -/// assert!(!neg_five.is_positive()); -/// # Some(()) -/// # } -/// ``` +/// Computes the dot product of `self` and `rhs`. The dot product is +/// equal to the cosine of the angle between two quaternion rotations. #[lua(kind = "Method")] - fn is_positive(self) -> bool; + fn dot(self, #[proxy] rhs: bevy::math::Quat) -> f32; "#, r#" -/// Returns `true` if `self` is negative and `false` if the -/// number is positive. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI32::new(5)?; -///let neg_five = NonZeroI32::new(-5)?; -/// assert!(neg_five.is_negative()); -/// assert!(!pos_five.is_negative()); -/// # Some(()) -/// # } -/// ``` +/// Computes the length of `self`. #[lua(kind = "Method")] - fn is_negative(self) -> bool; + fn length(self) -> f32; "#, r#" -/// Saturating negation. Computes `-self`, -///returning [`NonZeroI32::MAX`] -///if `self == NonZeroI32::MIN` -/// instead of overflowing. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI32::new(5)?; -///let neg_five = NonZeroI32::new(-5)?; -///let min = NonZeroI32::new(i32::MIN)?; -///let min_plus_one = NonZeroI32::new(i32::MIN + 1)?; -///let max = NonZeroI32::new(i32::MAX)?; -/// assert_eq!(pos_five.saturating_neg(), neg_five); -/// assert_eq!(min.saturating_neg(), max); -/// assert_eq!(max.saturating_neg(), min_plus_one); -/// # Some(()) -/// # } -/// ``` +/// Computes the squared length of `self`. +/// This is generally faster than `length()` as it avoids a square +/// root operation. - #[lua(kind = "Method", output(proxy))] - fn saturating_neg(self) -> std::num::NonZeroI32; + #[lua(kind = "Method")] + fn length_squared(self) -> f32; "#, r#" -/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary -/// of the type. -///See [`i32::wrapping_neg`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI32::new(5)?; -///let neg_five = NonZeroI32::new(-5)?; -///let min = NonZeroI32::new(i32::MIN)?; -/// assert_eq!(pos_five.wrapping_neg(), neg_five); -/// assert_eq!(min.wrapping_neg(), min); -/// # Some(()) -/// # } -/// ``` +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method", output(proxy))] - fn wrapping_neg(self) -> std::num::NonZeroI32; + #[lua(kind = "Method")] + fn length_recip(self) -> f32; "#, r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroI32::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroI32::new(2)?; -///let four = NonZeroI32::new(4)?; -///let max = NonZeroI32::new(i32::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must _not_ be of length zero. +/// Panics +/// Will panic if `self` is zero length when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroI32, - ) -> std::num::NonZeroI32; + fn normalize(self) -> bevy::math::Quat; "#, r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroI32::MIN`] or [`NonZeroI32::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroI32::new(3)?; -///let twenty_seven = NonZeroI32::new(27)?; -///let max = NonZeroI32::new(i32::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` +/// Returns `true` if, and only if, all elements are finite. +/// If any element is either `NaN`, positive or negative infinity, this will return `false`. - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI32; + #[lua(kind = "Method")] + fn is_finite(self) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroI32; + #[lua(kind = "Method")] + fn is_nan(self) -> bool; "#, r#" +/// Returns whether `self` of length `1.0` or not. +/// Uses a precision threshold of `1e-6`. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroI32) -> bool; + #[lua(kind = "Method")] + fn is_normalized(self) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method")] + fn is_near_identity(self) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct NonZeroI32(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroI64", - functions[r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. +/// Returns the angle (in radians) for the minimal rotation +/// for transforming this quaternion into another. +/// Both quaternions must be normalized. +/// # Panics +/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: i64) -> std::num::NonZeroI64; + #[lua(kind = "Method")] + fn angle_between(self, #[proxy] rhs: bevy::math::Quat) -> f32; "#, r#" -/// Returns the value as a primitive type. +/// Returns true if the absolute difference of all elements between `self` and `rhs` +/// is less than or equal to `max_abs_diff`. +/// This can be used to compare if two quaternions contain similar elements. It works +/// best when comparing with a known value. The `max_abs_diff` that should be used used +/// depends on the values being compared against. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). #[lua(kind = "Method")] - fn get(self) -> i64; + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Quat, max_abs_diff: f32) -> bool; "#, r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI64::new(-1i64).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` +/// Performs a linear interpolation between `self` and `rhs` based on +/// the value `s`. +/// When `s` is `0.0`, the result will be equal to `self`. When `s` +/// is `1.0`, the result will be equal to `rhs`. +/// # Panics +/// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] end: bevy::math::Quat, s: f32) -> bevy::math::Quat; "#, r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI64::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` +/// Performs a spherical linear interpolation between `self` and `end` +/// based on the value `s`. +/// When `s` is `0.0`, the result will be equal to `self`. When `s` +/// is `1.0`, the result will be equal to `end`. +/// # Panics +/// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn slerp(self, #[proxy] end: bevy::math::Quat, s: f32) -> bevy::math::Quat; "#, r#" -/// Computes the absolute value of self. -///See [`i64::abs`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI64::new(1)?; -///let neg = NonZeroI64::new(-1)?; -/// assert_eq!(pos, pos.abs()); -/// assert_eq!(pos, neg.abs()); -/// # Some(()) -/// # } -/// ``` +/// 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(kind = "Method", output(proxy))] - fn abs(self) -> std::num::NonZeroI64; + fn mul_vec3(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Saturating absolute value, see -///[`i64::saturating_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI64::new(1)?; -///let neg = NonZeroI64::new(-1)?; -///let min = NonZeroI64::new(i64::MIN)?; -///let min_plus = NonZeroI64::new(i64::MIN + 1)?; -///let max = NonZeroI64::new(i64::MAX)?; -/// assert_eq!(pos, pos.saturating_abs()); -/// assert_eq!(pos, neg.saturating_abs()); -/// assert_eq!(max, min.saturating_abs()); -/// assert_eq!(max, min_plus.saturating_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_abs(self) -> std::num::NonZeroI64; - -"#, - r#" -/// Wrapping absolute value, see -///[`i64::wrapping_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI64::new(1)?; -///let neg = NonZeroI64::new(-1)?; -///let min = NonZeroI64::new(i64::MIN)?; -///# let max = NonZeroI64::new(i64::MAX)?; -/// assert_eq!(pos, pos.wrapping_abs()); -/// assert_eq!(pos, neg.wrapping_abs()); -/// assert_eq!(min, min.wrapping_abs()); -/// assert_eq!(max, (-max).wrapping_abs()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn wrapping_abs(self) -> std::num::NonZeroI64; - -"#, - r#" -/// Computes the absolute value of self -/// without any wrapping or panicking. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -///# use std::num::NonZeroU64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let u_pos = NonZeroU64::new(1)?; -///let i_pos = NonZeroI64::new(1)?; -///let i_neg = NonZeroI64::new(-1)?; -///let i_min = NonZeroI64::new(i64::MIN)?; -///let u_max = NonZeroU64::new(u64::MAX / 2 + 1)?; -/// assert_eq!(u_pos, i_pos.unsigned_abs()); -/// assert_eq!(u_pos, i_neg.unsigned_abs()); -/// assert_eq!(u_max, i_min.unsigned_abs()); -/// # Some(()) -/// # } -/// ``` +/// 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(kind = "Method", output(proxy))] - fn unsigned_abs(self) -> std::num::NonZeroU64; - -"#, - r#" -/// Returns `true` if `self` is positive and `false` if the -/// number is negative. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI64::new(5)?; -///let neg_five = NonZeroI64::new(-5)?; -/// assert!(pos_five.is_positive()); -/// assert!(!neg_five.is_positive()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_positive(self) -> bool; - -"#, - r#" -/// Returns `true` if `self` is negative and `false` if the -/// number is positive. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI64::new(5)?; -///let neg_five = NonZeroI64::new(-5)?; -/// assert!(neg_five.is_negative()); -/// assert!(!pos_five.is_negative()); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method")] - fn is_negative(self) -> bool; + fn mul_quat(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; "#, r#" -/// Saturating negation. Computes `-self`, -///returning [`NonZeroI64::MAX`] -///if `self == NonZeroI64::MIN` -/// instead of overflowing. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI64::new(5)?; -///let neg_five = NonZeroI64::new(-5)?; -///let min = NonZeroI64::new(i64::MIN)?; -///let min_plus_one = NonZeroI64::new(i64::MIN + 1)?; -///let max = NonZeroI64::new(i64::MAX)?; -/// assert_eq!(pos_five.saturating_neg(), neg_five); -/// assert_eq!(min.saturating_neg(), max); -/// assert_eq!(max.saturating_neg(), min_plus_one); -/// # Some(()) -/// # } -/// ``` +/// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. - #[lua(kind = "Method", output(proxy))] - fn saturating_neg(self) -> std::num::NonZeroI64; + #[lua(kind = "Function", output(proxy))] + fn from_affine3(#[proxy] a: &glam::Affine3A) -> bevy::math::Quat; "#, r#" -/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary -/// of the type. -///See [`i64::wrapping_neg`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI64::new(5)?; -///let neg_five = NonZeroI64::new(-5)?; -///let min = NonZeroI64::new(i64::MIN)?; -/// assert_eq!(pos_five.wrapping_neg(), neg_five); -/// assert_eq!(min.wrapping_neg(), min); -/// # Some(()) -/// # } -/// ``` +/// Multiplies a quaternion and a 3D vector, returning the rotated vector. #[lua(kind = "Method", output(proxy))] - fn wrapping_neg(self) -> std::num::NonZeroI64; + fn mul_vec3a(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroI64::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroI64::new(2)?; -///let four = NonZeroI64::new(4)?; -///let max = NonZeroI64::new(i64::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroI64, - ) -> std::num::NonZeroI64; + fn as_dquat(self) -> bevy::math::DQuat; "#, r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroI64::MIN`] or [`NonZeroI64::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroI64::new(3)?; -///let twenty_seven = NonZeroI64::new(27)?; -///let max = NonZeroI64::new(i64::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI64; + 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::Neg", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "div", + metamethod = "Div", )] - fn neg(self) -> std::num::NonZeroI64; + 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::cmp::PartialEq", + as_trait = "std::ops::Sub", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn eq(&self, #[proxy] other: &std::num::NonZeroI64) -> bool; + fn sub(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; "#, 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 = "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) -> std::num::NonZeroI64; + 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::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::Vec3) -> bevy::math::Vec3; "#, r#" @@ -1975,1330 +1375,659 @@ fn index(&self) -> String { } "#] )] -struct NonZeroI64(); +struct Quat(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "std::num::NonZeroI8", + remote = "bevy::math::Vec3", functions[r#" +/// Creates a new vector. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> std::num::NonZeroI8; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroI8) -> bool; + #[lua(kind = "Function", output(proxy))] + fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3; "#, r#" +/// Creates a vector with all elements set to `v`. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroI8; + #[lua(kind = "Function", output(proxy))] + fn splat(v: f32) -> bevy::math::Vec3; "#, r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. +/// 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))] - unsafe fn new_unchecked(n: i8) -> std::num::NonZeroI8; + fn select( + #[proxy] + mask: bevy::math::BVec3, + #[proxy] + if_true: bevy::math::Vec3, + #[proxy] + if_false: bevy::math::Vec3, + ) -> bevy::math::Vec3; "#, r#" -/// Returns the value as a primitive type. +/// Creates a new vector from an array. - #[lua(kind = "Method")] - fn get(self) -> i8; + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f32; 3]) -> bevy::math::Vec3; "#, r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI8::new(-1i8).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` +/// `[x, y, z]` #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; + fn to_array(&self) -> [f32; 3]; "#, r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroI8::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` +/// Creates a 4D vector from `self` and the given `w` value. - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn extend(self, w: f32) -> bevy::math::Vec4; "#, r#" -/// Computes the absolute value of self. -///See [`i8::abs`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI8::new(1)?; -///let neg = NonZeroI8::new(-1)?; -/// assert_eq!(pos, pos.abs()); -/// assert_eq!(pos, neg.abs()); -/// # Some(()) -/// # } -/// ``` +/// 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 abs(self) -> std::num::NonZeroI8; + fn truncate(self) -> bevy::math::Vec2; "#, r#" -/// Saturating absolute value, see -///[`i8::saturating_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI8::new(1)?; -///let neg = NonZeroI8::new(-1)?; -///let min = NonZeroI8::new(i8::MIN)?; -///let min_plus = NonZeroI8::new(i8::MIN + 1)?; -///let max = NonZeroI8::new(i8::MAX)?; -/// assert_eq!(pos, pos.saturating_abs()); -/// assert_eq!(pos, neg.saturating_abs()); -/// assert_eq!(max, min.saturating_abs()); -/// assert_eq!(max, min_plus.saturating_abs()); -/// # Some(()) -/// # } -/// ``` +/// Creates a 3D vector from `self` with the given value of `x`. #[lua(kind = "Method", output(proxy))] - fn saturating_abs(self) -> std::num::NonZeroI8; + fn with_x(self, x: f32) -> bevy::math::Vec3; "#, r#" -/// Wrapping absolute value, see -///[`i8::wrapping_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroI8::new(1)?; -///let neg = NonZeroI8::new(-1)?; -///let min = NonZeroI8::new(i8::MIN)?; -///# let max = NonZeroI8::new(i8::MAX)?; -/// assert_eq!(pos, pos.wrapping_abs()); -/// assert_eq!(pos, neg.wrapping_abs()); -/// assert_eq!(min, min.wrapping_abs()); -/// assert_eq!(max, (-max).wrapping_abs()); -/// # Some(()) -/// # } -/// ``` +/// Creates a 3D vector from `self` with the given value of `y`. #[lua(kind = "Method", output(proxy))] - fn wrapping_abs(self) -> std::num::NonZeroI8; + fn with_y(self, y: f32) -> bevy::math::Vec3; "#, r#" -/// Computes the absolute value of self -/// without any wrapping or panicking. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -///# use std::num::NonZeroU8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let u_pos = NonZeroU8::new(1)?; -///let i_pos = NonZeroI8::new(1)?; -///let i_neg = NonZeroI8::new(-1)?; -///let i_min = NonZeroI8::new(i8::MIN)?; -///let u_max = NonZeroU8::new(u8::MAX / 2 + 1)?; -/// assert_eq!(u_pos, i_pos.unsigned_abs()); -/// assert_eq!(u_pos, i_neg.unsigned_abs()); -/// assert_eq!(u_max, i_min.unsigned_abs()); -/// # Some(()) -/// # } -/// ``` +/// Creates a 3D vector from `self` with the given value of `z`. #[lua(kind = "Method", output(proxy))] - fn unsigned_abs(self) -> std::num::NonZeroU8; + fn with_z(self, z: f32) -> bevy::math::Vec3; "#, r#" -/// Returns `true` if `self` is positive and `false` if the -/// number is negative. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI8::new(5)?; -///let neg_five = NonZeroI8::new(-5)?; -/// assert!(pos_five.is_positive()); -/// assert!(!neg_five.is_positive()); -/// # Some(()) -/// # } -/// ``` +/// Computes the dot product of `self` and `rhs`. #[lua(kind = "Method")] - fn is_positive(self) -> bool; + fn dot(self, #[proxy] rhs: bevy::math::Vec3) -> f32; "#, r#" -/// Returns `true` if `self` is negative and `false` if the -/// number is positive. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI8::new(5)?; -///let neg_five = NonZeroI8::new(-5)?; -/// assert!(neg_five.is_negative()); -/// assert!(!pos_five.is_negative()); -/// # Some(()) -/// # } -/// ``` +/// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "Method")] - fn is_negative(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Saturating negation. Computes `-self`, -///returning [`NonZeroI8::MAX`] -///if `self == NonZeroI8::MIN` -/// instead of overflowing. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI8::new(5)?; -///let neg_five = NonZeroI8::new(-5)?; -///let min = NonZeroI8::new(i8::MIN)?; -///let min_plus_one = NonZeroI8::new(i8::MIN + 1)?; -///let max = NonZeroI8::new(i8::MAX)?; -/// assert_eq!(pos_five.saturating_neg(), neg_five); -/// assert_eq!(min.saturating_neg(), max); -/// assert_eq!(max.saturating_neg(), min_plus_one); -/// # Some(()) -/// # } -/// ``` +/// Computes the cross product of `self` and `rhs`. #[lua(kind = "Method", output(proxy))] - fn saturating_neg(self) -> std::num::NonZeroI8; + fn cross(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary -/// of the type. -///See [`i8::wrapping_neg`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroI8::new(5)?; -///let neg_five = NonZeroI8::new(-5)?; -///let min = NonZeroI8::new(i8::MIN)?; -/// assert_eq!(pos_five.wrapping_neg(), neg_five); -/// assert_eq!(min.wrapping_neg(), min); -/// # Some(()) -/// # } -/// ``` +/// Returns a vector containing the minimum values for each element of `self` and `rhs`. +/// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_neg(self) -> std::num::NonZeroI8; + fn min(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroI8::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroI8::new(2)?; -///let four = NonZeroI8::new(4)?; -///let max = NonZeroI8::new(i8::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` +/// Returns a vector containing the maximum values for each element of `self` and `rhs`. +/// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] other: std::num::NonZeroI8) -> std::num::NonZeroI8; + fn max(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroI8::MIN`] or [`NonZeroI8::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroI8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroI8::new(3)?; -///let twenty_seven = NonZeroI8::new(27)?; -///let max = NonZeroI8::new(i8::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` +/// Component-wise clamping of values, similar to [`f32::clamp`]. +/// Each element in `min` must be less-or-equal to the corresponding element in `max`. +/// # Panics +/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroI8; + fn clamp( + self, + #[proxy] + min: bevy::math::Vec3, + #[proxy] + max: bevy::math::Vec3, + ) -> bevy::math::Vec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct NonZeroI8(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroU128", - functions[r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroU128; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method")] + fn min_element(self) -> f32; "#, r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroU128) -> bool; + #[lua(kind = "Method")] + fn max_element(self) -> f32; "#, r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: u128) -> std::num::NonZeroU128; + #[lua(kind = "Method")] + fn element_sum(self) -> f32; "#, r#" -/// Returns the value as a primitive type. +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. #[lua(kind = "Method")] - fn get(self) -> u128; + fn element_product(self) -> f32; "#, r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU128::new(u128::MAX).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` +/// Returns a vector mask containing the result of a `==` comparison for each element of +/// `self` and `rhs`. +/// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all +/// elements. - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; "#, r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU128::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` +/// Returns a vector mask containing the result of a `!=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all +/// elements. - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; "#, r#" -/// Adds an unsigned integer to a non-zero value. -///Return [`NonZeroU128::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let one = NonZeroU128::new(1)?; -///let two = NonZeroU128::new(2)?; -///let max = NonZeroU128::new(u128::MAX)?; -/// assert_eq!(two, one.saturating_add(1)); -/// assert_eq!(max, max.saturating_add(1)); -/// # Some(()) -/// # } -/// ``` +/// Returns a vector mask containing the result of a `>=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all +/// elements. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, other: u128) -> std::num::NonZeroU128; + fn cmpge(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; "#, r#" -/// Returns the base 2 logarithm of the number, rounded down. -/// This is the same operation as -///[`u128::ilog2`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU128; -///assert_eq!(NonZeroU128::new(7).unwrap().ilog2(), 2); -///assert_eq!(NonZeroU128::new(8).unwrap().ilog2(), 3); -///assert_eq!(NonZeroU128::new(9).unwrap().ilog2(), 3); -/// ``` +/// Returns a vector mask containing the result of a `>` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all +/// elements. - #[lua(kind = "Method")] - fn ilog2(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; "#, r#" -/// Returns the base 10 logarithm of the number, rounded down. -/// This is the same operation as -///[`u128::ilog10`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU128; -///assert_eq!(NonZeroU128::new(99).unwrap().ilog10(), 1); -///assert_eq!(NonZeroU128::new(100).unwrap().ilog10(), 2); -///assert_eq!(NonZeroU128::new(101).unwrap().ilog10(), 2); -/// ``` +/// Returns a vector mask containing the result of a `<=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all +/// elements. - #[lua(kind = "Method")] - fn ilog10(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; "#, r#" -/// Returns `true` if and only if `self == (1 << k)` for some `k`. -/// On many architectures, this function can perform better than `is_power_of_two()` -/// on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let eight = std::num::NonZeroU128::new(8).unwrap(); -/// assert!(eight.is_power_of_two()); -///let ten = std::num::NonZeroU128::new(10).unwrap(); -/// assert!(!ten.is_power_of_two()); -/// ``` +/// Returns a vector mask containing the result of a `<` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all +/// elements. - #[lua(kind = "Method")] - fn is_power_of_two(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; "#, r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroU128::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroU128::new(2)?; -///let four = NonZeroU128::new(4)?; -///let max = NonZeroU128::new(u128::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` +/// Returns a vector containing the absolute value of each element of `self`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroU128, - ) -> std::num::NonZeroU128; + fn abs(self) -> bevy::math::Vec3; "#, r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroU128::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU128; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroU128::new(3)?; -///let twenty_seven = NonZeroU128::new(27)?; -///let max = NonZeroU128::new(u128::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` +/// Returns a vector with elements representing the sign of `self`. +/// - `1.0` if the number is positive, `+0.0` or `INFINITY` +/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` +/// - `NAN` if the number is `NAN` #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU128; + fn signum(self) -> bevy::math::Vec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct NonZeroU128(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroU16", - functions[r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: u16) -> std::num::NonZeroU16; + #[lua(kind = "Method", output(proxy))] + fn copysign(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Returns the value as a primitive type. +/// Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. +/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes +/// into the first lowest bit, element `y` into the second, etc. #[lua(kind = "Method")] - fn get(self) -> u16; + fn is_negative_bitmask(self) -> u32; "#, r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU16::new(u16::MAX).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` +/// Returns `true` if, and only if, all elements are finite. If any element is either +/// `NaN`, positive or negative infinity, this will return `false`. #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; + fn is_finite(self) -> bool; "#, r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU16::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` +/// Returns `true` if any elements are `NaN`. #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; + fn is_nan(self) -> bool; "#, r#" -/// Adds an unsigned integer to a non-zero value. -///Return [`NonZeroU16::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let one = NonZeroU16::new(1)?; -///let two = NonZeroU16::new(2)?; -///let max = NonZeroU16::new(u16::MAX)?; -/// assert_eq!(two, one.saturating_add(1)); -/// assert_eq!(max, max.saturating_add(1)); -/// # Some(()) -/// # } -/// ``` +/// 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()]`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, other: u16) -> std::num::NonZeroU16; + fn is_nan_mask(self) -> bevy::math::BVec3; "#, r#" -/// Returns the base 2 logarithm of the number, rounded down. -/// This is the same operation as -///[`u16::ilog2`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU16; -///assert_eq!(NonZeroU16::new(7).unwrap().ilog2(), 2); -///assert_eq!(NonZeroU16::new(8).unwrap().ilog2(), 3); -///assert_eq!(NonZeroU16::new(9).unwrap().ilog2(), 3); -/// ``` +/// Computes the length of `self`. #[lua(kind = "Method")] - fn ilog2(self) -> u32; + fn length(self) -> f32; "#, r#" -/// Returns the base 10 logarithm of the number, rounded down. -/// This is the same operation as -///[`u16::ilog10`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU16; -///assert_eq!(NonZeroU16::new(99).unwrap().ilog10(), 1); -///assert_eq!(NonZeroU16::new(100).unwrap().ilog10(), 2); -///assert_eq!(NonZeroU16::new(101).unwrap().ilog10(), 2); -/// ``` +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. #[lua(kind = "Method")] - fn ilog10(self) -> u32; + fn length_squared(self) -> f32; "#, r#" -/// Returns `true` if and only if `self == (1 << k)` for some `k`. -/// On many architectures, this function can perform better than `is_power_of_two()` -/// on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let eight = std::num::NonZeroU16::new(8).unwrap(); -/// assert!(eight.is_power_of_two()); -///let ten = std::num::NonZeroU16::new(10).unwrap(); -/// assert!(!ten.is_power_of_two()); -/// ``` +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. #[lua(kind = "Method")] - fn is_power_of_two(self) -> bool; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroU16::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroU16::new(2)?; -///let four = NonZeroU16::new(4)?; -///let max = NonZeroU16::new(u16::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroU16, - ) -> std::num::NonZeroU16; + fn length_recip(self) -> f32; "#, r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroU16::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU16; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroU16::new(3)?; -///let twenty_seven = NonZeroU16::new(27)?; -///let max = NonZeroU16::new(u16::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` +/// Computes the Euclidean distance between two points in space. - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU16; + #[lua(kind = "Method")] + fn distance(self, #[proxy] rhs: bevy::math::Vec3) -> f32; "#, r#" +/// Compute the squared euclidean distance between two points in space. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroU16) -> bool; + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::Vec3) -> f32; "#, r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f32::rem_euclid - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroU16; + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct NonZeroU16(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroU32", - functions[r#" +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must _not_ be 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. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroU32) -> bool; + #[lua(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::Vec3; "#, r#" +/// Returns `self` normalized to length 1.0 if possible, else returns a +/// fallback value. +/// In particular, if the input is zero (or very close to zero), or non-finite, +/// the result of this operation will be the fallback value. +/// See also [`Self::try_normalize()`]. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method", output(proxy))] + fn normalize_or(self, #[proxy] fallback: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. +/// Returns `self` normalized to length 1.0 if possible, else returns zero. +/// In particular, if the input is zero (or very close to zero), or non-finite, +/// the result of this operation will be zero. +/// See also [`Self::try_normalize()`]. - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: u32) -> std::num::NonZeroU32; + #[lua(kind = "Method", output(proxy))] + fn normalize_or_zero(self) -> bevy::math::Vec3; "#, r#" -/// Returns the value as a primitive type. +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. #[lua(kind = "Method")] - fn get(self) -> u32; + fn is_normalized(self) -> bool; "#, r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU32::new(u32::MAX).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` +/// Returns the vector projection of `self` onto `rhs`. +/// `rhs` must be of non-zero length. +/// # Panics +/// Will panic if `rhs` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn project_onto(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU32::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` +/// Returns the vector rejection of `self` from `rhs`. +/// The vector rejection is the vector perpendicular to the projection of `self` onto +/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. +/// `rhs` must be of non-zero length. +/// # Panics +/// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn reject_from(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Adds an unsigned integer to a non-zero value. -///Return [`NonZeroU32::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let one = NonZeroU32::new(1)?; -///let two = NonZeroU32::new(2)?; -///let max = NonZeroU32::new(u32::MAX)?; -/// assert_eq!(two, one.saturating_add(1)); -/// assert_eq!(max, max.saturating_add(1)); -/// # Some(()) -/// # } -/// ``` +/// Returns the vector projection of `self` onto `rhs`. +/// `rhs` must be normalized. +/// # Panics +/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, other: u32) -> std::num::NonZeroU32; + fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Returns the base 2 logarithm of the number, rounded down. -/// This is the same operation as -///[`u32::ilog2`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU32; -///assert_eq!(NonZeroU32::new(7).unwrap().ilog2(), 2); -///assert_eq!(NonZeroU32::new(8).unwrap().ilog2(), 3); -///assert_eq!(NonZeroU32::new(9).unwrap().ilog2(), 3); -/// ``` +/// Returns the vector rejection of `self` from `rhs`. +/// The vector rejection is the vector perpendicular to the projection of `self` onto +/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. +/// `rhs` must be normalized. +/// # Panics +/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method")] - fn ilog2(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Returns the base 10 logarithm of the number, rounded down. -/// This is the same operation as -///[`u32::ilog10`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU32; -///assert_eq!(NonZeroU32::new(99).unwrap().ilog10(), 1); -///assert_eq!(NonZeroU32::new(100).unwrap().ilog10(), 2); -///assert_eq!(NonZeroU32::new(101).unwrap().ilog10(), 2); -/// ``` +/// Returns a vector containing the nearest integer to a number for each element of `self`. +/// Round half-way cases away from 0.0. - #[lua(kind = "Method")] - fn ilog10(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn round(self) -> bevy::math::Vec3; "#, r#" -/// Returns `true` if and only if `self == (1 << k)` for some `k`. -/// On many architectures, this function can perform better than `is_power_of_two()` -/// on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let eight = std::num::NonZeroU32::new(8).unwrap(); -/// assert!(eight.is_power_of_two()); -///let ten = std::num::NonZeroU32::new(10).unwrap(); -/// assert!(!ten.is_power_of_two()); -/// ``` +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. - #[lua(kind = "Method")] - fn is_power_of_two(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn floor(self) -> bevy::math::Vec3; "#, r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroU32::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroU32::new(2)?; -///let four = NonZeroU32::new(4)?; -///let max = NonZeroU32::new(u32::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroU32, - ) -> std::num::NonZeroU32; + fn ceil(self) -> bevy::math::Vec3; "#, r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroU32::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU32; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroU32::new(3)?; -///let twenty_seven = NonZeroU32::new(27)?; -///let max = NonZeroU32::new(u32::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU32; + fn trunc(self) -> bevy::math::Vec3; "#, r#" +/// Returns a vector containing the fractional part of the vector as `self - self.trunc()`. +/// Note that this differs from the GLSL implementation of `fract` which returns +/// `self - self.floor()`. +/// Note that this is fast but not precise for large numbers. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroU32; + #[lua(kind = "Method", output(proxy))] + fn fract(self) -> bevy::math::Vec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct NonZeroU32(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroU64", - functions[r#" +/// Returns a vector containing the fractional part of the vector as `self - self.floor()`. +/// Note that this differs from the Rust implementation of `fract` which returns +/// `self - self.trunc()`. +/// Note that this is fast but not precise for large numbers. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::num::NonZeroU64) -> bool; + #[lua(kind = "Method", output(proxy))] + fn fract_gl(self) -> bevy::math::Vec3; "#, r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: u64) -> std::num::NonZeroU64; + #[lua(kind = "Method", output(proxy))] + fn exp(self) -> bevy::math::Vec3; "#, r#" -/// Returns the value as a primitive type. +/// Returns a vector containing each element of `self` raised to the power of `n`. - #[lua(kind = "Method")] - fn get(self) -> u64; + #[lua(kind = "Method", output(proxy))] + fn powf(self, n: f32) -> bevy::math::Vec3; "#, r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU64::new(u64::MAX).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn recip(self) -> bevy::math::Vec3; "#, r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU64::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` +/// Performs a linear interpolation between `self` and `rhs` based on the value `s`. +/// When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result +/// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly +/// extrapolated. - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] rhs: bevy::math::Vec3, s: f32) -> bevy::math::Vec3; "#, r#" -/// Adds an unsigned integer to a non-zero value. -///Return [`NonZeroU64::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let one = NonZeroU64::new(1)?; -///let two = NonZeroU64::new(2)?; -///let max = NonZeroU64::new(u64::MAX)?; -/// assert_eq!(two, one.saturating_add(1)); -/// assert_eq!(max, max.saturating_add(1)); -/// # Some(()) -/// # } -/// ``` +/// Moves towards `rhs` based on the value `d`. +/// When `d` is `0.0`, the result will be equal to `self`. When `d` is equal to +/// `self.distance(rhs)`, the result will be equal to `rhs`. Will not go past `rhs`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, other: u64) -> std::num::NonZeroU64; + fn move_towards(&self, #[proxy] rhs: bevy::math::Vec3, d: f32) -> bevy::math::Vec3; "#, r#" -/// Returns the base 2 logarithm of the number, rounded down. -/// This is the same operation as -///[`u64::ilog2`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU64; -///assert_eq!(NonZeroU64::new(7).unwrap().ilog2(), 2); -///assert_eq!(NonZeroU64::new(8).unwrap().ilog2(), 3); -///assert_eq!(NonZeroU64::new(9).unwrap().ilog2(), 3); -/// ``` +/// Calculates the midpoint between `self` and `rhs`. +/// The midpoint is the average of, or halfway point between, two vectors. +/// `a.midpoint(b)` should yield the same result as `a.lerp(b, 0.5)` +/// while being slightly cheaper to compute. - #[lua(kind = "Method")] - fn ilog2(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn midpoint(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Returns the base 10 logarithm of the number, rounded down. -/// This is the same operation as -///[`u64::ilog10`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU64; -///assert_eq!(NonZeroU64::new(99).unwrap().ilog10(), 1); -///assert_eq!(NonZeroU64::new(100).unwrap().ilog10(), 2); -///assert_eq!(NonZeroU64::new(101).unwrap().ilog10(), 2); -/// ``` +/// Returns true if the absolute difference of all elements between `self` and `rhs` is +/// less than or equal to `max_abs_diff`. +/// This can be used to compare if two vectors contain similar elements. It works best when +/// comparing with a known value. The `max_abs_diff` that should be used used depends on +/// the values being compared against. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). #[lua(kind = "Method")] - fn ilog10(self) -> u32; + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec3, max_abs_diff: f32) -> bool; "#, r#" -/// Returns `true` if and only if `self == (1 << k)` for some `k`. -/// On many architectures, this function can perform better than `is_power_of_two()` -/// on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let eight = std::num::NonZeroU64::new(8).unwrap(); -/// assert!(eight.is_power_of_two()); -///let ten = std::num::NonZeroU64::new(10).unwrap(); -/// assert!(!ten.is_power_of_two()); -/// ``` +/// 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. - #[lua(kind = "Method")] - fn is_power_of_two(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3; "#, r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroU64::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroU64::new(2)?; -///let four = NonZeroU64::new(4)?; -///let max = NonZeroU64::new(u64::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` +/// Returns a vector with a length no more than `max` #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroU64, - ) -> std::num::NonZeroU64; + fn clamp_length_max(self, max: f32) -> bevy::math::Vec3; "#, r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroU64::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU64; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroU64::new(3)?; -///let twenty_seven = NonZeroU64::new(27)?; -///let max = NonZeroU64::new(u64::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` +/// Returns a vector with a length no less than `min` #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU64; + fn clamp_length_min(self, min: f32) -> bevy::math::Vec3; "#, r#" +/// Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding +/// error, yielding a more accurate result than an unfused multiply-add. +/// Using `mul_add` *may* be more performant than an unfused multiply-add if the target +/// architecture has a dedicated fma CPU instruction. However, this is not always true, +/// and will be heavily dependant on designing algorithms with specific target hardware in +/// mind. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroU64; + #[lua(kind = "Method", output(proxy))] + fn mul_add( + self, + #[proxy] + a: bevy::math::Vec3, + #[proxy] + b: bevy::math::Vec3, + ) -> bevy::math::Vec3; "#, r#" +/// Returns the angle (in radians) between two vectors. +/// The inputs do not need to be unit vectors however they must be non-zero. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method")] + fn angle_between(self, #[proxy] rhs: bevy::math::Vec3) -> f32; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct NonZeroU64(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroU8", - functions[r#" +/// Returns some vector that is orthogonal to the given one. +/// The input vector must be finite and non-zero. +/// The output vector is not necessarily unit length. For that use +/// [`Self::any_orthonormal_vector()`] instead. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method", output(proxy))] + fn any_orthogonal_vector(&self) -> bevy::math::Vec3; "#, r#" +/// Returns any unit vector that is orthogonal to the given one. +/// The input vector must be unit length. +/// # 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", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroU8; + #[lua(kind = "Method", output(proxy))] + fn any_orthonormal_vector(&self) -> bevy::math::Vec3; "#, r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. +/// Casts all elements of `self` to `f64`. - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: u8) -> std::num::NonZeroU8; + #[lua(kind = "Method", output(proxy))] + fn as_dvec3(&self) -> bevy::math::DVec3; "#, r#" -/// Returns the value as a primitive type. +/// Casts all elements of `self` to `i32`. - #[lua(kind = "Method")] - fn get(self) -> u8; + #[lua(kind = "Method", output(proxy))] + fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU8::new(u8::MAX).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` +/// Casts all elements of `self` to `u32`. - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroU8::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` +/// Casts all elements of `self` to `i64`. - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, r#" -/// Adds an unsigned integer to a non-zero value. -///Return [`NonZeroU8::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let one = NonZeroU8::new(1)?; -///let two = NonZeroU8::new(2)?; -///let max = NonZeroU8::new(u8::MAX)?; -/// assert_eq!(two, one.saturating_add(1)); -/// assert_eq!(max, max.saturating_add(1)); -/// # Some(()) -/// # } -/// ``` +/// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, other: u8) -> std::num::NonZeroU8; + fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, r#" -/// Returns the base 2 logarithm of the number, rounded down. -/// This is the same operation as -///[`u8::ilog2`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU8; -///assert_eq!(NonZeroU8::new(7).unwrap().ilog2(), 2); -///assert_eq!(NonZeroU8::new(8).unwrap().ilog2(), 3); -///assert_eq!(NonZeroU8::new(9).unwrap().ilog2(), 3); -/// ``` - #[lua(kind = "Method")] - fn ilog2(self) -> u32; - -"#, - r#" -/// Returns the base 10 logarithm of the number, rounded down. -/// This is the same operation as -///[`u8::ilog10`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroU8; -///assert_eq!(NonZeroU8::new(99).unwrap().ilog10(), 1); -///assert_eq!(NonZeroU8::new(100).unwrap().ilog10(), 2); -///assert_eq!(NonZeroU8::new(101).unwrap().ilog10(), 2); -/// ``` - - #[lua(kind = "Method")] - fn ilog10(self) -> u32; - -"#, - r#" -/// Returns `true` if and only if `self == (1 << k)` for some `k`. -/// On many architectures, this function can perform better than `is_power_of_two()` -/// on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let eight = std::num::NonZeroU8::new(8).unwrap(); -/// assert!(eight.is_power_of_two()); -///let ten = std::num::NonZeroU8::new(10).unwrap(); -/// assert!(!ten.is_power_of_two()); -/// ``` - - #[lua(kind = "Method")] - fn is_power_of_two(self) -> bool; - -"#, - r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroU8::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroU8::new(2)?; -///let four = NonZeroU8::new(4)?; -///let max = NonZeroU8::new(u8::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] other: std::num::NonZeroU8) -> std::num::NonZeroU8; - -"#, - r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroU8::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroU8; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroU8::new(3)?; -///let twenty_seven = NonZeroU8::new(27)?; -///let max = NonZeroU8::new(u8::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroU8; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" @@ -3309,212 +2038,137 @@ struct NonZeroU64(); composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &std::num::NonZeroU8) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct NonZeroU8(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::num::NonZeroUsize", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. - - #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: usize) -> std::num::NonZeroUsize; + fn eq(&self, #[proxy] other: &glam::Vec3) -> bool; "#, r#" -/// Returns the value as a primitive type. - #[lua(kind = "Method")] - fn get(self) -> usize; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f32) -> bevy::math::Vec3; "#, r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroUsize::new(usize::MAX).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` - #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Vec3; "#, r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroUsize::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` - #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec3; "#, r#" -/// Adds an unsigned integer to a non-zero value. -///Return [`NonZeroUsize::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroUsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let one = NonZeroUsize::new(1)?; -///let two = NonZeroUsize::new(2)?; -///let max = NonZeroUsize::new(usize::MAX)?; -/// assert_eq!(two, one.saturating_add(1)); -/// assert_eq!(max, max.saturating_add(1)); -/// # Some(()) -/// # } -/// ``` - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, other: usize) -> std::num::NonZeroUsize; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Returns the base 2 logarithm of the number, rounded down. -/// This is the same operation as -///[`usize::ilog2`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroUsize; -///assert_eq!(NonZeroUsize::new(7).unwrap().ilog2(), 2); -///assert_eq!(NonZeroUsize::new(8).unwrap().ilog2(), 3); -///assert_eq!(NonZeroUsize::new(9).unwrap().ilog2(), 3); -/// ``` - #[lua(kind = "Method")] - fn ilog2(self) -> u32; + #[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#" -/// Returns the base 10 logarithm of the number, rounded down. -/// This is the same operation as -///[`usize::ilog10`], -/// except that it has no failure cases to worry about -/// since this value can never be zero. -/// # Examples -/// ``` -///# use std::num::NonZeroUsize; -///assert_eq!(NonZeroUsize::new(99).unwrap().ilog10(), 1); -///assert_eq!(NonZeroUsize::new(100).unwrap().ilog10(), 2); -///assert_eq!(NonZeroUsize::new(101).unwrap().ilog10(), 2); -/// ``` - #[lua(kind = "Method")] - fn ilog10(self) -> u32; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Returns `true` if and only if `self == (1 << k)` for some `k`. -/// On many architectures, this function can perform better than `is_power_of_two()` -/// on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let eight = std::num::NonZeroUsize::new(8).unwrap(); -/// assert!(eight.is_power_of_two()); -///let ten = std::num::NonZeroUsize::new(10).unwrap(); -/// assert!(!ten.is_power_of_two()); -/// ``` - #[lua(kind = "Method")] - fn is_power_of_two(self) -> bool; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f32) -> bevy::math::Vec3; "#, r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroUsize::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroUsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroUsize::new(2)?; -///let four = NonZeroUsize::new(4)?; -///let max = NonZeroUsize::new(usize::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroUsize, - ) -> std::num::NonZeroUsize; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec3; "#, r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroUsize::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroUsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroUsize::new(3)?; -///let twenty_seven = NonZeroUsize::new(27)?; -///let max = NonZeroUsize::new(usize::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroUsize; + #[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", + as_trait = "std::ops::Neg", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "neg", + metamethod = "Unm", )] - fn eq(&self, #[proxy] other: &std::num::NonZeroUsize) -> bool; + fn neg(self) -> bevy::math::Vec3; "#, 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) -> std::num::NonZeroUsize; + fn add(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" @@ -3522,635 +2176,549 @@ struct NonZeroU8(); 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 NonZeroUsize(); +struct Vec3 { + x: f32, + y: f32, + z: f32, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "std::path::PathBuf", + remote = "bevy::math::IVec2", 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: &std::path::PathBuf) -> bool; + fn rem(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, 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) -> std::path::PathBuf; + fn mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "MutatingMethod", + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", )] - fn clone_from(&mut self, #[proxy] source: &std::path::PathBuf) -> (); + fn add(self, rhs: i32) -> bevy::math::IVec2; "#, r#" -/// Allocates an empty `PathBuf`. -/// # Examples -/// ``` -/// use std::path::PathBuf; -/// let path = PathBuf::new(); -/// ``` +/// Creates a new vector. #[lua(kind = "Function", output(proxy))] - fn new() -> std::path::PathBuf; + fn new(x: i32, y: i32) -> bevy::math::IVec2; "#, r#" -/// Creates a new `PathBuf` with a given capacity used to create the -/// internal [`OsString`]. See [`with_capacity`] defined on [`OsString`]. -/// # Examples -/// ``` -/// use std::path::PathBuf; -/// let mut path = PathBuf::with_capacity(10); -/// let capacity = path.capacity(); -/// // This push is done without reallocating -/// path.push(r"C:\"); -/// assert_eq!(capacity, path.capacity()); -/// ``` -/// [`with_capacity`]: OsString::with_capacity +/// Creates a vector with all elements set to `v`. #[lua(kind = "Function", output(proxy))] - fn with_capacity(capacity: usize) -> std::path::PathBuf; + fn splat(v: i32) -> bevy::math::IVec2; "#, r#" -/// Truncates `self` to [`self.parent`]. -/// Returns `false` and does nothing if [`self.parent`] is [`None`]. -/// Otherwise, returns `true`. -/// [`self.parent`]: Path::parent -/// # Examples -/// ``` -/// use std::path::{Path, PathBuf}; -/// let mut p = PathBuf::from("/spirited/away.rs"); -/// p.pop(); -/// assert_eq!(Path::new("/spirited"), p); -/// p.pop(); -/// assert_eq!(Path::new("/"), p); -/// ``` +/// 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 = "MutatingMethod")] - fn pop(&mut self) -> bool; + #[lua(kind = "Function", output(proxy))] + fn select( + #[proxy] + mask: bevy::math::BVec2, + #[proxy] + if_true: bevy::math::IVec2, + #[proxy] + if_false: bevy::math::IVec2, + ) -> bevy::math::IVec2; "#, r#" -/// Invokes [`capacity`] on the underlying instance of [`OsString`]. -/// [`capacity`]: OsString::capacity +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [i32; 2]) -> bevy::math::IVec2; + +"#, + r#" +/// `[x, y]` #[lua(kind = "Method")] - fn capacity(&self) -> usize; + fn to_array(&self) -> [i32; 2]; "#, r#" -/// Invokes [`clear`] on the underlying instance of [`OsString`]. -/// [`clear`]: OsString::clear +/// Creates a 3D vector from `self` and the given `z` value. - #[lua(kind = "MutatingMethod")] - fn clear(&mut self) -> (); + #[lua(kind = "Method", output(proxy))] + fn extend(self, z: i32) -> bevy::math::IVec3; "#, r#" -/// Invokes [`reserve`] on the underlying instance of [`OsString`]. -/// [`reserve`]: OsString::reserve +/// Creates a 2D vector from `self` with the given value of `x`. - #[lua(kind = "MutatingMethod")] - fn reserve(&mut self, additional: usize) -> (); + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: i32) -> bevy::math::IVec2; "#, r#" -/// Invokes [`reserve_exact`] on the underlying instance of [`OsString`]. -/// [`reserve_exact`]: OsString::reserve_exact +/// Creates a 2D vector from `self` with the given value of `y`. - #[lua(kind = "MutatingMethod")] - fn reserve_exact(&mut self, additional: usize) -> (); + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: i32) -> bevy::math::IVec2; "#, r#" -/// Invokes [`shrink_to_fit`] on the underlying instance of [`OsString`]. -/// [`shrink_to_fit`]: OsString::shrink_to_fit +/// Computes the dot product of `self` and `rhs`. - #[lua(kind = "MutatingMethod")] - fn shrink_to_fit(&mut self) -> (); + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::IVec2) -> i32; "#, r#" -/// Invokes [`shrink_to`] on the underlying instance of [`OsString`]. -/// [`shrink_to`]: OsString::shrink_to +/// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua(kind = "MutatingMethod")] - fn shrink_to(&mut self, min_capacity: usize) -> (); + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct PathBuf {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::ops::RangeFull", - functions[r#" +/// Returns a vector containing the minimum values for each element of `self` and `rhs`. +/// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::ops::RangeFull; + #[lua(kind = "Method", output(proxy))] + fn min(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" +/// Returns a vector containing the maximum values for each element of `self` and `rhs`. +/// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::ops::RangeFull) -> bool; + #[lua(kind = "Method", output(proxy))] + fn max(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" +/// Component-wise clamping of values, similar to [`i32::clamp`]. +/// Each element in `min` must be less-or-equal to the corresponding element in `max`. +/// # Panics +/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method", output(proxy))] + fn clamp( + self, + #[proxy] + min: bevy::math::IVec2, + #[proxy] + max: bevy::math::IVec2, + ) -> bevy::math::IVec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct RangeFull {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Quat", - functions[r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Quat; + #[lua(kind = "Method")] + fn min_element(self) -> i32; "#, r#" -/// Subtracts the `rhs` quaternion from `self`. -/// The difference is not guaranteed to be normalized. +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. - #[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; + #[lua(kind = "Method")] + fn max_element(self) -> i32; "#, r#" -/// Creates a new rotation quaternion. -/// This should generally not be called manually unless you know what you are doing. -/// Use one of the other constructors instead such as `identity` or `from_axis_angle`. -/// `from_xyzw` is mostly used by unit tests and `serde` deserialization. -/// # Preconditions -/// This function does not check if the input is normalized, it is up to the user to -/// provide normalized input or to normalized the resulting quaternion. +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. - #[lua(kind = "Function", output(proxy))] - fn from_xyzw(x: f32, y: f32, z: f32, w: f32) -> bevy::math::Quat; + #[lua(kind = "Method")] + fn element_sum(self) -> i32; "#, r#" -/// Creates a rotation quaternion from an array. -/// # Preconditions -/// This function does not check if the input is normalized, it is up to the user to -/// provide normalized input or to normalized the resulting quaternion. +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f32; 4]) -> bevy::math::Quat; + #[lua(kind = "Method")] + fn element_product(self) -> i32; "#, r#" -/// Creates a new rotation quaternion from a 4D vector. -/// # Preconditions -/// This function does not check if the input is normalized, it is up to the user to -/// provide normalized input or to normalized the resulting quaternion. +/// Returns a vector mask containing the result of a `==` comparison for each element of +/// `self` and `rhs`. +/// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all +/// elements. - #[lua(kind = "Function", output(proxy))] - fn from_vec4(#[proxy] v: bevy::math::Vec4) -> bevy::math::Quat; + #[lua(kind = "Method", output(proxy))] + fn cmpeq(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; "#, r#" -/// Create a quaternion for a normalized rotation `axis` and `angle` (in radians). -/// The axis must be a unit vector. -/// # Panics -/// Will panic if `axis` is not normalized when `glam_assert` is enabled. +/// Returns a vector mask containing the result of a `!=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all +/// elements. - #[lua(kind = "Function", output(proxy))] - fn from_axis_angle(#[proxy] axis: bevy::math::Vec3, angle: f32) -> bevy::math::Quat; + #[lua(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; "#, r#" -/// Create a quaternion that rotates `v.length()` radians around `v.normalize()`. -/// `from_scaled_axis(Vec3::ZERO)` results in the identity quaternion. +/// Returns a vector mask containing the result of a `>=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all +/// elements. - #[lua(kind = "Function", output(proxy))] - fn from_scaled_axis(#[proxy] v: bevy::math::Vec3) -> bevy::math::Quat; + #[lua(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; "#, r#" -/// Creates a quaternion from the `angle` (in radians) around the x axis. +/// Returns a vector mask containing the result of a `>` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all +/// elements. - #[lua(kind = "Function", output(proxy))] - fn from_rotation_x(angle: f32) -> bevy::math::Quat; + #[lua(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; "#, r#" -/// Creates a quaternion from the `angle` (in radians) around the y axis. +/// Returns a vector mask containing the result of a `<=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all +/// elements. - #[lua(kind = "Function", output(proxy))] - fn from_rotation_y(angle: f32) -> bevy::math::Quat; + #[lua(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; "#, r#" -/// Creates a quaternion from the `angle` (in radians) around the z axis. +/// Returns a vector mask containing the result of a `<` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all +/// elements. - #[lua(kind = "Function", output(proxy))] - fn from_rotation_z(angle: f32) -> bevy::math::Quat; + #[lua(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; "#, r#" -/// Creates a quaternion from the given Euler rotation sequence and the angles (in radians). +/// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Function", output(proxy))] - fn from_euler( - #[proxy] - euler: bevy::math::EulerRot, - a: f32, - b: f32, - c: f32, - ) -> bevy::math::Quat; + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::IVec2; "#, r#" -/// Creates a quaternion from a 3x3 rotation matrix. +/// Returns a vector with elements representing the sign of `self`. +/// - `0` if the number is zero +/// - `1` if the number is positive +/// - `-1` if the number is negative - #[lua(kind = "Function", output(proxy))] - fn from_mat3(#[proxy] mat: &glam::Mat3) -> bevy::math::Quat; + #[lua(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::IVec2; "#, r#" -/// Creates a quaternion from a 3x3 SIMD aligned rotation matrix. +/// Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. +/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes +/// into the first lowest bit, element `y` into the second, etc. - #[lua(kind = "Function", output(proxy))] - fn from_mat3a(#[proxy] mat: &glam::Mat3A) -> bevy::math::Quat; + #[lua(kind = "Method")] + fn is_negative_bitmask(self) -> u32; "#, r#" -/// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. +/// Computes the squared length of `self`. - #[lua(kind = "Function", output(proxy))] - fn from_mat4(#[proxy] mat: &glam::Mat4) -> bevy::math::Quat; + #[lua(kind = "Method")] + fn length_squared(self) -> i32; "#, r#" -/// Gets the minimal rotation for transforming `from` to `to`. The rotation is in the -/// plane spanned by the two vectors. Will rotate at most 180 degrees. -/// The inputs must be unit vectors. -/// `from_rotation_arc(from, to) * from ≈ to`. -/// For near-singular cases (from≈to and from≈-to) the current implementation -/// is only accurate to about 0.001 (for `f32`). -/// # Panics -/// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. +/// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Function", output(proxy))] - fn from_rotation_arc( - #[proxy] - from: bevy::math::Vec3, - #[proxy] - to: bevy::math::Vec3, - ) -> bevy::math::Quat; + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::IVec2) -> i32; "#, r#" -/// Gets the minimal rotation for transforming `from` to either `to` or `-to`. This means -/// that the resulting quaternion will rotate `from` so that it is colinear with `to`. -/// The rotation is in the plane spanned by the two vectors. Will rotate at most 90 -/// degrees. -/// The inputs must be unit vectors. -/// `to.dot(from_rotation_arc_colinear(from, to) * from).abs() ≈ 1`. +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. /// # Panics -/// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. +/// This function will panic if any `rhs` element is 0 or the division results in overflow. - #[lua(kind = "Function", output(proxy))] - fn from_rotation_arc_colinear( - #[proxy] - from: bevy::math::Vec3, - #[proxy] - to: bevy::math::Vec3, - ) -> bevy::math::Quat; + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" -/// Gets the minimal rotation for transforming `from` to `to`. The resulting rotation is -/// around the z axis. Will rotate at most 180 degrees. -/// The inputs must be unit vectors. -/// `from_rotation_arc_2d(from, to) * from ≈ to`. -/// For near-singular cases (from≈to and from≈-to) the current implementation -/// is only accurate to about 0.001 (for `f32`). +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. /// # Panics -/// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_arc_2d( - #[proxy] - from: bevy::math::Vec2, - #[proxy] - to: bevy::math::Vec2, - ) -> bevy::math::Quat; - -"#, - r#" -/// Returns the rotation axis scaled by the rotation in radians. +/// This function will panic if any `rhs` element is 0 or the division results in overflow. +/// [Euclidean division]: i32::rem_euclid #[lua(kind = "Method", output(proxy))] - fn to_scaled_axis(self) -> bevy::math::Vec3; + fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" -/// Returns the rotation angles for the given euler rotation sequence. +/// Returns a vector that is equal to `self` rotated by 90 degrees. - #[lua(kind = "Method")] - fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f32, f32, f32); + #[lua(kind = "Method", output(proxy))] + fn perp(self) -> bevy::math::IVec2; "#, r#" -/// `[x, y, z, w]` +/// The perpendicular dot product of `self` and `rhs`. +/// Also known as the wedge product, 2D cross product, and determinant. #[lua(kind = "Method")] - fn to_array(&self) -> [f32; 4]; + fn perp_dot(self, #[proxy] rhs: bevy::math::IVec2) -> i32; "#, r#" -/// Returns the vector part of the quaternion. +/// Returns `rhs` rotated by the angle of `self`. If `self` is normalized, +/// then this just rotation. This is what you usually want. Otherwise, +/// it will be like a rotation with a multiplication by `self`'s length. #[lua(kind = "Method", output(proxy))] - fn xyz(self) -> bevy::math::Vec3; + fn rotate(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" -/// Returns the quaternion conjugate of `self`. For a unit quaternion the -/// conjugate is also the inverse. +/// Casts all elements of `self` to `f32`. #[lua(kind = "Method", output(proxy))] - fn conjugate(self) -> bevy::math::Quat; + fn as_vec2(&self) -> bevy::math::Vec2; "#, r#" -/// Returns the inverse of a normalized quaternion. -/// Typically quaternion inverse returns the conjugate of a normalized quaternion. -/// Because `self` is assumed to already be unit length this method *does not* normalize -/// before returning the conjugate. -/// # Panics -/// Will panic if `self` is not normalized when `glam_assert` is enabled. +/// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn inverse(self) -> bevy::math::Quat; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. The dot product is -/// equal to the cosine of the angle between two quaternion rotations. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::Quat) -> f32; - -"#, - r#" -/// Computes the length of `self`. - - #[lua(kind = "Method")] - fn length(self) -> f32; - -"#, - r#" -/// Computes the squared length of `self`. -/// This is generally faster than `length()` as it avoids a square -/// root operation. - - #[lua(kind = "Method")] - fn length_squared(self) -> f32; - -"#, - r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - - #[lua(kind = "Method")] - fn length_recip(self) -> f32; + fn as_dvec2(&self) -> bevy::math::DVec2; "#, r#" -/// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero. -/// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::Quat; + fn as_uvec2(&self) -> bevy::math::UVec2; "#, r#" -/// Returns `true` if, and only if, all elements are finite. -/// If any element is either `NaN`, positive or negative infinity, this will return `false`. +/// Casts all elements of `self` to `i64`. - #[lua(kind = "Method")] - fn is_finite(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn as_i64vec2(&self) -> bevy::math::I64Vec2; "#, r#" +/// Casts all elements of `self` to `u64`. - #[lua(kind = "Method")] - fn is_nan(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn as_u64vec2(&self) -> bevy::math::U64Vec2; "#, r#" -/// Returns whether `self` of length `1.0` or not. -/// Uses a precision threshold of `1e-6`. +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - #[lua(kind = "Method")] - fn is_normalized(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - #[lua(kind = "Method")] - fn is_near_identity(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" -/// Returns the angle (in radians) for the minimal rotation -/// for transforming this quaternion into another. -/// Both quaternions must be normalized. -/// # Panics -/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - #[lua(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::Quat) -> f32; + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" -/// Returns true if the absolute difference of all elements between `self` and `rhs` -/// is less than or equal to `max_abs_diff`. -/// This can be used to compare if two quaternions contain similar elements. It works -/// best when comparing with a known value. The `max_abs_diff` that should be used used -/// depends on the values being compared against. -/// For more see -/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Quat, max_abs_diff: f32) -> bool; + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" -/// Performs a linear interpolation between `self` and `rhs` based on -/// the value `s`. -/// When `s` is `0.0`, the result will be equal to `self`. When `s` -/// is `1.0`, the result will be equal to `rhs`. -/// # Panics -/// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] end: bevy::math::Quat, s: f32) -> bevy::math::Quat; + fn saturating_add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" -/// Performs a spherical linear interpolation between `self` and `end` -/// based on the value `s`. -/// When `s` is `0.0`, the result will be equal to `self`. When `s` -/// is `1.0`, the result will be equal to `end`. -/// # Panics -/// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn slerp(self, #[proxy] end: bevy::math::Quat, s: f32) -> bevy::math::Quat; + fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, 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. +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn mul_vec3(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, 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. +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn mul_quat(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + fn saturating_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" -/// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. +/// Returns a vector containing the wrapping addition of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..]`. - #[lua(kind = "Function", output(proxy))] - fn from_affine3(#[proxy] a: &glam::Affine3A) -> bevy::math::Quat; + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_unsigned(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::IVec2; "#, r#" -/// Multiplies a quaternion and a 3D vector, returning the rotated vector. +/// Returns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn mul_vec3a(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn wrapping_sub_unsigned(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::IVec2; "#, r#" +/// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn as_dquat(self) -> bevy::math::DQuat; + fn saturating_add_unsigned( + self, + #[proxy] + rhs: bevy::math::UVec2, + ) -> bevy::math::IVec2; "#, r#" +/// Returns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn as_f64(self) -> bevy::math::DQuat; + fn saturating_sub_unsigned( + self, + #[proxy] + rhs: bevy::math::UVec2, + ) -> bevy::math::IVec2; "#, 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::Sub", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "sub", + metamethod = "Sub", )] - fn add(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + fn sub(self, rhs: i32) -> bevy::math::IVec2; "#, r#" -/// Multiplies a quaternion by a scalar value. -/// The product is not guaranteed to be normalized. #[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: f32) -> bevy::math::Quat; + fn div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, 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::Quat; + fn rem(self, rhs: i32) -> 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 = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::IVec2; "#, r#" -/// Divides a quaternion by a scalar value. -/// The quotient is not guaranteed to be normalized. #[lua( as_trait = "std::ops::Div", @@ -4159,34 +2727,31 @@ struct RangeFull {} composite = "div", metamethod = "Div", )] - fn div(self, rhs: f32) -> bevy::math::Quat; + fn div(self, rhs: i32) -> bevy::math::IVec2; "#, 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::Vec3A) -> bevy::math::Vec3A; + fn neg(self) -> bevy::math::IVec2; "#, 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::ops::Add", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "add", + metamethod = "Add", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; "#, r#" @@ -4197,16 +2762,10 @@ struct RangeFull {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] rhs: &glam::Quat) -> bool; + fn eq(&self, #[proxy] other: &glam::IVec2) -> 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. #[lua( as_trait = "std::ops::Mul", @@ -4215,24 +2774,13 @@ struct RangeFull {} composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + fn mul(self, rhs: i32) -> bevy::math::IVec2; "#, r#" -/// Rotates the [`Direction3d`] using a [`Quat`]. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul( - self, - #[proxy] - direction: bevy::math::primitives::Direction3d, - ) -> bevy::math::primitives::Direction3d; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -4240,37 +2788,74 @@ struct RangeFull {} 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 Quat(); +struct IVec2 { + x: i32, + y: i32, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::Vec3", + remote = "bevy::math::IVec3", functions[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: f32) -> bevy::math::Vec3; + fn neg(self) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: i32) -> bevy::math::IVec3; "#, r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] - fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3; + fn new(x: i32, y: i32, z: i32) -> bevy::math::IVec3; "#, r#" /// Creates a vector with all elements set to `v`. #[lua(kind = "Function", output(proxy))] - fn splat(v: f32) -> bevy::math::Vec3; + fn splat(v: i32) -> bevy::math::IVec3; "#, r#" @@ -4284,31 +2869,31 @@ struct Quat(); #[proxy] mask: bevy::math::BVec3, #[proxy] - if_true: bevy::math::Vec3, + if_true: bevy::math::IVec3, #[proxy] - if_false: bevy::math::Vec3, - ) -> bevy::math::Vec3; + if_false: bevy::math::IVec3, + ) -> bevy::math::IVec3; "#, r#" /// Creates a new vector from an array. #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f32; 3]) -> bevy::math::Vec3; + fn from_array(a: [i32; 3]) -> bevy::math::IVec3; "#, r#" /// `[x, y, z]` #[lua(kind = "Method")] - fn to_array(&self) -> [f32; 3]; + fn to_array(&self) -> [i32; 3]; "#, r#" /// Creates a 4D vector from `self` and the given `w` value. #[lua(kind = "Method", output(proxy))] - fn extend(self, w: f32) -> bevy::math::Vec4; + fn extend(self, w: i32) -> bevy::math::IVec4; "#, r#" @@ -4316,28 +2901,49 @@ struct Quat(); /// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::Vec2; + fn truncate(self) -> bevy::math::IVec2; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `x`. + + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: i32) -> bevy::math::IVec3; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `y`. + + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: i32) -> bevy::math::IVec3; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `z`. + + #[lua(kind = "Method", output(proxy))] + fn with_z(self, z: i32) -> bevy::math::IVec3; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::Vec3) -> f32; + fn dot(self, #[proxy] rhs: bevy::math::IVec3) -> i32; "#, 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::Vec3) -> bevy::math::Vec3; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" /// Computes the cross product of `self` and `rhs`. #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn cross(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" @@ -4345,7 +2951,7 @@ struct Quat(); /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn min(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" @@ -4353,11 +2959,11 @@ struct Quat(); /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn max(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Component-wise clamping of values, similar to [`f32::clamp`]. +/// Component-wise clamping of values, similar to [`i32::clamp`]. /// Each element in `min` must be less-or-equal to the corresponding element in `max`. /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. @@ -4366,10 +2972,10 @@ struct Quat(); fn clamp( self, #[proxy] - min: bevy::math::Vec3, + min: bevy::math::IVec3, #[proxy] - max: bevy::math::Vec3, - ) -> bevy::math::Vec3; + max: bevy::math::IVec3, + ) -> bevy::math::IVec3; "#, r#" @@ -4377,7 +2983,7 @@ struct Quat(); /// In other words this computes `min(x, y, ..)`. #[lua(kind = "Method")] - fn min_element(self) -> f32; + fn min_element(self) -> i32; "#, r#" @@ -4385,7 +2991,23 @@ struct Quat(); /// In other words this computes `max(x, y, ..)`. #[lua(kind = "Method")] - fn max_element(self) -> f32; + fn max_element(self) -> i32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> i32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> i32; "#, r#" @@ -4395,7 +3017,7 @@ struct Quat(); /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + fn cmpeq(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; "#, r#" @@ -4405,7 +3027,7 @@ struct Quat(); /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + fn cmpne(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; "#, r#" @@ -4415,7 +3037,7 @@ struct Quat(); /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + fn cmpge(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; "#, r#" @@ -4425,7 +3047,7 @@ struct Quat(); /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + fn cmpgt(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; "#, r#" @@ -4435,7 +3057,7 @@ struct Quat(); /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + fn cmple(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; "#, r#" @@ -4445,31 +3067,24 @@ struct Quat(); /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::BVec3; + fn cmplt(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::Vec3; + fn abs(self) -> bevy::math::IVec3; "#, r#" /// Returns a vector with elements representing the sign of `self`. -/// - `1.0` if the number is positive, `+0.0` or `INFINITY` -/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` -/// - `NAN` if the number is `NAN` - - #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::Vec3; - -"#, - r#" -/// Returns a vector with signs of `rhs` and the magnitudes of `self`. +/// - `0` if the number is zero +/// - `1` if the number is positive +/// - `-1` if the number is negative #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn signum(self) -> bevy::math::IVec3; "#, r#" @@ -4482,387 +3097,381 @@ struct Quat(); "#, r#" -/// Returns `true` if, and only if, all elements are finite. If any element is either -/// `NaN`, positive or negative infinity, this will return `false`. +/// Computes the squared length of `self`. #[lua(kind = "Method")] - fn is_finite(self) -> bool; + fn length_squared(self) -> i32; "#, r#" -/// Returns `true` if any elements are `NaN`. +/// Compute the squared euclidean distance between two points in space. #[lua(kind = "Method")] - fn is_nan(self) -> bool; + fn distance_squared(self, #[proxy] rhs: bevy::math::IVec3) -> i32; "#, 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()]`. +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. #[lua(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec3; + fn div_euclid(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Computes the length of `self`. +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// # Panics +/// This function will panic if any `rhs` element is 0 or the division results in overflow. +/// [Euclidean division]: i32::rem_euclid - #[lua(kind = "Method")] - fn length(self) -> f32; + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Computes the squared length of `self`. -/// This is faster than `length()` as it avoids a square root operation. +/// Casts all elements of `self` to `f32`. - #[lua(kind = "Method")] - fn length_squared(self) -> f32; + #[lua(kind = "Method", output(proxy))] + fn as_vec3(&self) -> bevy::math::Vec3; "#, r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. +/// Casts all elements of `self` to `f32`. - #[lua(kind = "Method")] - fn length_recip(self) -> f32; + #[lua(kind = "Method", output(proxy))] + fn as_vec3a(&self) -> bevy::math::Vec3A; "#, r#" -/// Computes the Euclidean distance between two points in space. +/// Casts all elements of `self` to `f64`. - #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::Vec3) -> f32; + #[lua(kind = "Method", output(proxy))] + fn as_dvec3(&self) -> bevy::math::DVec3; "#, r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::Vec3) -> f32; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. +/// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// [Euclidean division]: f32::rem_euclid +/// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, r#" -/// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be 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. +/// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::Vec3; + fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, r#" -/// Returns `self` normalized to length 1.0 if possible, else returns zero. -/// In particular, if the input is zero (or very close to zero), or non-finite, -/// the result of this operation will be zero. -/// See also [`Self::try_normalize()`]. +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::Vec3; - -"#, - r#" -/// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - - #[lua(kind = "Method")] - fn is_normalized(self) -> bool; + fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Returns the vector projection of `self` onto `rhs`. -/// `rhs` must be of non-zero length. -/// # Panics -/// Will panic if `rhs` is zero length when `glam_assert` is enabled. +/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Returns the vector rejection of `self` from `rhs`. -/// The vector rejection is the vector perpendicular to the projection of `self` onto -/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. -/// `rhs` must be of non-zero length. -/// # Panics -/// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Returns the vector projection of `self` onto `rhs`. -/// `rhs` must be normalized. -/// # Panics -/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Returns the vector rejection of `self` from `rhs`. -/// The vector rejection is the vector perpendicular to the projection of `self` onto -/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. -/// `rhs` must be normalized. -/// # Panics -/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn saturating_add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Returns a vector containing the nearest integer to a number for each element of `self`. -/// Round half-way cases away from 0.0. +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::Vec3; + fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Returns a vector containing the largest integer less than or equal to a number for each -/// element of `self`. +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::Vec3; + fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Returns a vector containing the smallest integer greater than or equal to a number for -/// each element of `self`. +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::Vec3; + fn saturating_div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Returns a vector containing the integer part each element of `self`. This means numbers are -/// always truncated towards zero. +/// Returns a vector containing the wrapping addition of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::Vec3; + fn wrapping_add_unsigned(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::IVec3; "#, r#" -/// Returns a vector containing the fractional part of the vector, e.g. `self - -/// self.floor()`. -/// Note that this is fast but not precise for large numbers. +/// Returns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::Vec3; + fn wrapping_sub_unsigned(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::IVec3; "#, r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of -/// `self`. +/// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::Vec3; + fn saturating_add_unsigned( + self, + #[proxy] + rhs: bevy::math::UVec3, + ) -> bevy::math::IVec3; "#, r#" -/// Returns a vector containing each element of `self` raised to the power of `n`. +/// Returns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f32) -> bevy::math::Vec3; + fn saturating_sub_unsigned( + self, + #[proxy] + rhs: bevy::math::UVec3, + ) -> bevy::math::IVec3; "#, r#" -/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::Vec3; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Performs a linear interpolation between `self` and `rhs` based on the value `s`. -/// When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result -/// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly -/// extrapolated. - #[lua(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::Vec3, s: f32) -> bevy::math::Vec3; + #[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#" -/// Returns true if the absolute difference of all elements between `self` and `rhs` is -/// less than or equal to `max_abs_diff`. -/// This can be used to compare if two vectors contain similar elements. It works best when -/// comparing with a known value. The `max_abs_diff` that should be used used depends on -/// the values being compared against. -/// For more see -/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec3, max_abs_diff: f32) -> bool; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: i32) -> bevy::math::IVec3; "#, r#" -/// 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. - #[lua(kind = "Method", output(proxy))] - fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i32) -> bevy::math::IVec3; "#, r#" -/// Returns a vector with a length no more than `max` - #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f32) -> bevy::math::Vec3; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -/// Returns a vector with a length no less than `min` - #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f32) -> bevy::math::Vec3; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i32) -> bevy::math::IVec3; "#, r#" -/// Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding -/// error, yielding a more accurate result than an unfused multiply-add. -/// Using `mul_add` *may* be more performant than an unfused multiply-add if the target -/// architecture has a dedicated fma CPU instruction. However, this is not always true, -/// and will be heavily dependant on designing algorithms with specific target hardware in -/// mind. - #[lua(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::Vec3, - #[proxy] - b: bevy::math::Vec3, - ) -> bevy::math::Vec3; + #[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#" -/// Returns the angle (in radians) between two vectors. -/// 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::Vec3) -> f32; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::IVec3) -> bool; "#, r#" -/// Returns some vector that is orthogonal to the given one. -/// The input vector must be finite and non-zero. -/// The output vector is not necessarily unit length. For that use -/// [`Self::any_orthonormal_vector()`] instead. - #[lua(kind = "Method", output(proxy))] - fn any_orthogonal_vector(&self) -> bevy::math::Vec3; + #[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#" -/// Returns any unit vector that is orthogonal to the given one. -/// The input vector must be unit length. -/// # Panics -/// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] - fn any_orthonormal_vector(&self) -> bevy::math::Vec3; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -/// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i32) -> bevy::math::IVec3; "#, r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; - +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} "#, r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; - +#[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 = "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, rhs: i32) -> bevy::math::IVec4; "#, 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: f32) -> bevy::math::Vec3; + fn neg(self) -> 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: f32) -> bevy::math::Vec3; + fn rem(self, rhs: i32) -> bevy::math::IVec4; "#, 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::Vec3) -> bevy::math::Vec3; + fn eq(&self, #[proxy] other: &glam::IVec4) -> bool; "#, r#" @@ -4874,327 +3483,158 @@ struct Quat(); composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: f32) -> bevy::math::Vec3; + fn sub(self, rhs: i32) -> bevy::math::IVec4; "#, 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::Vec3; + fn div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, 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: i32) -> bevy::math::IVec4; "#, 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, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "div", + metamethod = "Div", )] - fn neg(self) -> bevy::math::Vec3; + fn div(self, rhs: i32) -> bevy::math::IVec4; "#, r#" +/// Creates a new vector. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(kind = "Function", output(proxy))] + fn new(x: i32, y: i32, z: i32, w: i32) -> bevy::math::IVec4; "#, r#" +/// Creates a vector with all elements set to `v`. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(kind = "Function", output(proxy))] + fn splat(v: i32) -> bevy::math::IVec4; "#, 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::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::Vec3) -> bool; + #[lua(kind = "Function", output(proxy))] + fn select( + #[proxy] + mask: bevy::math::BVec4, + #[proxy] + if_true: bevy::math::IVec4, + #[proxy] + if_false: bevy::math::IVec4, + ) -> bevy::math::IVec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [i32; 4]) -> bevy::math::IVec4; + "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} +/// `[x, y, z, w]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [i32; 4]; + "#, 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 Vec3 { - x: f32, - y: f32, - z: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::IVec2", - functions[r#" +/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. +/// Truncation to [`IVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::IVec2) -> bool; + #[lua(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::IVec3; "#, r#" +/// Creates a 4D vector from `self` with the given value of `x`. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: i32) -> bevy::math::IVec4; "#, r#" +/// Creates a 4D vector from `self` with the given value of `y`. - #[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; + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: i32) -> bevy::math::IVec4; "#, r#" +/// Creates a 4D vector from `self` with the given value of `z`. - #[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; + #[lua(kind = "Method", output(proxy))] + fn with_z(self, z: i32) -> bevy::math::IVec4; "#, r#" +/// Creates a 4D vector from `self` with the given value of `w`. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i32) -> bevy::math::IVec2; + #[lua(kind = "Method", output(proxy))] + fn with_w(self, w: i32) -> bevy::math::IVec4; "#, r#" +/// Computes the dot product of `self` and `rhs`. - #[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; + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::IVec4) -> i32; "#, r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i32) -> bevy::math::IVec2; + #[lua(kind = "Method", output(proxy))] + fn dot_into_vec(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, rhs: i32) -> 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 = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> 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::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`. - - #[lua(kind = "Function", output(proxy))] - fn select( - #[proxy] - mask: bevy::math::BVec2, - #[proxy] - if_true: bevy::math::IVec2, - #[proxy] - if_false: bevy::math::IVec2, - ) -> bevy::math::IVec2; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i32; 2]) -> bevy::math::IVec2; - -"#, - r#" -/// `[x, y]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [i32; 2]; - -"#, - r#" -/// Creates a 3D vector from `self` and the given `z` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, z: i32) -> bevy::math::IVec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::IVec2) -> i32; - -"#, - 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::IVec2) -> bevy::math::IVec2; - -"#, - r#" -/// Returns a vector containing the minimum values for each element of `self` and `rhs`. -/// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. +/// Returns a vector containing the minimum values for each element of `self` and `rhs`. +/// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn min(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -5202,7 +3642,7 @@ struct Vec3 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn max(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -5215,10 +3655,10 @@ struct Vec3 { fn clamp( self, #[proxy] - min: bevy::math::IVec2, + min: bevy::math::IVec4, #[proxy] - max: bevy::math::IVec2, - ) -> bevy::math::IVec2; + max: bevy::math::IVec4, + ) -> bevy::math::IVec4; "#, r#" @@ -5236,6 +3676,22 @@ struct Vec3 { #[lua(kind = "Method")] fn max_element(self) -> i32; +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> i32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> i32; + "#, r#" /// Returns a vector mask containing the result of a `==` comparison for each element of @@ -5244,7 +3700,7 @@ struct Vec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + fn cmpeq(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; "#, r#" @@ -5254,7 +3710,7 @@ struct Vec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + fn cmpne(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; "#, r#" @@ -5264,7 +3720,7 @@ struct Vec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + fn cmpge(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; "#, r#" @@ -5274,7 +3730,7 @@ struct Vec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + fn cmpgt(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; "#, r#" @@ -5284,7 +3740,7 @@ struct Vec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + fn cmple(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; "#, r#" @@ -5294,14 +3750,14 @@ struct Vec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::BVec2; + fn cmplt(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::IVec2; + fn abs(self) -> bevy::math::IVec4; "#, r#" @@ -5311,11 +3767,11 @@ struct Vec3 { /// - `-1` if the number is negative #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::IVec2; + fn signum(self) -> bevy::math::IVec4; "#, r#" -/// Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. +/// Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. /// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes /// into the first lowest bit, element `y` into the second, etc. @@ -5334,7 +3790,7 @@ struct Vec3 { /// Compute the squared euclidean distance between two points in space. #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::IVec2) -> i32; + fn distance_squared(self, #[proxy] rhs: bevy::math::IVec4) -> i32; "#, r#" @@ -5343,7 +3799,7 @@ struct Vec3 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn div_euclid(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -5353,66 +3809,42 @@ struct Vec3 { /// [Euclidean division]: i32::rem_euclid #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" -/// Returns a vector that is equal to `self` rotated by 90 degrees. - - #[lua(kind = "Method", output(proxy))] - fn perp(self) -> bevy::math::IVec2; - -"#, - r#" -/// The perpendicular dot product of `self` and `rhs`. -/// Also known as the wedge product, 2D cross product, and determinant. - - #[lua(kind = "Method")] - fn perp_dot(self, #[proxy] rhs: bevy::math::IVec2) -> i32; - -"#, - r#" -/// Returns `rhs` rotated by the angle of `self`. If `self` is normalized, -/// then this just rotation. This is what you usually want. Otherwise, -/// it will be like a rotation with a multiplication by `self`'s length. - - #[lua(kind = "Method", output(proxy))] - fn rotate(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" /// Casts all elements of `self` to `f32`. #[lua(kind = "Method", output(proxy))] - fn as_vec2(&self) -> bevy::math::Vec2; + fn as_vec4(&self) -> bevy::math::Vec4; "#, r#" /// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn as_dvec2(&self) -> bevy::math::DVec2; + fn as_dvec4(&self) -> bevy::math::DVec4; "#, r#" /// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn as_uvec2(&self) -> bevy::math::UVec2; + fn as_uvec4(&self) -> bevy::math::UVec4; "#, r#" /// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; + fn as_i64vec4(&self) -> bevy::math::I64Vec4; "#, r#" /// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; + fn as_u64vec4(&self) -> bevy::math::U64Vec4; "#, r#" @@ -5420,7 +3852,7 @@ struct Vec3 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -5428,7 +3860,7 @@ struct Vec3 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -5436,7 +3868,7 @@ struct Vec3 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -5444,7 +3876,7 @@ struct Vec3 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -5452,7 +3884,7 @@ struct Vec3 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn saturating_add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -5460,7 +3892,7 @@ struct Vec3 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -5468,7 +3900,7 @@ struct Vec3 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -5476,60 +3908,129 @@ struct Vec3 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn saturating_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" +/// Returns a vector containing the wrapping addition of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..]`. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_unsigned(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::IVec4; "#, r#" +/// Returns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..]`. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i32) -> bevy::math::IVec2; + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub_unsigned(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::IVec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} +/// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add_unsigned( + self, + #[proxy] + rhs: bevy::math::UVec4, + ) -> bevy::math::IVec4; + "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} +/// Returns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub_unsigned( + self, + #[proxy] + rhs: bevy::math::UVec4, + ) -> bevy::math::IVec4; + "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] + + #[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) +} +"#, + 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 { +struct IVec4 { x: i32, y: i32, + z: i32, + w: i32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::IVec3", + remote = "bevy::math::I64Vec2", functions[r#" #[lua( @@ -5539,21 +4040,78 @@ struct IVec2 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + 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 = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i64) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::I64Vec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] - fn new(x: i32, y: i32, z: i32) -> bevy::math::IVec3; + fn new(x: i64, y: i64) -> bevy::math::I64Vec2; "#, r#" /// Creates a vector with all elements set to `v`. #[lua(kind = "Function", output(proxy))] - fn splat(v: i32) -> bevy::math::IVec3; + fn splat(v: i64) -> bevy::math::I64Vec2; "#, r#" @@ -5565,62 +4123,61 @@ struct IVec2 { #[lua(kind = "Function", output(proxy))] fn select( #[proxy] - mask: bevy::math::BVec3, + mask: bevy::math::BVec2, #[proxy] - if_true: bevy::math::IVec3, + if_true: bevy::math::I64Vec2, #[proxy] - if_false: bevy::math::IVec3, - ) -> bevy::math::IVec3; + if_false: bevy::math::I64Vec2, + ) -> bevy::math::I64Vec2; "#, r#" /// Creates a new vector from an array. #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i32; 3]) -> bevy::math::IVec3; + fn from_array(a: [i64; 2]) -> bevy::math::I64Vec2; "#, r#" -/// `[x, y, z]` +/// `[x, y]` #[lua(kind = "Method")] - fn to_array(&self) -> [i32; 3]; + fn to_array(&self) -> [i64; 2]; "#, r#" -/// Creates a 4D vector from `self` and the given `w` value. +/// Creates a 3D vector from `self` and the given `z` value. #[lua(kind = "Method", output(proxy))] - fn extend(self, w: i32) -> bevy::math::IVec4; + fn extend(self, z: i64) -> bevy::math::I64Vec3; "#, 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 `self` with the given value of `x`. #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::IVec2; + fn with_x(self, x: i64) -> bevy::math::I64Vec2; "#, r#" -/// Computes the dot product of `self` and `rhs`. +/// Creates a 2D vector from `self` with the given value of `y`. - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::IVec3) -> i32; + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: i64) -> bevy::math::I64Vec2; "#, r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. +/// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; "#, r#" -/// Computes the cross product of `self` and `rhs`. +/// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -5628,7 +4185,7 @@ struct IVec2 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn min(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -5636,11 +4193,11 @@ struct IVec2 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn max(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" -/// Component-wise clamping of values, similar to [`i32::clamp`]. +/// Component-wise clamping of values, similar to [`i64::clamp`]. /// Each element in `min` must be less-or-equal to the corresponding element in `max`. /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. @@ -5649,10 +4206,10 @@ struct IVec2 { fn clamp( self, #[proxy] - min: bevy::math::IVec3, + min: bevy::math::I64Vec2, #[proxy] - max: bevy::math::IVec3, - ) -> bevy::math::IVec3; + max: bevy::math::I64Vec2, + ) -> bevy::math::I64Vec2; "#, r#" @@ -5660,7 +4217,7 @@ struct IVec2 { /// In other words this computes `min(x, y, ..)`. #[lua(kind = "Method")] - fn min_element(self) -> i32; + fn min_element(self) -> i64; "#, r#" @@ -5668,7 +4225,23 @@ struct IVec2 { /// In other words this computes `max(x, y, ..)`. #[lua(kind = "Method")] - fn max_element(self) -> i32; + fn max_element(self) -> i64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> i64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> i64; "#, r#" @@ -5678,7 +4251,7 @@ struct IVec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; "#, r#" @@ -5688,7 +4261,7 @@ struct IVec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; "#, r#" @@ -5698,7 +4271,7 @@ struct IVec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; "#, r#" @@ -5708,7 +4281,7 @@ struct IVec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; "#, r#" @@ -5718,7 +4291,7 @@ struct IVec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + fn cmple(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; "#, r#" @@ -5728,14 +4301,14 @@ struct IVec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::BVec3; + fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::IVec3; + fn abs(self) -> bevy::math::I64Vec2; "#, r#" @@ -5745,11 +4318,11 @@ struct IVec2 { /// - `-1` if the number is negative #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::IVec3; + fn signum(self) -> bevy::math::I64Vec2; "#, r#" -/// Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. +/// Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. /// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes /// into the first lowest bit, element `y` into the second, etc. @@ -5761,14 +4334,14 @@ struct IVec2 { /// Computes the squared length of `self`. #[lua(kind = "Method")] - fn length_squared(self) -> i32; + fn length_squared(self) -> i64; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::IVec3) -> i32; + fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; "#, r#" @@ -5777,67 +4350,84 @@ struct IVec2 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. /// # Panics /// This function will panic if any `rhs` element is 0 or the division results in overflow. -/// [Euclidean division]: i32::rem_euclid +/// [Euclidean division]: i64::rem_euclid #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" -/// Casts all elements of `self` to `f32`. +/// Returns a vector that is equal to `self` rotated by 90 degrees. #[lua(kind = "Method", output(proxy))] - fn as_vec3(&self) -> bevy::math::Vec3; + fn perp(self) -> bevy::math::I64Vec2; "#, r#" -/// Casts all elements of `self` to `f32`. +/// The perpendicular dot product of `self` and `rhs`. +/// Also known as the wedge product, 2D cross product, and determinant. - #[lua(kind = "Method", output(proxy))] - fn as_vec3a(&self) -> bevy::math::Vec3A; + #[lua(kind = "Method")] + fn perp_dot(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; "#, r#" -/// Casts all elements of `self` to `f64`. +/// Returns `rhs` rotated by the angle of `self`. If `self` is normalized, +/// then this just rotation. This is what you usually want. Otherwise, +/// it will be like a rotation with a multiplication by `self`'s length. #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; + fn rotate(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" -/// Casts all elements of `self` to `u32`. +/// Casts all elements of `self` to `f32`. #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; + fn as_vec2(&self) -> bevy::math::Vec2; "#, r#" -/// Casts all elements of `self` to `i64`. +/// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; + fn as_dvec2(&self) -> bevy::math::DVec2; "#, r#" -/// Casts all elements of `self` to `u64`. +/// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; + fn as_ivec2(&self) -> bevy::math::IVec2; "#, r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. +/// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn as_uvec2(&self) -> bevy::math::UVec2; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec2(&self) -> bevy::math::U64Vec2; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -5845,7 +4435,7 @@ struct IVec2 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -5853,7 +4443,7 @@ struct IVec2 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -5861,7 +4451,7 @@ struct IVec2 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -5869,7 +4459,7 @@ struct IVec2 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -5877,7 +4467,7 @@ struct IVec2 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -5885,7 +4475,7 @@ struct IVec2 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -5893,82 +4483,90 @@ struct IVec2 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" +/// Returns a vector containing the wrapping addition of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..]`. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_unsigned( + self, + #[proxy] + rhs: bevy::math::U64Vec2, + ) -> bevy::math::I64Vec2; "#, r#" +/// Returns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..]`. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i32) -> bevy::math::IVec3; + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub_unsigned( + self, + #[proxy] + rhs: bevy::math::U64Vec2, + ) -> bevy::math::I64Vec2; "#, r#" +/// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: i32) -> bevy::math::IVec3; + #[lua(kind = "Method", output(proxy))] + fn saturating_add_unsigned( + self, + #[proxy] + rhs: bevy::math::U64Vec2, + ) -> bevy::math::I64Vec2; "#, r#" +/// Returns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..]`. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i32) -> bevy::math::IVec3; + #[lua(kind = "Method", output(proxy))] + fn saturating_sub_unsigned( + self, + #[proxy] + rhs: bevy::math::U64Vec2, + ) -> bevy::math::I64Vec2; "#, 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, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, 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::IVec3) -> bool; + fn add(self, rhs: i64) -> bevy::math::I64Vec2; "#, 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::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -5980,7 +4578,7 @@ struct IVec2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn mul(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" @@ -5992,19 +4590,7 @@ struct IVec2 { composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: i32) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i32) -> bevy::math::IVec3; + fn rem(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" @@ -6016,7 +4602,7 @@ struct IVec2 { composite = "neg", metamethod = "Unm", )] - fn neg(self) -> bevy::math::IVec3; + fn neg(self) -> bevy::math::I64Vec2; "#, r#" @@ -6028,19 +4614,13 @@ struct IVec2 { composite = "rem", metamethod = "Mod", )] - fn rem(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn rem(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, 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; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -6048,49 +4628,48 @@ struct IVec2 { 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, +struct I64Vec2 { + x: i64, + y: i64, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::IVec4", + remote = "bevy::math::I64Vec3", functions[r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "div", + metamethod = "Div", )] - fn rem(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, 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::IVec4; + fn rem(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" @@ -6102,80 +4681,98 @@ struct IVec3 { composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: i32) -> bevy::math::IVec4; + 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, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn div(self, rhs: i64) -> bevy::math::I64Vec3; "#, 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::I64Vec3; "#, 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::IVec4) -> bevy::math::IVec4; + fn mul(self, rhs: i64) -> bevy::math::I64Vec3; "#, 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: i32) -> bevy::math::IVec4; + fn mul(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::Rem", + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::I64Vec3) -> bool; + +"#, + r#" + + #[lua( + 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, rhs: i64) -> bevy::math::I64Vec3; "#, r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] - fn new(x: i32, y: i32, z: i32, w: i32) -> bevy::math::IVec4; + fn new(x: i64, y: i64, z: i64) -> bevy::math::I64Vec3; "#, r#" /// Creates a vector with all elements set to `v`. #[lua(kind = "Function", output(proxy))] - fn splat(v: i32) -> bevy::math::IVec4; + fn splat(v: i64) -> bevy::math::I64Vec3; "#, r#" @@ -6187,48 +4784,83 @@ struct IVec3 { #[lua(kind = "Function", output(proxy))] fn select( #[proxy] - mask: bevy::math::BVec4, + mask: bevy::math::BVec3, #[proxy] - if_true: bevy::math::IVec4, + if_true: bevy::math::I64Vec3, #[proxy] - if_false: bevy::math::IVec4, - ) -> bevy::math::IVec4; + if_false: bevy::math::I64Vec3, + ) -> bevy::math::I64Vec3; "#, r#" /// Creates a new vector from an array. #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i32; 4]) -> bevy::math::IVec4; + fn from_array(a: [i64; 3]) -> bevy::math::I64Vec3; "#, r#" -/// `[x, y, z, w]` +/// `[x, y, z]` #[lua(kind = "Method")] - fn to_array(&self) -> [i32; 4]; + fn to_array(&self) -> [i64; 3]; "#, r#" -/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. -/// Truncation to [`IVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. +/// Creates a 4D vector from `self` and the given `w` value. #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::IVec3; + fn extend(self, w: i64) -> bevy::math::I64Vec4; + +"#, + 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()]. + + #[lua(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::I64Vec2; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `x`. + + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: i64) -> bevy::math::I64Vec3; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `y`. + + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: i64) -> bevy::math::I64Vec3; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `z`. + + #[lua(kind = "Method", output(proxy))] + fn with_z(self, z: i64) -> bevy::math::I64Vec3; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::IVec4) -> i32; + fn dot(self, #[proxy] rhs: bevy::math::I64Vec3) -> i64; "#, 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::IVec4) -> bevy::math::IVec4; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn cross(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -6236,7 +4868,7 @@ struct IVec3 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn min(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -6244,11 +4876,11 @@ struct IVec3 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn max(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" -/// Component-wise clamping of values, similar to [`i32::clamp`]. +/// Component-wise clamping of values, similar to [`i64::clamp`]. /// Each element in `min` must be less-or-equal to the corresponding element in `max`. /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. @@ -6257,10 +4889,10 @@ struct IVec3 { fn clamp( self, #[proxy] - min: bevy::math::IVec4, + min: bevy::math::I64Vec3, #[proxy] - max: bevy::math::IVec4, - ) -> bevy::math::IVec4; + max: bevy::math::I64Vec3, + ) -> bevy::math::I64Vec3; "#, r#" @@ -6268,7 +4900,7 @@ struct IVec3 { /// In other words this computes `min(x, y, ..)`. #[lua(kind = "Method")] - fn min_element(self) -> i32; + fn min_element(self) -> i64; "#, r#" @@ -6276,7 +4908,23 @@ struct IVec3 { /// In other words this computes `max(x, y, ..)`. #[lua(kind = "Method")] - fn max_element(self) -> i32; + fn max_element(self) -> i64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> i64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> i64; "#, r#" @@ -6286,7 +4934,7 @@ struct IVec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; "#, r#" @@ -6296,7 +4944,7 @@ struct IVec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; "#, r#" @@ -6306,7 +4954,7 @@ struct IVec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; "#, r#" @@ -6316,7 +4964,7 @@ struct IVec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; "#, r#" @@ -6326,7 +4974,7 @@ struct IVec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + fn cmple(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; "#, r#" @@ -6336,14 +4984,14 @@ struct IVec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::BVec4; + fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::IVec4; + fn abs(self) -> bevy::math::I64Vec3; "#, r#" @@ -6353,11 +5001,11 @@ struct IVec3 { /// - `-1` if the number is negative #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::IVec4; + fn signum(self) -> bevy::math::I64Vec3; "#, r#" -/// Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. +/// Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. /// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes /// into the first lowest bit, element `y` into the second, etc. @@ -6369,14 +5017,14 @@ struct IVec3 { /// Computes the squared length of `self`. #[lua(kind = "Method")] - fn length_squared(self) -> i32; + fn length_squared(self) -> i64; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::IVec4) -> i32; + fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec3) -> i64; "#, r#" @@ -6385,52 +5033,59 @@ struct IVec3 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. /// # Panics /// This function will panic if any `rhs` element is 0 or the division results in overflow. -/// [Euclidean division]: i32::rem_euclid +/// [Euclidean division]: i64::rem_euclid #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" /// Casts all elements of `self` to `f32`. #[lua(kind = "Method", output(proxy))] - fn as_vec4(&self) -> bevy::math::Vec4; + fn as_vec3(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec3a(&self) -> bevy::math::Vec3A; "#, r#" /// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn as_dvec4(&self) -> bevy::math::DVec4; + fn as_dvec3(&self) -> bevy::math::DVec3; "#, r#" -/// Casts all elements of `self` to `u32`. +/// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn as_uvec4(&self) -> bevy::math::UVec4; + fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" -/// Casts all elements of `self` to `i64`. +/// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; + fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" /// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; + fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, r#" @@ -6438,7 +5093,7 @@ struct IVec3 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -6446,7 +5101,7 @@ struct IVec3 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -6454,7 +5109,7 @@ struct IVec3 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -6462,7 +5117,7 @@ struct IVec3 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -6470,7 +5125,7 @@ struct IVec3 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -6478,7 +5133,7 @@ struct IVec3 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -6486,7 +5141,7 @@ struct IVec3 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -6494,37 +5149,54 @@ struct IVec3 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" +/// Returns a vector containing the wrapping addition of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..]`. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_unsigned( + self, + #[proxy] + rhs: bevy::math::U64Vec3, + ) -> bevy::math::I64Vec3; "#, r#" +/// Returns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..]`. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i32) -> bevy::math::IVec4; + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub_unsigned( + self, + #[proxy] + rhs: bevy::math::U64Vec3, + ) -> bevy::math::I64Vec3; "#, r#" +/// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`. - #[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; + #[lua(kind = "Method", output(proxy))] + fn saturating_add_unsigned( + self, + #[proxy] + rhs: bevy::math::U64Vec3, + ) -> bevy::math::I64Vec3; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub_unsigned( + self, + #[proxy] + rhs: bevy::math::U64Vec3, + ) -> bevy::math::I64Vec3; "#, r#" @@ -6536,31 +5208,31 @@ struct IVec3 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn add(self, rhs: i64) -> bevy::math::I64Vec3; "#, 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::IVec4; + fn add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, 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::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -6568,190 +5240,121 @@ struct IVec3 { 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 IVec4 { - x: i32, - y: i32, - z: i32, - w: i32, +struct I64Vec3 { + x: i64, + y: i64, + z: i64, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::I64Vec2", + remote = "bevy::math::I64Vec4", 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::I64Vec2) -> bevy::math::I64Vec2; + fn eq(&self, #[proxy] other: &glam::I64Vec4) -> bool; "#, r#" +/// Creates a new vector. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i64) -> bevy::math::I64Vec2; + #[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( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[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( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i64) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::I64Vec2; + #[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( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: i64) -> bevy::math::I64Vec2; + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [i64; 4]) -> bevy::math::I64Vec4; "#, r#" -/// Creates a new vector. +/// `[x, y, z, w]` - #[lua(kind = "Function", output(proxy))] - fn new(x: i64, y: i64) -> bevy::math::I64Vec2; + #[lua(kind = "Method")] + fn to_array(&self) -> [i64; 4]; "#, r#" -/// Creates a vector with all elements set to `v`. +/// 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 = "Function", output(proxy))] - fn splat(v: i64) -> bevy::math::I64Vec2; + #[lua(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::I64Vec3; "#, 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`. +/// Creates a 4D vector from `self` with the given value of `x`. - #[lua(kind = "Function", output(proxy))] - fn select( - #[proxy] - mask: bevy::math::BVec2, - #[proxy] - if_true: bevy::math::I64Vec2, - #[proxy] - if_false: bevy::math::I64Vec2, - ) -> bevy::math::I64Vec2; + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: i64) -> bevy::math::I64Vec4; "#, r#" -/// Creates a new vector from an array. +/// Creates a 4D vector from `self` with the given value of `y`. - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i64; 2]) -> bevy::math::I64Vec2; + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: i64) -> bevy::math::I64Vec4; "#, r#" -/// `[x, y]` +/// Creates a 4D vector from `self` with the given value of `z`. - #[lua(kind = "Method")] - fn to_array(&self) -> [i64; 2]; + #[lua(kind = "Method", output(proxy))] + fn with_z(self, z: i64) -> bevy::math::I64Vec4; "#, r#" -/// Creates a 3D vector from `self` and the given `z` value. +/// Creates a 4D vector from `self` with the given value of `w`. #[lua(kind = "Method", output(proxy))] - fn extend(self, z: i64) -> bevy::math::I64Vec3; + fn with_w(self, w: i64) -> bevy::math::I64Vec4; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; + fn dot(self, #[proxy] rhs: bevy::math::I64Vec4) -> i64; "#, 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::I64Vec2) -> bevy::math::I64Vec2; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -6759,7 +5362,7 @@ struct IVec4 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn min(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -6767,7 +5370,7 @@ struct IVec4 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn max(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -6780,10 +5383,10 @@ struct IVec4 { fn clamp( self, #[proxy] - min: bevy::math::I64Vec2, + min: bevy::math::I64Vec4, #[proxy] - max: bevy::math::I64Vec2, - ) -> bevy::math::I64Vec2; + max: bevy::math::I64Vec4, + ) -> bevy::math::I64Vec4; "#, r#" @@ -6801,6 +5404,22 @@ struct IVec4 { #[lua(kind = "Method")] fn max_element(self) -> i64; +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> i64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> i64; + "#, r#" /// Returns a vector mask containing the result of a `==` comparison for each element of @@ -6809,7 +5428,7 @@ struct IVec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; "#, r#" @@ -6819,7 +5438,7 @@ struct IVec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; "#, r#" @@ -6829,7 +5448,7 @@ struct IVec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; "#, r#" @@ -6839,7 +5458,7 @@ struct IVec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; "#, r#" @@ -6849,7 +5468,7 @@ struct IVec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + fn cmple(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; "#, r#" @@ -6859,14 +5478,14 @@ struct IVec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::BVec2; + fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::I64Vec2; + fn abs(self) -> bevy::math::I64Vec4; "#, r#" @@ -6876,11 +5495,11 @@ struct IVec4 { /// - `-1` if the number is negative #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::I64Vec2; + fn signum(self) -> bevy::math::I64Vec4; "#, r#" -/// Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. +/// Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. /// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes /// into the first lowest bit, element `y` into the second, etc. @@ -6899,7 +5518,7 @@ struct IVec4 { /// Compute the squared euclidean distance between two points in space. #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; + fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec4) -> i64; "#, r#" @@ -6908,7 +5527,7 @@ struct IVec4 { /// This function will panic if any `rhs` element is 0 or the division results in overflow. #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -6918,66 +5537,42 @@ struct IVec4 { /// [Euclidean division]: i64::rem_euclid #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; - -"#, - r#" -/// Returns a vector that is equal to `self` rotated by 90 degrees. - - #[lua(kind = "Method", output(proxy))] - fn perp(self) -> bevy::math::I64Vec2; - -"#, - r#" -/// The perpendicular dot product of `self` and `rhs`. -/// Also known as the wedge product, 2D cross product, and determinant. - - #[lua(kind = "Method")] - fn perp_dot(self, #[proxy] rhs: bevy::math::I64Vec2) -> i64; - -"#, - r#" -/// Returns `rhs` rotated by the angle of `self`. If `self` is normalized, -/// then this just rotation. This is what you usually want. Otherwise, -/// it will be like a rotation with a multiplication by `self`'s length. - - #[lua(kind = "Method", output(proxy))] - fn rotate(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" /// Casts all elements of `self` to `f32`. #[lua(kind = "Method", output(proxy))] - fn as_vec2(&self) -> bevy::math::Vec2; + fn as_vec4(&self) -> bevy::math::Vec4; "#, r#" /// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn as_dvec2(&self) -> bevy::math::DVec2; + fn as_dvec4(&self) -> bevy::math::DVec4; "#, r#" /// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn as_ivec2(&self) -> bevy::math::IVec2; + fn as_ivec4(&self) -> bevy::math::IVec4; "#, r#" /// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn as_uvec2(&self) -> bevy::math::UVec2; + fn as_uvec4(&self) -> bevy::math::UVec4; "#, r#" /// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; + fn as_u64vec4(&self) -> bevy::math::U64Vec4; "#, r#" @@ -6985,7 +5580,7 @@ struct IVec4 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -6993,7 +5588,7 @@ struct IVec4 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -7001,7 +5596,7 @@ struct IVec4 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -7009,7 +5604,7 @@ struct IVec4 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -7017,7 +5612,7 @@ struct IVec4 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -7025,7 +5620,7 @@ struct IVec4 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -7033,7 +5628,7 @@ struct IVec4 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -7041,40 +5636,66 @@ struct IVec4 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" +/// Returns a vector containing the wrapping addition of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..]`. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::I64Vec2) -> bool; + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_unsigned( + self, + #[proxy] + rhs: bevy::math::U64Vec4, + ) -> bevy::math::I64Vec4; "#, r#" +/// Returns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..]`. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + #[lua(kind = "Method", output(proxy))] + fn wrapping_sub_unsigned( + self, + #[proxy] + rhs: bevy::math::U64Vec4, + ) -> bevy::math::I64Vec4; + +"#, + r#" +/// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add_unsigned( + self, + #[proxy] + rhs: bevy::math::U64Vec4, + ) -> bevy::math::I64Vec4; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`. +/// In other words this computes `[self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub_unsigned( + self, + #[proxy] + rhs: bevy::math::U64Vec4, + ) -> bevy::math::I64Vec4; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Sub", + kind = "MetaFunction", output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn clone(&self) -> bevy::math::I64Vec2; + fn sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -7086,19 +5707,19 @@ struct IVec4 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn add(self, rhs: i64) -> bevy::math::I64Vec4; "#, 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::I64Vec2; + fn rem(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -7108,42 +5729,27 @@ struct IVec4 { "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct I64Vec2 { - x: i64, - y: i64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::I64Vec3", - functions[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: i64) -> bevy::math::I64Vec3; + fn div(self, rhs: i64) -> bevy::math::I64Vec4; "#, 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::I64Vec3) -> bevy::math::I64Vec3; + fn rem(self, rhs: i64) -> bevy::math::I64Vec4; "#, r#" @@ -7155,7 +5761,55 @@ struct I64Vec2 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::I64Vec4; + +"#, + r#" + + #[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, rhs: i64) -> bevy::math::I64Vec4; + +"#, + r#" + + #[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#" @@ -7167,7 +5821,7 @@ struct I64Vec2 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -7177,55 +5831,72 @@ struct I64Vec2 { kind = "Method", output(proxy), )] - fn clone(&self) -> bevy::math::I64Vec3; + 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::Rem", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "sub", + metamethod = "Sub", )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec3; + fn sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, 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::I64Vec3) -> bevy::math::I64Vec3; + fn mul(self, rhs: u32) -> 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::I64Vec3; + fn rem(self, rhs: u32) -> bevy::math::UVec2; "#, 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, rhs: u32) -> bevy::math::UVec2; "#, r#" @@ -7237,21 +5908,50 @@ struct I64Vec2 { composite = "add", metamethod = "Add", )] - fn add(self, rhs: i64) -> bevy::math::I64Vec3; + 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. #[lua(kind = "Function", output(proxy))] - fn new(x: i64, y: i64, z: i64) -> bevy::math::I64Vec3; + fn new(x: u32, y: u32) -> bevy::math::UVec2; "#, r#" /// Creates a vector with all elements set to `v`. #[lua(kind = "Function", output(proxy))] - fn splat(v: i64) -> bevy::math::I64Vec3; + fn splat(v: u32) -> bevy::math::UVec2; "#, r#" @@ -7263,62 +5963,61 @@ struct I64Vec2 { #[lua(kind = "Function", output(proxy))] fn select( #[proxy] - mask: bevy::math::BVec3, + mask: bevy::math::BVec2, #[proxy] - if_true: bevy::math::I64Vec3, + if_true: bevy::math::UVec2, #[proxy] - if_false: bevy::math::I64Vec3, - ) -> bevy::math::I64Vec3; + if_false: bevy::math::UVec2, + ) -> bevy::math::UVec2; "#, r#" /// Creates a new vector from an array. #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i64; 3]) -> bevy::math::I64Vec3; + fn from_array(a: [u32; 2]) -> bevy::math::UVec2; "#, r#" -/// `[x, y, z]` +/// `[x, y]` #[lua(kind = "Method")] - fn to_array(&self) -> [i64; 3]; + fn to_array(&self) -> [u32; 2]; "#, r#" -/// Creates a 4D vector from `self` and the given `w` value. +/// Creates a 3D vector from `self` and the given `z` value. #[lua(kind = "Method", output(proxy))] - fn extend(self, w: i64) -> bevy::math::I64Vec4; + fn extend(self, z: u32) -> bevy::math::UVec3; "#, 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 `self` with the given value of `x`. #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::I64Vec2; + fn with_x(self, x: u32) -> bevy::math::UVec2; "#, r#" -/// Computes the dot product of `self` and `rhs`. +/// Creates a 2D vector from `self` with the given value of `y`. - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::I64Vec3) -> i64; + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: u32) -> bevy::math::UVec2; "#, r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. +/// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::UVec2) -> u32; "#, r#" -/// Computes the cross product of `self` and `rhs`. +/// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" @@ -7326,7 +6025,7 @@ struct I64Vec2 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn min(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" @@ -7334,11 +6033,11 @@ struct I64Vec2 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn max(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" -/// Component-wise clamping of values, similar to [`i64::clamp`]. +/// Component-wise clamping of values, similar to [`u32::clamp`]. /// Each element in `min` must be less-or-equal to the corresponding element in `max`. /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. @@ -7347,10 +6046,10 @@ struct I64Vec2 { fn clamp( self, #[proxy] - min: bevy::math::I64Vec3, + min: bevy::math::UVec2, #[proxy] - max: bevy::math::I64Vec3, - ) -> bevy::math::I64Vec3; + max: bevy::math::UVec2, + ) -> bevy::math::UVec2; "#, r#" @@ -7358,7 +6057,7 @@ struct I64Vec2 { /// In other words this computes `min(x, y, ..)`. #[lua(kind = "Method")] - fn min_element(self) -> i64; + fn min_element(self) -> u32; "#, r#" @@ -7366,7 +6065,23 @@ struct I64Vec2 { /// In other words this computes `max(x, y, ..)`. #[lua(kind = "Method")] - fn max_element(self) -> i64; + fn max_element(self) -> u32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> u32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> u32; "#, r#" @@ -7376,7 +6091,7 @@ struct I64Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + fn cmpeq(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; "#, r#" @@ -7386,7 +6101,7 @@ struct I64Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + fn cmpne(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; "#, r#" @@ -7396,7 +6111,7 @@ struct I64Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + fn cmpge(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; "#, r#" @@ -7406,7 +6121,7 @@ struct I64Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + fn cmpgt(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; "#, r#" @@ -7416,7 +6131,7 @@ struct I64Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + fn cmple(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; "#, r#" @@ -7426,108 +6141,49 @@ struct I64Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::BVec3; + fn cmplt(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; "#, r#" -/// Returns a vector containing the absolute value of each element of `self`. +/// Computes the squared length of `self`. - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::I64Vec3; + #[lua(kind = "Method")] + fn length_squared(self) -> u32; "#, r#" -/// Returns a vector with elements representing the sign of `self`. -/// - `0` if the number is zero -/// - `1` if the number is positive -/// - `-1` if the number is negative +/// Casts all elements of `self` to `f32`. #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::I64Vec3; + fn as_vec2(&self) -> bevy::math::Vec2; "#, r#" -/// Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. -/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes -/// into the first lowest bit, element `y` into the second, etc. +/// Casts all elements of `self` to `f64`. - #[lua(kind = "Method")] - fn is_negative_bitmask(self) -> u32; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> i64; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec3) -> i64; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. -/// [Euclidean division]: i64::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3(&self) -> bevy::math::Vec3; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3a(&self) -> bevy::math::Vec3A; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn as_dvec2(&self) -> bevy::math::DVec2; "#, r#" /// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; + fn as_ivec2(&self) -> bevy::math::IVec2; "#, r#" -/// Casts all elements of `self` to `u32`. +/// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; + fn as_i64vec2(&self) -> bevy::math::I64Vec2; "#, r#" /// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; + fn as_u64vec2(&self) -> bevy::math::U64Vec2; "#, r#" @@ -7535,7 +6191,7 @@ struct I64Vec2 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" @@ -7543,7 +6199,7 @@ struct I64Vec2 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" @@ -7551,7 +6207,7 @@ struct I64Vec2 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" @@ -7559,7 +6215,7 @@ struct I64Vec2 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" @@ -7567,7 +6223,7 @@ struct I64Vec2 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn saturating_add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" @@ -7575,7 +6231,7 @@ struct I64Vec2 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" @@ -7583,7 +6239,7 @@ struct I64Vec2 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" @@ -7591,91 +6247,111 @@ struct I64Vec2 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn saturating_div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" +/// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i64) -> bevy::math::I64Vec3; + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_signed(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::UVec2; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`. + + #[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", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, 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::I64Vec3) -> bool; + fn rem(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, 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::Sub", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "div", + metamethod = "Div", )] - fn sub(self, rhs: i64) -> bevy::math::I64Vec4; + fn div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" #[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::I64Vec4) -> bevy::math::I64Vec4; + fn clone(&self) -> bevy::math::UVec2; "#, 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: u32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +struct UVec2 { + x: u32, + y: u32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::UVec3", + functions[r#" #[lua( as_trait = "std::ops::Mul", @@ -7684,42 +6360,43 @@ struct I64Vec3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: i64) -> bevy::math::I64Vec4; + fn mul(self, rhs: u32) -> bevy::math::UVec3; "#, 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::I64Vec4) -> bevy::math::I64Vec4; + fn div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, 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, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn rem(self, rhs: u32) -> bevy::math::UVec3; "#, 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::I64Vec4) -> bool; + fn add(self, rhs: u32) -> bevy::math::UVec3; "#, r#" @@ -7731,31 +6408,31 @@ struct I64Vec3 { composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec4; + fn rem(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, rhs: i64) -> bevy::math::I64Vec4; + fn sub(self, rhs: u32) -> bevy::math::UVec3; "#, 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::I64Vec4) -> bevy::math::I64Vec4; + fn sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -7765,7 +6442,7 @@ struct I64Vec3 { kind = "Method", output(proxy), )] - fn clone(&self) -> bevy::math::I64Vec4; + fn clone(&self) -> bevy::math::UVec3; "#, r#" @@ -7777,7 +6454,7 @@ struct I64Vec3 { composite = "add", metamethod = "Add", )] - fn add(self, rhs: i64) -> bevy::math::I64Vec4; + fn add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -7789,33 +6466,39 @@ struct I64Vec3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn mul(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) -> (); "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "div", + metamethod = "Div", )] - fn neg(self) -> bevy::math::I64Vec4; + fn div(self, rhs: u32) -> bevy::math::UVec3; "#, r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] - fn new(x: i64, y: i64, z: i64, w: i64) -> bevy::math::I64Vec4; + fn new(x: u32, y: u32, z: u32) -> bevy::math::UVec3; "#, r#" /// Creates a vector with all elements set to `v`. #[lua(kind = "Function", output(proxy))] - fn splat(v: i64) -> bevy::math::I64Vec4; + fn splat(v: u32) -> bevy::math::UVec3; "#, r#" @@ -7827,48 +6510,83 @@ struct I64Vec3 { #[lua(kind = "Function", output(proxy))] fn select( #[proxy] - mask: bevy::math::BVec4, + mask: bevy::math::BVec3, #[proxy] - if_true: bevy::math::I64Vec4, + if_true: bevy::math::UVec3, #[proxy] - if_false: bevy::math::I64Vec4, - ) -> bevy::math::I64Vec4; + if_false: bevy::math::UVec3, + ) -> bevy::math::UVec3; "#, r#" /// Creates a new vector from an array. #[lua(kind = "Function", output(proxy))] - fn from_array(a: [i64; 4]) -> bevy::math::I64Vec4; + fn from_array(a: [u32; 3]) -> bevy::math::UVec3; "#, r#" -/// `[x, y, z, w]` +/// `[x, y, z]` #[lua(kind = "Method")] - fn to_array(&self) -> [i64; 4]; + fn to_array(&self) -> [u32; 3]; "#, 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()]. +/// Creates a 4D vector from `self` and the given `w` value. #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::I64Vec3; + fn extend(self, w: u32) -> bevy::math::UVec4; + +"#, + 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()]. + + #[lua(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::UVec2; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `x`. + + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: u32) -> bevy::math::UVec3; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `y`. + + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: u32) -> bevy::math::UVec3; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `z`. + + #[lua(kind = "Method", output(proxy))] + fn with_z(self, z: u32) -> bevy::math::UVec3; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::I64Vec4) -> i64; + fn dot(self, #[proxy] rhs: bevy::math::UVec3) -> u32; "#, 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::I64Vec4) -> bevy::math::I64Vec4; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn cross(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -7876,7 +6594,7 @@ struct I64Vec3 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn min(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -7884,11 +6602,11 @@ struct I64Vec3 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn max(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" -/// Component-wise clamping of values, similar to [`i64::clamp`]. +/// Component-wise clamping of values, similar to [`u32::clamp`]. /// Each element in `min` must be less-or-equal to the corresponding element in `max`. /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. @@ -7897,10 +6615,10 @@ struct I64Vec3 { fn clamp( self, #[proxy] - min: bevy::math::I64Vec4, + min: bevy::math::UVec3, #[proxy] - max: bevy::math::I64Vec4, - ) -> bevy::math::I64Vec4; + max: bevy::math::UVec3, + ) -> bevy::math::UVec3; "#, r#" @@ -7908,7 +6626,7 @@ struct I64Vec3 { /// In other words this computes `min(x, y, ..)`. #[lua(kind = "Method")] - fn min_element(self) -> i64; + fn min_element(self) -> u32; "#, r#" @@ -7916,7 +6634,23 @@ struct I64Vec3 { /// In other words this computes `max(x, y, ..)`. #[lua(kind = "Method")] - fn max_element(self) -> i64; + fn max_element(self) -> u32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> u32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> u32; "#, r#" @@ -7926,7 +6660,7 @@ struct I64Vec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; + fn cmpeq(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; "#, r#" @@ -7936,7 +6670,7 @@ struct I64Vec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; + fn cmpne(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; "#, r#" @@ -7946,7 +6680,7 @@ struct I64Vec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; + fn cmpge(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; "#, r#" @@ -7956,7 +6690,7 @@ struct I64Vec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; + fn cmpgt(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; "#, r#" @@ -7966,7 +6700,7 @@ struct I64Vec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; + fn cmple(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; "#, r#" @@ -7976,101 +6710,56 @@ struct I64Vec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::BVec4; - -"#, - r#" -/// Returns a vector containing the absolute value of each element of `self`. - - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns a vector with elements representing the sign of `self`. -/// - `0` if the number is zero -/// - `1` if the number is positive -/// - `-1` if the number is negative - - #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. -/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes -/// into the first lowest bit, element `y` into the second, etc. - - #[lua(kind = "Method")] - fn is_negative_bitmask(self) -> u32; + fn cmplt(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; "#, r#" /// Computes the squared length of `self`. #[lua(kind = "Method")] - fn length_squared(self) -> i64; - -"#, - r#" -/// Compute the squared euclidean distance between two points in space. - - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::I64Vec4) -> i64; - -"#, - r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. - - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn length_squared(self) -> u32; "#, r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// # Panics -/// This function will panic if any `rhs` element is 0 or the division results in overflow. -/// [Euclidean division]: i64::rem_euclid +/// Casts all elements of `self` to `f32`. #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn as_vec3(&self) -> bevy::math::Vec3; "#, r#" /// Casts all elements of `self` to `f32`. #[lua(kind = "Method", output(proxy))] - fn as_vec4(&self) -> bevy::math::Vec4; + fn as_vec3a(&self) -> bevy::math::Vec3A; "#, r#" /// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn as_dvec4(&self) -> bevy::math::DVec4; + fn as_dvec3(&self) -> bevy::math::DVec3; "#, r#" /// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn as_ivec4(&self) -> bevy::math::IVec4; + fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" -/// Casts all elements of `self` to `u32`. +/// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn as_uvec4(&self) -> bevy::math::UVec4; + fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, r#" /// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; + fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, r#" @@ -8078,7 +6767,7 @@ struct I64Vec3 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -8086,7 +6775,7 @@ struct I64Vec3 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -8094,7 +6783,7 @@ struct I64Vec3 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -8102,7 +6791,7 @@ struct I64Vec3 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -8110,7 +6799,7 @@ struct I64Vec3 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn saturating_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -8118,7 +6807,7 @@ struct I64Vec3 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -8126,7 +6815,7 @@ struct I64Vec3 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -8134,13 +6823,34 @@ struct I64Vec3 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn saturating_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" +/// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_signed(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add_signed(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::UVec3) -> bool; "#, r#" @@ -8148,94 +6858,233 @@ struct I64Vec3 { 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: u32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} "#] )] -struct I64Vec4 { - x: i64, - y: i64, - z: i64, - w: i64, +struct UVec3 { + x: u32, + y: u32, + z: u32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::UVec2", + remote = "bevy::math::UVec4", functions[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::UVec2) -> bevy::math::UVec2; + fn rem(self, rhs: u32) -> bevy::math::UVec4; "#, r#" -/// Creates a new vector. - #[lua(kind = "Function", output(proxy))] - fn new(x: u32, y: u32) -> bevy::math::UVec2; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::UVec4) -> bool; "#, r#" -/// Creates a vector with all elements set to `v`. - #[lua(kind = "Function", output(proxy))] - fn splat(v: u32) -> bevy::math::UVec2; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u32) -> bevy::math::UVec4; "#, 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::BVec2, - #[proxy] - if_true: bevy::math::UVec2, - #[proxy] - if_false: bevy::math::UVec2, - ) -> bevy::math::UVec2; + #[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#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [u32; 2]) -> bevy::math::UVec2; + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u32) -> bevy::math::UVec4; "#, r#" -/// `[x, y]` + + #[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. + + #[lua(kind = "Function", output(proxy))] + fn new(x: u32, y: u32, z: u32, w: u32) -> bevy::math::UVec4; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: u32) -> bevy::math::UVec4; + +"#, + 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::UVec4, + #[proxy] + if_false: bevy::math::UVec4, + ) -> bevy::math::UVec4; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [u32; 4]) -> bevy::math::UVec4; + +"#, + r#" +/// `[x, y, z, w]` #[lua(kind = "Method")] - fn to_array(&self) -> [u32; 2]; + fn to_array(&self) -> [u32; 4]; "#, r#" -/// Creates a 3D vector from `self` and the given `z` value. +/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. +/// Truncation to [`UVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. #[lua(kind = "Method", output(proxy))] - fn extend(self, z: u32) -> bevy::math::UVec3; + fn truncate(self) -> bevy::math::UVec3; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `x`. + + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: u32) -> bevy::math::UVec4; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `y`. + + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: u32) -> bevy::math::UVec4; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `z`. + + #[lua(kind = "Method", output(proxy))] + fn with_z(self, z: u32) -> bevy::math::UVec4; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `w`. + + #[lua(kind = "Method", output(proxy))] + fn with_w(self, w: u32) -> bevy::math::UVec4; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::UVec2) -> u32; + fn dot(self, #[proxy] rhs: bevy::math::UVec4) -> u32; "#, 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::UVec2) -> bevy::math::UVec2; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" @@ -8243,7 +7092,7 @@ struct I64Vec4 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn min(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" @@ -8251,7 +7100,7 @@ struct I64Vec4 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn max(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" @@ -8264,10 +7113,10 @@ struct I64Vec4 { fn clamp( self, #[proxy] - min: bevy::math::UVec2, + min: bevy::math::UVec4, #[proxy] - max: bevy::math::UVec2, - ) -> bevy::math::UVec2; + max: bevy::math::UVec4, + ) -> bevy::math::UVec4; "#, r#" @@ -8285,6 +7134,22 @@ struct I64Vec4 { #[lua(kind = "Method")] fn max_element(self) -> u32; +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> u32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> u32; + "#, r#" /// Returns a vector mask containing the result of a `==` comparison for each element of @@ -8293,7 +7158,7 @@ struct I64Vec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + fn cmpeq(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; "#, r#" @@ -8303,7 +7168,7 @@ struct I64Vec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + fn cmpne(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; "#, r#" @@ -8313,7 +7178,7 @@ struct I64Vec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + fn cmpge(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; "#, r#" @@ -8323,7 +7188,7 @@ struct I64Vec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + fn cmpgt(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; "#, r#" @@ -8333,7 +7198,7 @@ struct I64Vec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + fn cmple(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; "#, r#" @@ -8343,7 +7208,7 @@ struct I64Vec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::BVec2; + fn cmplt(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; "#, r#" @@ -8357,35 +7222,35 @@ struct I64Vec4 { /// Casts all elements of `self` to `f32`. #[lua(kind = "Method", output(proxy))] - fn as_vec2(&self) -> bevy::math::Vec2; + fn as_vec4(&self) -> bevy::math::Vec4; "#, r#" /// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn as_dvec2(&self) -> bevy::math::DVec2; + fn as_dvec4(&self) -> bevy::math::DVec4; "#, r#" /// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn as_ivec2(&self) -> bevy::math::IVec2; + fn as_ivec4(&self) -> bevy::math::IVec4; "#, r#" /// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; + fn as_i64vec4(&self) -> bevy::math::I64Vec4; "#, r#" /// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; + fn as_u64vec4(&self) -> bevy::math::U64Vec4; "#, r#" @@ -8393,7 +7258,7 @@ struct I64Vec4 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" @@ -8401,7 +7266,7 @@ struct I64Vec4 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" @@ -8409,7 +7274,7 @@ struct I64Vec4 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" @@ -8417,7 +7282,7 @@ struct I64Vec4 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" @@ -8425,7 +7290,7 @@ struct I64Vec4 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn saturating_add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" @@ -8433,7 +7298,7 @@ struct I64Vec4 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" @@ -8441,7 +7306,7 @@ struct I64Vec4 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" @@ -8449,118 +7314,109 @@ struct I64Vec4 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn saturating_div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" +/// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u32) -> bevy::math::UVec2; + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_signed(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::UVec4; "#, r#" +/// Returns a vector containing the saturating addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u32) -> bevy::math::UVec2; + #[lua(kind = "Method", output(proxy))] + fn saturating_add_signed(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::UVec4; "#, 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: u32) -> bevy::math::UVec2; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + fn sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, 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::UVec2) -> bevy::math::UVec2; + fn mul(self, rhs: u32) -> bevy::math::UVec4; "#, 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::UVec2) -> bool; + 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::UVec2) -> bevy::math::UVec2; - +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} "#, r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - +#[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: u32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +struct UVec4 { + x: u32, + y: u32, + z: u32, + w: u32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::U64Vec2", + 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::UVec2; + fn eq(&self, #[proxy] other: &glam::U64Vec2) -> 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, rhs: u32) -> bevy::math::UVec2; + fn clone(&self) -> bevy::math::U64Vec2; "#, r#" @@ -8572,72 +7428,27 @@ struct I64Vec4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::UVec2) -> 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; + fn mul(self, rhs: u64) -> bevy::math::U64Vec2; "#, 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: u32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -struct UVec2 { - x: u32, - y: u32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::UVec3", - functions[r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] - fn new(x: u32, y: u32, z: u32) -> bevy::math::UVec3; + 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: u32) -> bevy::math::UVec3; + fn splat(v: u64) -> bevy::math::U64Vec2; "#, r#" @@ -8649,62 +7460,61 @@ struct UVec2 { #[lua(kind = "Function", output(proxy))] fn select( #[proxy] - mask: bevy::math::BVec3, + mask: bevy::math::BVec2, #[proxy] - if_true: bevy::math::UVec3, + if_true: bevy::math::U64Vec2, #[proxy] - if_false: bevy::math::UVec3, - ) -> bevy::math::UVec3; + if_false: bevy::math::U64Vec2, + ) -> bevy::math::U64Vec2; "#, r#" /// Creates a new vector from an array. #[lua(kind = "Function", output(proxy))] - fn from_array(a: [u32; 3]) -> bevy::math::UVec3; + fn from_array(a: [u64; 2]) -> bevy::math::U64Vec2; "#, r#" -/// `[x, y, z]` +/// `[x, y]` #[lua(kind = "Method")] - fn to_array(&self) -> [u32; 3]; + fn to_array(&self) -> [u64; 2]; "#, r#" -/// Creates a 4D vector from `self` and the given `w` value. +/// Creates a 3D vector from `self` and the given `z` value. #[lua(kind = "Method", output(proxy))] - fn extend(self, w: u32) -> bevy::math::UVec4; + fn extend(self, z: u64) -> bevy::math::U64Vec3; "#, 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 `self` with the given value of `x`. #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::UVec2; + fn with_x(self, x: u64) -> bevy::math::U64Vec2; "#, r#" -/// Computes the dot product of `self` and `rhs`. +/// Creates a 2D vector from `self` with the given value of `y`. - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::UVec3) -> u32; + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: u64) -> bevy::math::U64Vec2; "#, r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. +/// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::U64Vec2) -> u64; "#, r#" -/// Computes the cross product of `self` and `rhs`. +/// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -8712,7 +7522,7 @@ struct UVec2 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn min(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -8720,11 +7530,11 @@ struct UVec2 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn max(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" -/// Component-wise clamping of values, similar to [`u32::clamp`]. +/// Component-wise clamping of values, similar to [`u64::clamp`]. /// Each element in `min` must be less-or-equal to the corresponding element in `max`. /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. @@ -8733,10 +7543,10 @@ struct UVec2 { fn clamp( self, #[proxy] - min: bevy::math::UVec3, + min: bevy::math::U64Vec2, #[proxy] - max: bevy::math::UVec3, - ) -> bevy::math::UVec3; + max: bevy::math::U64Vec2, + ) -> bevy::math::U64Vec2; "#, r#" @@ -8744,7 +7554,7 @@ struct UVec2 { /// In other words this computes `min(x, y, ..)`. #[lua(kind = "Method")] - fn min_element(self) -> u32; + fn min_element(self) -> u64; "#, r#" @@ -8752,7 +7562,23 @@ struct UVec2 { /// In other words this computes `max(x, y, ..)`. #[lua(kind = "Method")] - fn max_element(self) -> u32; + fn max_element(self) -> u64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> u64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> u64; "#, r#" @@ -8762,7 +7588,7 @@ struct UVec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; "#, r#" @@ -8772,7 +7598,7 @@ struct UVec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; "#, r#" @@ -8782,7 +7608,7 @@ struct UVec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; "#, r#" @@ -8792,7 +7618,7 @@ struct UVec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; "#, r#" @@ -8802,7 +7628,7 @@ struct UVec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + fn cmple(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; "#, r#" @@ -8812,56 +7638,49 @@ struct UVec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::BVec3; + fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; "#, r#" /// Computes the squared length of `self`. #[lua(kind = "Method")] - fn length_squared(self) -> u32; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec3(&self) -> bevy::math::Vec3; + fn length_squared(self) -> u64; "#, r#" /// Casts all elements of `self` to `f32`. #[lua(kind = "Method", output(proxy))] - fn as_vec3a(&self) -> bevy::math::Vec3A; + fn as_vec2(&self) -> bevy::math::Vec2; "#, r#" /// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; + fn as_dvec2(&self) -> bevy::math::DVec2; "#, r#" /// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; + fn as_ivec2(&self) -> bevy::math::IVec2; "#, r#" -/// Casts all elements of `self` to `i64`. +/// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; + fn as_uvec2(&self) -> bevy::math::UVec2; "#, r#" -/// Casts all elements of `self` to `u64`. +/// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; + fn as_i64vec2(&self) -> bevy::math::I64Vec2; "#, r#" @@ -8869,7 +7688,7 @@ struct UVec2 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -8877,7 +7696,7 @@ struct UVec2 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -8885,7 +7704,7 @@ struct UVec2 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -8893,7 +7712,7 @@ struct UVec2 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -8901,7 +7720,7 @@ struct UVec2 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -8909,7 +7728,7 @@ struct UVec2 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -8917,7 +7736,7 @@ struct UVec2 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -8925,72 +7744,103 @@ struct UVec2 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" +/// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u32) -> bevy::math::UVec3; + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_signed( + self, + #[proxy] + rhs: bevy::math::I64Vec2, + ) -> bevy::math::U64Vec2; "#, r#" +/// Returns a vector containing the saturating addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::UVec3) -> bool; + #[lua(kind = "Method", output(proxy))] + fn saturating_add_signed( + self, + #[proxy] + rhs: bevy::math::I64Vec2, + ) -> bevy::math::U64Vec2; "#, 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: u32) -> bevy::math::UVec3; + fn add(self, #[proxy] rhs: bevy::math::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::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u64) -> bevy::math::U64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "sub", + composite = "rem", + metamethod = "Mod", + )] + fn rem(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, 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: bevy::math::UVec3) -> bevy::math::UVec3; + fn sub(self, rhs: u64) -> bevy::math::U64Vec2; "#, 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: u32) -> bevy::math::UVec3; + fn sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -9002,7 +7852,7 @@ struct UVec2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -9014,19 +7864,56 @@ struct UVec2 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: u32) -> bevy::math::UVec3; + fn div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; "#, 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, 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#" @@ -9038,60 +7925,46 @@ struct UVec2 { composite = "rem", metamethod = "Mod", )] - fn rem(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn rem(self, rhs: u64) -> bevy::math::U64Vec3; "#, 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: u32) -> bevy::math::UVec3; + fn mul(self, rhs: u64) -> bevy::math::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::UVec3; + fn rem(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, 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]) -} + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u64) -> bevy::math::U64Vec3; + "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -struct UVec3 { - x: u32, - y: u32, - z: u32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::UVec4", - functions[r#" #[lua( as_trait = "std::ops::Div", @@ -9100,21 +7973,45 @@ struct UVec3 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: u32) -> bevy::math::UVec4; + 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: u32, y: u32, z: u32, w: u32) -> bevy::math::UVec4; + 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: u32) -> bevy::math::UVec4; + fn splat(v: u64) -> bevy::math::U64Vec3; "#, r#" @@ -9126,48 +8023,83 @@ struct UVec3 { #[lua(kind = "Function", output(proxy))] fn select( #[proxy] - mask: bevy::math::BVec4, + mask: bevy::math::BVec3, #[proxy] - if_true: bevy::math::UVec4, + if_true: bevy::math::U64Vec3, #[proxy] - if_false: bevy::math::UVec4, - ) -> bevy::math::UVec4; + 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: [u32; 4]) -> bevy::math::UVec4; + fn from_array(a: [u64; 3]) -> bevy::math::U64Vec3; "#, r#" -/// `[x, y, z, w]` +/// `[x, y, z]` #[lua(kind = "Method")] - fn to_array(&self) -> [u32; 4]; + fn to_array(&self) -> [u64; 3]; "#, r#" -/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. -/// Truncation to [`UVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. +/// Creates a 4D vector from `self` and the given `w` value. #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::UVec3; + 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()]. + + #[lua(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::U64Vec2; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `x`. + + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: u64) -> bevy::math::U64Vec3; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `y`. + + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: u64) -> bevy::math::U64Vec3; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `z`. + + #[lua(kind = "Method", output(proxy))] + fn with_z(self, z: u64) -> bevy::math::U64Vec3; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::UVec4) -> u32; + fn dot(self, #[proxy] rhs: bevy::math::U64Vec3) -> u64; "#, 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::UVec4) -> bevy::math::UVec4; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn cross(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -9175,7 +8107,7 @@ struct UVec3 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn min(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -9183,11 +8115,11 @@ struct UVec3 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn max(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" -/// Component-wise clamping of values, similar to [`u32::clamp`]. +/// Component-wise clamping of values, similar to [`u64::clamp`]. /// Each element in `min` must be less-or-equal to the corresponding element in `max`. /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. @@ -9196,10 +8128,10 @@ struct UVec3 { fn clamp( self, #[proxy] - min: bevy::math::UVec4, + min: bevy::math::U64Vec3, #[proxy] - max: bevy::math::UVec4, - ) -> bevy::math::UVec4; + max: bevy::math::U64Vec3, + ) -> bevy::math::U64Vec3; "#, r#" @@ -9207,7 +8139,7 @@ struct UVec3 { /// In other words this computes `min(x, y, ..)`. #[lua(kind = "Method")] - fn min_element(self) -> u32; + fn min_element(self) -> u64; "#, r#" @@ -9215,7 +8147,23 @@ struct UVec3 { /// In other words this computes `max(x, y, ..)`. #[lua(kind = "Method")] - fn max_element(self) -> u32; + fn max_element(self) -> u64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> u64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> u64; "#, r#" @@ -9225,7 +8173,7 @@ struct UVec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; "#, r#" @@ -9235,7 +8183,7 @@ struct UVec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; "#, r#" @@ -9245,7 +8193,7 @@ struct UVec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; "#, r#" @@ -9255,7 +8203,7 @@ struct UVec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; "#, r#" @@ -9265,7 +8213,7 @@ struct UVec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + fn cmple(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; "#, r#" @@ -9275,49 +8223,56 @@ struct UVec3 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::BVec4; + fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; "#, r#" /// Computes the squared length of `self`. #[lua(kind = "Method")] - fn length_squared(self) -> u32; + fn length_squared(self) -> u64; "#, r#" /// Casts all elements of `self` to `f32`. #[lua(kind = "Method", output(proxy))] - fn as_vec4(&self) -> bevy::math::Vec4; + fn as_vec3(&self) -> bevy::math::Vec3; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec3a(&self) -> bevy::math::Vec3A; "#, r#" /// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn as_dvec4(&self) -> bevy::math::DVec4; + fn as_dvec3(&self) -> bevy::math::DVec3; "#, r#" /// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn as_ivec4(&self) -> bevy::math::IVec4; + fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" -/// Casts all elements of `self` to `i64`. +/// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; + fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" -/// Casts all elements of `self` to `u64`. +/// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; + fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, r#" @@ -9325,7 +8280,7 @@ struct UVec3 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -9333,7 +8288,7 @@ struct UVec3 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -9341,7 +8296,7 @@ struct UVec3 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -9349,7 +8304,7 @@ struct UVec3 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -9357,7 +8312,7 @@ struct UVec3 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -9365,7 +8320,7 @@ struct UVec3 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -9373,7 +8328,7 @@ struct UVec3 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -9381,7 +8336,31 @@ struct UVec3 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_signed( + self, + #[proxy] + rhs: bevy::math::I64Vec3, + ) -> bevy::math::U64Vec3; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add_signed( + self, + #[proxy] + rhs: bevy::math::I64Vec3, + ) -> bevy::math::U64Vec3; "#, r#" @@ -9392,19 +8371,13 @@ struct UVec3 { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &glam::UVec4) -> bool; + 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, rhs: u32) -> bevy::math::UVec4; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -9416,41 +8389,59 @@ struct UVec3 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn add(self, rhs: u64) -> bevy::math::U64Vec3; "#, 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::UVec4) -> bevy::math::UVec4; + fn sub(self, #[proxy] rhs: bevy::math::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 = "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::UVec4; + fn rem(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn sub(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" @@ -9462,303 +8453,124 @@ struct UVec3 { composite = "sub", metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, 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::UVec4; + fn div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::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, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn clone(&self) -> bevy::math::U64Vec4; "#, r#" +/// Creates a new vector. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Function", output(proxy))] + fn new(x: u64, y: u64, z: u64, w: u64) -> bevy::math::U64Vec4; "#, r#" +/// Creates a vector with all elements set to `v`. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u32) -> bevy::math::UVec4; + #[lua(kind = "Function", output(proxy))] + fn splat(v: u64) -> bevy::math::U64Vec4; "#, 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, rhs: u32) -> bevy::math::UVec4; + #[lua(kind = "Function", output(proxy))] + fn select( + #[proxy] + mask: bevy::math::BVec4, + #[proxy] + if_true: bevy::math::U64Vec4, + #[proxy] + if_false: bevy::math::U64Vec4, + ) -> bevy::math::U64Vec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [u64; 4]) -> bevy::math::U64Vec4; + "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} +/// `[x, y, z, w]` + + #[lua(kind = "Method")] + fn to_array(&self) -> [u64; 4]; + "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: u32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -struct UVec4 { - x: u32, - y: u32, - z: u32, - w: u32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::U64Vec2", - functions[r#" +/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. +/// Truncation to [`U64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u64) -> bevy::math::U64Vec2; + #[lua(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::U64Vec3; "#, r#" +/// Creates a 4D vector from `self` with the given value of `x`. - #[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 = "Method", output(proxy))] + fn with_x(self, x: u64) -> bevy::math::U64Vec4; "#, r#" +/// Creates a 4D vector from `self` with the given value of `y`. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec2; + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: u64) -> bevy::math::U64Vec4; "#, r#" +/// Creates a 4D vector from `self` with the given value of `z`. - #[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 = "Method", output(proxy))] + fn with_z(self, z: u64) -> bevy::math::U64Vec4; "#, r#" +/// Creates a 4D vector from `self` with the given value of `w`. - #[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; + #[lua(kind = "Method", output(proxy))] + fn with_w(self, w: u64) -> bevy::math::U64Vec4; "#, 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::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::U64Vec2) -> bool; - -"#, - 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::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::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - 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, rhs: u64) -> 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 -/// uses the element from `if_false`. - - #[lua(kind = "Function", output(proxy))] - fn select( - #[proxy] - mask: bevy::math::BVec2, - #[proxy] - if_true: bevy::math::U64Vec2, - #[proxy] - if_false: bevy::math::U64Vec2, - ) -> bevy::math::U64Vec2; - -"#, - r#" -/// Creates a new vector from an array. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [u64; 2]) -> bevy::math::U64Vec2; - -"#, - r#" -/// `[x, y]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [u64; 2]; - -"#, - r#" -/// Creates a 3D vector from `self` and the given `z` value. - - #[lua(kind = "Method", output(proxy))] - fn extend(self, z: u64) -> bevy::math::U64Vec3; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. +/// Computes the dot product of `self` and `rhs`. #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::U64Vec2) -> u64; + fn dot(self, #[proxy] rhs: bevy::math::U64Vec4) -> u64; "#, 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::U64Vec2) -> bevy::math::U64Vec2; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -9766,7 +8578,7 @@ struct UVec4 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn min(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -9774,7 +8586,7 @@ struct UVec4 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn max(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -9787,10 +8599,10 @@ struct UVec4 { fn clamp( self, #[proxy] - min: bevy::math::U64Vec2, + min: bevy::math::U64Vec4, #[proxy] - max: bevy::math::U64Vec2, - ) -> bevy::math::U64Vec2; + max: bevy::math::U64Vec4, + ) -> bevy::math::U64Vec4; "#, r#" @@ -9808,6 +8620,22 @@ struct UVec4 { #[lua(kind = "Method")] fn max_element(self) -> u64; +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> u64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> u64; + "#, r#" /// Returns a vector mask containing the result of a `==` comparison for each element of @@ -9816,7 +8644,7 @@ struct UVec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; "#, r#" @@ -9826,7 +8654,7 @@ struct UVec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; "#, r#" @@ -9836,7 +8664,7 @@ struct UVec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; "#, r#" @@ -9846,7 +8674,7 @@ struct UVec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; "#, r#" @@ -9856,7 +8684,7 @@ struct UVec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + fn cmple(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; "#, r#" @@ -9866,7 +8694,7 @@ struct UVec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::BVec2; + fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; "#, r#" @@ -9880,35 +8708,35 @@ struct UVec4 { /// Casts all elements of `self` to `f32`. #[lua(kind = "Method", output(proxy))] - fn as_vec2(&self) -> bevy::math::Vec2; + fn as_vec4(&self) -> bevy::math::Vec4; "#, r#" /// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn as_dvec2(&self) -> bevy::math::DVec2; + fn as_dvec4(&self) -> bevy::math::DVec4; "#, r#" /// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn as_ivec2(&self) -> bevy::math::IVec2; + fn as_ivec4(&self) -> bevy::math::IVec4; "#, r#" /// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn as_uvec2(&self) -> bevy::math::UVec2; + fn as_uvec4(&self) -> bevy::math::UVec4; "#, r#" /// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; + fn as_i64vec4(&self) -> bevy::math::I64Vec4; "#, r#" @@ -9916,7 +8744,7 @@ struct UVec4 { /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -9924,7 +8752,7 @@ struct UVec4 { /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -9932,7 +8760,7 @@ struct UVec4 { /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -9940,7 +8768,7 @@ struct UVec4 { /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -9948,7 +8776,7 @@ struct UVec4 { /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -9956,7 +8784,7 @@ struct UVec4 { /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -9964,7 +8792,7 @@ struct UVec4 { /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -9972,103 +8800,275 @@ struct UVec4 { /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec2) -> 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#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: u64, y: u64, z: u64) -> bevy::math::U64Vec3; + fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" -/// Creates a vector with all elements set to `v`. +/// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`. - #[lua(kind = "Function", output(proxy))] - fn splat(v: u64) -> bevy::math::U64Vec3; + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_signed( + self, + #[proxy] + rhs: bevy::math::I64Vec4, + ) -> bevy::math::U64Vec4; "#, 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`. +/// Returns a vector containing the saturating addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`. - #[lua(kind = "Function", output(proxy))] - fn select( - #[proxy] - mask: bevy::math::BVec3, - #[proxy] - if_true: bevy::math::U64Vec3, + #[lua(kind = "Method", output(proxy))] + fn saturating_add_signed( + self, #[proxy] - if_false: bevy::math::U64Vec3, - ) -> bevy::math::U64Vec3; + rhs: bevy::math::I64Vec4, + ) -> bevy::math::U64Vec4; "#, r#" -/// Creates a new vector from an array. - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [u64; 3]) -> bevy::math::U64Vec3; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::U64Vec4) -> bool; "#, r#" -/// `[x, y, z]` - #[lua(kind = "Method")] - fn to_array(&self) -> [u64; 3]; - -"#, + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u64) -> bevy::math::U64Vec4; + +"#, 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; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: 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()]. - #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::U64Vec2; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" -/// Computes the dot product of `self` and `rhs`. + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + 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", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(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#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +struct U64Vec4 { + x: u64, + y: u64, + z: u64, + w: u64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Vec2", + functions[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::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Vec2; + +"#, + r#" +/// Creates a new vector. + + #[lua(kind = "Function", output(proxy))] + fn new(x: f32, y: f32) -> bevy::math::Vec2; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua(kind = "Function", output(proxy))] + fn splat(v: f32) -> bevy::math::Vec2; + +"#, + 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::BVec2, + #[proxy] + if_true: bevy::math::Vec2, + #[proxy] + if_false: bevy::math::Vec2, + ) -> bevy::math::Vec2; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f32; 2]) -> bevy::math::Vec2; + +"#, + r#" +/// `[x, y]` #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::U64Vec3) -> u64; + fn to_array(&self) -> [f32; 2]; "#, r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. +/// Creates a 3D vector from `self` and the given `z` value. #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn extend(self, z: f32) -> bevy::math::Vec3; "#, r#" -/// Computes the cross product of `self` and `rhs`. +/// Creates a 2D vector from `self` with the given value of `x`. #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn with_x(self, x: f32) -> bevy::math::Vec2; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `y`. + + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: f32) -> bevy::math::Vec2; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::Vec2) -> 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::Vec2) -> bevy::math::Vec2; "#, r#" @@ -10076,7 +9076,7 @@ struct U64Vec2 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn min(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" @@ -10084,11 +9084,11 @@ struct U64Vec2 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn max(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" -/// Component-wise clamping of values, similar to [`u64::clamp`]. +/// Component-wise clamping of values, similar to [`f32::clamp`]. /// Each element in `min` must be less-or-equal to the corresponding element in `max`. /// # Panics /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. @@ -10097,10 +9097,10 @@ struct U64Vec2 { fn clamp( self, #[proxy] - min: bevy::math::U64Vec3, + min: bevy::math::Vec2, #[proxy] - max: bevy::math::U64Vec3, - ) -> bevy::math::U64Vec3; + max: bevy::math::Vec2, + ) -> bevy::math::Vec2; "#, r#" @@ -10108,7 +9108,7 @@ struct U64Vec2 { /// In other words this computes `min(x, y, ..)`. #[lua(kind = "Method")] - fn min_element(self) -> u64; + fn min_element(self) -> f32; "#, r#" @@ -10116,7 +9116,23 @@ struct U64Vec2 { /// In other words this computes `max(x, y, ..)`. #[lua(kind = "Method")] - fn max_element(self) -> u64; + fn max_element(self) -> f32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> f32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> f32; "#, r#" @@ -10126,7 +9142,7 @@ struct U64Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + fn cmpeq(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; "#, r#" @@ -10136,7 +9152,7 @@ struct U64Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + fn cmpne(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; "#, r#" @@ -10146,7 +9162,7 @@ struct U64Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + fn cmpge(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; "#, r#" @@ -10156,7 +9172,7 @@ struct U64Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + fn cmpgt(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; "#, r#" @@ -10166,7 +9182,7 @@ struct U64Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + fn cmple(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; "#, r#" @@ -10176,676 +9192,477 @@ struct U64Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::BVec3; + fn cmplt(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; "#, r#" -/// Computes the squared length of `self`. +/// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method")] - fn length_squared(self) -> u64; + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::Vec2; "#, r#" -/// Casts all elements of `self` to `f32`. +/// Returns a vector with elements representing the sign of `self`. +/// - `1.0` if the number is positive, `+0.0` or `INFINITY` +/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` +/// - `NAN` if the number is `NAN` #[lua(kind = "Method", output(proxy))] - fn as_vec3(&self) -> bevy::math::Vec3; + fn signum(self) -> bevy::math::Vec2; "#, r#" -/// Casts all elements of `self` to `f32`. +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. #[lua(kind = "Method", output(proxy))] - fn as_vec3a(&self) -> bevy::math::Vec3A; + fn copysign(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" -/// Casts all elements of `self` to `f64`. +/// Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. +/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes +/// into the first lowest bit, element `y` into the second, etc. - #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; + #[lua(kind = "Method")] + fn is_negative_bitmask(self) -> u32; "#, r#" -/// Casts all elements of `self` to `i32`. +/// Returns `true` if, and only if, all elements are finite. If any element is either +/// `NaN`, positive or negative infinity, this will return `false`. - #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; + #[lua(kind = "Method")] + fn is_finite(self) -> bool; "#, r#" -/// Casts all elements of `self` to `u32`. +/// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; + #[lua(kind = "Method")] + fn is_nan(self) -> bool; "#, r#" -/// Casts all elements of `self` to `i64`. +/// 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()]`. #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; + fn is_nan_mask(self) -> bevy::math::BVec2; "#, r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. +/// Computes the length of `self`. - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + #[lua(kind = "Method")] + fn length(self) -> f32; "#, r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + #[lua(kind = "Method")] + fn length_squared(self) -> f32; "#, r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + #[lua(kind = "Method")] + fn length_recip(self) -> f32; "#, r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. +/// Computes the Euclidean distance between two points in space. - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + #[lua(kind = "Method")] + fn distance(self, #[proxy] rhs: bevy::math::Vec2) -> f32; "#, r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. +/// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::Vec2) -> f32; "#, r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn div_euclid(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f32::rem_euclid #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must _not_ be 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. #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn normalize(self) -> bevy::math::Vec2; "#, r#" +/// Returns `self` normalized to length 1.0 if possible, else returns a +/// fallback value. +/// In particular, if the input is zero (or very close to zero), or non-finite, +/// the result of this operation will be the fallback value. +/// See also [`Self::try_normalize()`]. - #[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; + #[lua(kind = "Method", output(proxy))] + fn normalize_or(self, #[proxy] fallback: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" +/// Returns `self` normalized to length 1.0 if possible, else returns zero. +/// In particular, if the input is zero (or very close to zero), or non-finite, +/// the result of this operation will be zero. +/// See also [`Self::try_normalize()`]. - #[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; + #[lua(kind = "Method", output(proxy))] + fn normalize_or_zero(self) -> bevy::math::Vec2; "#, r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. - #[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; + #[lua(kind = "Method")] + fn is_normalized(self) -> bool; "#, r#" +/// Returns the vector projection of `self` onto `rhs`. +/// `rhs` must be of non-zero length. +/// # Panics +/// Will panic if `rhs` is zero length when `glam_assert` is enabled. - #[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; + #[lua(kind = "Method", output(proxy))] + fn project_onto(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" +/// Returns the vector rejection of `self` from `rhs`. +/// The vector rejection is the vector perpendicular to the projection of `self` onto +/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. +/// `rhs` must be of non-zero length. +/// # Panics +/// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u64) -> bevy::math::U64Vec3; + #[lua(kind = "Method", output(proxy))] + fn reject_from(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" +/// Returns the vector projection of `self` onto `rhs`. +/// `rhs` must be normalized. +/// # Panics +/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec3; + #[lua(kind = "Method", output(proxy))] + fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" +/// Returns the vector rejection of `self` from `rhs`. +/// The vector rejection is the vector perpendicular to the projection of `self` onto +/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. +/// `rhs` must be normalized. +/// # Panics +/// Will panic if `rhs` 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, rhs: u64) -> bevy::math::U64Vec3; + #[lua(kind = "Method", output(proxy))] + fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" +/// Returns a vector containing the nearest integer to a number for each element of `self`. +/// Round half-way cases away from 0.0. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u64) -> bevy::math::U64Vec3; + #[lua(kind = "Method", output(proxy))] + fn round(self) -> bevy::math::Vec2; "#, r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method", output(proxy))] + fn floor(self) -> bevy::math::Vec2; "#, r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u64) -> bevy::math::U64Vec3; + #[lua(kind = "Method", output(proxy))] + fn ceil(self) -> bevy::math::Vec2; "#, r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::U64Vec3; + #[lua(kind = "Method", output(proxy))] + fn trunc(self) -> bevy::math::Vec2; "#, r#" +/// Returns a vector containing the fractional part of the vector as `self - self.trunc()`. +/// Note that this differs from the GLSL implementation of `fract` which returns +/// `self - self.floor()`. +/// Note that this is fast but not precise for large numbers. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::U64Vec3) -> bool; + #[lua(kind = "Method", output(proxy))] + fn fract(self) -> bevy::math::Vec2; "#, r#" +/// Returns a vector containing the fractional part of the vector as `self - self.floor()`. +/// Note that this differs from the Rust implementation of `fract` which returns +/// `self - self.trunc()`. +/// Note that this is fast but not precise for large numbers. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + #[lua(kind = "Method", output(proxy))] + fn fract_gl(self) -> bevy::math::Vec2; "#, 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#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::U64Vec4; + #[lua(kind = "Method", output(proxy))] + fn exp(self) -> bevy::math::Vec2; "#, r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + #[lua(kind = "Method", output(proxy))] + fn powf(self, n: f32) -> bevy::math::Vec2; "#, r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: u64) -> bevy::math::U64Vec4; + #[lua(kind = "Method", output(proxy))] + fn recip(self) -> bevy::math::Vec2; "#, r#" +/// Performs a linear interpolation between `self` and `rhs` based on the value `s`. +/// When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result +/// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly +/// extrapolated. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec4; + #[lua(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] rhs: bevy::math::Vec2, s: f32) -> bevy::math::Vec2; "#, r#" +/// Moves towards `rhs` based on the value `d`. +/// When `d` is `0.0`, the result will be equal to `self`. When `d` is equal to +/// `self.distance(rhs)`, the result will be equal to `rhs`. Will not go past `rhs`. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec4; + #[lua(kind = "Method", output(proxy))] + fn move_towards(&self, #[proxy] rhs: bevy::math::Vec2, d: f32) -> bevy::math::Vec2; "#, r#" +/// Calculates the midpoint between `self` and `rhs`. +/// The midpoint is the average of, or halfway point between, two vectors. +/// `a.midpoint(b)` should yield the same result as `a.lerp(b, 0.5)` +/// while being slightly cheaper to compute. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u64) -> bevy::math::U64Vec4; + #[lua(kind = "Method", output(proxy))] + fn midpoint(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" +/// Returns true if the absolute difference of all elements between `self` and `rhs` is +/// less than or equal to `max_abs_diff`. +/// This can be used to compare if two vectors contain similar elements. It works best when +/// comparing with a known value. The `max_abs_diff` that should be used used depends on +/// the values being compared against. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[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; + #[lua(kind = "Method")] + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec2, max_abs_diff: f32) -> bool; "#, r#" +/// 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. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + #[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` - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + #[lua(kind = "Method", output(proxy))] + fn clamp_length_max(self, max: f32) -> bevy::math::Vec2; "#, r#" -/// Creates a new vector. +/// Returns a vector with a length no less than `min` - #[lua(kind = "Function", output(proxy))] - fn new(x: u64, y: u64, z: u64, w: u64) -> bevy::math::U64Vec4; + #[lua(kind = "Method", output(proxy))] + fn clamp_length_min(self, min: f32) -> bevy::math::Vec2; "#, r#" -/// Creates a vector with all elements set to `v`. +/// Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding +/// error, yielding a more accurate result than an unfused multiply-add. +/// Using `mul_add` *may* be more performant than an unfused multiply-add if the target +/// architecture has a dedicated fma CPU instruction. However, this is not always true, +/// and will be heavily dependant on designing algorithms with specific target hardware in +/// mind. - #[lua(kind = "Function", output(proxy))] - fn splat(v: u64) -> bevy::math::U64Vec4; + #[lua(kind = "Method", output(proxy))] + fn mul_add( + self, + #[proxy] + a: bevy::math::Vec2, + #[proxy] + b: bevy::math::Vec2, + ) -> bevy::math::Vec2; "#, 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`. +/// Creates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in +/// conjunction with the [`rotate()`][Self::rotate()] method, e.g. +/// `Vec2::from_angle(PI).rotate(Vec2::Y)` will create the vector `[-1, 0]` +/// and rotate [`Vec2::Y`] around it returning `-Vec2::Y`. #[lua(kind = "Function", output(proxy))] - fn select( - #[proxy] - mask: bevy::math::BVec4, - #[proxy] - if_true: bevy::math::U64Vec4, - #[proxy] - if_false: bevy::math::U64Vec4, - ) -> bevy::math::U64Vec4; + fn from_angle(angle: f32) -> bevy::math::Vec2; "#, r#" -/// Creates a new vector from an array. +/// Returns the angle (in radians) of this vector in the range `[-π, +π]`. +/// The input does not need to be a unit vector however it must be non-zero. - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [u64; 4]) -> bevy::math::U64Vec4; + #[lua(kind = "Method")] + fn to_angle(self) -> f32; "#, r#" -/// `[x, y, z, w]` +/// 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 to_array(&self) -> [u64; 4]; + fn angle_between(self, #[proxy] rhs: bevy::math::Vec2) -> f32; "#, r#" -/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. -/// Truncation to [`U64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. +/// Returns a vector that is equal to `self` rotated by 90 degrees. #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::U64Vec3; + fn perp(self) -> bevy::math::Vec2; "#, r#" -/// Computes the dot product of `self` and `rhs`. +/// The perpendicular dot product of `self` and `rhs`. +/// Also known as the wedge product, 2D cross product, and determinant. #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::U64Vec4) -> u64; + fn perp_dot(self, #[proxy] rhs: bevy::math::Vec2) -> f32; "#, r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. +/// Returns `rhs` rotated by the angle of `self`. If `self` is normalized, +/// then this just rotation. This is what you usually want. Otherwise, +/// it will be like a rotation with a multiplication by `self`'s length. #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn rotate(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" -/// Returns a vector containing the minimum values for each element of `self` and `rhs`. -/// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. +/// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn as_dvec2(&self) -> bevy::math::DVec2; "#, r#" -/// Returns a vector containing the maximum values for each element of `self` and `rhs`. -/// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. +/// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn as_ivec2(&self) -> bevy::math::IVec2; "#, r#" -/// Component-wise clamping of values, similar to [`u64::clamp`]. -/// Each element in `min` must be less-or-equal to the corresponding element in `max`. -/// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::U64Vec4, - #[proxy] - max: bevy::math::U64Vec4, - ) -> bevy::math::U64Vec4; + fn as_uvec2(&self) -> bevy::math::UVec2; "#, r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. +/// Casts all elements of `self` to `i64`. - #[lua(kind = "Method")] - fn min_element(self) -> u64; + #[lua(kind = "Method", output(proxy))] + fn as_i64vec2(&self) -> bevy::math::I64Vec2; "#, r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. +/// Casts all elements of `self` to `u64`. - #[lua(kind = "Method")] - fn max_element(self) -> u64; + #[lua(kind = "Method", output(proxy))] + fn as_u64vec2(&self) -> bevy::math::U64Vec2; "#, r#" -/// Returns a vector mask containing the result of a `==` comparison for each element of -/// `self` and `rhs`. -/// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all -/// elements. - #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec2; "#, r#" -/// Returns a vector mask containing the result of a `!=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all -/// elements. - #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" -/// Returns a vector mask containing the result of a `>=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all -/// elements. - - #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; - -"#, - r#" -/// Returns a vector mask containing the result of a `>` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all -/// elements. - - #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; - -"#, - r#" -/// Returns a vector mask containing the result of a `<=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all -/// elements. - - #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; - -"#, - r#" -/// Returns a vector mask containing the result of a `<` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all -/// elements. - - #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::BVec4; - -"#, - r#" -/// Computes the squared length of `self`. - - #[lua(kind = "Method")] - fn length_squared(self) -> u64; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec4(&self) -> bevy::math::Vec4; - -"#, - r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec4(&self) -> bevy::math::DVec4; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec4(&self) -> bevy::math::IVec4; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec4(&self) -> bevy::math::UVec4; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping addition of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; - -"#, - r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - - #[lua(kind = "Method", output(proxy))] - fn saturating_div(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) -> (); + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" @@ -10856,7 +9673,7 @@ struct U64Vec3 { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &glam::U64Vec4) -> bool; + fn eq(&self, #[proxy] other: &glam::Vec2) -> bool; "#, r#" @@ -10868,47 +9685,19 @@ struct U64Vec3 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn div(self, rhs: f32) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u64) -> bevy::math::U64Vec4; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct U64Vec4 { - x: u64, - y: u64, - z: u64, - w: u64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Vec2", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + composite = "neg", + metamethod = "Unm", )] - fn eq(&self, #[proxy] other: &glam::Vec2) -> bool; + fn neg(self) -> bevy::math::Vec2; "#, r#" @@ -10926,35 +9715,64 @@ struct U64Vec4 { 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: f32) -> bevy::math::Vec2; + fn sub(self, rhs: f32) -> bevy::math::Vec2; "#, 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 Vec2 { + x: f32, + y: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Vec3A", + functions[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::Vec2; + fn add(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::Vec2) -> bevy::math::Vec2; + fn sub(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" @@ -10966,19 +9784,19 @@ struct U64Vec4 { composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: f32) -> bevy::math::Vec2; + fn sub(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, 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, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn neg(self) -> bevy::math::Vec3A; "#, r#" @@ -10990,81 +9808,57 @@ struct U64Vec4 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn div(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Vec2; - -"#, - 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::Vec2) -> bevy::math::Vec2; + fn add(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, 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::Vec2; + fn mul(self, rhs: f32) -> bevy::math::Vec3A; "#, 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: f32) -> bevy::math::Vec2; + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] - fn new(x: f32, y: f32) -> bevy::math::Vec2; + fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3A; "#, r#" /// Creates a vector with all elements set to `v`. #[lua(kind = "Function", output(proxy))] - fn splat(v: f32) -> bevy::math::Vec2; + fn splat(v: f32) -> bevy::math::Vec3A; "#, r#" @@ -11076,47 +9870,83 @@ struct U64Vec4 { #[lua(kind = "Function", output(proxy))] fn select( #[proxy] - mask: bevy::math::BVec2, + mask: bevy::math::BVec3A, #[proxy] - if_true: bevy::math::Vec2, + if_true: bevy::math::Vec3A, #[proxy] - if_false: bevy::math::Vec2, - ) -> bevy::math::Vec2; + if_false: bevy::math::Vec3A, + ) -> bevy::math::Vec3A; "#, r#" /// Creates a new vector from an array. #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f32; 2]) -> bevy::math::Vec2; + fn from_array(a: [f32; 3]) -> bevy::math::Vec3A; "#, r#" -/// `[x, y]` +/// `[x, y, z]` #[lua(kind = "Method")] - fn to_array(&self) -> [f32; 2]; + fn to_array(&self) -> [f32; 3]; "#, r#" -/// Creates a 3D vector from `self` and the given `z` value. +/// Creates a 4D vector from `self` and the given `w` value. #[lua(kind = "Method", output(proxy))] - fn extend(self, z: f32) -> bevy::math::Vec3; + fn extend(self, w: f32) -> bevy::math::Vec4; + +"#, + 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()]. + + #[lua(kind = "Method", output(proxy))] + fn truncate(self) -> bevy::math::Vec2; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `x`. + + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: f32) -> bevy::math::Vec3A; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `y`. + + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: f32) -> bevy::math::Vec3A; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `z`. + + #[lua(kind = "Method", output(proxy))] + fn with_z(self, z: f32) -> bevy::math::Vec3A; "#, r#" /// Computes the dot product of `self` and `rhs`. #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + fn dot(self, #[proxy] rhs: bevy::math::Vec3A) -> 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::Vec2) -> bevy::math::Vec2; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn cross(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -11124,7 +9954,7 @@ struct U64Vec4 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn min(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -11132,7 +9962,7 @@ struct U64Vec4 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn max(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -11145,10 +9975,10 @@ struct U64Vec4 { fn clamp( self, #[proxy] - min: bevy::math::Vec2, + min: bevy::math::Vec3A, #[proxy] - max: bevy::math::Vec2, - ) -> bevy::math::Vec2; + max: bevy::math::Vec3A, + ) -> bevy::math::Vec3A; "#, r#" @@ -11166,6 +9996,22 @@ struct U64Vec4 { #[lua(kind = "Method")] fn max_element(self) -> f32; +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> f32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> f32; + "#, r#" /// Returns a vector mask containing the result of a `==` comparison for each element of @@ -11174,7 +10020,7 @@ struct U64Vec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + fn cmpeq(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; "#, r#" @@ -11184,7 +10030,7 @@ struct U64Vec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + fn cmpne(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; "#, r#" @@ -11194,7 +10040,7 @@ struct U64Vec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + fn cmpge(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; "#, r#" @@ -11204,7 +10050,7 @@ struct U64Vec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + fn cmpgt(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; "#, r#" @@ -11214,7 +10060,7 @@ struct U64Vec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + fn cmple(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; "#, r#" @@ -11224,14 +10070,14 @@ struct U64Vec4 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::BVec2; + fn cmplt(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::Vec2; + fn abs(self) -> bevy::math::Vec3A; "#, r#" @@ -11241,18 +10087,18 @@ struct U64Vec4 { /// - `NAN` if the number is `NAN` #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::Vec2; + fn signum(self) -> bevy::math::Vec3A; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn copysign(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" -/// Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. +/// Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. /// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes /// into the first lowest bit, element `y` into the second, etc. @@ -11280,7 +10126,7 @@ struct U64Vec4 { /// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. #[lua(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec2; + fn is_nan_mask(self) -> bevy::math::BVec3A; "#, r#" @@ -11310,21 +10156,21 @@ struct U64Vec4 { /// Computes the Euclidean distance between two points in space. #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + fn distance(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + fn distance_squared(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn div_euclid(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -11332,7 +10178,7 @@ struct U64Vec4 { /// [Euclidean division]: f32::rem_euclid #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -11343,7 +10189,18 @@ struct U64Vec4 { /// Will panic if `self` is zero length when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::Vec2; + fn normalize(self) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns `self` normalized to length 1.0 if possible, else returns a +/// fallback value. +/// In particular, if the input is zero (or very close to zero), or non-finite, +/// the result of this operation will be the fallback value. +/// See also [`Self::try_normalize()`]. + + #[lua(kind = "Method", output(proxy))] + fn normalize_or(self, #[proxy] fallback: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -11353,12 +10210,12 @@ struct U64Vec4 { /// See also [`Self::try_normalize()`]. #[lua(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::Vec2; + fn normalize_or_zero(self) -> bevy::math::Vec3A; "#, r#" /// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. +/// Uses a precision threshold of approximately `1e-4`. #[lua(kind = "Method")] fn is_normalized(self) -> bool; @@ -11371,7 +10228,7 @@ struct U64Vec4 { /// Will panic if `rhs` is zero length when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn project_onto(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -11383,7 +10240,7 @@ struct U64Vec4 { /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn reject_from(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -11393,7 +10250,11 @@ struct U64Vec4 { /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn project_onto_normalized( + self, + #[proxy] + rhs: bevy::math::Vec3A, + ) -> bevy::math::Vec3A; "#, r#" @@ -11405,7 +10266,11 @@ struct U64Vec4 { /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn reject_from_normalized( + self, + #[proxy] + rhs: bevy::math::Vec3A, + ) -> bevy::math::Vec3A; "#, r#" @@ -11413,7 +10278,7 @@ struct U64Vec4 { /// Round half-way cases away from 0.0. #[lua(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::Vec2; + fn round(self) -> bevy::math::Vec3A; "#, r#" @@ -11421,7 +10286,7 @@ struct U64Vec4 { /// element of `self`. #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::Vec2; + fn floor(self) -> bevy::math::Vec3A; "#, r#" @@ -11429,7 +10294,7 @@ struct U64Vec4 { /// each element of `self`. #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::Vec2; + fn ceil(self) -> bevy::math::Vec3A; "#, r#" @@ -11437,16 +10302,27 @@ struct U64Vec4 { /// always truncated towards zero. #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::Vec2; + fn trunc(self) -> bevy::math::Vec3A; "#, r#" -/// Returns a vector containing the fractional part of the vector, e.g. `self - -/// self.floor()`. +/// Returns a vector containing the fractional part of the vector as `self - self.trunc()`. +/// Note that this differs from the GLSL implementation of `fract` which returns +/// `self - self.floor()`. /// Note that this is fast but not precise for large numbers. #[lua(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::Vec2; + fn fract(self) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns a vector containing the fractional part of the vector as `self - self.floor()`. +/// Note that this differs from the Rust implementation of `fract` which returns +/// `self - self.trunc()`. +/// Note that this is fast but not precise for large numbers. + + #[lua(kind = "Method", output(proxy))] + fn fract_gl(self) -> bevy::math::Vec3A; "#, r#" @@ -11454,21 +10330,21 @@ struct U64Vec4 { /// `self`. #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::Vec2; + fn exp(self) -> bevy::math::Vec3A; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f32) -> bevy::math::Vec2; + fn powf(self, n: f32) -> bevy::math::Vec3A; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::Vec2; + fn recip(self) -> bevy::math::Vec3A; "#, r#" @@ -11478,7 +10354,26 @@ struct U64Vec4 { /// extrapolated. #[lua(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::Vec2, s: f32) -> bevy::math::Vec2; + fn lerp(self, #[proxy] rhs: bevy::math::Vec3A, s: f32) -> bevy::math::Vec3A; + +"#, + r#" +/// Moves towards `rhs` based on the value `d`. +/// When `d` is `0.0`, the result will be equal to `self`. When `d` is equal to +/// `self.distance(rhs)`, the result will be equal to `rhs`. Will not go past `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn move_towards(&self, #[proxy] rhs: bevy::math::Vec3A, d: f32) -> bevy::math::Vec3A; + +"#, + r#" +/// Calculates the midpoint between `self` and `rhs`. +/// The midpoint is the average of, or halfway point between, two vectors. +/// `a.midpoint(b)` should yield the same result as `a.lerp(b, 0.5)` +/// while being slightly cheaper to compute. + + #[lua(kind = "Method", output(proxy))] + fn midpoint(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -11491,7 +10386,7 @@ struct U64Vec4 { /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). #[lua(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec2, max_abs_diff: f32) -> bool; + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec3A, max_abs_diff: f32) -> bool; "#, r#" @@ -11500,21 +10395,21 @@ struct U64Vec4 { /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec2; + fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3A; "#, r#" /// Returns a vector with a length no more than `max` #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f32) -> bevy::math::Vec2; + fn clamp_length_max(self, max: f32) -> bevy::math::Vec3A; "#, r#" /// Returns a vector with a length no less than `min` #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f32) -> bevy::math::Vec2; + fn clamp_length_min(self, min: f32) -> bevy::math::Vec3A; "#, r#" @@ -11529,95 +10424,130 @@ struct U64Vec4 { fn mul_add( self, #[proxy] - a: bevy::math::Vec2, + a: bevy::math::Vec3A, #[proxy] - b: bevy::math::Vec2, - ) -> bevy::math::Vec2; - -"#, - r#" -/// Creates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in -/// conjunction with the [`rotate()`][Self::rotate()] method, e.g. -/// `Vec2::from_angle(PI).rotate(Vec2::Y)` will create the vector `[-1, 0]` -/// and rotate [`Vec2::Y`] around it returning `-Vec2::Y`. - - #[lua(kind = "Function", output(proxy))] - fn from_angle(angle: f32) -> bevy::math::Vec2; + b: bevy::math::Vec3A, + ) -> bevy::math::Vec3A; "#, r#" -/// Returns the angle (in radians) of this vector in the range `[-π, +π]`. -/// The input does not need to be a unit vector however it must be non-zero. +/// Returns the angle (in radians) between two vectors. +/// The inputs do not need to be unit vectors however they must be non-zero. #[lua(kind = "Method")] - fn to_angle(self) -> f32; + fn angle_between(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; "#, 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. +/// Returns some vector that is orthogonal to the given one. +/// The input vector must be finite and non-zero. +/// The output vector is not necessarily unit length. For that use +/// [`Self::any_orthonormal_vector()`] instead. - #[lua(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + #[lua(kind = "Method", output(proxy))] + fn any_orthogonal_vector(&self) -> bevy::math::Vec3A; "#, r#" -/// Returns a vector that is equal to `self` rotated by 90 degrees. +/// Returns any unit vector that is orthogonal to the given one. +/// The input vector must be unit length. +/// # Panics +/// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn perp(self) -> bevy::math::Vec2; + fn any_orthonormal_vector(&self) -> bevy::math::Vec3A; "#, r#" -/// The perpendicular dot product of `self` and `rhs`. -/// Also known as the wedge product, 2D cross product, and determinant. +/// Casts all elements of `self` to `f64`. - #[lua(kind = "Method")] - fn perp_dot(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + #[lua(kind = "Method", output(proxy))] + fn as_dvec3(&self) -> bevy::math::DVec3; "#, r#" -/// Returns `rhs` rotated by the angle of `self`. If `self` is normalized, -/// then this just rotation. This is what you usually want. Otherwise, -/// it will be like a rotation with a multiplication by `self`'s length. +/// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn rotate(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" -/// Casts all elements of `self` to `f64`. +/// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn as_dvec2(&self) -> bevy::math::DVec2; + fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" -/// Casts all elements of `self` to `i32`. +/// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn as_ivec2(&self) -> bevy::math::IVec2; + fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, r#" -/// Casts all elements of `self` to `u32`. +/// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn as_uvec2(&self) -> bevy::math::UVec2; + fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, r#" -/// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Vec3A) -> bool; "#, r#" -/// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -11639,50 +10569,23 @@ fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Res } "#] )] -struct Vec2 { - x: f32, - y: f32, -} +struct Vec3A(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::Vec3A", + remote = "bevy::math::Vec4", functions[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::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Vec3A; - -"#, - r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] - fn new(x: f32, y: f32, z: f32) -> bevy::math::Vec3A; + 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::Vec3A; + fn splat(v: f32) -> bevy::math::Vec4; "#, r#" @@ -11694,62 +10597,77 @@ struct Vec2 { #[lua(kind = "Function", output(proxy))] fn select( #[proxy] - mask: bevy::math::BVec3A, + mask: bevy::math::BVec4A, #[proxy] - if_true: bevy::math::Vec3A, + if_true: bevy::math::Vec4, #[proxy] - if_false: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; + 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; 3]) -> bevy::math::Vec3A; + fn from_array(a: [f32; 4]) -> bevy::math::Vec4; "#, r#" -/// `[x, y, z]` +/// `[x, y, z, w]` #[lua(kind = "Method")] - fn to_array(&self) -> [f32; 3]; + fn to_array(&self) -> [f32; 4]; "#, r#" -/// Creates a 4D vector from `self` and the given `w` value. +/// 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 extend(self, w: f32) -> bevy::math::Vec4; + fn truncate(self) -> bevy::math::Vec3; "#, 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 4D vector from `self` with the given value of `x`. #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::Vec2; + fn with_x(self, x: f32) -> bevy::math::Vec4; "#, r#" -/// Computes the dot product of `self` and `rhs`. +/// Creates a 4D vector from `self` with the given value of `y`. - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; + #[lua(kind = "Method", output(proxy))] + fn with_y(self, y: f32) -> bevy::math::Vec4; "#, r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. +/// Creates a 4D vector from `self` with the given value of `z`. #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn with_z(self, z: f32) -> bevy::math::Vec4; "#, r#" -/// Computes the cross product of `self` and `rhs`. +/// Creates a 4D vector from `self` with the given value of `w`. #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + 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#" @@ -11757,7 +10675,7 @@ struct Vec2 { /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn min(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -11765,7 +10683,7 @@ struct Vec2 { /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn max(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -11778,10 +10696,10 @@ struct Vec2 { fn clamp( self, #[proxy] - min: bevy::math::Vec3A, + min: bevy::math::Vec4, #[proxy] - max: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; + max: bevy::math::Vec4, + ) -> bevy::math::Vec4; "#, r#" @@ -11799,6 +10717,22 @@ struct Vec2 { #[lua(kind = "Method")] fn max_element(self) -> f32; +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua(kind = "Method")] + fn element_sum(self) -> f32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua(kind = "Method")] + fn element_product(self) -> f32; + "#, r#" /// Returns a vector mask containing the result of a `==` comparison for each element of @@ -11807,7 +10741,7 @@ struct Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + fn cmpeq(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; "#, r#" @@ -11817,7 +10751,7 @@ struct Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + fn cmpne(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; "#, r#" @@ -11827,7 +10761,7 @@ struct Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + fn cmpge(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; "#, r#" @@ -11837,7 +10771,7 @@ struct Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + fn cmpgt(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; "#, r#" @@ -11847,7 +10781,7 @@ struct Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + fn cmple(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; "#, r#" @@ -11857,14 +10791,14 @@ struct Vec2 { /// elements. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::BVec3A; + fn cmplt(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; "#, r#" /// Returns a vector containing the absolute value of each element of `self`. #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::Vec3A; + fn abs(self) -> bevy::math::Vec4; "#, r#" @@ -11874,18 +10808,18 @@ struct Vec2 { /// - `NAN` if the number is `NAN` #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::Vec3A; + fn signum(self) -> bevy::math::Vec4; "#, r#" /// Returns a vector with signs of `rhs` and the magnitudes of `self`. #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn copysign(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" -/// Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. +/// Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. /// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes /// into the first lowest bit, element `y` into the second, etc. @@ -11913,7 +10847,7 @@ struct Vec2 { /// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. #[lua(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec3A; + fn is_nan_mask(self) -> bevy::math::BVec4A; "#, r#" @@ -11943,21 +10877,21 @@ struct Vec2 { /// Computes the Euclidean distance between two points in space. #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; + fn distance(self, #[proxy] rhs: bevy::math::Vec4) -> f32; "#, r#" /// Compute the squared euclidean distance between two points in space. #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; + fn distance_squared(self, #[proxy] rhs: bevy::math::Vec4) -> f32; "#, r#" /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn div_euclid(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -11965,7 +10899,7 @@ struct Vec2 { /// [Euclidean division]: f32::rem_euclid #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -11976,7 +10910,18 @@ struct Vec2 { /// Will panic if `self` is zero length when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::Vec3A; + fn normalize(self) -> bevy::math::Vec4; + +"#, + r#" +/// Returns `self` normalized to length 1.0 if possible, else returns a +/// fallback value. +/// In particular, if the input is zero (or very close to zero), or non-finite, +/// the result of this operation will be the fallback value. +/// See also [`Self::try_normalize()`]. + + #[lua(kind = "Method", output(proxy))] + fn normalize_or(self, #[proxy] fallback: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -11986,12 +10931,12 @@ struct Vec2 { /// See also [`Self::try_normalize()`]. #[lua(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::Vec3A; + fn normalize_or_zero(self) -> bevy::math::Vec4; "#, r#" /// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. +/// Uses a precision threshold of approximately `1e-4`. #[lua(kind = "Method")] fn is_normalized(self) -> bool; @@ -12004,7 +10949,7 @@ struct Vec2 { /// Will panic if `rhs` is zero length when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn project_onto(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -12016,7 +10961,7 @@ struct Vec2 { /// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn reject_from(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -12026,11 +10971,7 @@ struct Vec2 { /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn project_onto_normalized( - self, - #[proxy] - rhs: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; + fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -12042,11 +10983,7 @@ struct Vec2 { /// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn reject_from_normalized( - self, - #[proxy] - rhs: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; + fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -12054,7 +10991,7 @@ struct Vec2 { /// Round half-way cases away from 0.0. #[lua(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::Vec3A; + fn round(self) -> bevy::math::Vec4; "#, r#" @@ -12062,7 +10999,7 @@ struct Vec2 { /// element of `self`. #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::Vec3A; + fn floor(self) -> bevy::math::Vec4; "#, r#" @@ -12070,7 +11007,7 @@ struct Vec2 { /// each element of `self`. #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::Vec3A; + fn ceil(self) -> bevy::math::Vec4; "#, r#" @@ -12078,38 +11015,49 @@ struct Vec2 { /// always truncated towards zero. #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::Vec3A; + fn trunc(self) -> bevy::math::Vec4; "#, r#" -/// Returns a vector containing the fractional part of the vector, e.g. `self - -/// self.floor()`. +/// Returns a vector containing the fractional part of the vector as `self - self.trunc()`. +/// Note that this differs from the GLSL implementation of `fract` which returns +/// `self - self.floor()`. /// Note that this is fast but not precise for large numbers. #[lua(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::Vec3A; + fn fract(self) -> bevy::math::Vec4; "#, r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of +/// Returns a vector containing the fractional part of the vector as `self - self.floor()`. +/// Note that this differs from the Rust implementation of `fract` which returns +/// `self - self.trunc()`. +/// Note that this is fast but not precise for large numbers. + + #[lua(kind = "Method", output(proxy))] + fn fract_gl(self) -> bevy::math::Vec4; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of /// `self`. #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::Vec3A; + fn exp(self) -> bevy::math::Vec4; "#, r#" /// Returns a vector containing each element of `self` raised to the power of `n`. #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f32) -> bevy::math::Vec3A; + fn powf(self, n: f32) -> bevy::math::Vec4; "#, r#" /// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::Vec3A; + fn recip(self) -> bevy::math::Vec4; "#, r#" @@ -12119,7 +11067,26 @@ struct Vec2 { /// extrapolated. #[lua(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::Vec3A, s: f32) -> bevy::math::Vec3A; + fn lerp(self, #[proxy] rhs: bevy::math::Vec4, s: f32) -> bevy::math::Vec4; + +"#, + r#" +/// Moves towards `rhs` based on the value `d`. +/// When `d` is `0.0`, the result will be equal to `self`. When `d` is equal to +/// `self.distance(rhs)`, the result will be equal to `rhs`. Will not go past `rhs`. + + #[lua(kind = "Method", output(proxy))] + fn move_towards(&self, #[proxy] rhs: bevy::math::Vec4, d: f32) -> bevy::math::Vec4; + +"#, + r#" +/// Calculates the midpoint between `self` and `rhs`. +/// The midpoint is the average of, or halfway point between, two vectors. +/// `a.midpoint(b)` should yield the same result as `a.lerp(b, 0.5)` +/// while being slightly cheaper to compute. + + #[lua(kind = "Method", output(proxy))] + fn midpoint(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -12132,7 +11099,7 @@ struct Vec2 { /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). #[lua(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec3A, max_abs_diff: f32) -> bool; + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec4, max_abs_diff: f32) -> bool; "#, r#" @@ -12141,21 +11108,21 @@ struct Vec2 { /// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3A; + fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec4; "#, r#" /// Returns a vector with a length no more than `max` #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f32) -> bevy::math::Vec3A; + fn clamp_length_max(self, max: f32) -> bevy::math::Vec4; "#, r#" /// Returns a vector with a length no less than `min` #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f32) -> bevy::math::Vec3A; + fn clamp_length_min(self, min: f32) -> bevy::math::Vec4; "#, r#" @@ -12170,118 +11137,92 @@ struct Vec2 { fn mul_add( self, #[proxy] - a: bevy::math::Vec3A, + a: bevy::math::Vec4, #[proxy] - b: bevy::math::Vec3A, - ) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns the angle (in radians) between two vectors. -/// 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::Vec3A) -> f32; - -"#, - r#" -/// Returns some vector that is orthogonal to the given one. -/// The input vector must be finite and non-zero. -/// The output vector is not necessarily unit length. For that use -/// [`Self::any_orthonormal_vector()`] instead. - - #[lua(kind = "Method", output(proxy))] - fn any_orthogonal_vector(&self) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns any unit vector that is orthogonal to the given one. -/// The input vector must be unit length. -/// # Panics -/// Will panic if `self` is not normalized when `glam_assert` is enabled. - - #[lua(kind = "Method", output(proxy))] - fn any_orthonormal_vector(&self) -> bevy::math::Vec3A; + b: bevy::math::Vec4, + ) -> bevy::math::Vec4; "#, r#" /// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; + fn as_dvec4(&self) -> bevy::math::DVec4; "#, r#" /// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; + fn as_ivec4(&self) -> bevy::math::IVec4; "#, r#" /// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; + fn as_uvec4(&self) -> bevy::math::UVec4; "#, r#" /// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; + fn as_i64vec4(&self) -> bevy::math::I64Vec4; "#, r#" /// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; + fn as_u64vec4(&self) -> bevy::math::U64Vec4; "#, 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::Vec3A) -> bevy::math::Vec3A; + fn eq(&self, #[proxy] rhs: &glam::Vec4) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, rhs: f32) -> bevy::math::Vec3A; + fn sub(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, 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::Vec3A; + fn neg(self) -> bevy::math::Vec4; "#, 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::Vec3A) -> bool; + fn add(self, rhs: f32) -> bevy::math::Vec4; "#, r#" @@ -12293,55 +11234,65 @@ struct Vec2 { composite = "sub", metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn sub(self, rhs: f32) -> bevy::math::Vec4; "#, 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::Vec3A) -> bevy::math::Vec3A; + fn div(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, 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: f32) -> bevy::math::Vec3A; + fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "div", + metamethod = "Div", )] - fn add(self, rhs: f32) -> bevy::math::Vec3A; + fn div(self, rhs: f32) -> bevy::math::Vec4; "#, 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::Vec4) -> bevy::math::Vec4; "#, r#" @@ -12353,19 +11304,31 @@ struct Vec2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn mul(self, rhs: f32) -> bevy::math::Vec4; "#, 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::Vec3A; + 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#" @@ -12387,11 +11350,11 @@ fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Res } "#] )] -struct Vec3A(); +struct Vec4(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::Vec4", + remote = "bevy::math::BVec2", functions[r#" #[lua( @@ -12400,7 +11363,7 @@ struct Vec3A(); composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] rhs: &glam::Vec4) -> bool; + fn eq(&self, #[proxy] other: &glam::BVec2) -> bool; "#, r#" @@ -12410,3224 +11373,2888 @@ struct Vec3A(); kind = "Method", output(proxy), )] - fn clone(&self) -> bevy::math::Vec4; + fn clone(&self) -> bevy::math::BVec2; "#, 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; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" +/// Creates a new vector mask. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> 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 = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn splat(v: bool) -> bevy::math::BVec2; "#, r#" -/// Creates a new vector. +/// Creates a new vector mask from a bool array. #[lua(kind = "Function", output(proxy))] - fn new(x: f32, y: f32, z: f32, w: f32) -> bevy::math::Vec4; + fn from_array(a: [bool; 2]) -> bevy::math::BVec2; "#, r#" -/// Creates a vector with all elements set to `v`. +/// Returns a bitmask with the lowest 2 bits set from the elements of `self`. +/// A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes +/// into the first lowest bit, element `y` into the second, etc. - #[lua(kind = "Function", output(proxy))] - fn splat(v: f32) -> bevy::math::Vec4; + #[lua(kind = "Method")] + fn bitmask(self) -> u32; "#, 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`. +/// Returns true if any of the elements are true, false otherwise. - #[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(kind = "Method")] + fn any(self) -> bool; "#, r#" -/// Creates a new vector from an array. +/// Returns true if all the elements are true, false otherwise. - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f32; 4]) -> bevy::math::Vec4; + #[lua(kind = "Method")] + fn all(self) -> bool; "#, r#" -/// `[x, y, z, w]` +/// Tests the value at `index`. +/// Panics if `index` is greater than 1. #[lua(kind = "Method")] - fn to_array(&self) -> [f32; 4]; + fn test(&self, index: usize) -> bool; "#, 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()`]. +/// Sets the element at `index`. +/// Panics if `index` is greater than 1. - #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::Vec3; + #[lua(kind = "MutatingMethod")] + fn set(&mut self, index: usize, value: bool) -> (); "#, r#" -/// Computes the dot product of `self` and `rhs`. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +struct BVec2 { + x: bool, + y: bool, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::BVec3", + functions[r#" - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::Vec4) -> f32; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::BVec3) -> bool; "#, 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 = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec3; "#, r#" -/// Returns a vector containing the minimum values for each element of `self` and `rhs`. -/// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. +/// Creates a new vector mask. - #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn new(x: bool, y: bool, z: bool) -> bevy::math::BVec3; "#, r#" -/// Returns a vector containing the maximum values for each element of `self` and `rhs`. -/// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. +/// Creates a vector mask with all elements set to `v`. - #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn splat(v: bool) -> bevy::math::BVec3; "#, r#" -/// Component-wise clamping of values, similar to [`f32::clamp`]. -/// Each element in `min` must be less-or-equal to the corresponding element in `max`. -/// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Creates a new vector mask from a bool array. - #[lua(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::Vec4, - #[proxy] - max: bevy::math::Vec4, - ) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [bool; 3]) -> bevy::math::BVec3; "#, r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. +/// Returns a bitmask with the lowest 3 bits set from the elements of `self`. +/// A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes +/// into the first lowest bit, element `y` into the second, etc. #[lua(kind = "Method")] - fn min_element(self) -> f32; + fn bitmask(self) -> u32; "#, r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. +/// Returns true if any of the elements are true, false otherwise. #[lua(kind = "Method")] - fn max_element(self) -> f32; + fn any(self) -> bool; "#, r#" -/// Returns a vector mask containing the result of a `==` comparison for each element of -/// `self` and `rhs`. -/// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all -/// elements. +/// Returns true if all the elements are true, false otherwise. - #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + #[lua(kind = "Method")] + fn all(self) -> bool; "#, r#" -/// Returns a vector mask containing the result of a `!=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all -/// elements. +/// Tests the value at `index`. +/// Panics if `index` is greater than 2. - #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + #[lua(kind = "Method")] + fn test(&self, index: usize) -> bool; "#, r#" -/// Returns a vector mask containing the result of a `>=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all -/// elements. +/// Sets the element at `index`. +/// Panics if `index` is greater than 2. - #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + #[lua(kind = "MutatingMethod")] + fn set(&mut self, index: usize, value: bool) -> (); "#, r#" -/// Returns a vector mask containing the result of a `>` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all -/// elements. - #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -/// Returns a vector mask containing the result of a `<=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all -/// elements. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +struct BVec3 { + x: bool, + y: bool, + z: bool, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::BVec4", + functions[r#" - #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec4; "#, r#" -/// Returns a vector mask containing the result of a `<` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all -/// elements. - #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::BVec4A; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::BVec4) -> bool; "#, r#" -/// Returns a vector containing the absolute value of each element of `self`. +/// Creates a new vector mask. - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn new(x: bool, y: bool, z: bool, w: bool) -> bevy::math::BVec4; "#, r#" -/// Returns a vector with elements representing the sign of `self`. -/// - `1.0` if the number is positive, `+0.0` or `INFINITY` -/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` -/// - `NAN` if the number is `NAN` +/// Creates a vector mask with all elements set to `v`. - #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn splat(v: bool) -> bevy::math::BVec4; "#, r#" -/// Returns a vector with signs of `rhs` and the magnitudes of `self`. +/// Creates a new vector mask from a bool array. - #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [bool; 4]) -> bevy::math::BVec4; "#, r#" -/// Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. -/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes +/// Returns a bitmask with the lowest 4 bits set from the elements of `self`. +/// A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes /// into the first lowest bit, element `y` into the second, etc. #[lua(kind = "Method")] - fn is_negative_bitmask(self) -> u32; + fn bitmask(self) -> u32; "#, r#" -/// Returns `true` if, and only if, all elements are finite. If any element is either -/// `NaN`, positive or negative infinity, this will return `false`. +/// Returns true if any of the elements are true, false otherwise. #[lua(kind = "Method")] - fn is_finite(self) -> bool; + fn any(self) -> bool; "#, r#" -/// Returns `true` if any elements are `NaN`. +/// Returns true if all the elements are true, false otherwise. #[lua(kind = "Method")] - fn is_nan(self) -> bool; - -"#, - 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()]`. - - #[lua(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec4A; + fn all(self) -> bool; "#, r#" -/// Computes the length of `self`. +/// Tests the value at `index`. +/// Panics if `index` is greater than 3. #[lua(kind = "Method")] - fn length(self) -> f32; + fn test(&self, index: usize) -> bool; "#, r#" -/// Computes the squared length of `self`. -/// This is faster than `length()` as it avoids a square root operation. +/// Sets the element at `index`. +/// Panics if `index` is greater than 3. - #[lua(kind = "Method")] - fn length_squared(self) -> f32; + #[lua(kind = "MutatingMethod")] + fn set(&mut self, index: usize, value: bool) -> (); "#, r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method")] - fn length_recip(self) -> f32; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -/// Computes the Euclidean distance between two points in space. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +struct BVec4 { + x: bool, + y: bool, + z: bool, + w: bool, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::DVec2", + functions[r#" - #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::Vec4) -> f32; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DVec2; "#, r#" -/// Compute the squared euclidean distance between two points in space. - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::Vec4) -> f32; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f64) -> bevy::math::DVec2; "#, r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// [Euclidean division]: f32::rem_euclid - - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" -/// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be 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. - - #[lua(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::Vec4; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f64) -> bevy::math::DVec2; "#, r#" -/// Returns `self` normalized to length 1.0 if possible, else returns zero. -/// In particular, if the input is zero (or very close to zero), or non-finite, -/// the result of this operation will be zero. -/// See also [`Self::try_normalize()`]. - #[lua(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::Vec4; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f64) -> bevy::math::DVec2; "#, r#" -/// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - #[lua(kind = "Method")] - fn is_normalized(self) -> bool; + #[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#" -/// Returns the vector projection of `self` onto `rhs`. -/// `rhs` must be of non-zero length. -/// # Panics -/// Will panic if `rhs` is zero length when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] - fn project_onto(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::DVec2) -> bevy::math::DVec2; "#, r#" -/// Returns the vector rejection of `self` from `rhs`. -/// The vector rejection is the vector perpendicular to the projection of `self` onto -/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. -/// `rhs` must be of non-zero length. -/// # Panics -/// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DVec2; "#, r#" -/// Returns the vector projection of `self` onto `rhs`. -/// `rhs` must be normalized. -/// # Panics -/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] - fn project_onto_normalized(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DVec2; "#, r#" -/// Returns the vector rejection of `self` from `rhs`. -/// The vector rejection is the vector perpendicular to the projection of `self` onto -/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. -/// `rhs` must be normalized. -/// # Panics -/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] - fn reject_from_normalized(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" -/// Returns a vector containing the nearest integer to a number for each element of `self`. -/// Round half-way cases away from 0.0. - #[lua(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::Vec4; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::DVec2) -> bool; "#, r#" -/// Returns a vector containing the largest integer less than or equal to a number for each -/// element of `self`. +/// Creates a new vector. - #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn new(x: f64, y: f64) -> bevy::math::DVec2; "#, r#" -/// Returns a vector containing the smallest integer greater than or equal to a number for -/// each element of `self`. +/// Creates a vector with all elements set to `v`. - #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn splat(v: f64) -> bevy::math::DVec2; "#, r#" -/// Returns a vector containing the integer part each element of `self`. This means numbers are -/// always truncated towards zero. +/// 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 = "Method", output(proxy))] - fn trunc(self) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn select( + #[proxy] + mask: bevy::math::BVec2, + #[proxy] + if_true: bevy::math::DVec2, + #[proxy] + if_false: bevy::math::DVec2, + ) -> bevy::math::DVec2; "#, r#" -/// Returns a vector containing the fractional part of the vector, e.g. `self - -/// self.floor()`. -/// Note that this is fast but not precise for large numbers. +/// Creates a new vector from an array. - #[lua(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::Vec4; + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f64; 2]) -> bevy::math::DVec2; "#, r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of -/// `self`. +/// `[x, y]` - #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::Vec4; + #[lua(kind = "Method")] + fn to_array(&self) -> [f64; 2]; "#, r#" -/// Returns a vector containing each element of `self` raised to the power of `n`. +/// Creates a 3D vector from `self` and the given `z` value. #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f32) -> bevy::math::Vec4; + fn extend(self, z: f64) -> bevy::math::DVec3; "#, r#" -/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. +/// Creates a 2D vector from `self` with the given value of `x`. #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::Vec4; + fn with_x(self, x: f64) -> bevy::math::DVec2; "#, r#" -/// Performs a linear interpolation between `self` and `rhs` based on the value `s`. -/// When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result -/// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly -/// extrapolated. +/// Creates a 2D vector from `self` with the given value of `y`. #[lua(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::Vec4, s: f32) -> bevy::math::Vec4; + fn with_y(self, y: f64) -> bevy::math::DVec2; "#, r#" -/// Returns true if the absolute difference of all elements between `self` and `rhs` is -/// less than or equal to `max_abs_diff`. -/// This can be used to compare if two vectors contain similar elements. It works best when -/// comparing with a known value. The `max_abs_diff` that should be used used depends on -/// the values being compared against. -/// For more see -/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). +/// Computes the dot product of `self` and `rhs`. #[lua(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::Vec4, max_abs_diff: f32) -> bool; + fn dot(self, #[proxy] rhs: bevy::math::DVec2) -> f64; "#, r#" -/// 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. +/// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua(kind = "Method", output(proxy))] - fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec4; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector containing the minimum values for each element of `self` and `rhs`. +/// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f32) -> bevy::math::Vec4; + fn min(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector containing the maximum values for each element of `self` and `rhs`. +/// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f32) -> bevy::math::Vec4; + fn max(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" -/// Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding -/// error, yielding a more accurate result than an unfused multiply-add. -/// Using `mul_add` *may* be more performant than an unfused multiply-add if the target -/// architecture has a dedicated fma CPU instruction. However, this is not always true, -/// and will be heavily dependant on designing algorithms with specific target hardware in -/// mind. +/// Component-wise clamping of values, similar to [`f64::clamp`]. +/// Each element in `min` must be less-or-equal to the corresponding element in `max`. +/// # Panics +/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn mul_add( + fn clamp( self, #[proxy] - a: bevy::math::Vec4, + min: bevy::math::DVec2, #[proxy] - b: bevy::math::Vec4, - ) -> bevy::math::Vec4; + max: bevy::math::DVec2, + ) -> bevy::math::DVec2; "#, r#" -/// Casts all elements of `self` to `f64`. +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method", output(proxy))] - fn as_dvec4(&self) -> bevy::math::DVec4; + #[lua(kind = "Method")] + fn min_element(self) -> f64; "#, r#" -/// Casts all elements of `self` to `i32`. +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method", output(proxy))] - fn as_ivec4(&self) -> bevy::math::IVec4; + #[lua(kind = "Method")] + fn max_element(self) -> f64; "#, r#" -/// Casts all elements of `self` to `u32`. +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. - #[lua(kind = "Method", output(proxy))] - fn as_uvec4(&self) -> bevy::math::UVec4; + #[lua(kind = "Method")] + fn element_sum(self) -> f64; "#, r#" -/// Casts all elements of `self` to `i64`. +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. - #[lua(kind = "Method", output(proxy))] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; + #[lua(kind = "Method")] + fn element_product(self) -> f64; "#, r#" -/// Casts all elements of `self` to `u64`. +/// Returns a vector mask containing the result of a `==` comparison for each element of +/// `self` and `rhs`. +/// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all +/// elements. #[lua(kind = "Method", output(proxy))] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; + fn cmpeq(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; "#, r#" +/// Returns a vector mask containing the result of a `!=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all +/// elements. - #[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; + #[lua(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; "#, r#" +/// Returns a vector mask containing the result of a `>=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all +/// elements. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f32) -> bevy::math::Vec4; + #[lua(kind = "Method", output(proxy))] + fn cmpge(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; "#, r#" +/// Returns a vector mask containing the result of a `>` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all +/// elements. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Vec4; + #[lua(kind = "Method", output(proxy))] + fn cmpgt(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; "#, r#" +/// Returns a vector mask containing the result of a `<=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all +/// elements. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f32) -> bevy::math::Vec4; + #[lua(kind = "Method", output(proxy))] + fn cmple(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; "#, r#" +/// Returns a vector mask containing the result of a `<` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all +/// elements. - #[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; + #[lua(kind = "Method", output(proxy))] + fn cmplt(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; "#, r#" +/// Returns a vector containing the absolute value of each element of `self`. - #[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 = "Method", output(proxy))] + fn abs(self) -> bevy::math::DVec2; "#, r#" +/// Returns a vector with elements representing the sign of `self`. +/// - `1.0` if the number is positive, `+0.0` or `INFINITY` +/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` +/// - `NAN` if the number is `NAN` - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f32) -> bevy::math::Vec4; + #[lua(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::DVec2; "#, r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. - #[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; + #[lua(kind = "Method", output(proxy))] + fn copysign(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} +/// Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. +/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes +/// into the first lowest bit, element `y` into the second, etc. + + #[lua(kind = "Method")] + fn is_negative_bitmask(self) -> u32; + "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} +/// Returns `true` if, and only if, all elements are finite. If any element is either +/// `NaN`, positive or negative infinity, this will return `false`. + + #[lua(kind = "Method")] + fn is_finite(self) -> bool; + "#, 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#" +/// Returns `true` if any elements are `NaN`. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::BVec2) -> bool; + #[lua(kind = "Method")] + fn is_nan(self) -> bool; "#, r#" -/// Creates a new vector mask. +/// 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()]`. - #[lua(kind = "Function", output(proxy))] - fn new(x: bool, y: bool) -> bevy::math::BVec2; + #[lua(kind = "Method", output(proxy))] + fn is_nan_mask(self) -> bevy::math::BVec2; "#, r#" -/// Creates a vector with all elements set to `v`. +/// Computes the length of `self`. - #[lua(kind = "Function", output(proxy))] - fn splat(v: bool) -> bevy::math::BVec2; + #[lua(kind = "Method")] + fn length(self) -> f64; "#, r#" -/// Returns a bitmask with the lowest 2 bits set from the elements of `self`. -/// A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes -/// into the first lowest bit, element `y` into the second, etc. +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. #[lua(kind = "Method")] - fn bitmask(self) -> u32; + fn length_squared(self) -> f64; "#, r#" -/// Returns true if any of the elements are true, false otherwise. +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. #[lua(kind = "Method")] - fn any(self) -> bool; + fn length_recip(self) -> f64; "#, r#" -/// Returns true if all the elements are true, false otherwise. +/// Computes the Euclidean distance between two points in space. #[lua(kind = "Method")] - fn all(self) -> bool; + fn distance(self, #[proxy] rhs: bevy::math::DVec2) -> f64; "#, r#" -/// Tests the value at `index`. -/// Panics if `index` is greater than 1. +/// Compute the squared euclidean distance between two points in space. #[lua(kind = "Method")] - fn test(&self, index: usize) -> bool; + fn distance_squared(self, #[proxy] rhs: bevy::math::DVec2) -> f64; "#, r#" -/// Sets the element at `index`. -/// Panics if `index` is greater than 1. +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - #[lua(kind = "MutatingMethod")] - fn set(&mut self, index: usize, value: bool) -> (); + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f64::rem_euclid - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must _not_ be 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. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec2; + #[lua(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::DVec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct BVec2 { - x: bool, - y: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::BVec3", - functions[r#" +/// Returns `self` normalized to length 1.0 if possible, else returns a +/// fallback value. +/// In particular, if the input is zero (or very close to zero), or non-finite, +/// the result of this operation will be the fallback value. +/// See also [`Self::try_normalize()`]. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::BVec3) -> bool; + #[lua(kind = "Method", output(proxy))] + fn normalize_or(self, #[proxy] fallback: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" +/// Returns `self` normalized to length 1.0 if possible, else returns zero. +/// In particular, if the input is zero (or very close to zero), or non-finite, +/// the result of this operation will be zero. +/// See also [`Self::try_normalize()`]. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec3; + #[lua(kind = "Method", output(proxy))] + fn normalize_or_zero(self) -> bevy::math::DVec2; "#, r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method")] + fn is_normalized(self) -> bool; "#, r#" -/// Creates a new vector mask. +/// Returns the vector projection of `self` onto `rhs`. +/// `rhs` must be of non-zero length. +/// # Panics +/// Will panic if `rhs` is zero length when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] - fn new(x: bool, y: bool, z: bool) -> bevy::math::BVec3; + #[lua(kind = "Method", output(proxy))] + fn project_onto(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" -/// Creates a vector with all elements set to `v`. +/// Returns the vector rejection of `self` from `rhs`. +/// The vector rejection is the vector perpendicular to the projection of `self` onto +/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. +/// `rhs` must be of non-zero length. +/// # Panics +/// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] - fn splat(v: bool) -> bevy::math::BVec3; + #[lua(kind = "Method", output(proxy))] + fn reject_from(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" -/// Returns a bitmask with the lowest 3 bits set from the elements of `self`. -/// A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes -/// into the first lowest bit, element `y` into the second, etc. +/// Returns the vector projection of `self` onto `rhs`. +/// `rhs` must be normalized. +/// # Panics +/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method")] - fn bitmask(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn project_onto_normalized( + self, + #[proxy] + rhs: bevy::math::DVec2, + ) -> bevy::math::DVec2; "#, r#" -/// Returns true if any of the elements are true, false otherwise. +/// Returns the vector rejection of `self` from `rhs`. +/// The vector rejection is the vector perpendicular to the projection of `self` onto +/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. +/// `rhs` must be normalized. +/// # Panics +/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method")] - fn any(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn reject_from_normalized( + self, + #[proxy] + rhs: bevy::math::DVec2, + ) -> bevy::math::DVec2; "#, r#" -/// Returns true if all the elements are true, false otherwise. +/// Returns a vector containing the nearest integer to a number for each element of `self`. +/// Round half-way cases away from 0.0. - #[lua(kind = "Method")] - fn all(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn round(self) -> bevy::math::DVec2; "#, r#" -/// Tests the value at `index`. -/// Panics if `index` is greater than 2. +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. - #[lua(kind = "Method")] - fn test(&self, index: usize) -> bool; + #[lua(kind = "Method", output(proxy))] + fn floor(self) -> bevy::math::DVec2; "#, r#" -/// Sets the element at `index`. -/// Panics if `index` is greater than 2. +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. - #[lua(kind = "MutatingMethod")] - fn set(&mut self, index: usize, value: bool) -> (); + #[lua(kind = "Method", output(proxy))] + fn ceil(self) -> bevy::math::DVec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct BVec3 { - x: bool, - y: bool, - z: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::BVec4", - functions[r#" -/// Creates a new vector mask. +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. - #[lua(kind = "Function", output(proxy))] - fn new(x: bool, y: bool, z: bool, w: bool) -> bevy::math::BVec4; + #[lua(kind = "Method", output(proxy))] + fn trunc(self) -> bevy::math::DVec2; "#, r#" -/// Creates a vector with all elements set to `v`. +/// Returns a vector containing the fractional part of the vector as `self - self.trunc()`. +/// Note that this differs from the GLSL implementation of `fract` which returns +/// `self - self.floor()`. +/// Note that this is fast but not precise for large numbers. - #[lua(kind = "Function", output(proxy))] - fn splat(v: bool) -> bevy::math::BVec4; + #[lua(kind = "Method", output(proxy))] + fn fract(self) -> bevy::math::DVec2; "#, r#" -/// Returns a bitmask with the lowest 4 bits set from the elements of `self`. -/// A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes -/// into the first lowest bit, element `y` into the second, etc. +/// Returns a vector containing the fractional part of the vector as `self - self.floor()`. +/// Note that this differs from the Rust implementation of `fract` which returns +/// `self - self.trunc()`. +/// Note that this is fast but not precise for large numbers. - #[lua(kind = "Method")] - fn bitmask(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn fract_gl(self) -> bevy::math::DVec2; "#, r#" -/// Returns true if any of the elements are true, false otherwise. +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. - #[lua(kind = "Method")] - fn any(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn exp(self) -> bevy::math::DVec2; "#, r#" -/// Returns true if all the elements are true, false otherwise. +/// Returns a vector containing each element of `self` raised to the power of `n`. - #[lua(kind = "Method")] - fn all(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn powf(self, n: f64) -> bevy::math::DVec2; "#, r#" -/// Tests the value at `index`. -/// Panics if `index` is greater than 3. +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - #[lua(kind = "Method")] - fn test(&self, index: usize) -> bool; + #[lua(kind = "Method", output(proxy))] + fn recip(self) -> bevy::math::DVec2; "#, r#" -/// Sets the element at `index`. -/// Panics if `index` is greater than 3. +/// Performs a linear interpolation between `self` and `rhs` based on the value `s`. +/// When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result +/// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly +/// extrapolated. - #[lua(kind = "MutatingMethod")] - fn set(&mut self, index: usize, value: bool) -> (); + #[lua(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] rhs: bevy::math::DVec2, s: f64) -> bevy::math::DVec2; "#, r#" +/// Moves towards `rhs` based on the value `d`. +/// When `d` is `0.0`, the result will be equal to `self`. When `d` is equal to +/// `self.distance(rhs)`, the result will be equal to `rhs`. Will not go past `rhs`. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::BVec4) -> bool; + #[lua(kind = "Method", output(proxy))] + fn move_towards(&self, #[proxy] rhs: bevy::math::DVec2, d: f64) -> bevy::math::DVec2; "#, r#" +/// Calculates the midpoint between `self` and `rhs`. +/// The midpoint is the average of, or halfway point between, two vectors. +/// `a.midpoint(b)` should yield the same result as `a.lerp(b, 0.5)` +/// while being slightly cheaper to compute. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec4; + #[lua(kind = "Method", output(proxy))] + fn midpoint(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" +/// Returns true if the absolute difference of all elements between `self` and `rhs` is +/// less than or equal to `max_abs_diff`. +/// This can be used to compare if two vectors contain similar elements. It works best when +/// comparing with a known value. The `max_abs_diff` that should be used used depends on +/// the values being compared against. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method")] + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec2, max_abs_diff: f64) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct BVec4 { - x: bool, - y: bool, - z: bool, - w: bool, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DVec2", - functions[r#" +/// 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. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f64) -> bevy::math::DVec2; + #[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` - #[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; + #[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` - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(kind = "Method", output(proxy))] + fn clamp_length_min(self, min: f64) -> bevy::math::DVec2; "#, r#" +/// Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding +/// error, yielding a more accurate result than an unfused multiply-add. +/// Using `mul_add` *may* be more performant than an unfused multiply-add if the target +/// architecture has a dedicated fma CPU instruction. However, this is not always true, +/// and will be heavily dependant on designing algorithms with specific target hardware in +/// mind. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::DVec2) -> bool; + #[lua(kind = "Method", output(proxy))] + fn mul_add( + self, + #[proxy] + a: bevy::math::DVec2, + #[proxy] + b: bevy::math::DVec2, + ) -> bevy::math::DVec2; "#, r#" +/// Creates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in +/// conjunction with the [`rotate()`][Self::rotate()] method, e.g. +/// `DVec2::from_angle(PI).rotate(DVec2::Y)` will create the vector `[-1, 0]` +/// and rotate [`DVec2::Y`] around it returning `-DVec2::Y`. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f64) -> bevy::math::DVec2; + #[lua(kind = "Function", output(proxy))] + fn from_angle(angle: f64) -> bevy::math::DVec2; "#, r#" +/// Returns the angle (in radians) of this vector in the range `[-π, +π]`. +/// The input does not need to be a unit vector however it must be non-zero. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(kind = "Method")] + fn to_angle(self) -> f64; "#, r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: f64, y: f64) -> bevy::math::DVec2; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: f64) -> bevy::math::DVec2; - -"#, - 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`. +/// 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 = "Function", output(proxy))] - fn select( - #[proxy] - mask: bevy::math::BVec2, - #[proxy] - if_true: bevy::math::DVec2, - #[proxy] - if_false: bevy::math::DVec2, - ) -> bevy::math::DVec2; + #[lua(kind = "Method")] + fn angle_between(self, #[proxy] rhs: bevy::math::DVec2) -> f64; "#, r#" -/// Creates a new vector from an array. +/// Returns a vector that is equal to `self` rotated by 90 degrees. - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f64; 2]) -> bevy::math::DVec2; + #[lua(kind = "Method", output(proxy))] + fn perp(self) -> bevy::math::DVec2; "#, r#" -/// `[x, y]` +/// The perpendicular dot product of `self` and `rhs`. +/// Also known as the wedge product, 2D cross product, and determinant. #[lua(kind = "Method")] - fn to_array(&self) -> [f64; 2]; + fn perp_dot(self, #[proxy] rhs: bevy::math::DVec2) -> f64; "#, r#" -/// Creates a 3D vector from `self` and the given `z` value. +/// Returns `rhs` rotated by the angle of `self`. If `self` is normalized, +/// then this just rotation. This is what you usually want. Otherwise, +/// it will be like a rotation with a multiplication by `self`'s length. #[lua(kind = "Method", output(proxy))] - fn extend(self, z: f64) -> bevy::math::DVec3; + fn rotate(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" -/// Computes the dot product of `self` and `rhs`. +/// Casts all elements of `self` to `f32`. - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + #[lua(kind = "Method", output(proxy))] + fn as_vec2(&self) -> bevy::math::Vec2; "#, r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. +/// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn as_ivec2(&self) -> bevy::math::IVec2; "#, r#" -/// Returns a vector containing the minimum values for each element of `self` and `rhs`. -/// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. +/// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn as_uvec2(&self) -> bevy::math::UVec2; "#, r#" -/// Returns a vector containing the maximum values for each element of `self` and `rhs`. -/// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. +/// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn as_i64vec2(&self) -> bevy::math::I64Vec2; "#, r#" -/// Component-wise clamping of values, similar to [`f64::clamp`]. -/// Each element in `min` must be less-or-equal to the corresponding element in `max`. -/// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::DVec2, - #[proxy] - max: bevy::math::DVec2, - ) -> bevy::math::DVec2; + fn as_u64vec2(&self) -> bevy::math::U64Vec2; "#, r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method")] - fn min_element(self) -> f64; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method")] - fn max_element(self) -> f64; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DVec2; "#, r#" -/// Returns a vector mask containing the result of a `==` comparison for each element of -/// `self` and `rhs`. -/// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all -/// elements. - #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" -/// Returns a vector mask containing the result of a `!=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all -/// elements. - - #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; - +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} "#, r#" -/// Returns a vector mask containing the result of a `>=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all -/// elements. +#[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 DVec2 { + x: f64, + y: f64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::DVec3", + functions[r#" - #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f64) -> bevy::math::DVec3; "#, r#" -/// Returns a vector mask containing the result of a `>` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all -/// elements. - #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DVec3; "#, r#" -/// Returns a vector mask containing the result of a `<=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all -/// elements. - #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f64) -> bevy::math::DVec3; "#, r#" -/// Returns a vector mask containing the result of a `<` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all -/// elements. - #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::BVec2; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::DVec2; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// Returns a vector with elements representing the sign of `self`. -/// - `1.0` if the number is positive, `+0.0` or `INFINITY` -/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` -/// - `NAN` if the number is `NAN` - #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::DVec2; + #[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#" -/// Returns a vector with signs of `rhs` and the magnitudes of `self`. - #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DVec3; "#, r#" -/// Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. -/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes -/// into the first lowest bit, element `y` into the second, etc. - #[lua(kind = "Method")] - fn is_negative_bitmask(self) -> u32; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::DVec3) -> bool; "#, r#" -/// Returns `true` if, and only if, all elements are finite. If any element is either -/// `NaN`, positive or negative infinity, this will return `false`. - #[lua(kind = "Method")] - fn is_finite(self) -> bool; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] - fn is_nan(self) -> bool; + #[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#" -/// 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()]`. - #[lua(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec2; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DVec3; "#, r#" -/// Computes the length of `self`. - #[lua(kind = "Method")] - fn length(self) -> f64; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f64) -> bevy::math::DVec3; "#, r#" -/// Computes the squared length of `self`. -/// This is faster than `length()` as it avoids a square root operation. - #[lua(kind = "Method")] - fn length_squared(self) -> f64; + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DVec3; "#, r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. +/// Creates a new vector. - #[lua(kind = "Method")] - fn length_recip(self) -> f64; + #[lua(kind = "Function", output(proxy))] + fn new(x: f64, y: f64, z: f64) -> bevy::math::DVec3; "#, r#" -/// Computes the Euclidean distance between two points in space. +/// Creates a vector with all elements set to `v`. - #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + #[lua(kind = "Function", output(proxy))] + fn splat(v: f64) -> bevy::math::DVec3; "#, r#" -/// Compute the squared euclidean distance between two points in space. +/// 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 = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + #[lua(kind = "Function", output(proxy))] + fn select( + #[proxy] + mask: bevy::math::BVec3, + #[proxy] + if_true: bevy::math::DVec3, + #[proxy] + if_false: bevy::math::DVec3, + ) -> bevy::math::DVec3; "#, r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. +/// Creates a new vector from an array. - #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f64; 3]) -> bevy::math::DVec3; "#, r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// [Euclidean division]: f64::rem_euclid +/// `[x, y, z]` - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(kind = "Method")] + fn to_array(&self) -> [f64; 3]; "#, r#" -/// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be 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. +/// Creates a 4D vector from `self` and the given `w` value. #[lua(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::DVec2; + fn extend(self, w: f64) -> bevy::math::DVec4; "#, r#" -/// Returns `self` normalized to length 1.0 if possible, else returns zero. -/// In particular, if the input is zero (or very close to zero), or non-finite, -/// the result of this operation will be zero. -/// See also [`Self::try_normalize()`]. +/// 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 normalize_or_zero(self) -> bevy::math::DVec2; + fn truncate(self) -> bevy::math::DVec2; "#, r#" -/// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. +/// Creates a 3D vector from `self` with the given value of `x`. - #[lua(kind = "Method")] - fn is_normalized(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: f64) -> bevy::math::DVec3; "#, r#" -/// Returns the vector projection of `self` onto `rhs`. -/// `rhs` must be of non-zero length. -/// # Panics -/// Will panic if `rhs` is zero length when `glam_assert` is enabled. +/// Creates a 3D vector from `self` with the given value of `y`. #[lua(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn with_y(self, y: f64) -> bevy::math::DVec3; "#, r#" -/// Returns the vector rejection of `self` from `rhs`. -/// The vector rejection is the vector perpendicular to the projection of `self` onto -/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. -/// `rhs` must be of non-zero length. -/// # Panics -/// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. +/// Creates a 3D vector from `self` with the given value of `z`. #[lua(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn with_z(self, z: f64) -> bevy::math::DVec3; "#, r#" -/// Returns the vector projection of `self` onto `rhs`. -/// `rhs` must be normalized. -/// # Panics -/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. +/// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] - fn project_onto_normalized( - self, - #[proxy] - rhs: bevy::math::DVec2, - ) -> bevy::math::DVec2; + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::DVec3) -> f64; "#, r#" -/// Returns the vector rejection of `self` from `rhs`. -/// The vector rejection is the vector perpendicular to the projection of `self` onto -/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. -/// `rhs` must be normalized. -/// # Panics -/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. +/// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua(kind = "Method", output(proxy))] - fn reject_from_normalized( - self, - #[proxy] - rhs: bevy::math::DVec2, - ) -> bevy::math::DVec2; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// Returns a vector containing the nearest integer to a number for each element of `self`. -/// Round half-way cases away from 0.0. +/// Computes the cross product of `self` and `rhs`. #[lua(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::DVec2; + fn cross(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// Returns a vector containing the largest integer less than or equal to a number for each -/// element of `self`. +/// Returns a vector containing the minimum values for each element of `self` and `rhs`. +/// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::DVec2; + fn min(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// Returns a vector containing the smallest integer greater than or equal to a number for -/// each element of `self`. +/// Returns a vector containing the maximum values for each element of `self` and `rhs`. +/// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::DVec2; + fn max(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// Returns a vector containing the integer part each element of `self`. This means numbers are -/// always truncated towards zero. +/// Component-wise clamping of values, similar to [`f64::clamp`]. +/// Each element in `min` must be less-or-equal to the corresponding element in `max`. +/// # Panics +/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::DVec2; + fn clamp( + self, + #[proxy] + min: bevy::math::DVec3, + #[proxy] + max: bevy::math::DVec3, + ) -> bevy::math::DVec3; "#, r#" -/// Returns a vector containing the fractional part of the vector, e.g. `self - -/// self.floor()`. -/// Note that this is fast but not precise for large numbers. +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::DVec2; + #[lua(kind = "Method")] + fn min_element(self) -> f64; "#, r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of -/// `self`. +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::DVec2; + #[lua(kind = "Method")] + fn max_element(self) -> f64; "#, r#" -/// Returns a vector containing each element of `self` raised to the power of `n`. +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. - #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f64) -> bevy::math::DVec2; + #[lua(kind = "Method")] + fn element_sum(self) -> f64; "#, r#" -/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. - #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::DVec2; + #[lua(kind = "Method")] + fn element_product(self) -> f64; "#, r#" -/// Performs a linear interpolation between `self` and `rhs` based on the value `s`. -/// When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result -/// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly -/// extrapolated. +/// Returns a vector mask containing the result of a `==` comparison for each element of +/// `self` and `rhs`. +/// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all +/// elements. #[lua(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::DVec2, s: f64) -> bevy::math::DVec2; + fn cmpeq(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; "#, r#" -/// Returns true if the absolute difference of all elements between `self` and `rhs` is -/// less than or equal to `max_abs_diff`. -/// This can be used to compare if two vectors contain similar elements. It works best when -/// comparing with a known value. The `max_abs_diff` that should be used used depends on -/// the values being compared against. -/// For more see -/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). +/// Returns a vector mask containing the result of a `!=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all +/// elements. - #[lua(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec2, max_abs_diff: f64) -> bool; + #[lua(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; "#, r#" -/// 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. +/// Returns a vector mask containing the result of a `>=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all +/// elements. #[lua(kind = "Method", output(proxy))] - fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec2; + fn cmpge(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector mask containing the result of a `>` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all +/// elements. #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f64) -> bevy::math::DVec2; + fn cmpgt(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector mask containing the result of a `<=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all +/// elements. #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f64) -> bevy::math::DVec2; + fn cmple(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; "#, r#" -/// Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding -/// error, yielding a more accurate result than an unfused multiply-add. -/// Using `mul_add` *may* be more performant than an unfused multiply-add if the target -/// architecture has a dedicated fma CPU instruction. However, this is not always true, -/// and will be heavily dependant on designing algorithms with specific target hardware in -/// mind. +/// Returns a vector mask containing the result of a `<` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all +/// elements. #[lua(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::DVec2, - #[proxy] - b: bevy::math::DVec2, - ) -> bevy::math::DVec2; + fn cmplt(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; "#, r#" -/// Creates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in -/// conjunction with the [`rotate()`][Self::rotate()] method, e.g. -/// `DVec2::from_angle(PI).rotate(DVec2::Y)` will create the vector `[-1, 0]` -/// and rotate [`DVec2::Y`] around it returning `-DVec2::Y`. +/// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Function", output(proxy))] - fn from_angle(angle: f64) -> bevy::math::DVec2; + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::DVec3; "#, r#" -/// Returns the angle (in radians) of this vector in the range `[-π, +π]`. -/// The input does not need to be a unit vector however it must be non-zero. +/// Returns a vector with elements representing the sign of `self`. +/// - `1.0` if the number is positive, `+0.0` or `INFINITY` +/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` +/// - `NAN` if the number is `NAN` - #[lua(kind = "Method")] - fn to_angle(self) -> f64; + #[lua(kind = "Method", output(proxy))] + fn signum(self) -> bevy::math::DVec3; "#, 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. +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. - #[lua(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + #[lua(kind = "Method", output(proxy))] + fn copysign(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// Returns a vector that is equal to `self` rotated by 90 degrees. +/// Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. +/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes +/// into the first lowest bit, element `y` into the second, etc. - #[lua(kind = "Method", output(proxy))] - fn perp(self) -> bevy::math::DVec2; + #[lua(kind = "Method")] + fn is_negative_bitmask(self) -> u32; "#, r#" -/// The perpendicular dot product of `self` and `rhs`. -/// Also known as the wedge product, 2D cross product, and determinant. +/// Returns `true` if, and only if, all elements are finite. If any element is either +/// `NaN`, positive or negative infinity, this will return `false`. #[lua(kind = "Method")] - fn perp_dot(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + fn is_finite(self) -> bool; "#, r#" -/// Returns `rhs` rotated by the angle of `self`. If `self` is normalized, -/// then this just rotation. This is what you usually want. Otherwise, -/// it will be like a rotation with a multiplication by `self`'s length. +/// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method", output(proxy))] - fn rotate(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(kind = "Method")] + fn is_nan(self) -> bool; "#, r#" -/// Casts all elements of `self` to `f32`. +/// 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()]`. #[lua(kind = "Method", output(proxy))] - fn as_vec2(&self) -> bevy::math::Vec2; + fn is_nan_mask(self) -> bevy::math::BVec3; "#, r#" -/// Casts all elements of `self` to `i32`. +/// Computes the length of `self`. - #[lua(kind = "Method", output(proxy))] - fn as_ivec2(&self) -> bevy::math::IVec2; + #[lua(kind = "Method")] + fn length(self) -> f64; "#, r#" -/// Casts all elements of `self` to `u32`. +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. - #[lua(kind = "Method", output(proxy))] - fn as_uvec2(&self) -> bevy::math::UVec2; + #[lua(kind = "Method")] + fn length_squared(self) -> f64; "#, r#" -/// Casts all elements of `self` to `i64`. +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method", output(proxy))] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; + #[lua(kind = "Method")] + fn length_recip(self) -> f64; "#, r#" -/// Casts all elements of `self` to `u64`. +/// Computes the Euclidean distance between two points in space. - #[lua(kind = "Method", output(proxy))] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; + #[lua(kind = "Method")] + fn distance(self, #[proxy] rhs: bevy::math::DVec3) -> f64; "#, r#" +/// Compute the squared euclidean distance between two points in space. - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DVec2; + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::DVec3) -> f64; "#, r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DVec2; + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f64::rem_euclid - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f64) -> bevy::math::DVec2; + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must _not_ be 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. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::DVec3; "#, r#" +/// Returns `self` normalized to length 1.0 if possible, else returns a +/// fallback value. +/// In particular, if the input is zero (or very close to zero), or non-finite, +/// the result of this operation will be the fallback value. +/// See also [`Self::try_normalize()`]. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f64) -> bevy::math::DVec2; + #[lua(kind = "Method", output(proxy))] + fn normalize_or(self, #[proxy] fallback: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" +/// Returns `self` normalized to length 1.0 if possible, else returns zero. +/// In particular, if the input is zero (or very close to zero), or non-finite, +/// the result of this operation will be zero. +/// See also [`Self::try_normalize()`]. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DVec2; + #[lua(kind = "Method", output(proxy))] + fn normalize_or_zero(self) -> bevy::math::DVec3; "#, r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + #[lua(kind = "Method")] + fn is_normalized(self) -> bool; "#, 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]) -} +/// Returns the vector projection of `self` onto `rhs`. +/// `rhs` must be of non-zero length. +/// # Panics +/// Will panic if `rhs` is zero length when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn project_onto(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 DVec2 { - x: f64, - y: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DVec3", - functions[r#" +/// Returns the vector rejection of `self` from `rhs`. +/// The vector rejection is the vector perpendicular to the projection of `self` onto +/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. +/// `rhs` must be of non-zero length. +/// # Panics +/// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn reject_from(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" +/// Returns the vector projection of `self` onto `rhs`. +/// `rhs` must be normalized. +/// # Panics +/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f64) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn project_onto_normalized( + self, + #[proxy] + rhs: bevy::math::DVec3, + ) -> bevy::math::DVec3; "#, r#" +/// Returns the vector rejection of `self` from `rhs`. +/// The vector rejection is the vector perpendicular to the projection of `self` onto +/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. +/// `rhs` must be normalized. +/// # Panics +/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[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; + #[lua(kind = "Method", output(proxy))] + fn reject_from_normalized( + self, + #[proxy] + rhs: bevy::math::DVec3, + ) -> bevy::math::DVec3; "#, r#" +/// Returns a vector containing the nearest integer to a number for each element of `self`. +/// Round half-way cases away from 0.0. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::DVec3) -> bool; + #[lua(kind = "Method", output(proxy))] + fn round(self) -> bevy::math::DVec3; "#, r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn floor(self) -> bevy::math::DVec3; "#, r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f64) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn ceil(self) -> bevy::math::DVec3; "#, r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn trunc(self) -> bevy::math::DVec3; "#, r#" +/// Returns a vector containing the fractional part of the vector as `self - self.trunc()`. +/// Note that this differs from the GLSL implementation of `fract` which returns +/// `self - self.floor()`. +/// Note that this is fast but not precise for large numbers. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f64) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn fract(self) -> bevy::math::DVec3; "#, r#" +/// Returns a vector containing the fractional part of the vector as `self - self.floor()`. +/// Note that this differs from the Rust implementation of `fract` which returns +/// `self - self.trunc()`. +/// Note that this is fast but not precise for large numbers. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f64) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn fract_gl(self) -> bevy::math::DVec3; "#, r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn exp(self) -> bevy::math::DVec3; "#, r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn powf(self, n: f64) -> bevy::math::DVec3; "#, r#" -/// Creates a new vector. +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - #[lua(kind = "Function", output(proxy))] - fn new(x: f64, y: f64, z: f64) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn recip(self) -> bevy::math::DVec3; "#, r#" -/// Creates a vector with all elements set to `v`. +/// Performs a linear interpolation between `self` and `rhs` based on the value `s`. +/// When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result +/// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly +/// extrapolated. - #[lua(kind = "Function", output(proxy))] - fn splat(v: f64) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn lerp(self, #[proxy] rhs: bevy::math::DVec3, s: f64) -> bevy::math::DVec3; "#, 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`. +/// Moves towards `rhs` based on the value `d`. +/// When `d` is `0.0`, the result will be equal to `self`. When `d` is equal to +/// `self.distance(rhs)`, the result will be equal to `rhs`. Will not go past `rhs`. - #[lua(kind = "Function", output(proxy))] - fn select( - #[proxy] - mask: bevy::math::BVec3, - #[proxy] - if_true: bevy::math::DVec3, - #[proxy] - if_false: bevy::math::DVec3, - ) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn move_towards(&self, #[proxy] rhs: bevy::math::DVec3, d: f64) -> bevy::math::DVec3; "#, r#" -/// Creates a new vector from an array. +/// Calculates the midpoint between `self` and `rhs`. +/// The midpoint is the average of, or halfway point between, two vectors. +/// `a.midpoint(b)` should yield the same result as `a.lerp(b, 0.5)` +/// while being slightly cheaper to compute. - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f64; 3]) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn midpoint(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// `[x, y, z]` +/// Returns true if the absolute difference of all elements between `self` and `rhs` is +/// less than or equal to `max_abs_diff`. +/// This can be used to compare if two vectors contain similar elements. It works best when +/// comparing with a known value. The `max_abs_diff` that should be used used depends on +/// the values being compared against. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). #[lua(kind = "Method")] - fn to_array(&self) -> [f64; 3]; + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec3, max_abs_diff: f64) -> bool; "#, r#" -/// Creates a 4D vector from `self` and the given `w` value. +/// 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. #[lua(kind = "Method", output(proxy))] - fn extend(self, w: f64) -> bevy::math::DVec4; + fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec3; "#, 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()]. +/// Returns a vector with a length no more than `max` #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::DVec2; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::DVec3) -> f64; + fn clamp_length_max(self, max: f64) -> bevy::math::DVec3; "#, r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. +/// Returns a vector with a length no less than `min` #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn clamp_length_min(self, min: f64) -> bevy::math::DVec3; "#, r#" -/// Computes the cross product of `self` and `rhs`. +/// Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding +/// error, yielding a more accurate result than an unfused multiply-add. +/// Using `mul_add` *may* be more performant than an unfused multiply-add if the target +/// architecture has a dedicated fma CPU instruction. However, this is not always true, +/// and will be heavily dependant on designing algorithms with specific target hardware in +/// mind. #[lua(kind = "Method", output(proxy))] - fn cross(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn mul_add( + self, + #[proxy] + a: bevy::math::DVec3, + #[proxy] + b: bevy::math::DVec3, + ) -> bevy::math::DVec3; "#, r#" -/// Returns a vector containing the minimum values for each element of `self` and `rhs`. -/// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. +/// Returns the angle (in radians) between two vectors. +/// The inputs do not need to be unit vectors however they must be non-zero. - #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(kind = "Method")] + fn angle_between(self, #[proxy] rhs: bevy::math::DVec3) -> f64; "#, r#" -/// Returns a vector containing the maximum values for each element of `self` and `rhs`. -/// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. +/// Returns some vector that is orthogonal to the given one. +/// The input vector must be finite and non-zero. +/// The output vector is not necessarily unit length. For that use +/// [`Self::any_orthonormal_vector()`] instead. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn any_orthogonal_vector(&self) -> bevy::math::DVec3; "#, r#" -/// Component-wise clamping of values, similar to [`f64::clamp`]. -/// Each element in `min` must be less-or-equal to the corresponding element in `max`. +/// Returns any unit vector that is orthogonal to the given one. +/// The input vector must be unit length. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn clamp( - self, - #[proxy] - min: bevy::math::DVec3, - #[proxy] - max: bevy::math::DVec3, - ) -> bevy::math::DVec3; + fn any_orthonormal_vector(&self) -> bevy::math::DVec3; "#, r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. +/// Casts all elements of `self` to `f32`. - #[lua(kind = "Method")] - fn min_element(self) -> f64; + #[lua(kind = "Method", output(proxy))] + fn as_vec3(&self) -> bevy::math::Vec3; "#, r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. +/// Casts all elements of `self` to `f32`. - #[lua(kind = "Method")] - fn max_element(self) -> f64; + #[lua(kind = "Method", output(proxy))] + fn as_vec3a(&self) -> bevy::math::Vec3A; "#, r#" -/// Returns a vector mask containing the result of a `==` comparison for each element of -/// `self` and `rhs`. -/// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all -/// elements. +/// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + fn as_ivec3(&self) -> bevy::math::IVec3; "#, r#" -/// Returns a vector mask containing the result of a `!=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all -/// elements. +/// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + fn as_uvec3(&self) -> bevy::math::UVec3; "#, r#" -/// Returns a vector mask containing the result of a `>=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all -/// elements. +/// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + fn as_i64vec3(&self) -> bevy::math::I64Vec3; "#, r#" -/// Returns a vector mask containing the result of a `>` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all -/// elements. +/// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + fn as_u64vec3(&self) -> bevy::math::U64Vec3; "#, r#" -/// Returns a vector mask containing the result of a `<=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all -/// elements. +#[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#" - #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::DVec4) -> bool; "#, r#" -/// Returns a vector mask containing the result of a `<` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all -/// elements. - #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::BVec3; + #[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#" -/// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::DVec3; + #[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#" -/// Returns a vector with elements representing the sign of `self`. -/// - `1.0` if the number is positive, `+0.0` or `INFINITY` -/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` -/// - `NAN` if the number is `NAN` - #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::DVec3; + #[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#" -/// Returns a vector with signs of `rhs` and the magnitudes of `self`. - #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[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#" -/// Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. -/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes -/// into the first lowest bit, element `y` into the second, etc. - #[lua(kind = "Method")] - fn is_negative_bitmask(self) -> u32; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DVec4; "#, r#" -/// Returns `true` if, and only if, all elements are finite. If any element is either -/// `NaN`, positive or negative infinity, this will return `false`. - #[lua(kind = "Method")] - fn is_finite(self) -> bool; + #[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#" -/// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method")] - fn is_nan(self) -> bool; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DVec4; "#, 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()]`. - #[lua(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec3; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f64) -> bevy::math::DVec4; "#, r#" -/// Computes the length of `self`. - #[lua(kind = "Method")] - fn length(self) -> f64; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f64) -> bevy::math::DVec4; "#, r#" -/// Computes the squared length of `self`. -/// This is faster than `length()` as it avoids a square root operation. - #[lua(kind = "Method")] - fn length_squared(self) -> f64; + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DVec4; "#, r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - #[lua(kind = "Method")] - fn length_recip(self) -> f64; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DVec4; "#, r#" -/// Computes the Euclidean distance between two points in space. +/// Creates a new vector. - #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::DVec3) -> f64; + #[lua(kind = "Function", output(proxy))] + fn new(x: f64, y: f64, z: f64, w: f64) -> bevy::math::DVec4; "#, r#" -/// Compute the squared euclidean distance between two points in space. +/// Creates a vector with all elements set to `v`. - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::DVec3) -> f64; + #[lua(kind = "Function", output(proxy))] + fn splat(v: f64) -> bevy::math::DVec4; "#, r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. +/// 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 = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(kind = "Function", output(proxy))] + fn select( + #[proxy] + mask: bevy::math::BVec4, + #[proxy] + if_true: bevy::math::DVec4, + #[proxy] + if_false: bevy::math::DVec4, + ) -> bevy::math::DVec4; "#, r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// [Euclidean division]: f64::rem_euclid +/// Creates a new vector from an array. - #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [f64; 4]) -> bevy::math::DVec4; "#, r#" -/// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be 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. +/// `[x, y, z, w]` - #[lua(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::DVec3; + #[lua(kind = "Method")] + fn to_array(&self) -> [f64; 4]; "#, r#" -/// Returns `self` normalized to length 1.0 if possible, else returns zero. -/// In particular, if the input is zero (or very close to zero), or non-finite, -/// the result of this operation will be zero. -/// See also [`Self::try_normalize()`]. +/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. +/// Truncation to [`DVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. #[lua(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::DVec3; + fn truncate(self) -> bevy::math::DVec3; "#, r#" -/// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. +/// Creates a 4D vector from `self` with the given value of `x`. - #[lua(kind = "Method")] - fn is_normalized(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn with_x(self, x: f64) -> bevy::math::DVec4; "#, r#" -/// Returns the vector projection of `self` onto `rhs`. -/// `rhs` must be of non-zero length. -/// # Panics -/// Will panic if `rhs` is zero length when `glam_assert` is enabled. +/// Creates a 4D vector from `self` with the given value of `y`. #[lua(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn with_y(self, y: f64) -> bevy::math::DVec4; "#, r#" -/// Returns the vector rejection of `self` from `rhs`. -/// The vector rejection is the vector perpendicular to the projection of `self` onto -/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. -/// `rhs` must be of non-zero length. -/// # Panics -/// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. +/// Creates a 4D vector from `self` with the given value of `z`. #[lua(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn with_z(self, z: f64) -> bevy::math::DVec4; "#, r#" -/// Returns the vector projection of `self` onto `rhs`. -/// `rhs` must be normalized. -/// # Panics -/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. +/// Creates a 4D vector from `self` with the given value of `w`. #[lua(kind = "Method", output(proxy))] - fn project_onto_normalized( - self, - #[proxy] - rhs: bevy::math::DVec3, - ) -> bevy::math::DVec3; + fn with_w(self, w: f64) -> bevy::math::DVec4; "#, r#" -/// Returns the vector rejection of `self` from `rhs`. -/// The vector rejection is the vector perpendicular to the projection of `self` onto -/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. -/// `rhs` must be normalized. -/// # Panics -/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. +/// Computes the dot product of `self` and `rhs`. - #[lua(kind = "Method", output(proxy))] - fn reject_from_normalized( - self, - #[proxy] - rhs: bevy::math::DVec3, - ) -> bevy::math::DVec3; + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::DVec4) -> f64; "#, r#" -/// Returns a vector containing the nearest integer to a number for each element of `self`. -/// Round half-way cases away from 0.0. +/// Returns a vector where every component is the dot product of `self` and `rhs`. #[lua(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::DVec3; + fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" -/// Returns a vector containing the largest integer less than or equal to a number for each -/// element of `self`. +/// Returns a vector containing the minimum values for each element of `self` and `rhs`. +/// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::DVec3; + fn min(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" -/// Returns a vector containing the smallest integer greater than or equal to a number for -/// each element of `self`. +/// Returns a vector containing the maximum values for each element of `self` and `rhs`. +/// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::DVec3; + fn max(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" -/// Returns a vector containing the integer part each element of `self`. This means numbers are -/// always truncated towards zero. +/// Component-wise clamping of values, similar to [`f64::clamp`]. +/// Each element in `min` must be less-or-equal to the corresponding element in `max`. +/// # Panics +/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::DVec3; + fn clamp( + self, + #[proxy] + min: bevy::math::DVec4, + #[proxy] + max: bevy::math::DVec4, + ) -> bevy::math::DVec4; "#, r#" -/// Returns a vector containing the fractional part of the vector, e.g. `self - -/// self.floor()`. -/// Note that this is fast but not precise for large numbers. +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. - #[lua(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::DVec3; + #[lua(kind = "Method")] + fn min_element(self) -> f64; "#, r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of -/// `self`. +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. - #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::DVec3; + #[lua(kind = "Method")] + fn max_element(self) -> f64; "#, r#" -/// Returns a vector containing each element of `self` raised to the power of `n`. +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. - #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f64) -> bevy::math::DVec3; + #[lua(kind = "Method")] + fn element_sum(self) -> f64; "#, r#" -/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. - #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::DVec3; + #[lua(kind = "Method")] + fn element_product(self) -> f64; "#, r#" -/// Performs a linear interpolation between `self` and `rhs` based on the value `s`. -/// When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result -/// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly -/// extrapolated. +/// Returns a vector mask containing the result of a `==` comparison for each element of +/// `self` and `rhs`. +/// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all +/// elements. #[lua(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::DVec3, s: f64) -> bevy::math::DVec3; + fn cmpeq(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; "#, r#" -/// Returns true if the absolute difference of all elements between `self` and `rhs` is -/// less than or equal to `max_abs_diff`. -/// This can be used to compare if two vectors contain similar elements. It works best when -/// comparing with a known value. The `max_abs_diff` that should be used used depends on -/// the values being compared against. -/// For more see -/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). +/// Returns a vector mask containing the result of a `!=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all +/// elements. - #[lua(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec3, max_abs_diff: f64) -> bool; + #[lua(kind = "Method", output(proxy))] + fn cmpne(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; "#, r#" -/// 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. +/// Returns a vector mask containing the result of a `>=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all +/// elements. #[lua(kind = "Method", output(proxy))] - fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec3; + fn cmpge(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector mask containing the result of a `>` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all +/// elements. #[lua(kind = "Method", output(proxy))] - fn clamp_length_max(self, max: f64) -> bevy::math::DVec3; + fn cmpgt(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector mask containing the result of a `<=` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all +/// elements. #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f64) -> bevy::math::DVec3; + fn cmple(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; "#, r#" -/// Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding -/// error, yielding a more accurate result than an unfused multiply-add. -/// Using `mul_add` *may* be more performant than an unfused multiply-add if the target -/// architecture has a dedicated fma CPU instruction. However, this is not always true, -/// and will be heavily dependant on designing algorithms with specific target hardware in -/// mind. +/// Returns a vector mask containing the result of a `<` comparison for each element of +/// `self` and `rhs`. +/// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all +/// elements. #[lua(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::DVec3, - #[proxy] - b: bevy::math::DVec3, - ) -> bevy::math::DVec3; + fn cmplt(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; "#, r#" -/// Returns the angle (in radians) between two vectors. -/// The inputs do not need to be unit vectors however they must be non-zero. +/// Returns a vector containing the absolute value of each element of `self`. - #[lua(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::DVec3) -> f64; + #[lua(kind = "Method", output(proxy))] + fn abs(self) -> bevy::math::DVec4; "#, r#" -/// Returns some vector that is orthogonal to the given one. -/// The input vector must be finite and non-zero. -/// The output vector is not necessarily unit length. For that use -/// [`Self::any_orthonormal_vector()`] instead. +/// Returns a vector with elements representing the sign of `self`. +/// - `1.0` if the number is positive, `+0.0` or `INFINITY` +/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` +/// - `NAN` if the number is `NAN` #[lua(kind = "Method", output(proxy))] - fn any_orthogonal_vector(&self) -> bevy::math::DVec3; + fn signum(self) -> bevy::math::DVec4; "#, r#" -/// Returns any unit vector that is orthogonal to the given one. -/// The input vector must be unit length. -/// # Panics -/// Will panic if `self` is not normalized when `glam_assert` is enabled. +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. #[lua(kind = "Method", output(proxy))] - fn any_orthonormal_vector(&self) -> bevy::math::DVec3; + fn copysign(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" -/// Casts all elements of `self` to `f32`. +/// Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. +/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes +/// into the first lowest bit, element `y` into the second, etc. - #[lua(kind = "Method", output(proxy))] - fn as_vec3(&self) -> bevy::math::Vec3; + #[lua(kind = "Method")] + fn is_negative_bitmask(self) -> u32; "#, r#" -/// Casts all elements of `self` to `f32`. +/// Returns `true` if, and only if, all elements are finite. If any element is either +/// `NaN`, positive or negative infinity, this will return `false`. - #[lua(kind = "Method", output(proxy))] - fn as_vec3a(&self) -> bevy::math::Vec3A; + #[lua(kind = "Method")] + fn is_finite(self) -> bool; "#, r#" -/// Casts all elements of `self` to `i32`. +/// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; + #[lua(kind = "Method")] + fn is_nan(self) -> bool; "#, r#" -/// Casts all elements of `self` to `u32`. +/// 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()]`. #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; + fn is_nan_mask(self) -> bevy::math::BVec4; "#, r#" -/// Casts all elements of `self` to `i64`. +/// Computes the length of `self`. - #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; + #[lua(kind = "Method")] + fn length(self) -> f64; "#, r#" -/// Casts all elements of `self` to `u64`. +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. - #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; + #[lua(kind = "Method")] + fn length_squared(self) -> f64; "#, r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. - #[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; + #[lua(kind = "Method")] + fn length_recip(self) -> f64; "#, r#" +/// Computes the Euclidean distance between two points in space. - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(kind = "Method")] + fn distance(self, #[proxy] rhs: bevy::math::DVec4) -> f64; "#, 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]) -} +/// Compute the squared euclidean distance between two points in space. + + #[lua(kind = "Method")] + fn distance_squared(self, #[proxy] rhs: bevy::math::DVec4) -> f64; + "#, 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#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. - #[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; + #[lua(kind = "Method", output(proxy))] + fn div_euclid(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f64::rem_euclid - #[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::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; - -"#, - r#" -/// Creates a new vector. - - #[lua(kind = "Function", output(proxy))] - fn new(x: f64, y: f64, z: f64, w: f64) -> bevy::math::DVec4; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: f64) -> bevy::math::DVec4; - -"#, - 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::DVec4, - #[proxy] - if_false: bevy::math::DVec4, - ) -> bevy::math::DVec4; + #[lua(kind = "Method", output(proxy))] + fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" -/// Creates a new vector from an array. +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must _not_ be 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. - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f64; 4]) -> bevy::math::DVec4; + #[lua(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::DVec4; "#, r#" -/// `[x, y, z, w]` +/// Returns `self` normalized to length 1.0 if possible, else returns a +/// fallback value. +/// In particular, if the input is zero (or very close to zero), or non-finite, +/// the result of this operation will be the fallback value. +/// See also [`Self::try_normalize()`]. - #[lua(kind = "Method")] - fn to_array(&self) -> [f64; 4]; + #[lua(kind = "Method", output(proxy))] + fn normalize_or(self, #[proxy] fallback: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" -/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. -/// Truncation to [`DVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. +/// Returns `self` normalized to length 1.0 if possible, else returns zero. +/// In particular, if the input is zero (or very close to zero), or non-finite, +/// the result of this operation will be zero. +/// See also [`Self::try_normalize()`]. #[lua(kind = "Method", output(proxy))] - fn truncate(self) -> bevy::math::DVec3; + fn normalize_or_zero(self) -> bevy::math::DVec4; "#, r#" -/// Computes the dot product of `self` and `rhs`. +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::DVec4) -> f64; + fn is_normalized(self) -> bool; "#, r#" -/// Returns a vector where every component is the dot product of `self` and `rhs`. +/// Returns the vector projection of `self` onto `rhs`. +/// `rhs` must be of non-zero length. +/// # Panics +/// Will panic if `rhs` is zero length when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn dot_into_vec(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn project_onto(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" -/// Returns a vector containing the minimum values for each element of `self` and `rhs`. -/// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. +/// Returns the vector rejection of `self` from `rhs`. +/// The vector rejection is the vector perpendicular to the projection of `self` onto +/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. +/// `rhs` must be of non-zero length. +/// # Panics +/// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn min(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn reject_from(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" -/// Returns a vector containing the maximum values for each element of `self` and `rhs`. -/// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. +/// Returns the vector projection of `self` onto `rhs`. +/// `rhs` must be normalized. +/// # Panics +/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn max(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn project_onto_normalized( + self, + #[proxy] + rhs: bevy::math::DVec4, + ) -> bevy::math::DVec4; "#, r#" -/// Component-wise clamping of values, similar to [`f64::clamp`]. -/// Each element in `min` must be less-or-equal to the corresponding element in `max`. +/// Returns the vector rejection of `self` from `rhs`. +/// The vector rejection is the vector perpendicular to the projection of `self` onto +/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. +/// `rhs` must be normalized. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn clamp( + fn reject_from_normalized( self, #[proxy] - min: bevy::math::DVec4, - #[proxy] - max: bevy::math::DVec4, + rhs: bevy::math::DVec4, ) -> bevy::math::DVec4; "#, r#" -/// Returns the horizontal minimum of `self`. -/// In other words this computes `min(x, y, ..)`. +/// Returns a vector containing the nearest integer to a number for each element of `self`. +/// Round half-way cases away from 0.0. - #[lua(kind = "Method")] - fn min_element(self) -> f64; + #[lua(kind = "Method", output(proxy))] + fn round(self) -> bevy::math::DVec4; "#, r#" -/// Returns the horizontal maximum of `self`. -/// In other words this computes `max(x, y, ..)`. +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. - #[lua(kind = "Method")] - fn max_element(self) -> f64; + #[lua(kind = "Method", output(proxy))] + fn floor(self) -> bevy::math::DVec4; "#, r#" -/// Returns a vector mask containing the result of a `==` comparison for each element of -/// `self` and `rhs`. -/// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all -/// elements. +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. #[lua(kind = "Method", output(proxy))] - fn cmpeq(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + fn ceil(self) -> bevy::math::DVec4; "#, r#" -/// Returns a vector mask containing the result of a `!=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all -/// elements. +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. #[lua(kind = "Method", output(proxy))] - fn cmpne(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + fn trunc(self) -> bevy::math::DVec4; "#, r#" -/// Returns a vector mask containing the result of a `>=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all -/// elements. +/// Returns a vector containing the fractional part of the vector as `self - self.trunc()`. +/// Note that this differs from the GLSL implementation of `fract` which returns +/// `self - self.floor()`. +/// Note that this is fast but not precise for large numbers. #[lua(kind = "Method", output(proxy))] - fn cmpge(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + fn fract(self) -> bevy::math::DVec4; "#, r#" -/// Returns a vector mask containing the result of a `>` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all -/// elements. +/// Returns a vector containing the fractional part of the vector as `self - self.floor()`. +/// Note that this differs from the Rust implementation of `fract` which returns +/// `self - self.trunc()`. +/// Note that this is fast but not precise for large numbers. #[lua(kind = "Method", output(proxy))] - fn cmpgt(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + fn fract_gl(self) -> bevy::math::DVec4; "#, r#" -/// Returns a vector mask containing the result of a `<=` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all -/// elements. +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. #[lua(kind = "Method", output(proxy))] - fn cmple(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + fn exp(self) -> bevy::math::DVec4; "#, r#" -/// Returns a vector mask containing the result of a `<` comparison for each element of -/// `self` and `rhs`. -/// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all -/// elements. +/// Returns a vector containing each element of `self` raised to the power of `n`. #[lua(kind = "Method", output(proxy))] - fn cmplt(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::BVec4; + fn powf(self, n: f64) -> bevy::math::DVec4; "#, r#" -/// Returns a vector containing the absolute value of each element of `self`. +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. #[lua(kind = "Method", output(proxy))] - fn abs(self) -> bevy::math::DVec4; + fn recip(self) -> bevy::math::DVec4; "#, r#" -/// Returns a vector with elements representing the sign of `self`. -/// - `1.0` if the number is positive, `+0.0` or `INFINITY` -/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` -/// - `NAN` if the number is `NAN` +/// Performs a linear interpolation between `self` and `rhs` based on the value `s`. +/// When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result +/// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly +/// extrapolated. #[lua(kind = "Method", output(proxy))] - fn signum(self) -> bevy::math::DVec4; + fn lerp(self, #[proxy] rhs: bevy::math::DVec4, s: f64) -> bevy::math::DVec4; "#, r#" -/// Returns a vector with signs of `rhs` and the magnitudes of `self`. +/// Moves towards `rhs` based on the value `d`. +/// When `d` is `0.0`, the result will be equal to `self`. When `d` is equal to +/// `self.distance(rhs)`, the result will be equal to `rhs`. Will not go past `rhs`. #[lua(kind = "Method", output(proxy))] - fn copysign(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn move_towards(&self, #[proxy] rhs: bevy::math::DVec4, d: f64) -> bevy::math::DVec4; "#, r#" -/// Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. -/// A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes -/// into the first lowest bit, element `y` into the second, etc. +/// Calculates the midpoint between `self` and `rhs`. +/// The midpoint is the average of, or halfway point between, two vectors. +/// `a.midpoint(b)` should yield the same result as `a.lerp(b, 0.5)` +/// while being slightly cheaper to compute. - #[lua(kind = "Method")] - fn is_negative_bitmask(self) -> u32; + #[lua(kind = "Method", output(proxy))] + fn midpoint(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" -/// Returns `true` if, and only if, all elements are finite. If any element is either -/// `NaN`, positive or negative infinity, this will return `false`. +/// Returns true if the absolute difference of all elements between `self` and `rhs` is +/// less than or equal to `max_abs_diff`. +/// This can be used to compare if two vectors contain similar elements. It works best when +/// comparing with a known value. The `max_abs_diff` that should be used used depends on +/// the values being compared against. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). #[lua(kind = "Method")] - fn is_finite(self) -> bool; + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec4, max_abs_diff: f64) -> bool; "#, r#" -/// Returns `true` if any elements are `NaN`. +/// 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. - #[lua(kind = "Method")] - fn is_nan(self) -> bool; + #[lua(kind = "Method", output(proxy))] + fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec4; "#, 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()]`. +/// Returns a vector with a length no more than `max` #[lua(kind = "Method", output(proxy))] - fn is_nan_mask(self) -> bevy::math::BVec4; + fn clamp_length_max(self, max: f64) -> bevy::math::DVec4; "#, r#" -/// Computes the length of `self`. +/// Returns a vector with a length no less than `min` - #[lua(kind = "Method")] - fn length(self) -> f64; + #[lua(kind = "Method", output(proxy))] + fn clamp_length_min(self, min: f64) -> bevy::math::DVec4; "#, r#" -/// Computes the squared length of `self`. -/// This is faster than `length()` as it avoids a square root operation. +/// Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding +/// error, yielding a more accurate result than an unfused multiply-add. +/// Using `mul_add` *may* be more performant than an unfused multiply-add if the target +/// architecture has a dedicated fma CPU instruction. However, this is not always true, +/// and will be heavily dependant on designing algorithms with specific target hardware in +/// mind. - #[lua(kind = "Method")] - fn length_squared(self) -> f64; + #[lua(kind = "Method", output(proxy))] + fn mul_add( + self, + #[proxy] + a: bevy::math::DVec4, + #[proxy] + b: bevy::math::DVec4, + ) -> bevy::math::DVec4; "#, r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. +/// Casts all elements of `self` to `f32`. - #[lua(kind = "Method")] - fn length_recip(self) -> f64; + #[lua(kind = "Method", output(proxy))] + fn as_vec4(&self) -> bevy::math::Vec4; "#, r#" -/// Computes the Euclidean distance between two points in space. +/// Casts all elements of `self` to `i32`. - #[lua(kind = "Method")] - fn distance(self, #[proxy] rhs: bevy::math::DVec4) -> f64; + #[lua(kind = "Method", output(proxy))] + fn as_ivec4(&self) -> bevy::math::IVec4; "#, r#" -/// Compute the squared euclidean distance between two points in space. +/// Casts all elements of `self` to `u32`. - #[lua(kind = "Method")] - fn distance_squared(self, #[proxy] rhs: bevy::math::DVec4) -> f64; + #[lua(kind = "Method", output(proxy))] + fn as_uvec4(&self) -> bevy::math::UVec4; "#, r#" -/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. +/// Casts all elements of `self` to `i64`. #[lua(kind = "Method", output(proxy))] - fn div_euclid(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn as_i64vec4(&self) -> bevy::math::I64Vec4; "#, r#" -/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. -/// [Euclidean division]: f64::rem_euclid +/// Casts all elements of `self` to `u64`. #[lua(kind = "Method", output(proxy))] - fn rem_euclid(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn as_u64vec4(&self) -> bevy::math::U64Vec4; "#, r#" -/// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be 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. - #[lua(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::DVec4; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f64) -> bevy::math::DVec4; "#, r#" -/// Returns `self` normalized to length 1.0 if possible, else returns zero. -/// In particular, if the input is zero (or very close to zero), or non-finite, -/// the result of this operation will be zero. -/// See also [`Self::try_normalize()`]. - - #[lua(kind = "Method", output(proxy))] - fn normalize_or_zero(self) -> bevy::math::DVec4; - +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} "#, r#" -/// Returns whether `self` is length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - - #[lua(kind = "Method")] - fn is_normalized(self) -> bool; - +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} "#, r#" -/// Returns the vector projection of `self` onto `rhs`. -/// `rhs` must be of non-zero length. -/// # Panics -/// Will panic if `rhs` is zero length when `glam_assert` is enabled. +#[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(kind = "Method", output(proxy))] - fn project_onto(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Mat2; "#, r#" -/// Returns the vector rejection of `self` from `rhs`. -/// The vector rejection is the vector perpendicular to the projection of `self` onto -/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. -/// `rhs` must be of non-zero length. -/// # Panics -/// Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] - fn reject_from(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + #[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#" -/// Returns the vector projection of `self` onto `rhs`. -/// `rhs` must be normalized. -/// # Panics -/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] - fn project_onto_normalized( - self, - #[proxy] - rhs: bevy::math::DVec4, - ) -> bevy::math::DVec4; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Mat2; "#, r#" -/// Returns the vector rejection of `self` from `rhs`. -/// The vector rejection is the vector perpendicular to the projection of `self` onto -/// `rhs`, in rhs words the result of `self - self.project_onto(rhs)`. -/// `rhs` must be normalized. -/// # Panics -/// Will panic if `rhs` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] - fn reject_from_normalized( - self, - #[proxy] - rhs: bevy::math::DVec4, - ) -> bevy::math::DVec4; + #[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#" -/// Returns a vector containing the nearest integer to a number for each element of `self`. -/// Round half-way cases away from 0.0. - #[lua(kind = "Method", output(proxy))] - fn round(self) -> bevy::math::DVec4; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Mat2) -> bool; "#, r#" -/// Returns a vector containing the largest integer less than or equal to a number for each -/// element of `self`. - #[lua(kind = "Method", output(proxy))] - fn floor(self) -> bevy::math::DVec4; + #[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#" -/// Returns a vector containing the smallest integer greater than or equal to a number for -/// each element of `self`. - #[lua(kind = "Method", output(proxy))] - fn ceil(self) -> bevy::math::DVec4; + #[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#" -/// Returns a vector containing the integer part each element of `self`. This means numbers are -/// always truncated towards zero. - #[lua(kind = "Method", output(proxy))] - fn trunc(self) -> bevy::math::DVec4; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Mat2; "#, r#" -/// Returns a vector containing the fractional part of the vector, e.g. `self - -/// self.floor()`. -/// Note that this is fast but not precise for large numbers. - #[lua(kind = "Method", output(proxy))] - fn fract(self) -> bevy::math::DVec4; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Mat2; "#, r#" -/// Returns a vector containing `e^self` (the exponential function) for each element of -/// `self`. +/// Creates a 2x2 matrix from two column vectors. - #[lua(kind = "Method", output(proxy))] - fn exp(self) -> bevy::math::DVec4; + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::Vec2, + #[proxy] + y_axis: bevy::math::Vec2, + ) -> bevy::math::Mat2; "#, r#" -/// Returns a vector containing each element of `self` raised to the power of `n`. +/// Creates a `[f32; 4]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method", output(proxy))] - fn powf(self, n: f64) -> bevy::math::DVec4; + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f32; 4]; "#, r#" -/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. +/// Creates a `[[f32; 2]; 2]` 2D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. - #[lua(kind = "Method", output(proxy))] - fn recip(self) -> bevy::math::DVec4; + #[lua(kind = "Method")] + fn to_cols_array_2d(&self) -> [[f32; 2]; 2]; "#, r#" -/// Performs a linear interpolation between `self` and `rhs` based on the value `s`. -/// When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result -/// will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly -/// extrapolated. +/// Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. - #[lua(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] rhs: bevy::math::DVec4, s: f64) -> bevy::math::DVec4; - -"#, - r#" -/// Returns true if the absolute difference of all elements between `self` and `rhs` is -/// less than or equal to `max_abs_diff`. -/// This can be used to compare if two vectors contain similar elements. It works best when -/// comparing with a known value. The `max_abs_diff` that should be used used depends on -/// the values being compared against. -/// For more see -/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - - #[lua(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DVec4, max_abs_diff: f64) -> bool; - -"#, - r#" -/// 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. - - #[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` - - #[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` - - #[lua(kind = "Method", output(proxy))] - fn clamp_length_min(self, min: f64) -> bevy::math::DVec4; - -"#, - r#" -/// Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding -/// error, yielding a more accurate result than an unfused multiply-add. -/// Using `mul_add` *may* be more performant than an unfused multiply-add if the target -/// architecture has a dedicated fma CPU instruction. However, this is not always true, -/// and will be heavily dependant on designing algorithms with specific target hardware in -/// mind. - - #[lua(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::DVec4, - #[proxy] - b: bevy::math::DVec4, - ) -> bevy::math::DVec4; - -"#, - r#" -/// Casts all elements of `self` to `f32`. - - #[lua(kind = "Method", output(proxy))] - fn as_vec4(&self) -> bevy::math::Vec4; - -"#, - r#" -/// Casts all elements of `self` to `i32`. - - #[lua(kind = "Method", output(proxy))] - fn as_ivec4(&self) -> bevy::math::IVec4; - -"#, - r#" -/// Casts all elements of `self` to `u32`. - - #[lua(kind = "Method", output(proxy))] - fn as_uvec4(&self) -> bevy::math::UVec4; - -"#, - r#" -/// Casts all elements of `self` to `i64`. - - #[lua(kind = "Method", output(proxy))] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; - -"#, - r#" -/// Casts all elements of `self` to `u64`. - - #[lua(kind = "Method", output(proxy))] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f64) -> 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::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::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(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; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DVec4; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::DVec4) -> bool; - -"#, - 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(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#" -/// Creates a 2x2 matrix from two column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::Vec2, - #[proxy] - y_axis: bevy::math::Vec2, - ) -> bevy::math::Mat2; - -"#, - r#" -/// Creates a `[f32; 4]` array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f32; 4]; - -"#, - r#" -/// Creates a `[[f32; 2]; 2]` 2D array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f32; 2]; 2]; - -"#, - r#" -/// Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. - - #[lua(kind = "Function", output(proxy))] - fn from_diagonal(#[proxy] diagonal: bevy::math::Vec2) -> bevy::math::Mat2; + #[lua(kind = "Function", output(proxy))] + fn from_diagonal(#[proxy] diagonal: bevy::math::Vec2) -> bevy::math::Mat2; "#, r#" @@ -15756,8 +14383,15 @@ struct DVec4 { "#, r#" -/// Returns true if the absolute difference of all elements between `self` and `rhs` -/// is less than or equal to `max_abs_diff`. +/// Divides a 2x2 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn div_scalar(&self, rhs: f32) -> bevy::math::Mat2; + +"#, + r#" +/// Returns true if the absolute difference of all elements between `self` and `rhs` +/// is less than or equal to `max_abs_diff`. /// This can be used to compare if two matrices contain similar elements. It works best /// when comparing with a known value. The `max_abs_diff` that should be used used /// depends on the values being compared against. @@ -15769,102 +14403,16 @@ struct DVec4 { "#, r#" +/// Takes the absolute value of each element in `self` #[lua(kind = "Method", output(proxy))] - fn as_dmat2(&self) -> bevy::math::DMat2; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Mat2; - -"#, - 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::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> 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#" - - #[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 = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Mat2) -> bool; + fn abs(&self) -> bevy::math::Mat2; "#, 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; + #[lua(kind = "Method", output(proxy))] + fn as_dmat2(&self) -> bevy::math::DMat2; "#, r#" @@ -15905,42 +14453,6 @@ struct Mat2(); remote = "bevy::math::Mat3", functions[r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(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::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - #[lua( as_trait = "std::ops::Mul", kind = "MetaFunction", @@ -15950,63 +14462,6 @@ struct Mat2(); )] fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> 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::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 = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&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::Mat3) -> bevy::math::Mat3; - "#, r#" /// Creates a 3x3 matrix from three column vectors. @@ -16281,6 +14736,13 @@ struct Mat2(); #[lua(kind = "Method", output(proxy))] fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat3; +"#, + r#" +/// Divides a 3x3 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn div_scalar(&self, rhs: f32) -> bevy::math::Mat3; + "#, r#" /// Returns true if the absolute difference of all elements between `self` and `rhs` @@ -16294,6 +14756,13 @@ struct Mat2(); #[lua(kind = "Method")] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat3, max_abs_diff: f32) -> bool; +"#, + r#" +/// Takes the absolute value of each element in `self` + + #[lua(kind = "Method", output(proxy))] + fn abs(&self) -> bevy::math::Mat3; + "#, r#" @@ -16310,54 +14779,183 @@ struct Mat2(); composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Mat3; + "#, r#" -#[lua(kind = "MetaMethod", raw, metamethod="Index")] -fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(LuaVec3::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 Mat3 { - #[lua(output(proxy))] - x_axis: bevy::math::Vec3, - #[lua(output(proxy))] - y_axis: bevy::math::Vec3, - #[lua(output(proxy))] - z_axis: bevy::math::Vec3, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Mat3A", - functions[r#" -/// Creates a 3x3 matrix from three column vectors. + + #[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::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::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::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#" + + #[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::Mat3) -> 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(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(LuaVec3::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 Mat3 { + #[lua(output(proxy))] + x_axis: bevy::math::Vec3, + #[lua(output(proxy))] + y_axis: bevy::math::Vec3, + #[lua(output(proxy))] + z_axis: bevy::math::Vec3, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Mat3A", + functions[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::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3A; + +"#, + r#" +/// Creates a 3x3 matrix from three column vectors. #[lua(kind = "Function", output(proxy))] fn from_cols( @@ -16629,6 +15227,13 @@ struct Mat3 { #[lua(kind = "Method", output(proxy))] fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat3A; +"#, + r#" +/// Divides a 3x3 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn div_scalar(&self, rhs: f32) -> bevy::math::Mat3A; + "#, r#" /// Returns true if the absolute difference of all elements between `self` and `rhs` @@ -16644,79 +15249,73 @@ struct Mat3 { "#, r#" +/// Takes the absolute value of each element in `self` #[lua(kind = "Method", output(proxy))] - fn as_dmat3(&self) -> bevy::math::DMat3; + fn abs(&self) -> bevy::math::Mat3A; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Mat3A; + #[lua(kind = "Method", output(proxy))] + fn as_dmat3(&self) -> bevy::math::DMat3; "#, 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::Vec3) -> bevy::math::Vec3; + fn eq(&self, #[proxy] rhs: &glam::Mat3A) -> bool; "#, 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::Mat3A) -> bevy::math::Mat3A; + fn sub(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, 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::Affine2) -> bevy::math::Mat3A; + fn clone(&self) -> bevy::math::Mat3A; "#, 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::Vec3A) -> bevy::math::Vec3A; + fn div(self, rhs: f32) -> bevy::math::Mat3A; "#, 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::Mat3A) -> bevy::math::Mat3A; + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" @@ -16734,36 +15333,37 @@ struct Mat3 { 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::Mat3A; + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, 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::Mat3A) -> bevy::math::Mat3A; + fn add(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, 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::Mat3A) -> bool; + fn neg(self) -> bevy::math::Mat3A; "#, r#" @@ -16812,27 +15412,132 @@ struct Mat3A { 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, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn div(self, rhs: f32) -> bevy::math::Mat4; "#, r#" -/// Creates a 4x4 matrix from four column vectors. - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::Vec4, - #[proxy] - y_axis: bevy::math::Vec4, - #[proxy] - z_axis: bevy::math::Vec4, - #[proxy] + #[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", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Mat4) -> bool; + +"#, + 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", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> 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::Mat4) -> bevy::math::Mat4; + +"#, + r#" +/// Creates a 4x4 matrix from four column vectors. + + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::Vec4, + #[proxy] + y_axis: bevy::math::Vec4, + #[proxy] + z_axis: bevy::math::Vec4, + #[proxy] w_axis: bevy::math::Vec4, ) -> bevy::math::Mat4; @@ -17283,7 +15988,7 @@ struct Mat3A { /// This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is /// `1.0`. /// This method assumes that `self` contains a valid affine transform. It does not perform -/// a persective divide, if `self` contains a perspective transform, or if you are unsure, +/// a perspective divide, if `self` contains a perspective transform, or if you are unsure, /// the [`Self::project_point3()`] method should be used instead. /// # Panics /// Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. @@ -17354,6 +16059,13 @@ struct Mat3A { #[lua(kind = "Method", output(proxy))] fn mul_scalar(&self, rhs: f32) -> bevy::math::Mat4; +"#, + r#" +/// Divides a 4x4 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn div_scalar(&self, rhs: f32) -> bevy::math::Mat4; + "#, r#" /// Returns true if the absolute difference of all elements between `self` and `rhs` @@ -17367,6 +16079,13 @@ struct Mat3A { #[lua(kind = "Method")] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Mat4, max_abs_diff: f32) -> bool; +"#, + r#" +/// Takes the absolute value of each element in `self` + + #[lua(kind = "Method", output(proxy))] + fn abs(&self) -> bevy::math::Mat4; + "#, r#" @@ -17375,38 +16094,83 @@ 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::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::Mat4) -> bevy::math::Mat4; + fn eq(&self, #[proxy] rhs: &glam::DMat2) -> bool; "#, 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::Mat4) -> bevy::math::Mat4; + fn div(self, rhs: f64) -> bevy::math::DMat2; "#, 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::Mat4) -> bool; + fn neg(self) -> bevy::math::DMat2; "#, r#" @@ -17418,7 +16182,7 @@ struct Mat3A { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Mat4; + fn mul(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; "#, r#" @@ -17430,7 +16194,31 @@ struct Mat3A { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + fn mul(self, rhs: f64) -> 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::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; "#, r#" @@ -17442,7 +16230,7 @@ struct Mat3A { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Mat4; + fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" @@ -17452,85 +16240,28 @@ struct Mat3A { kind = "Method", output(proxy), )] - fn clone(&self) -> bevy::math::Mat4; + fn clone(&self) -> bevy::math::DMat2; "#, r#" +/// Creates a 2x2 matrix from two column vectors. - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Mat4; + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::DVec2, + #[proxy] + y_axis: bevy::math::DVec2, + ) -> bevy::math::DMat2; "#, 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#" -/// 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, - ) -> bevy::math::DMat2; - -"#, - r#" -/// Creates a `[f64; 4]` array storing data in column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f64; 4]; - +/// Creates a `[f64; 4]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f64; 4]; + "#, r#" /// Creates a `[[f64; 2]; 2]` 2D array storing data in column major order. @@ -17664,6 +16395,13 @@ struct Mat4 { #[lua(kind = "Method", output(proxy))] fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat2; +"#, + r#" +/// Divides a 2x2 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn div_scalar(&self, rhs: f64) -> bevy::math::DMat2; + "#, r#" /// Returns true if the absolute difference of all elements between `self` and `rhs` @@ -17679,102 +16417,16 @@ struct Mat4 { "#, r#" +/// Takes the absolute value of each element in `self` #[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, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - 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 = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> 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::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::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DMat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DMat2; + fn abs(&self) -> bevy::math::DMat2; "#, 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; + #[lua(kind = "Method", output(proxy))] + fn as_mat2(&self) -> bevy::math::Mat2; "#, r#" @@ -17821,70 +16473,71 @@ struct DMat2 { functions[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::DMat3; + fn sub(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; "#, 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::DMat3; + fn neg(self) -> bevy::math::DMat3; "#, 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::DMat3; + fn add(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; "#, r#" #[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::DMat3) -> bevy::math::DMat3; + fn clone(&self) -> bevy::math::DMat3; "#, 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::DVec3) -> bevy::math::DVec3; + fn div(self, rhs: f64) -> bevy::math::DMat3; "#, 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::DMat3) -> bool; + fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DMat3; "#, r#" @@ -18157,6 +16810,13 @@ struct DMat2 { #[lua(kind = "Method", output(proxy))] fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat3; +"#, + r#" +/// Divides a 3x3 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn div_scalar(&self, rhs: f64) -> bevy::math::DMat3; + "#, r#" /// Returns true if the absolute difference of all elements between `self` and `rhs` @@ -18170,6 +16830,13 @@ struct DMat2 { #[lua(kind = "Method")] fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DMat3, max_abs_diff: f64) -> bool; +"#, + r#" +/// Takes the absolute value of each element in `self` + + #[lua(kind = "Method", output(proxy))] + fn abs(&self) -> bevy::math::DMat3; + "#, r#" @@ -18180,13 +16847,13 @@ struct DMat2 { 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::DMat3) -> bevy::math::DMat3; + fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" @@ -18198,7 +16865,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::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#" @@ -18210,7 +16888,7 @@ struct DMat2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + fn mul(self, rhs: f64) -> bevy::math::DMat3; "#, r#" @@ -18258,18 +16936,6 @@ struct DMat3 { remote = "bevy::math::DMat4", functions[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::cmp::PartialEq", kind = "MetaFunction", @@ -18294,25 +16960,47 @@ struct DMat3 { 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::DMat4) -> bevy::math::DMat4; + fn clone(&self) -> bevy::math::DMat4; "#, 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::DMat4; + fn sub(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::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#" @@ -18330,11 +17018,13 @@ struct DMat3 { 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::DMat4; + fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DMat4; "#, r#" @@ -18793,7 +17483,7 @@ struct DMat3 { /// This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is /// `1.0`. /// This method assumes that `self` contains a valid affine transform. It does not perform -/// a persective divide, if `self` contains a perspective transform, or if you are unsure, +/// a perspective divide, if `self` contains a perspective transform, or if you are unsure, /// the [`Self::project_point3()`] method should be used instead. /// # Panics /// Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. @@ -18848,6 +17538,13 @@ struct DMat3 { #[lua(kind = "Method", output(proxy))] fn mul_scalar(&self, rhs: f64) -> bevy::math::DMat4; +"#, + r#" +/// Divides a 4x4 matrix by a scalar. + + #[lua(kind = "Method", output(proxy))] + fn div_scalar(&self, rhs: f64) -> bevy::math::DMat4; + "#, r#" /// Returns true if the absolute difference of all elements between `self` and `rhs` @@ -18858,2636 +17555,283 @@ struct DMat3 { /// For more see /// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DMat4, max_abs_diff: f64) -> bool; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_mat4(&self) -> 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::DAffine3) -> bevy::math::DMat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; - -"#, - 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(LuaDVec4::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 DMat4 { - #[lua(output(proxy))] - x_axis: bevy::math::DVec4, - #[lua(output(proxy))] - y_axis: bevy::math::DVec4, - #[lua(output(proxy))] - z_axis: bevy::math::DVec4, - #[lua(output(proxy))] - w_axis: bevy::math::DVec4, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Affine2", - functions[r#" -/// Creates an affine transform from three column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::Vec2, - #[proxy] - y_axis: bevy::math::Vec2, - #[proxy] - z_axis: bevy::math::Vec2, - ) -> bevy::math::Affine2; - -"#, - r#" -/// Creates a `[f32; 6]` array storing data in column major order. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f32; 6]; - -"#, - r#" -/// Creates a `[[f32; 2]; 3]` 2D array storing data in -/// column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f32; 2]; 3]; - -"#, - r#" -/// Creates an affine transform that changes scale. -/// Note that if any scale is zero the transform will be non-invertible. - - #[lua(kind = "Function", output(proxy))] - fn from_scale(#[proxy] scale: bevy::math::Vec2) -> bevy::math::Affine2; - -"#, - r#" -/// Creates an affine transform from the given rotation `angle`. - - #[lua(kind = "Function", output(proxy))] - fn from_angle(angle: f32) -> bevy::math::Affine2; - -"#, - r#" -/// Creates an affine transformation from the given 2D `translation`. - - #[lua(kind = "Function", output(proxy))] - fn from_translation(#[proxy] translation: bevy::math::Vec2) -> bevy::math::Affine2; - -"#, - r#" -/// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) - - #[lua(kind = "Function", output(proxy))] - fn from_mat2(#[proxy] matrix2: bevy::math::Mat2) -> bevy::math::Affine2; - -"#, - r#" -/// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) and a -/// translation vector. -/// Equivalent to -/// `Affine2::from_translation(translation) * Affine2::from_mat2(mat2)` - - #[lua(kind = "Function", output(proxy))] - fn from_mat2_translation( - #[proxy] - matrix2: bevy::math::Mat2, - #[proxy] - translation: bevy::math::Vec2, - ) -> bevy::math::Affine2; - -"#, - r#" -/// Creates an affine transform from the given 2D `scale`, rotation `angle` (in radians) and -/// `translation`. -/// Equivalent to `Affine2::from_translation(translation) * -/// Affine2::from_angle(angle) * Affine2::from_scale(scale)` - - #[lua(kind = "Function", output(proxy))] - fn from_scale_angle_translation( - #[proxy] - scale: bevy::math::Vec2, - angle: f32, - #[proxy] - translation: bevy::math::Vec2, - ) -> bevy::math::Affine2; - -"#, - r#" -/// Creates an affine transform from the given 2D rotation `angle` (in radians) and -/// `translation`. -/// Equivalent to `Affine2::from_translation(translation) * Affine2::from_angle(angle)` - - #[lua(kind = "Function", output(proxy))] - fn from_angle_translation( - angle: f32, - #[proxy] - translation: bevy::math::Vec2, - ) -> bevy::math::Affine2; - -"#, - r#" -/// The given `Mat3` must be an affine transform, - - #[lua(kind = "Function", output(proxy))] - fn from_mat3(#[proxy] m: bevy::math::Mat3) -> bevy::math::Affine2; - -"#, - r#" -/// The given [`Mat3A`] must be an affine transform, - - #[lua(kind = "Function", output(proxy))] - fn from_mat3a(#[proxy] m: bevy::math::Mat3A) -> bevy::math::Affine2; - -"#, - r#" -/// Transforms the given 2D point, applying shear, scale, rotation and translation. - - #[lua(kind = "Method", output(proxy))] - fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" -/// Transforms the given 2D vector, applying shear, scale and rotation (but NOT -/// translation). -/// To also apply translation, use [`Self::transform_point2()`] instead. - - #[lua(kind = "Method", output(proxy))] - fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" -/// Returns `true` if, and only if, all elements are finite. -/// If any element is either `NaN`, positive or negative infinity, this will return -/// `false`. - - #[lua(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - fn is_nan(&self) -> bool; - -"#, - r#" -/// Returns true if the absolute difference of all elements between `self` and `rhs` -/// is less than or equal to `max_abs_diff`. -/// This can be used to compare if two 3x4 matrices contain similar elements. It works -/// best when comparing with a known value. The `max_abs_diff` that should be used used -/// depends on the values being compared against. -/// For more see -/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - - #[lua(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Affine2, max_abs_diff: f32) -> bool; - -"#, - r#" -/// Return the inverse of this transform. -/// Note that if the transform is not invertible the result will be invalid. - - #[lua(kind = "Method", output(proxy))] - fn inverse(&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::Affine2) -> 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::Mat3) -> bevy::math::Mat3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Affine2) -> bool; - -"#, - 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(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))] - fn from_cols( - #[proxy] - x_axis: bevy::math::Vec3A, - #[proxy] - y_axis: bevy::math::Vec3A, - #[proxy] - z_axis: bevy::math::Vec3A, - #[proxy] - w_axis: bevy::math::Vec3A, - ) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates a `[f32; 12]` array storing data in column major order. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f32; 12]; - -"#, - r#" -/// Creates a `[[f32; 3]; 4]` 3D array storing data in -/// column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f32; 3]; 4]; - -"#, - r#" -/// Creates an affine transform that changes scale. -/// Note that if any scale is zero the transform will be non-invertible. - - #[lua(kind = "Function", output(proxy))] - fn from_scale(#[proxy] scale: bevy::math::Vec3) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates an affine transform from the given `rotation` quaternion. - - #[lua(kind = "Function", output(proxy))] - fn from_quat(#[proxy] rotation: bevy::math::Quat) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates an affine transform containing a 3D rotation around a normalized -/// rotation `axis` of `angle` (in radians). - - #[lua(kind = "Function", output(proxy))] - fn from_axis_angle( - #[proxy] - axis: bevy::math::Vec3, - angle: f32, - ) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates an affine transform containing a 3D rotation around the x axis of -/// `angle` (in radians). - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_x(angle: f32) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates an affine transform containing a 3D rotation around the y axis of -/// `angle` (in radians). - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_y(angle: f32) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates an affine transform containing a 3D rotation around the z axis of -/// `angle` (in radians). - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_z(angle: f32) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates an affine transformation from the given 3D `translation`. - - #[lua(kind = "Function", output(proxy))] - fn from_translation(#[proxy] translation: bevy::math::Vec3) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates an affine transform from a 3x3 matrix (expressing scale, shear and -/// rotation) - - #[lua(kind = "Function", output(proxy))] - fn from_mat3(#[proxy] mat3: bevy::math::Mat3) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation) -/// and a translation vector. -/// Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_mat3(mat3)` - - #[lua(kind = "Function", output(proxy))] - fn from_mat3_translation( - #[proxy] - mat3: bevy::math::Mat3, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates an affine transform from the given 3D `scale`, `rotation` and -/// `translation`. -/// Equivalent to `Affine3A::from_translation(translation) * -/// Affine3A::from_quat(rotation) * Affine3A::from_scale(scale)` - - #[lua(kind = "Function", output(proxy))] - fn from_scale_rotation_translation( - #[proxy] - scale: bevy::math::Vec3, - #[proxy] - rotation: bevy::math::Quat, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates an affine transform from the given 3D `rotation` and `translation`. -/// Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_quat(rotation)` - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_translation( - #[proxy] - rotation: bevy::math::Quat, - #[proxy] - translation: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - r#" -/// The given `Mat4` must be an affine transform, -/// i.e. contain no perspective transform. - - #[lua(kind = "Function", output(proxy))] - fn from_mat4(#[proxy] m: bevy::math::Mat4) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates a left-handed view transform using a camera position, an up direction, and a facing -/// direction. -/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - - #[lua(kind = "Function", output(proxy))] - fn look_to_lh( - #[proxy] - eye: bevy::math::Vec3, - #[proxy] - dir: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates a right-handed view transform using a camera position, an up direction, and a facing -/// direction. -/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - - #[lua(kind = "Function", output(proxy))] - fn look_to_rh( - #[proxy] - eye: bevy::math::Vec3, - #[proxy] - dir: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates a left-handed view transform using a camera position, an up direction, and a focal -/// point. -/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. -/// # Panics -/// Will panic if `up` is not normalized when `glam_assert` is enabled. - - #[lua(kind = "Function", output(proxy))] - fn look_at_lh( - #[proxy] - eye: bevy::math::Vec3, - #[proxy] - center: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - r#" -/// Creates a right-handed view transform using a camera position, an up direction, and a focal -/// point. -/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. -/// # Panics -/// Will panic if `up` is not normalized when `glam_assert` is enabled. - - #[lua(kind = "Function", output(proxy))] - fn look_at_rh( - #[proxy] - eye: bevy::math::Vec3, - #[proxy] - center: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::math::Affine3A; - -"#, - r#" -/// Transforms the given 3D points, applying shear, scale, rotation and translation. - - #[lua(kind = "Method", output(proxy))] - fn transform_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" -/// Transforms the given 3D vector, applying shear, scale and rotation (but NOT -/// translation). -/// To also apply translation, use [`Self::transform_point3()`] instead. - - #[lua(kind = "Method", output(proxy))] - fn transform_vector3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" -/// Transforms the given [`Vec3A`], applying shear, scale, rotation and translation. - - #[lua(kind = "Method", output(proxy))] - fn transform_point3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" -/// Transforms the given [`Vec3A`], applying shear, scale and rotation (but NOT -/// translation). -/// To also apply translation, use [`Self::transform_point3a()`] instead. - - #[lua(kind = "Method", output(proxy))] - fn transform_vector3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" -/// Returns `true` if, and only if, all elements are finite. -/// If any element is either `NaN`, positive or negative infinity, this will return -/// `false`. - - #[lua(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - fn is_nan(&self) -> bool; - -"#, - r#" -/// Returns true if the absolute difference of all elements between `self` and `rhs` -/// is less than or equal to `max_abs_diff`. -/// This can be used to compare if two 3x4 matrices contain similar elements. It works -/// best when comparing with a known value. The `max_abs_diff` that should be used used -/// depends on the values being compared against. -/// For more see -/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - - #[lua(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Affine3A, max_abs_diff: f32) -> bool; - -"#, - r#" -/// Return the inverse of this transform. -/// Note that if the transform is not invertible the result will be invalid. - - #[lua(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::Affine3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - 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( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Affine3A) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct Affine3A { - #[lua(output(proxy))] - matrix3: bevy::math::Mat3A, - #[lua(output(proxy))] - translation: bevy::math::Vec3A, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DAffine2", - functions[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::DAffine2; - -"#, - 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 = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DAffine2; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DAffine2) -> bool; - -"#, - r#" -/// Creates an affine transform from three column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::DVec2, - #[proxy] - y_axis: bevy::math::DVec2, - #[proxy] - z_axis: bevy::math::DVec2, - ) -> bevy::math::DAffine2; - -"#, - r#" -/// Creates a `[f64; 6]` array storing data in column major order. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f64; 6]; - -"#, - r#" -/// Creates a `[[f64; 2]; 3]` 2D array storing data in -/// column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f64; 2]; 3]; - -"#, - r#" -/// Creates an affine transform that changes scale. -/// Note that if any scale is zero the transform will be non-invertible. - - #[lua(kind = "Function", output(proxy))] - fn from_scale(#[proxy] scale: bevy::math::DVec2) -> bevy::math::DAffine2; - -"#, - r#" -/// Creates an affine transform from the given rotation `angle`. - - #[lua(kind = "Function", output(proxy))] - fn from_angle(angle: f64) -> bevy::math::DAffine2; - -"#, - r#" -/// Creates an affine transformation from the given 2D `translation`. - - #[lua(kind = "Function", output(proxy))] - fn from_translation(#[proxy] translation: bevy::math::DVec2) -> bevy::math::DAffine2; - -"#, - r#" -/// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) - - #[lua(kind = "Function", output(proxy))] - fn from_mat2(#[proxy] matrix2: bevy::math::DMat2) -> bevy::math::DAffine2; - -"#, - r#" -/// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) and a -/// translation vector. -/// Equivalent to -/// `DAffine2::from_translation(translation) * DAffine2::from_mat2(mat2)` - - #[lua(kind = "Function", output(proxy))] - fn from_mat2_translation( - #[proxy] - matrix2: bevy::math::DMat2, - #[proxy] - translation: bevy::math::DVec2, - ) -> bevy::math::DAffine2; - -"#, - r#" -/// Creates an affine transform from the given 2D `scale`, rotation `angle` (in radians) and -/// `translation`. -/// Equivalent to `DAffine2::from_translation(translation) * -/// DAffine2::from_angle(angle) * DAffine2::from_scale(scale)` - - #[lua(kind = "Function", output(proxy))] - fn from_scale_angle_translation( - #[proxy] - scale: bevy::math::DVec2, - angle: f64, - #[proxy] - translation: bevy::math::DVec2, - ) -> bevy::math::DAffine2; - -"#, - r#" -/// Creates an affine transform from the given 2D rotation `angle` (in radians) and -/// `translation`. -/// Equivalent to `DAffine2::from_translation(translation) * DAffine2::from_angle(angle)` - - #[lua(kind = "Function", output(proxy))] - fn from_angle_translation( - angle: f64, - #[proxy] - translation: bevy::math::DVec2, - ) -> bevy::math::DAffine2; - -"#, - r#" -/// The given `DMat3` must be an affine transform, - - #[lua(kind = "Function", output(proxy))] - fn from_mat3(#[proxy] m: bevy::math::DMat3) -> bevy::math::DAffine2; - -"#, - r#" -/// Transforms the given 2D point, applying shear, scale, rotation and translation. - - #[lua(kind = "Method", output(proxy))] - fn transform_point2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" -/// Transforms the given 2D vector, applying shear, scale and rotation (but NOT -/// translation). -/// To also apply translation, use [`Self::transform_point2()`] instead. - - #[lua(kind = "Method", output(proxy))] - fn transform_vector2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - -"#, - r#" -/// Returns `true` if, and only if, all elements are finite. -/// If any element is either `NaN`, positive or negative infinity, this will return -/// `false`. - - #[lua(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - fn is_nan(&self) -> bool; - -"#, - r#" -/// Returns true if the absolute difference of all elements between `self` and `rhs` -/// is less than or equal to `max_abs_diff`. -/// This can be used to compare if two 3x4 matrices contain similar elements. It works -/// best when comparing with a known value. The `max_abs_diff` that should be used used -/// depends on the values being compared against. -/// For more see -/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - - #[lua(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DAffine2, max_abs_diff: f64) -> bool; - -"#, - r#" -/// Return the inverse of this transform. -/// Note that if the transform is not invertible the result will be invalid. - - #[lua(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::DAffine2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct DAffine2 { - #[lua(output(proxy))] - matrix2: bevy::math::DMat2, - #[lua(output(proxy))] - translation: bevy::math::DVec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DAffine3", - functions[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#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DAffine3) -> bool; - -"#, - r#" -/// Creates an affine transform from three column vectors. - - #[lua(kind = "Function", output(proxy))] - fn from_cols( - #[proxy] - x_axis: bevy::math::DVec3, - #[proxy] - y_axis: bevy::math::DVec3, - #[proxy] - z_axis: bevy::math::DVec3, - #[proxy] - w_axis: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates a `[f64; 12]` array storing data in column major order. - - #[lua(kind = "Method")] - fn to_cols_array(&self) -> [f64; 12]; - -"#, - r#" -/// Creates a `[[f64; 3]; 4]` 3D array storing data in -/// column major order. -/// If you require data in row major order `transpose` the matrix first. - - #[lua(kind = "Method")] - fn to_cols_array_2d(&self) -> [[f64; 3]; 4]; - -"#, - r#" -/// Creates an affine transform that changes scale. -/// Note that if any scale is zero the transform will be non-invertible. - - #[lua(kind = "Function", output(proxy))] - fn from_scale(#[proxy] scale: bevy::math::DVec3) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates an affine transform from the given `rotation` quaternion. - - #[lua(kind = "Function", output(proxy))] - fn from_quat(#[proxy] rotation: bevy::math::DQuat) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates an affine transform containing a 3D rotation around a normalized -/// rotation `axis` of `angle` (in radians). - - #[lua(kind = "Function", output(proxy))] - fn from_axis_angle( - #[proxy] - axis: bevy::math::DVec3, - angle: f64, - ) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates an affine transform containing a 3D rotation around the x axis of -/// `angle` (in radians). - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_x(angle: f64) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates an affine transform containing a 3D rotation around the y axis of -/// `angle` (in radians). - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_y(angle: f64) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates an affine transform containing a 3D rotation around the z axis of -/// `angle` (in radians). - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_z(angle: f64) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates an affine transformation from the given 3D `translation`. - - #[lua(kind = "Function", output(proxy))] - fn from_translation(#[proxy] translation: bevy::math::DVec3) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates an affine transform from a 3x3 matrix (expressing scale, shear and -/// rotation) - - #[lua(kind = "Function", output(proxy))] - fn from_mat3(#[proxy] mat3: bevy::math::DMat3) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation) -/// and a translation vector. -/// Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_mat3(mat3)` - - #[lua(kind = "Function", output(proxy))] - fn from_mat3_translation( - #[proxy] - mat3: bevy::math::DMat3, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates an affine transform from the given 3D `scale`, `rotation` and -/// `translation`. -/// Equivalent to `DAffine3::from_translation(translation) * -/// DAffine3::from_quat(rotation) * DAffine3::from_scale(scale)` - - #[lua(kind = "Function", output(proxy))] - fn from_scale_rotation_translation( - #[proxy] - scale: bevy::math::DVec3, - #[proxy] - rotation: bevy::math::DQuat, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates an affine transform from the given 3D `rotation` and `translation`. -/// Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_quat(rotation)` - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_translation( - #[proxy] - rotation: bevy::math::DQuat, - #[proxy] - translation: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - r#" -/// The given `DMat4` must be an affine transform, -/// i.e. contain no perspective transform. - - #[lua(kind = "Function", output(proxy))] - fn from_mat4(#[proxy] m: bevy::math::DMat4) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates a left-handed view transform using a camera position, an up direction, and a facing -/// direction. -/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - - #[lua(kind = "Function", output(proxy))] - fn look_to_lh( - #[proxy] - eye: bevy::math::DVec3, - #[proxy] - dir: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates a right-handed view transform using a camera position, an up direction, and a facing -/// direction. -/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - - #[lua(kind = "Function", output(proxy))] - fn look_to_rh( - #[proxy] - eye: bevy::math::DVec3, - #[proxy] - dir: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates a left-handed view transform using a camera position, an up direction, and a focal -/// point. -/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. -/// # Panics -/// Will panic if `up` is not normalized when `glam_assert` is enabled. - - #[lua(kind = "Function", output(proxy))] - fn look_at_lh( - #[proxy] - eye: bevy::math::DVec3, - #[proxy] - center: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - r#" -/// Creates a right-handed view transform using a camera position, an up direction, and a focal -/// point. -/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. -/// # Panics -/// Will panic if `up` is not normalized when `glam_assert` is enabled. - - #[lua(kind = "Function", output(proxy))] - fn look_at_rh( - #[proxy] - eye: bevy::math::DVec3, - #[proxy] - center: bevy::math::DVec3, - #[proxy] - up: bevy::math::DVec3, - ) -> bevy::math::DAffine3; - -"#, - r#" -/// Transforms the given 3D points, applying shear, scale, rotation and translation. - - #[lua(kind = "Method", output(proxy))] - fn transform_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" -/// Transforms the given 3D vector, applying shear, scale and rotation (but NOT -/// translation). -/// To also apply translation, use [`Self::transform_point3()`] instead. - - #[lua(kind = "Method", output(proxy))] - fn transform_vector3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" -/// Returns `true` if, and only if, all elements are finite. -/// If any element is either `NaN`, positive or negative infinity, this will return -/// `false`. - - #[lua(kind = "Method")] - fn is_finite(&self) -> bool; - -"#, - r#" -/// Returns `true` if any elements are `NaN`. - - #[lua(kind = "Method")] - fn is_nan(&self) -> bool; - -"#, - r#" -/// Returns true if the absolute difference of all elements between `self` and `rhs` -/// is less than or equal to `max_abs_diff`. -/// This can be used to compare if two 3x4 matrices contain similar elements. It works -/// best when comparing with a known value. The `max_abs_diff` that should be used used -/// depends on the values being compared against. -/// For more see -/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - - #[lua(kind = "Method")] - fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DAffine3, max_abs_diff: f64) -> bool; - -"#, - r#" -/// Return the inverse of this transform. -/// Note that if the transform is not invertible the result will be invalid. - - #[lua(kind = "Method", output(proxy))] - fn inverse(&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(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct DAffine3 { - #[lua(output(proxy))] - matrix3: bevy::math::DMat3, - #[lua(output(proxy))] - translation: bevy::math::DVec3, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DQuat", - functions[r#" - - #[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", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f64) -> bevy::math::DQuat; - -"#, - 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::DQuat) -> bevy::math::DQuat; - -"#, - 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::DQuat) -> 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", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - 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::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; - -"#, - r#" -/// Multiplies a quaternion by a scalar value. -/// The product is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DQuat; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DQuat; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a new rotation quaternion. -/// This should generally not be called manually unless you know what you are doing. -/// Use one of the other constructors instead such as `identity` or `from_axis_angle`. -/// `from_xyzw` is mostly used by unit tests and `serde` deserialization. -/// # Preconditions -/// This function does not check if the input is normalized, it is up to the user to -/// provide normalized input or to normalized the resulting quaternion. - - #[lua(kind = "Function", output(proxy))] - fn from_xyzw(x: f64, y: f64, z: f64, w: f64) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a rotation quaternion from an array. -/// # Preconditions -/// This function does not check if the input is normalized, it is up to the user to -/// provide normalized input or to normalized the resulting quaternion. - - #[lua(kind = "Function", output(proxy))] - fn from_array(a: [f64; 4]) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a new rotation quaternion from a 4D vector. -/// # Preconditions -/// This function does not check if the input is normalized, it is up to the user to -/// provide normalized input or to normalized the resulting quaternion. - - #[lua(kind = "Function", output(proxy))] - fn from_vec4(#[proxy] v: bevy::math::DVec4) -> bevy::math::DQuat; - -"#, - r#" -/// Create a quaternion for a normalized rotation `axis` and `angle` (in radians). -/// The axis must be a unit vector. -/// # Panics -/// Will panic if `axis` is not normalized when `glam_assert` is enabled. - - #[lua(kind = "Function", output(proxy))] - fn from_axis_angle( - #[proxy] - axis: bevy::math::DVec3, - angle: f64, - ) -> bevy::math::DQuat; - -"#, - r#" -/// Create a quaternion that rotates `v.length()` radians around `v.normalize()`. -/// `from_scaled_axis(Vec3::ZERO)` results in the identity quaternion. - - #[lua(kind = "Function", output(proxy))] - fn from_scaled_axis(#[proxy] v: bevy::math::DVec3) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from the `angle` (in radians) around the x axis. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_x(angle: f64) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from the `angle` (in radians) around the y axis. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_y(angle: f64) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from the `angle` (in radians) around the z axis. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_z(angle: f64) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from the given Euler rotation sequence and the angles (in radians). - - #[lua(kind = "Function", output(proxy))] - fn from_euler( - #[proxy] - euler: bevy::math::EulerRot, - a: f64, - b: f64, - c: f64, - ) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from a 3x3 rotation matrix. - - #[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. - - #[lua(kind = "Function", output(proxy))] - fn from_mat4(#[proxy] mat: &glam::DMat4) -> bevy::math::DQuat; - -"#, - r#" -/// Gets the minimal rotation for transforming `from` to `to`. The rotation is in the -/// plane spanned by the two vectors. Will rotate at most 180 degrees. -/// The inputs must be unit vectors. -/// `from_rotation_arc(from, to) * from ≈ to`. -/// For near-singular cases (from≈to and from≈-to) the current implementation -/// is only accurate to about 0.001 (for `f32`). -/// # Panics -/// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_arc( - #[proxy] - from: bevy::math::DVec3, - #[proxy] - to: bevy::math::DVec3, - ) -> bevy::math::DQuat; - -"#, - r#" -/// Gets the minimal rotation for transforming `from` to either `to` or `-to`. This means -/// that the resulting quaternion will rotate `from` so that it is colinear with `to`. -/// The rotation is in the plane spanned by the two vectors. Will rotate at most 90 -/// degrees. -/// The inputs must be unit vectors. -/// `to.dot(from_rotation_arc_colinear(from, to) * from).abs() ≈ 1`. -/// # Panics -/// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_arc_colinear( - #[proxy] - from: bevy::math::DVec3, - #[proxy] - to: bevy::math::DVec3, - ) -> bevy::math::DQuat; - -"#, - r#" -/// Gets the minimal rotation for transforming `from` to `to`. The resulting rotation is -/// around the z axis. Will rotate at most 180 degrees. -/// The inputs must be unit vectors. -/// `from_rotation_arc_2d(from, to) * from ≈ to`. -/// For near-singular cases (from≈to and from≈-to) the current implementation -/// is only accurate to about 0.001 (for `f32`). -/// # Panics -/// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - - #[lua(kind = "Function", output(proxy))] - fn from_rotation_arc_2d( - #[proxy] - from: bevy::math::DVec2, - #[proxy] - to: bevy::math::DVec2, - ) -> bevy::math::DQuat; - -"#, - r#" -/// Returns the rotation axis scaled by the rotation in radians. - - #[lua(kind = "Method", output(proxy))] - fn to_scaled_axis(self) -> bevy::math::DVec3; - -"#, - r#" -/// 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); - -"#, - r#" -/// `[x, y, z, w]` - - #[lua(kind = "Method")] - fn to_array(&self) -> [f64; 4]; - -"#, - r#" -/// Returns the vector part of the quaternion. - - #[lua(kind = "Method", output(proxy))] - fn xyz(self) -> bevy::math::DVec3; - -"#, - r#" -/// Returns the quaternion conjugate of `self`. For a unit quaternion the -/// conjugate is also the inverse. - - #[lua(kind = "Method", output(proxy))] - fn conjugate(self) -> bevy::math::DQuat; - -"#, - r#" -/// Returns the inverse of a normalized quaternion. -/// Typically quaternion inverse returns the conjugate of a normalized quaternion. -/// Because `self` is assumed to already be unit length this method *does not* normalize -/// before returning the conjugate. -/// # Panics -/// Will panic if `self` is not normalized when `glam_assert` is enabled. - - #[lua(kind = "Method", output(proxy))] - fn inverse(self) -> bevy::math::DQuat; - -"#, - r#" -/// Computes the dot product of `self` and `rhs`. The dot product is -/// equal to the cosine of the angle between two quaternion rotations. - - #[lua(kind = "Method")] - fn dot(self, #[proxy] rhs: bevy::math::DQuat) -> f64; - -"#, - r#" -/// Computes the length of `self`. - - #[lua(kind = "Method")] - fn length(self) -> f64; - -"#, - r#" -/// Computes the squared length of `self`. -/// This is generally faster than `length()` as it avoids a square -/// root operation. - - #[lua(kind = "Method")] - fn length_squared(self) -> f64; - -"#, - r#" -/// Computes `1.0 / length()`. -/// For valid results, `self` must _not_ be of length zero. - - #[lua(kind = "Method")] - fn length_recip(self) -> f64; - -"#, - r#" -/// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero. -/// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. - - #[lua(kind = "Method", output(proxy))] - fn normalize(self) -> bevy::math::DQuat; - -"#, - r#" -/// Returns `true` if, and only if, all elements are finite. -/// If any element is either `NaN`, positive or negative infinity, this will return `false`. - - #[lua(kind = "Method")] - fn is_finite(self) -> bool; - -"#, - r#" - - #[lua(kind = "Method")] - fn is_nan(self) -> bool; - -"#, - r#" -/// Returns whether `self` of length `1.0` or not. -/// Uses a precision threshold of `1e-6`. - - #[lua(kind = "Method")] - fn is_normalized(self) -> bool; - -"#, - r#" - - #[lua(kind = "Method")] - fn is_near_identity(self) -> bool; - -"#, - r#" -/// Returns the angle (in radians) for the minimal rotation -/// for transforming this quaternion into another. -/// Both quaternions must be normalized. -/// # Panics -/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - - #[lua(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::DQuat) -> f64; - -"#, - r#" -/// Returns true if the absolute difference of all elements between `self` and `rhs` -/// is less than or equal to `max_abs_diff`. -/// This can be used to compare if two quaternions contain similar elements. It works -/// best when comparing with a known value. The `max_abs_diff` that should be used used -/// depends on the values being compared against. -/// For more see -/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - - #[lua(kind = "Method")] - fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DQuat, max_abs_diff: f64) -> bool; - -"#, - r#" -/// Performs a linear interpolation between `self` and `rhs` based on -/// the value `s`. -/// When `s` is `0.0`, the result will be equal to `self`. When `s` -/// is `1.0`, the result will be equal to `rhs`. -/// # Panics -/// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - - #[lua(kind = "Method", output(proxy))] - fn lerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; - -"#, - r#" -/// Performs a spherical linear interpolation between `self` and `end` -/// based on the value `s`. -/// When `s` is `0.0`, the result will be equal to `self`. When `s` -/// is `1.0`, the result will be equal to `end`. -/// # Panics -/// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - - #[lua(kind = "Method", output(proxy))] - fn slerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> 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(kind = "Method", output(proxy))] - fn mul_vec3(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - 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(kind = "Method", output(proxy))] - fn mul_quat(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. - - #[lua(kind = "Function", output(proxy))] - fn from_affine3(#[proxy] a: &glam::DAffine3) -> bevy::math::DQuat; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_quat(self) -> bevy::math::Quat; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_f32(self) -> bevy::math::Quat; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct DQuat { - x: f64, - y: f64, - z: f64, - w: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::EulerRot", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::EulerRot) -> 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::EulerRot; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct EulerRot {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::BVec3A", - functions[r#" -/// Creates a new vector mask. - - #[lua(kind = "Function", output(proxy))] - fn new(x: bool, y: bool, z: bool) -> bevy::math::BVec3A; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: bool) -> bevy::math::BVec3A; - -"#, - r#" -/// Returns a bitmask with the lowest 3 bits set from the elements of `self`. -/// A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes -/// into the first lowest bit, element `y` into the second, etc. - - #[lua(kind = "Method")] - fn bitmask(self) -> u32; - -"#, - r#" -/// Returns true if any of the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn any(self) -> bool; - -"#, - r#" -/// Returns true if all the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn all(self) -> bool; - -"#, - r#" -/// Tests the value at `index`. -/// Panics if `index` is greater than 2. - - #[lua(kind = "Method")] - fn test(&self, index: usize) -> bool; - -"#, - r#" -/// Sets the element at `index`. -/// Panics if `index` is greater than 2. - - #[lua(kind = "MutatingMethod")] - fn set(&mut self, index: usize, value: bool) -> (); - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec3A; - -"#, - r#" - - #[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) -} -"#] -)] -struct BVec3A(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::BVec4A", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::BVec4A) -> bool; - -"#, - r#" -/// Creates a new vector mask. - - #[lua(kind = "Function", output(proxy))] - fn new(x: bool, y: bool, z: bool, w: bool) -> bevy::math::BVec4A; - -"#, - r#" -/// Creates a vector with all elements set to `v`. - - #[lua(kind = "Function", output(proxy))] - fn splat(v: bool) -> bevy::math::BVec4A; - -"#, - r#" -/// Returns a bitmask with the lowest 4 bits set from the elements of `self`. -/// A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes -/// into the first lowest bit, element `y` into the second, etc. - - #[lua(kind = "Method")] - fn bitmask(self) -> u32; - -"#, - r#" -/// Returns true if any of the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn any(self) -> bool; - -"#, - r#" -/// Returns true if all the elements are true, false otherwise. - - #[lua(kind = "Method")] - fn all(self) -> bool; - -"#, - r#" -/// Tests the value at `index`. -/// Panics if `index` is greater than 3. - - #[lua(kind = "Method")] - fn test(&self, index: usize) -> bool; - -"#, - r#" -/// Sets the element at `index`. -/// Panics if `index` is greater than 3. - - #[lua(kind = "MutatingMethod")] - fn set(&mut self, index: usize, value: bool) -> (); - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec4A; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct BVec4A(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Direction2d", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction2d) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Direction2d; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::primitives::Direction2d; - -"#, - r#" -/// Create a [`Direction2d`] from a [`Vec2`] that is already normalized. -/// # Warning -/// `value` must be normalized, i.e it's length must be `1.0`. - - #[lua(kind = "Function", output(proxy))] - fn new_unchecked( - #[proxy] - value: bevy::math::Vec2, - ) -> bevy::math::primitives::Direction2d; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Direction2d(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Circle", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Circle) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::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#" -/// Get the area of the circle - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" -/// Get the perimeter or circumference of the circle - - #[lua(kind = "Method")] - fn perimeter(&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::Vec2) -> bevy::math::Vec2; - -"#, - r#" -#[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::Ellipse", - functions[r#" -/// Create a new `Ellipse` from half of its width and height. -/// This corresponds to the two perpendicular radii defining the ellipse. - - #[lua(kind = "Function", output(proxy))] - fn new(half_width: f32, half_height: f32) -> bevy::math::primitives::Ellipse; - -"#, - r#" -/// Create a new `Ellipse` from a given full size. -/// `size.x` is the diameter along the X axis, and `size.y` is the diameter along the Y axis. - - #[lua(kind = "Function", output(proxy))] - fn from_size(#[proxy] size: bevy::math::Vec2) -> bevy::math::primitives::Ellipse; - -"#, - r#" -/// Returns the length of the semi-major axis. This corresponds to the longest radius of the ellipse. - - #[lua(kind = "Method")] - fn semi_major(self) -> f32; - -"#, - r#" -/// Returns the length of the semi-minor axis. This corresponds to the shortest radius of the ellipse. - - #[lua(kind = "Method")] - fn semi_minor(self) -> f32; - -"#, - r#" -/// Get the area of the ellipse - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::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: &bevy_math::primitives::Ellipse) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Ellipse { - #[lua(output(proxy))] - half_size: bevy::math::Vec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Plane2d", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Plane2d; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::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. - - #[lua(kind = "Function", output(proxy))] - fn new(#[proxy] normal: bevy::math::Vec2) -> bevy::math::primitives::Plane2d; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Plane2d { - #[lua(output(proxy))] - normal: bevy::math::primitives::Direction2d, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Line2d", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Line2d; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Line2d) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Line2d { - #[lua(output(proxy))] - direction: bevy::math::primitives::Direction2d, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - 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: &bevy_math::primitives::Segment2d) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::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))] - fn new( - #[proxy] - direction: bevy::math::primitives::Direction2d, - length: f32, - ) -> bevy::math::primitives::Segment2d; - -"#, - r#" -/// Get the position of the first point on the line segment - - #[lua(kind = "Method", output(proxy))] - fn point1(&self) -> bevy::math::Vec2; - -"#, - r#" -/// Get the position of the second point on the line segment - - #[lua(kind = "Method", output(proxy))] - fn point2(&self) -> bevy::math::Vec2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Segment2d { - #[lua(output(proxy))] - direction: bevy::math::primitives::Direction2d, - half_length: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Triangle2d", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Triangle2d; - -"#, - r#" -/// Create a new `Triangle2d` from points `a`, `b`, and `c` - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - a: bevy::math::Vec2, - #[proxy] - b: bevy::math::Vec2, - #[proxy] - c: bevy::math::Vec2, - ) -> bevy::math::primitives::Triangle2d; - -"#, - r#" -/// Get the area of the triangle - - #[lua(kind = "Method")] - fn area(&self) -> f32; - -"#, - r#" -/// Get the perimeter of the triangle - - #[lua(kind = "Method")] - fn perimeter(&self) -> f32; - -"#, - r#" -/// Reverse the [`WindingOrder`] of the triangle -/// by swapping the second and third vertices - - #[lua(kind = "MutatingMethod")] - fn reverse(&mut self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Triangle2d) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Triangle2d { - vertices: ReflectedValue, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Rectangle", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Rectangle; - -"#, - r#" -/// Create a new `Rectangle` from a full width and height - - #[lua(kind = "Function", output(proxy))] - fn new(width: f32, height: f32) -> bevy::math::primitives::Rectangle; - -"#, - r#" -/// Create a new `Rectangle` from a given full size - - #[lua(kind = "Function", output(proxy))] - fn from_size(#[proxy] size: bevy::math::Vec2) -> bevy::math::primitives::Rectangle; - -"#, - r#" -/// Create a new `Rectangle` from two corner points - - #[lua(kind = "Function", output(proxy))] - fn from_corners( - #[proxy] - point1: bevy::math::Vec2, - #[proxy] - point2: bevy::math::Vec2, - ) -> bevy::math::primitives::Rectangle; + #[lua(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DMat4, max_abs_diff: f64) -> bool; "#, r#" -/// Get the size of the rectangle +/// Takes the absolute value of each element in `self` #[lua(kind = "Method", output(proxy))] - fn size(&self) -> bevy::math::Vec2; - -"#, - r#" -/// Get the area of the rectangle - - #[lua(kind = "Method")] - fn area(&self) -> f32; + fn abs(&self) -> bevy::math::DMat4; "#, r#" -/// Get the perimeter of the rectangle - #[lua(kind = "Method")] - fn perimeter(&self) -> f32; + #[lua(kind = "Method", output(proxy))] + fn as_mat4(&self) -> bevy::math::Mat4; "#, r#" -/// Finds the point on the rectangle that is closest to the given `point`. -/// If the point is outside the rectangle, the returned point will be on the perimeter of the rectangle. -/// Otherwise, it will be inside the rectangle and returned as is. - #[lua(kind = "Method", output(proxy))] - fn closest_point(&self, #[proxy] point: bevy::math::Vec2) -> bevy::math::Vec2; + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DMat4; "#, 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: &bevy_math::primitives::Rectangle) -> bool; + fn div(self, rhs: f64) -> bevy::math::DMat4; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{:?}", _self) + format!("{}", _self) +} +"#, + r#" +#[lua(kind = "MetaMethod", raw, metamethod="Index")] +fn index(&self, ctx : &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(LuaDVec4::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 Rectangle { +struct DMat4 { #[lua(output(proxy))] - half_size: bevy::math::Vec2, + x_axis: bevy::math::DVec4, + #[lua(output(proxy))] + y_axis: bevy::math::DVec4, + #[lua(output(proxy))] + z_axis: bevy::math::DVec4, + #[lua(output(proxy))] + w_axis: bevy::math::DVec4, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::primitives::RegularPolygon", + remote = "bevy::math::Affine2", functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Affine2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::primitives::RegularPolygon; + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Affine2; "#, r#" -/// Create a new `RegularPolygon` -/// from the radius of the circumcircle and a number of sides -/// # Panics -/// Panics if `circumradius` is non-positive +/// Creates an affine transform from three column vectors. #[lua(kind = "Function", output(proxy))] - fn new(circumradius: f32, sides: usize) -> bevy::math::primitives::RegularPolygon; + fn from_cols( + #[proxy] + x_axis: bevy::math::Vec2, + #[proxy] + y_axis: bevy::math::Vec2, + #[proxy] + z_axis: bevy::math::Vec2, + ) -> bevy::math::Affine2; "#, r#" -/// Get the radius of the circumcircle on which all vertices -/// of the regular polygon lie +/// Creates a `[f32; 6]` array storing data in column major order. #[lua(kind = "Method")] - fn circumradius(&self) -> f32; + fn to_cols_array(&self) -> [f32; 6]; "#, r#" -/// Get the inradius or apothem of the regular polygon. -/// This is the radius of the largest circle that can -/// be drawn within the polygon +/// Creates a `[[f32; 2]; 3]` 2D array storing data in +/// column major order. +/// If you require data in row major order `transpose` the matrix first. #[lua(kind = "Method")] - fn inradius(&self) -> f32; + fn to_cols_array_2d(&self) -> [[f32; 2]; 3]; "#, r#" -/// Get the length of one side of the regular polygon +/// Creates an affine transform that changes scale. +/// Note that if any scale is zero the transform will be non-invertible. - #[lua(kind = "Method")] - fn side_length(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_scale(#[proxy] scale: bevy::math::Vec2) -> bevy::math::Affine2; "#, r#" -/// Get the area of the regular polygon +/// Creates an affine transform from the given rotation `angle`. - #[lua(kind = "Method")] - fn area(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_angle(angle: f32) -> bevy::math::Affine2; "#, r#" -/// Get the perimeter of the regular polygon. -/// This is the sum of its sides +/// Creates an affine transformation from the given 2D `translation`. - #[lua(kind = "Method")] - fn perimeter(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_translation(#[proxy] translation: bevy::math::Vec2) -> bevy::math::Affine2; "#, r#" -/// Get the internal angle of the regular polygon in degrees. -/// This is the angle formed by two adjacent sides with points -/// within the angle being in the interior of the polygon +/// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) - #[lua(kind = "Method")] - fn internal_angle_degrees(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_mat2(#[proxy] matrix2: bevy::math::Mat2) -> bevy::math::Affine2; "#, r#" -/// Get the internal angle of the regular polygon in radians. -/// This is the angle formed by two adjacent sides with points -/// within the angle being in the interior of the polygon +/// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) and a +/// translation vector. +/// Equivalent to +/// `Affine2::from_translation(translation) * Affine2::from_mat2(mat2)` - #[lua(kind = "Method")] - fn internal_angle_radians(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_mat2_translation( + #[proxy] + matrix2: bevy::math::Mat2, + #[proxy] + translation: bevy::math::Vec2, + ) -> bevy::math::Affine2; "#, r#" -/// Get the external angle of the regular polygon in degrees. -/// This is the angle formed by two adjacent sides with points -/// within the angle being in the exterior of the polygon +/// Creates an affine transform from the given 2D `scale`, rotation `angle` (in radians) and +/// `translation`. +/// Equivalent to `Affine2::from_translation(translation) * +/// Affine2::from_angle(angle) * Affine2::from_scale(scale)` - #[lua(kind = "Method")] - fn external_angle_degrees(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_scale_angle_translation( + #[proxy] + scale: bevy::math::Vec2, + angle: f32, + #[proxy] + translation: bevy::math::Vec2, + ) -> bevy::math::Affine2; "#, r#" -/// Get the external angle of the regular polygon in radians. -/// This is the angle formed by two adjacent sides with points -/// within the angle being in the exterior of the polygon +/// Creates an affine transform from the given 2D rotation `angle` (in radians) and +/// `translation`. +/// Equivalent to `Affine2::from_translation(translation) * Affine2::from_angle(angle)` - #[lua(kind = "Method")] - fn external_angle_radians(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_angle_translation( + angle: f32, + #[proxy] + translation: bevy::math::Vec2, + ) -> bevy::math::Affine2; "#, r#" +/// The given `Mat3` must be an affine transform, - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::RegularPolygon) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_mat3(#[proxy] m: bevy::math::Mat3) -> bevy::math::Affine2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct RegularPolygon { - #[lua(output(proxy))] - circumcircle: bevy::math::primitives::Circle, - sides: usize, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Capsule2d", - functions[r#" -/// Create a new `Capsule2d` from a radius and length +/// The given [`Mat3A`] must be an affine transform, #[lua(kind = "Function", output(proxy))] - fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule2d; + fn from_mat3a(#[proxy] m: bevy::math::Mat3A) -> bevy::math::Affine2; "#, r#" +/// Transforms the given 2D point, applying shear, scale, rotation and translation. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule2d) -> bool; + #[lua(kind = "Method", output(proxy))] + fn transform_point2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" +/// Transforms the given 2D vector, applying shear, scale and rotation (but NOT +/// translation). +/// To also apply translation, use [`Self::transform_point2()`] instead. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Capsule2d; + #[lua(kind = "Method", output(proxy))] + fn transform_vector2(&self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Capsule2d { - radius: f32, - half_length: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Direction3d", - functions[r#" +/// Returns `true` if, and only if, all elements are finite. +/// If any element is either `NaN`, positive or negative infinity, this will return +/// `false`. - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::primitives::Direction3d; + #[lua(kind = "Method")] + fn is_finite(&self) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua(kind = "Method")] + fn is_nan(&self) -> bool; + +"#, + r#" +/// Returns true if the absolute difference of all elements between `self` and `rhs` +/// is less than or equal to `max_abs_diff`. +/// This can be used to compare if two 3x4 matrices contain similar elements. It works +/// best when comparing with a known value. The `max_abs_diff` that should be used used +/// depends on the values being compared against. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Affine2, max_abs_diff: f32) -> bool; + +"#, + r#" +/// Return the inverse of this transform. +/// Note that if the transform is not invertible the result will be invalid. + + #[lua(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::Affine2; "#, r#" @@ -21497,30 +17841,19 @@ struct Capsule2d { kind = "Method", output(proxy), )] - fn clone(&self) -> bevy::math::primitives::Direction3d; + fn clone(&self) -> bevy::math::Affine2; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Direction3d) -> bool; - -"#, - r#" -/// Create a [`Direction3d`] from a [`Vec3`] that is already normalized. -/// # Warning -/// `value` must be normalized, i.e it's length must be `1.0`. - - #[lua(kind = "Function", output(proxy))] - fn new_unchecked( - #[proxy] - value: bevy::math::Vec3, - ) -> bevy::math::primitives::Direction3d; + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; "#, r#" @@ -21532,305 +17865,346 @@ struct Capsule2d { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Vec3; + fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{:?}", _self) + format!("{}", _self) } "#] )] -struct Direction3d(); +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::primitives::Sphere", + remote = "bevy::math::Affine3A", functions[r#" +/// Creates an affine transform from three column vectors. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Sphere; + #[lua(kind = "Function", output(proxy))] + fn from_cols( + #[proxy] + x_axis: bevy::math::Vec3A, + #[proxy] + y_axis: bevy::math::Vec3A, + #[proxy] + z_axis: bevy::math::Vec3A, + #[proxy] + w_axis: bevy::math::Vec3A, + ) -> bevy::math::Affine3A; "#, r#" -/// Create a new [`Sphere`] from a `radius` +/// Creates a `[f32; 12]` array storing data in column major order. - #[lua(kind = "Function", output(proxy))] - fn new(radius: f32) -> bevy::math::primitives::Sphere; + #[lua(kind = "Method")] + fn to_cols_array(&self) -> [f32; 12]; "#, r#" -/// Get the diameter of the sphere +/// Creates a `[[f32; 3]; 4]` 3D array storing data in +/// column major order. +/// If you require data in row major order `transpose` the matrix first. #[lua(kind = "Method")] - fn diameter(&self) -> f32; + fn to_cols_array_2d(&self) -> [[f32; 3]; 4]; "#, r#" -/// Get the surface area of the sphere +/// Creates an affine transform that changes scale. +/// Note that if any scale is zero the transform will be non-invertible. - #[lua(kind = "Method")] - fn area(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_scale(#[proxy] scale: bevy::math::Vec3) -> bevy::math::Affine3A; "#, r#" -/// Get the volume of the sphere +/// Creates an affine transform from the given `rotation` quaternion. - #[lua(kind = "Method")] - fn volume(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_quat(#[proxy] rotation: bevy::math::Quat) -> bevy::math::Affine3A; "#, r#" -/// Finds the point on the sphere that is closest to the given `point`. -/// If the point is outside the sphere, the returned point will be on the surface of the sphere. -/// Otherwise, it will be inside the sphere and returned as is. +/// Creates an affine transform containing a 3D rotation around a normalized +/// rotation `axis` of `angle` (in radians). - #[lua(kind = "Method", output(proxy))] - fn closest_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; + #[lua(kind = "Function", output(proxy))] + fn from_axis_angle( + #[proxy] + axis: bevy::math::Vec3, + angle: f32, + ) -> bevy::math::Affine3A; "#, r#" +/// Creates an affine transform containing a 3D rotation around the x axis of +/// `angle` (in radians). - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Sphere) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_rotation_x(angle: f32) -> bevy::math::Affine3A; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Sphere { - radius: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Plane3d", - functions[r#" -/// Create a new `Plane3d` from a normal -/// # Panics -/// Panics if the given `normal` is zero (or very close to zero), or non-finite. +/// Creates an affine transform containing a 3D rotation around the y axis of +/// `angle` (in radians). #[lua(kind = "Function", output(proxy))] - fn new(#[proxy] normal: bevy::math::Vec3) -> bevy::math::primitives::Plane3d; + fn from_rotation_y(angle: f32) -> bevy::math::Affine3A; "#, r#" +/// Creates an affine transform containing a 3D rotation around the z axis of +/// `angle` (in radians). - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Plane3d) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_rotation_z(angle: f32) -> bevy::math::Affine3A; "#, r#" +/// Creates an affine transformation from the given 3D `translation`. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Plane3d; + #[lua(kind = "Function", output(proxy))] + fn from_translation(#[proxy] translation: bevy::math::Vec3) -> bevy::math::Affine3A; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Plane3d { - #[lua(output(proxy))] - normal: bevy::math::primitives::Direction3d, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Line3d", - functions[r#" +/// Creates an affine transform from a 3x3 matrix (expressing scale, shear and +/// rotation) - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Line3d; + #[lua(kind = "Function", output(proxy))] + fn from_mat3(#[proxy] mat3: bevy::math::Mat3) -> bevy::math::Affine3A; "#, r#" +/// Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation) +/// and a translation vector. +/// Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_mat3(mat3)` - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Line3d) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_mat3_translation( + #[proxy] + mat3: bevy::math::Mat3, + #[proxy] + translation: bevy::math::Vec3, + ) -> bevy::math::Affine3A; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Line3d { - #[lua(output(proxy))] - direction: bevy::math::primitives::Direction3d, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Segment3d", - functions[r#" +/// Creates an affine transform from the given 3D `scale`, `rotation` and +/// `translation`. +/// Equivalent to `Affine3A::from_translation(translation) * +/// Affine3A::from_quat(rotation) * Affine3A::from_scale(scale)` - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Segment3d; + #[lua(kind = "Function", output(proxy))] + fn from_scale_rotation_translation( + #[proxy] + scale: bevy::math::Vec3, + #[proxy] + rotation: bevy::math::Quat, + #[proxy] + translation: bevy::math::Vec3, + ) -> bevy::math::Affine3A; + +"#, + r#" +/// Creates an affine transform from the given 3D `rotation` and `translation`. +/// Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_quat(rotation)` + + #[lua(kind = "Function", output(proxy))] + fn from_rotation_translation( + #[proxy] + rotation: bevy::math::Quat, + #[proxy] + translation: bevy::math::Vec3, + ) -> bevy::math::Affine3A; + +"#, + r#" +/// The given `Mat4` must be an affine transform, +/// i.e. contain no perspective transform. + + #[lua(kind = "Function", output(proxy))] + fn from_mat4(#[proxy] m: bevy::math::Mat4) -> bevy::math::Affine3A; + +"#, + r#" +/// Creates a left-handed view transform using a camera position, an up direction, and a facing +/// direction. +/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. + + #[lua(kind = "Function", output(proxy))] + fn look_to_lh( + #[proxy] + eye: bevy::math::Vec3, + #[proxy] + dir: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::math::Affine3A; + +"#, + r#" +/// Creates a right-handed view transform using a camera position, an up direction, and a facing +/// direction. +/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. + + #[lua(kind = "Function", output(proxy))] + fn look_to_rh( + #[proxy] + eye: bevy::math::Vec3, + #[proxy] + dir: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::math::Affine3A; + +"#, + r#" +/// Creates a left-handed view transform using a camera position, an up direction, and a focal +/// point. +/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. +/// # Panics +/// Will panic if `up` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Function", output(proxy))] + fn look_at_lh( + #[proxy] + eye: bevy::math::Vec3, + #[proxy] + center: bevy::math::Vec3, + #[proxy] + up: bevy::math::Vec3, + ) -> bevy::math::Affine3A; "#, r#" -/// Create a new `Segment3d` from a direction and full length of the segment +/// Creates a right-handed view transform using a camera position, an up direction, and a focal +/// point. +/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. +/// # Panics +/// Will panic if `up` is not normalized when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] - fn new( + fn look_at_rh( + #[proxy] + eye: bevy::math::Vec3, + #[proxy] + center: bevy::math::Vec3, #[proxy] - direction: bevy::math::primitives::Direction3d, - length: f32, - ) -> bevy::math::primitives::Segment3d; + up: bevy::math::Vec3, + ) -> bevy::math::Affine3A; "#, r#" -/// Get the position of the first point on the line segment +/// Transforms the given 3D points, applying shear, scale, rotation and translation. #[lua(kind = "Method", output(proxy))] - fn point1(&self) -> bevy::math::Vec3; + fn transform_point3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -/// Get the position of the second point on the line segment +/// Transforms the given 3D vector, applying shear, scale and rotation (but NOT +/// translation). +/// To also apply translation, use [`Self::transform_point3()`] instead. #[lua(kind = "Method", output(proxy))] - fn point2(&self) -> bevy::math::Vec3; + fn transform_vector3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" +/// Transforms the given [`Vec3A`], applying shear, scale, rotation and translation. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Segment3d) -> bool; + #[lua(kind = "Method", output(proxy))] + fn transform_point3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Segment3d { - #[lua(output(proxy))] - direction: bevy::math::primitives::Direction3d, - half_length: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Cuboid", - functions[r#" +/// Transforms the given [`Vec3A`], applying shear, scale and rotation (but NOT +/// translation). +/// To also apply translation, use [`Self::transform_point3a()`] instead. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Cuboid) -> bool; + #[lua(kind = "Method", output(proxy))] + fn transform_vector3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" -/// Create a new `Cuboid` from a full x, y, and z length +/// Returns `true` if, and only if, all elements are finite. +/// If any element is either `NaN`, positive or negative infinity, this will return +/// `false`. - #[lua(kind = "Function", output(proxy))] - fn new( - x_length: f32, - y_length: f32, - z_length: f32, - ) -> bevy::math::primitives::Cuboid; + #[lua(kind = "Method")] + fn is_finite(&self) -> bool; "#, r#" -/// Create a new `Cuboid` from a given full size +/// Returns `true` if any elements are `NaN`. - #[lua(kind = "Function", output(proxy))] - fn from_size(#[proxy] size: bevy::math::Vec3) -> bevy::math::primitives::Cuboid; + #[lua(kind = "Method")] + fn is_nan(&self) -> bool; "#, r#" -/// Create a new `Cuboid` from two corner points +/// Returns true if the absolute difference of all elements between `self` and `rhs` +/// is less than or equal to `max_abs_diff`. +/// This can be used to compare if two 3x4 matrices contain similar elements. It works +/// best when comparing with a known value. The `max_abs_diff` that should be used used +/// depends on the values being compared against. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Function", output(proxy))] - fn from_corners( - #[proxy] - point1: bevy::math::Vec3, - #[proxy] - point2: bevy::math::Vec3, - ) -> bevy::math::primitives::Cuboid; + #[lua(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::Affine3A, max_abs_diff: f32) -> bool; "#, r#" -/// Get the size of the cuboid +/// Return the inverse of this transform. +/// Note that if the transform is not invertible the result will be invalid. #[lua(kind = "Method", output(proxy))] - fn size(&self) -> bevy::math::Vec3; + fn inverse(&self) -> bevy::math::Affine3A; "#, r#" -/// Get the surface area of the cuboid - #[lua(kind = "Method")] - fn area(&self) -> f32; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Affine3A) -> bool; "#, r#" -/// Get the volume of the cuboid - #[lua(kind = "Method")] - fn volume(&self) -> f32; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; "#, r#" -/// Finds the point on the cuboid that is closest to the given `point`. -/// If the point is outside the cuboid, the returned point will be on the surface of the cuboid. -/// Otherwise, it will be inside the cuboid and returned as is. - #[lua(kind = "Method", output(proxy))] - fn closest_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; + #[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#" @@ -21840,1326 +18214,1098 @@ struct Segment3d { kind = "Method", output(proxy), )] - fn clone(&self) -> bevy::math::primitives::Cuboid; + fn clone(&self) -> bevy::math::Affine3A; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{:?}", _self) + format!("{}", _self) } "#] )] -struct Cuboid { +struct Affine3A { #[lua(output(proxy))] - half_size: bevy::math::Vec3, + matrix3: bevy::math::Mat3A, + #[lua(output(proxy))] + translation: bevy::math::Vec3A, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::primitives::Cylinder", + remote = "bevy::math::DAffine2", functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Cylinder; - -"#, - 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: &bevy_math::primitives::Cylinder) -> bool; + fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; "#, r#" -/// Create a new `Cylinder` from a radius and full height +/// Creates an affine transform from three column vectors. #[lua(kind = "Function", output(proxy))] - fn new(radius: f32, height: f32) -> bevy::math::primitives::Cylinder; - -"#, - r#" -/// Get the base of the cylinder as a [`Circle`] - - #[lua(kind = "Method", output(proxy))] - fn base(&self) -> bevy::math::primitives::Circle; - -"#, - r#" -/// Get the surface area of the side of the cylinder, -/// also known as the lateral area - - #[lua(kind = "Method")] - fn lateral_area(&self) -> f32; + fn from_cols( + #[proxy] + x_axis: bevy::math::DVec2, + #[proxy] + y_axis: bevy::math::DVec2, + #[proxy] + z_axis: bevy::math::DVec2, + ) -> bevy::math::DAffine2; "#, r#" -/// Get the surface area of one base of the cylinder +/// Creates a `[f64; 6]` array storing data in column major order. #[lua(kind = "Method")] - fn base_area(&self) -> f32; + fn to_cols_array(&self) -> [f64; 6]; "#, r#" -/// Get the total surface area of the cylinder +/// Creates a `[[f64; 2]; 3]` 2D array storing data in +/// column major order. +/// If you require data in row major order `transpose` the matrix first. #[lua(kind = "Method")] - fn area(&self) -> f32; + fn to_cols_array_2d(&self) -> [[f64; 2]; 3]; "#, r#" -/// Get the volume of the cylinder +/// Creates an affine transform that changes scale. +/// Note that if any scale is zero the transform will be non-invertible. - #[lua(kind = "Method")] - fn volume(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_scale(#[proxy] scale: bevy::math::DVec2) -> bevy::math::DAffine2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Cylinder { - radius: f32, - half_height: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Capsule3d", - functions[r#" +/// Creates an affine transform from the given rotation `angle`. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Capsule3d) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_angle(angle: f64) -> bevy::math::DAffine2; "#, r#" +/// Creates an affine transformation from the given 2D `translation`. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Capsule3d; + #[lua(kind = "Function", output(proxy))] + fn from_translation(#[proxy] translation: bevy::math::DVec2) -> bevy::math::DAffine2; "#, r#" -/// Create a new `Capsule3d` from a radius and length +/// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) #[lua(kind = "Function", output(proxy))] - fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule3d; + fn from_mat2(#[proxy] matrix2: bevy::math::DMat2) -> bevy::math::DAffine2; "#, r#" -/// Get the part connecting the hemispherical ends -/// of the capsule as a [`Cylinder`] +/// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) and a +/// translation vector. +/// Equivalent to +/// `DAffine2::from_translation(translation) * DAffine2::from_mat2(mat2)` - #[lua(kind = "Method", output(proxy))] - fn to_cylinder(&self) -> bevy::math::primitives::Cylinder; + #[lua(kind = "Function", output(proxy))] + fn from_mat2_translation( + #[proxy] + matrix2: bevy::math::DMat2, + #[proxy] + translation: bevy::math::DVec2, + ) -> bevy::math::DAffine2; "#, r#" -/// Get the surface area of the capsule +/// Creates an affine transform from the given 2D `scale`, rotation `angle` (in radians) and +/// `translation`. +/// Equivalent to `DAffine2::from_translation(translation) * +/// DAffine2::from_angle(angle) * DAffine2::from_scale(scale)` - #[lua(kind = "Method")] - fn area(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_scale_angle_translation( + #[proxy] + scale: bevy::math::DVec2, + angle: f64, + #[proxy] + translation: bevy::math::DVec2, + ) -> bevy::math::DAffine2; "#, r#" -/// Get the volume of the capsule +/// Creates an affine transform from the given 2D rotation `angle` (in radians) and +/// `translation`. +/// Equivalent to `DAffine2::from_translation(translation) * DAffine2::from_angle(angle)` - #[lua(kind = "Method")] - fn volume(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_angle_translation( + angle: f64, + #[proxy] + translation: bevy::math::DVec2, + ) -> bevy::math::DAffine2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Capsule3d { - radius: f32, - half_length: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::Cone", - functions[r#" +/// The given `DMat3` must be an affine transform, - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Cone) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_mat3(#[proxy] m: bevy::math::DMat3) -> bevy::math::DAffine2; "#, r#" -/// Get the base of the cone as a [`Circle`] +/// Transforms the given 2D point, applying shear, scale, rotation and translation. #[lua(kind = "Method", output(proxy))] - fn base(&self) -> bevy::math::primitives::Circle; + fn transform_point2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" -/// Get the slant height of the cone, the length of the line segment -/// connecting a point on the base to the apex +/// Transforms the given 2D vector, applying shear, scale and rotation (but NOT +/// translation). +/// To also apply translation, use [`Self::transform_point2()`] instead. - #[lua(kind = "Method")] - fn slant_height(&self) -> f32; + #[lua(kind = "Method", output(proxy))] + fn transform_vector2(&self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" -/// Get the surface area of the side of the cone, -/// also known as the lateral area +/// Returns `true` if, and only if, all elements are finite. +/// If any element is either `NaN`, positive or negative infinity, this will return +/// `false`. #[lua(kind = "Method")] - fn lateral_area(&self) -> f32; + fn is_finite(&self) -> bool; "#, r#" -/// Get the surface area of the base of the cone +/// Returns `true` if any elements are `NaN`. #[lua(kind = "Method")] - fn base_area(&self) -> f32; + fn is_nan(&self) -> bool; "#, r#" -/// Get the total surface area of the cone +/// Returns true if the absolute difference of all elements between `self` and `rhs` +/// is less than or equal to `max_abs_diff`. +/// This can be used to compare if two 3x4 matrices contain similar elements. It works +/// best when comparing with a known value. The `max_abs_diff` that should be used used +/// depends on the values being compared against. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). #[lua(kind = "Method")] - fn area(&self) -> f32; + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DAffine2, max_abs_diff: f64) -> bool; "#, r#" -/// Get the volume of the cone +/// Return the inverse of this transform. +/// Note that if the transform is not invertible the result will be invalid. - #[lua(kind = "Method")] - fn volume(&self) -> f32; + #[lua(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::DAffine2; "#, r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone(&self) -> bevy::math::primitives::Cone; + fn eq(&self, #[proxy] rhs: &glam::DAffine2) -> bool; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Cone { - radius: f32, - height: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::ConicalFrustum", - functions[r#" #[lua( as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", kind = "Method", output(proxy), )] - fn clone(&self) -> bevy::math::primitives::ConicalFrustum; + fn clone(&self) -> bevy::math::DAffine2; "#, 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: &bevy_math::primitives::ConicalFrustum) -> bool; + fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DAffine2; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{:?}", _self) + format!("{}", _self) } "#] )] -struct ConicalFrustum { - radius_top: f32, - radius_bottom: f32, - height: f32, +struct DAffine2 { + #[lua(output(proxy))] + matrix2: bevy::math::DMat2, + #[lua(output(proxy))] + translation: bevy::math::DVec2, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::primitives::Torus", + remote = "bevy::math::DAffine3", functions[r#" -/// Create a new `Torus` from an inner and outer radius. -/// The inner radius is the radius of the hole, and the outer radius -/// is the radius of the entire object +/// Creates an affine transform from three column vectors. #[lua(kind = "Function", output(proxy))] - fn new(inner_radius: f32, outer_radius: f32) -> bevy::math::primitives::Torus; + fn from_cols( + #[proxy] + x_axis: bevy::math::DVec3, + #[proxy] + y_axis: bevy::math::DVec3, + #[proxy] + z_axis: bevy::math::DVec3, + #[proxy] + w_axis: bevy::math::DVec3, + ) -> bevy::math::DAffine3; "#, r#" -/// Get the inner radius of the torus. -/// For a ring torus, this corresponds to the radius of the hole, -/// or `major_radius - minor_radius` +/// Creates a `[f64; 12]` array storing data in column major order. #[lua(kind = "Method")] - fn inner_radius(&self) -> f32; + fn to_cols_array(&self) -> [f64; 12]; "#, r#" -/// Get the outer radius of the torus. -/// This corresponds to the overall radius of the entire object, -/// or `major_radius + minor_radius` +/// Creates a `[[f64; 3]; 4]` 3D array storing data in +/// column major order. +/// If you require data in row major order `transpose` the matrix first. #[lua(kind = "Method")] - fn outer_radius(&self) -> f32; + fn to_cols_array_2d(&self) -> [[f64; 3]; 4]; "#, r#" -/// Get the surface area of the torus. Note that this only produces -/// the expected result when the torus has a ring and isn't self-intersecting +/// Creates an affine transform that changes scale. +/// Note that if any scale is zero the transform will be non-invertible. - #[lua(kind = "Method")] - fn area(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_scale(#[proxy] scale: bevy::math::DVec3) -> bevy::math::DAffine3; "#, r#" -/// Get the volume of the torus. Note that this only produces -/// the expected result when the torus has a ring and isn't self-intersecting +/// Creates an affine transform from the given `rotation` quaternion. - #[lua(kind = "Method")] - fn volume(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_quat(#[proxy] rotation: bevy::math::DQuat) -> bevy::math::DAffine3; "#, r#" +/// Creates an affine transform containing a 3D rotation around a normalized +/// rotation `axis` of `angle` (in radians). - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::primitives::Torus; + #[lua(kind = "Function", output(proxy))] + fn from_axis_angle( + #[proxy] + axis: bevy::math::DVec3, + angle: f64, + ) -> bevy::math::DAffine3; "#, r#" +/// Creates an affine transform containing a 3D rotation around the x axis of +/// `angle` (in radians). - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::primitives::Torus) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_rotation_x(angle: f64) -> bevy::math::DAffine3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Torus { - minor_radius: f32, - major_radius: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::IRect", - functions[r#" +/// Creates an affine transform containing a 3D rotation around the y axis of +/// `angle` (in radians). - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Function", output(proxy))] + fn from_rotation_y(angle: f64) -> bevy::math::DAffine3; "#, r#" +/// Creates an affine transform containing a 3D rotation around the z axis of +/// `angle` (in radians). - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::IRect; + #[lua(kind = "Function", output(proxy))] + fn from_rotation_z(angle: f64) -> bevy::math::DAffine3; "#, 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. -/// # Examples -/// ``` -/// # use bevy_math::IRect; -/// let r = IRect::new(0, 4, 10, 6); // w=10 h=2 -/// let r = IRect::new(2, 3, 5, -1); // w=3 h=4 -/// ``` +/// Creates an affine transformation from the given 3D `translation`. #[lua(kind = "Function", output(proxy))] - fn new(x0: i32, y0: i32, x1: i32, y1: i32) -> bevy::math::IRect; + fn from_translation(#[proxy] translation: bevy::math::DVec3) -> bevy::math::DAffine3; "#, 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. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// // Unit rect from [0,0] to [1,1] -/// let r = IRect::from_corners(IVec2::ZERO, IVec2::ONE); // w=1 h=1 -/// // Same; the points do not need to be ordered -/// let r = IRect::from_corners(IVec2::ONE, IVec2::ZERO); // w=1 h=1 -/// ``` +/// Creates an affine transform from a 3x3 matrix (expressing scale, shear and +/// rotation) + + #[lua(kind = "Function", output(proxy))] + fn from_mat3(#[proxy] mat3: bevy::math::DMat3) -> bevy::math::DAffine3; + +"#, + r#" +/// Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation) +/// and a translation vector. +/// Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_mat3(mat3)` #[lua(kind = "Function", output(proxy))] - fn from_corners( + fn from_mat3_translation( #[proxy] - p0: bevy::math::IVec2, + mat3: bevy::math::DMat3, #[proxy] - p1: bevy::math::IVec2, - ) -> bevy::math::IRect; + translation: bevy::math::DVec3, + ) -> bevy::math::DAffine3; "#, r#" -/// Create a new rectangle from its center and size. -/// # Rounding Behaviour -/// 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. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::from_center_size(IVec2::ZERO, IVec2::new(3, 2)); // w=2 h=2 -/// assert_eq!(r.min, IVec2::splat(-1)); -/// assert_eq!(r.max, IVec2::splat(1)); -/// ``` +/// Creates an affine transform from the given 3D `scale`, `rotation` and +/// `translation`. +/// Equivalent to `DAffine3::from_translation(translation) * +/// DAffine3::from_quat(rotation) * DAffine3::from_scale(scale)` #[lua(kind = "Function", output(proxy))] - fn from_center_size( + fn from_scale_rotation_translation( + #[proxy] + scale: bevy::math::DVec3, #[proxy] - origin: bevy::math::IVec2, + rotation: bevy::math::DQuat, #[proxy] - size: bevy::math::IVec2, - ) -> bevy::math::IRect; + translation: bevy::math::DVec3, + ) -> bevy::math::DAffine3; "#, r#" -/// Create a new rectangle from its center and half-size. -/// # Panics -/// This method panics if any of the components of the half-size is negative. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::from_center_half_size(IVec2::ZERO, IVec2::ONE); // w=2 h=2 -/// assert_eq!(r.min, IVec2::splat(-1)); -/// assert_eq!(r.max, IVec2::splat(1)); -/// ``` +/// Creates an affine transform from the given 3D `rotation` and `translation`. +/// Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_quat(rotation)` #[lua(kind = "Function", output(proxy))] - fn from_center_half_size( + fn from_rotation_translation( #[proxy] - origin: bevy::math::IVec2, + rotation: bevy::math::DQuat, #[proxy] - half_size: bevy::math::IVec2, - ) -> bevy::math::IRect; + translation: bevy::math::DVec3, + ) -> bevy::math::DAffine3; "#, r#" -/// Check if the rectangle is empty. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::from_corners(IVec2::ZERO, IVec2::new(0, 1)); // w=0 h=1 -/// assert!(r.is_empty()); -/// ``` +/// The given `DMat4` must be an affine transform, +/// i.e. contain no perspective transform. - #[lua(kind = "Method")] - fn is_empty(&self) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_mat4(#[proxy] m: bevy::math::DMat4) -> bevy::math::DAffine3; "#, r#" -/// Rectangle width (max.x - min.x). -/// # Examples -/// ``` -/// # use bevy_math::IRect; -/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// assert_eq!(r.width(), 5); -/// ``` +/// Creates a left-handed view transform using a camera position, an up direction, and a facing +/// direction. +/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - #[lua(kind = "Method")] - fn width(&self) -> i32; + #[lua(kind = "Function", output(proxy))] + fn look_to_lh( + #[proxy] + eye: bevy::math::DVec3, + #[proxy] + dir: bevy::math::DVec3, + #[proxy] + up: bevy::math::DVec3, + ) -> bevy::math::DAffine3; "#, r#" -/// Rectangle height (max.y - min.y). -/// # Examples -/// ``` -/// # use bevy_math::IRect; -/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// assert_eq!(r.height(), 1); -/// ``` +/// Creates a right-handed view transform using a camera position, an up direction, and a facing +/// direction. +/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - #[lua(kind = "Method")] - fn height(&self) -> i32; + #[lua(kind = "Function", output(proxy))] + fn look_to_rh( + #[proxy] + eye: bevy::math::DVec3, + #[proxy] + dir: bevy::math::DVec3, + #[proxy] + up: bevy::math::DVec3, + ) -> bevy::math::DAffine3; "#, r#" -/// Rectangle size. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// assert_eq!(r.size(), IVec2::new(5, 1)); -/// ``` +/// Creates a left-handed view transform using a camera position, an up direction, and a focal +/// point. +/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. +/// # Panics +/// Will panic if `up` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] - fn size(&self) -> bevy::math::IVec2; + #[lua(kind = "Function", output(proxy))] + fn look_at_lh( + #[proxy] + eye: bevy::math::DVec3, + #[proxy] + center: bevy::math::DVec3, + #[proxy] + up: bevy::math::DVec3, + ) -> bevy::math::DAffine3; "#, r#" -/// Rectangle half-size. -/// # Rounding Behaviour -/// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::new(0, 0, 4, 3); // w=4 h=3 -/// assert_eq!(r.half_size(), IVec2::new(2, 1)); -/// ``` +/// Creates a right-handed view transform using a camera position, an up direction, and a focal +/// point. +/// For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. +/// # Panics +/// Will panic if `up` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Function", output(proxy))] + fn look_at_rh( + #[proxy] + eye: bevy::math::DVec3, + #[proxy] + center: bevy::math::DVec3, + #[proxy] + up: bevy::math::DVec3, + ) -> bevy::math::DAffine3; + +"#, + r#" +/// Transforms the given 3D points, applying shear, scale, rotation and translation. #[lua(kind = "Method", output(proxy))] - fn half_size(&self) -> bevy::math::IVec2; + fn transform_point3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// The center point of the rectangle. -/// # Rounding Behaviour -/// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::new(0, 0, 5, 2); // w=5 h=2 -/// assert_eq!(r.center(), IVec2::new(2, 1)); -/// ``` +/// Transforms the given 3D vector, applying shear, scale and rotation (but NOT +/// translation). +/// To also apply translation, use [`Self::transform_point3()`] instead. #[lua(kind = "Method", output(proxy))] - fn center(&self) -> bevy::math::IVec2; + fn transform_vector3(&self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// Check if a point lies within this rectangle, inclusive of its edges. -/// # Examples -/// ``` -/// # use bevy_math::IRect; -/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// assert!(r.contains(r.center())); -/// assert!(r.contains(r.min)); -/// assert!(r.contains(r.max)); -/// ``` +/// Returns `true` if, and only if, all elements are finite. +/// If any element is either `NaN`, positive or negative infinity, this will return +/// `false`. #[lua(kind = "Method")] - fn contains(&self, #[proxy] point: bevy::math::IVec2) -> bool; + fn is_finite(&self) -> bool; "#, r#" -/// Build a new rectangle formed of the union of this rectangle and another rectangle. -/// The union is the smallest rectangle enclosing both rectangles. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r1 = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// let r2 = IRect::new(1, -1, 3, 3); // w=2 h=4 -/// let r = r1.union(r2); -/// assert_eq!(r.min, IVec2::new(0, -1)); -/// assert_eq!(r.max, IVec2::new(5, 3)); -/// ``` +/// Returns `true` if any elements are `NaN`. - #[lua(kind = "Method", output(proxy))] - fn union(&self, #[proxy] other: bevy::math::IRect) -> bevy::math::IRect; + #[lua(kind = "Method")] + fn is_nan(&self) -> bool; "#, r#" -/// Build a new rectangle formed of the union of this rectangle and a point. -/// The union is the smallest rectangle enclosing both the rectangle and the point. If the -/// point is already inside the rectangle, this method returns a copy of the rectangle. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// let u = r.union_point(IVec2::new(3, 6)); -/// assert_eq!(u.min, IVec2::ZERO); -/// assert_eq!(u.max, IVec2::new(5, 6)); -/// ``` +/// Returns true if the absolute difference of all elements between `self` and `rhs` +/// is less than or equal to `max_abs_diff`. +/// This can be used to compare if two 3x4 matrices contain similar elements. It works +/// best when comparing with a known value. The `max_abs_diff` that should be used used +/// depends on the values being compared against. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - #[lua(kind = "Method", output(proxy))] - fn union_point(&self, #[proxy] other: bevy::math::IVec2) -> bevy::math::IRect; + #[lua(kind = "Method")] + fn abs_diff_eq(&self, #[proxy] rhs: bevy::math::DAffine3, max_abs_diff: f64) -> bool; "#, r#" -/// Build a new rectangle formed of the intersection of this rectangle and another rectangle. -/// The intersection is the largest rectangle enclosed in both rectangles. If the intersection -/// is empty, this method returns an empty rectangle ([`IRect::is_empty()`] returns `true`), but -/// the actual values of [`IRect::min`] and [`IRect::max`] are implementation-dependent. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r1 = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// let r2 = IRect::new(1, -1, 3, 3); // w=2 h=4 -/// let r = r1.intersect(r2); -/// assert_eq!(r.min, IVec2::new(1, 0)); -/// assert_eq!(r.max, IVec2::new(3, 1)); -/// ``` +/// Return the inverse of this transform. +/// Note that if the transform is not invertible the result will be invalid. #[lua(kind = "Method", output(proxy))] - fn intersect(&self, #[proxy] other: bevy::math::IRect) -> bevy::math::IRect; + fn inverse(&self) -> bevy::math::DAffine3; "#, r#" -/// Create a new rectangle with a constant inset. -/// The inset is the extra border on all sides. A positive inset produces a larger rectangle, -/// while a negative inset is allowed and produces a smaller rectangle. If the inset is negative -/// and its absolute value is larger than the rectangle half-size, the created rectangle is empty. -/// # Examples -/// ``` -/// # use bevy_math::{IRect, IVec2}; -/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1 -/// let r2 = r.inset(3); // w=11 h=7 -/// assert_eq!(r2.min, IVec2::splat(-3)); -/// assert_eq!(r2.max, IVec2::new(8, 4)); -/// let r = IRect::new(0, -1, 4, 3); // w=4 h=4 -/// let r2 = r.inset(-1); // w=2 h=2 -/// assert_eq!(r2.min, IVec2::new(1, 0)); -/// assert_eq!(r2.max, IVec2::new(3, 2)); -/// ``` - #[lua(kind = "Method", output(proxy))] - fn inset(&self, inset: i32) -> bevy::math::IRect; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DAffine3) -> bool; "#, r#" -/// Returns self as [`Rect`] (f32) - #[lua(kind = "Method", output(proxy))] - fn as_rect(&self) -> bevy::math::Rect; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DAffine3; "#, r#" -/// Returns self as [`URect`] (u32) - #[lua(kind = "Method", output(proxy))] - fn as_urect(&self) -> bevy::math::URect; + #[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::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] other: &bevy_math::IRect) -> bool; + 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) } "#] )] -struct IRect { +struct DAffine3 { #[lua(output(proxy))] - min: bevy::math::IVec2, + matrix3: bevy::math::DMat3, #[lua(output(proxy))] - max: bevy::math::IVec2, + translation: bevy::math::DVec3, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::Rect", + remote = "bevy::math::DQuat", functions[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. -/// # Examples -/// ``` -/// # use bevy_math::Rect; -/// let r = Rect::new(0., 4., 10., 6.); // w=10 h=2 -/// let r = Rect::new(2., 3., 5., -1.); // w=3 h=4 -/// ``` + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DQuat; + +"#, + r#" +/// Multiplies a quaternion by a scalar value. +/// The product is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DQuat; + +"#, + r#" + + #[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", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DQuat; + +"#, + r#" +/// Creates a new rotation quaternion. +/// This should generally not be called manually unless you know what you are doing. +/// Use one of the other constructors instead such as `identity` or `from_axis_angle`. +/// `from_xyzw` is mostly used by unit tests and `serde` deserialization. +/// # Preconditions +/// This function does not check if the input is normalized, it is up to the user to +/// provide normalized input or to normalized the resulting quaternion. #[lua(kind = "Function", output(proxy))] - fn new(x0: f32, y0: f32, x1: f32, y1: f32) -> bevy::math::Rect; + fn from_xyzw(x: f64, y: f64, z: f64, w: f64) -> bevy::math::DQuat; "#, 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. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// // Unit rect from [0,0] to [1,1] -/// let r = Rect::from_corners(Vec2::ZERO, Vec2::ONE); // w=1 h=1 -/// // Same; the points do not need to be ordered -/// let r = Rect::from_corners(Vec2::ONE, Vec2::ZERO); // w=1 h=1 -/// ``` +/// Creates a rotation quaternion from an array. +/// # Preconditions +/// This function does not check if the input is normalized, it is up to the user to +/// provide normalized input or to normalized the resulting quaternion. #[lua(kind = "Function", output(proxy))] - fn from_corners( - #[proxy] - p0: bevy::math::Vec2, - #[proxy] - p1: bevy::math::Vec2, - ) -> bevy::math::Rect; + fn from_array(a: [f64; 4]) -> bevy::math::DQuat; "#, r#" -/// Create a new rectangle from its center and size. -/// # Panics -/// This method panics if any of the components of the size is negative. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// let r = Rect::from_center_size(Vec2::ZERO, Vec2::ONE); // w=1 h=1 -/// assert!(r.min.abs_diff_eq(Vec2::splat(-0.5), 1e-5)); -/// assert!(r.max.abs_diff_eq(Vec2::splat(0.5), 1e-5)); -/// ``` +/// Creates a new rotation quaternion from a 4D vector. +/// # Preconditions +/// This function does not check if the input is normalized, it is up to the user to +/// provide normalized input or to normalized the resulting quaternion. #[lua(kind = "Function", output(proxy))] - fn from_center_size( - #[proxy] - origin: bevy::math::Vec2, - #[proxy] - size: bevy::math::Vec2, - ) -> bevy::math::Rect; + fn from_vec4(#[proxy] v: bevy::math::DVec4) -> bevy::math::DQuat; "#, r#" -/// Create a new rectangle from its center and half-size. +/// Create a quaternion for a normalized rotation `axis` and `angle` (in radians). +/// The axis must be a unit vector. /// # Panics -/// This method panics if any of the components of the half-size is negative. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// let r = Rect::from_center_half_size(Vec2::ZERO, Vec2::ONE); // w=2 h=2 -/// assert!(r.min.abs_diff_eq(Vec2::splat(-1.), 1e-5)); -/// assert!(r.max.abs_diff_eq(Vec2::splat(1.), 1e-5)); -/// ``` +/// Will panic if `axis` is not normalized when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] - fn from_center_half_size( - #[proxy] - origin: bevy::math::Vec2, + fn from_axis_angle( #[proxy] - half_size: bevy::math::Vec2, - ) -> bevy::math::Rect; + axis: bevy::math::DVec3, + angle: f64, + ) -> bevy::math::DQuat; "#, r#" -/// Check if the rectangle is empty. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// let r = Rect::from_corners(Vec2::ZERO, Vec2::new(0., 1.)); // w=0 h=1 -/// assert!(r.is_empty()); -/// ``` +/// Create a quaternion that rotates `v.length()` radians around `v.normalize()`. +/// `from_scaled_axis(Vec3::ZERO)` results in the identity quaternion. - #[lua(kind = "Method")] - fn is_empty(&self) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_scaled_axis(#[proxy] v: bevy::math::DVec3) -> bevy::math::DQuat; "#, r#" -/// Rectangle width (max.x - min.x). -/// # Examples -/// ``` -/// # use bevy_math::Rect; -/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 -/// assert!((r.width() - 5.).abs() <= 1e-5); -/// ``` +/// Creates a quaternion from the `angle` (in radians) around the x axis. - #[lua(kind = "Method")] - fn width(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_rotation_x(angle: f64) -> bevy::math::DQuat; "#, r#" -/// Rectangle height (max.y - min.y). -/// # Examples -/// ``` -/// # use bevy_math::Rect; -/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 -/// assert!((r.height() - 1.).abs() <= 1e-5); -/// ``` +/// Creates a quaternion from the `angle` (in radians) around the y axis. - #[lua(kind = "Method")] - fn height(&self) -> f32; + #[lua(kind = "Function", output(proxy))] + fn from_rotation_y(angle: f64) -> bevy::math::DQuat; "#, r#" -/// Rectangle size. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 -/// assert!(r.size().abs_diff_eq(Vec2::new(5., 1.), 1e-5)); -/// ``` +/// Creates a quaternion from the `angle` (in radians) around the z axis. - #[lua(kind = "Method", output(proxy))] - fn size(&self) -> bevy::math::Vec2; + #[lua(kind = "Function", output(proxy))] + fn from_rotation_z(angle: f64) -> bevy::math::DQuat; "#, r#" -/// Rectangle half-size. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 -/// assert!(r.half_size().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5)); -/// ``` +/// Creates a quaternion from the given Euler rotation sequence and the angles (in radians). - #[lua(kind = "Method", output(proxy))] - fn half_size(&self) -> bevy::math::Vec2; + #[lua(kind = "Function", output(proxy))] + fn from_euler( + #[proxy] + euler: bevy::math::EulerRot, + a: f64, + b: f64, + c: f64, + ) -> bevy::math::DQuat; "#, r#" -/// The center point of the rectangle. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 -/// assert!(r.center().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5)); -/// ``` +/// Creates a quaternion from a 3x3 rotation matrix. - #[lua(kind = "Method", output(proxy))] - fn center(&self) -> bevy::math::Vec2; + #[lua(kind = "Function", output(proxy))] + fn from_mat3(#[proxy] mat: &glam::DMat3) -> bevy::math::DQuat; "#, r#" -/// Check if a point lies within this rectangle, inclusive of its edges. -/// # Examples -/// ``` -/// # use bevy_math::Rect; -/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 -/// assert!(r.contains(r.center())); -/// assert!(r.contains(r.min)); -/// assert!(r.contains(r.max)); -/// ``` +/// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. + + #[lua(kind = "Function", output(proxy))] + fn from_mat4(#[proxy] mat: &glam::DMat4) -> bevy::math::DQuat; + +"#, + r#" +/// Gets the minimal rotation for transforming `from` to `to`. The rotation is in the +/// plane spanned by the two vectors. Will rotate at most 180 degrees. +/// The inputs must be unit vectors. +/// `from_rotation_arc(from, to) * from ≈ to`. +/// For near-singular cases (from≈to and from≈-to) the current implementation +/// is only accurate to about 0.001 (for `f32`). +/// # Panics +/// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. + + #[lua(kind = "Function", output(proxy))] + fn from_rotation_arc( + #[proxy] + from: bevy::math::DVec3, + #[proxy] + to: bevy::math::DVec3, + ) -> bevy::math::DQuat; + +"#, + r#" +/// Gets the minimal rotation for transforming `from` to either `to` or `-to`. This means +/// that the resulting quaternion will rotate `from` so that it is colinear with `to`. +/// The rotation is in the plane spanned by the two vectors. Will rotate at most 90 +/// degrees. +/// The inputs must be unit vectors. +/// `to.dot(from_rotation_arc_colinear(from, to) * from).abs() ≈ 1`. +/// # Panics +/// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. + + #[lua(kind = "Function", output(proxy))] + fn from_rotation_arc_colinear( + #[proxy] + from: bevy::math::DVec3, + #[proxy] + to: bevy::math::DVec3, + ) -> bevy::math::DQuat; + +"#, + r#" +/// Gets the minimal rotation for transforming `from` to `to`. The resulting rotation is +/// around the z axis. Will rotate at most 180 degrees. +/// The inputs must be unit vectors. +/// `from_rotation_arc_2d(from, to) * from ≈ to`. +/// For near-singular cases (from≈to and from≈-to) the current implementation +/// is only accurate to about 0.001 (for `f32`). +/// # Panics +/// Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - #[lua(kind = "Method")] - fn contains(&self, #[proxy] point: bevy::math::Vec2) -> bool; + #[lua(kind = "Function", output(proxy))] + fn from_rotation_arc_2d( + #[proxy] + from: bevy::math::DVec2, + #[proxy] + to: bevy::math::DVec2, + ) -> bevy::math::DQuat; "#, r#" -/// Build a new rectangle formed of the union of this rectangle and another rectangle. -/// The union is the smallest rectangle enclosing both rectangles. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// let r1 = Rect::new(0., 0., 5., 1.); // w=5 h=1 -/// let r2 = Rect::new(1., -1., 3., 3.); // w=2 h=4 -/// let r = r1.union(r2); -/// assert!(r.min.abs_diff_eq(Vec2::new(0., -1.), 1e-5)); -/// assert!(r.max.abs_diff_eq(Vec2::new(5., 3.), 1e-5)); -/// ``` +/// Returns the rotation axis scaled by the rotation in radians. #[lua(kind = "Method", output(proxy))] - fn union(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; + fn to_scaled_axis(self) -> bevy::math::DVec3; "#, r#" -/// Build a new rectangle formed of the union of this rectangle and a point. -/// The union is the smallest rectangle enclosing both the rectangle and the point. If the -/// point is already inside the rectangle, this method returns a copy of the rectangle. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 -/// let u = r.union_point(Vec2::new(3., 6.)); -/// assert!(u.min.abs_diff_eq(Vec2::ZERO, 1e-5)); -/// assert!(u.max.abs_diff_eq(Vec2::new(5., 6.), 1e-5)); -/// ``` +/// Returns the rotation angles for the given euler rotation sequence. - #[lua(kind = "Method", output(proxy))] - fn union_point(&self, #[proxy] other: bevy::math::Vec2) -> bevy::math::Rect; + #[lua(kind = "Method")] + fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f64, f64, f64); "#, r#" -/// Build a new rectangle formed of the intersection of this rectangle and another rectangle. -/// The intersection is the largest rectangle enclosed in both rectangles. If the intersection -/// is empty, this method returns an empty rectangle ([`Rect::is_empty()`] returns `true`), but -/// the actual values of [`Rect::min`] and [`Rect::max`] are implementation-dependent. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// let r1 = Rect::new(0., 0., 5., 1.); // w=5 h=1 -/// let r2 = Rect::new(1., -1., 3., 3.); // w=2 h=4 -/// let r = r1.intersect(r2); -/// assert!(r.min.abs_diff_eq(Vec2::new(1., 0.), 1e-5)); -/// assert!(r.max.abs_diff_eq(Vec2::new(3., 1.), 1e-5)); -/// ``` +/// `[x, y, z, w]` - #[lua(kind = "Method", output(proxy))] - fn intersect(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; + #[lua(kind = "Method")] + fn to_array(&self) -> [f64; 4]; "#, r#" -/// Create a new rectangle with a constant inset. -/// The inset is the extra border on all sides. A positive inset produces a larger rectangle, -/// while a negative inset is allowed and produces a smaller rectangle. If the inset is negative -/// and its absolute value is larger than the rectangle half-size, the created rectangle is empty. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 -/// let r2 = r.inset(3.); // w=11 h=7 -/// assert!(r2.min.abs_diff_eq(Vec2::splat(-3.), 1e-5)); -/// assert!(r2.max.abs_diff_eq(Vec2::new(8., 4.), 1e-5)); -/// let r = Rect::new(0., -1., 6., 7.); // w=6 h=8 -/// let r2 = r.inset(-2.); // w=11 h=7 -/// assert!(r2.min.abs_diff_eq(Vec2::new(2., 1.), 1e-5)); -/// assert!(r2.max.abs_diff_eq(Vec2::new(4., 5.), 1e-5)); -/// ``` +/// Returns the vector part of the quaternion. #[lua(kind = "Method", output(proxy))] - fn inset(&self, inset: f32) -> bevy::math::Rect; + fn xyz(self) -> bevy::math::DVec3; "#, r#" -/// Build a new rectangle from this one with its coordinates expressed -/// relative to `other` in a normalized ([0..1] x [0..1]) coordinate system. -/// # Examples -/// ``` -/// # use bevy_math::{Rect, Vec2}; -/// let r = Rect::new(2., 3., 4., 6.); -/// let s = Rect::new(0., 0., 10., 10.); -/// let n = r.normalize(s); -/// assert_eq!(n.min.x, 0.2); -/// assert_eq!(n.min.y, 0.3); -/// assert_eq!(n.max.x, 0.4); -/// assert_eq!(n.max.y, 0.6); -/// ``` +/// Returns the quaternion conjugate of `self`. For a unit quaternion the +/// conjugate is also the inverse. #[lua(kind = "Method", output(proxy))] - fn normalize(&self, #[proxy] other: bevy::math::Rect) -> bevy::math::Rect; + fn conjugate(self) -> bevy::math::DQuat; "#, r#" -/// Returns self as [`IRect`] (i32) +/// Returns the inverse of a normalized quaternion. +/// Typically quaternion inverse returns the conjugate of a normalized quaternion. +/// Because `self` is assumed to already be unit length this method *does not* normalize +/// before returning the conjugate. +/// # Panics +/// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn as_irect(&self) -> bevy::math::IRect; + fn inverse(self) -> bevy::math::DQuat; "#, r#" -/// Returns self as [`URect`] (u32) +/// Computes the dot product of `self` and `rhs`. The dot product is +/// equal to the cosine of the angle between two quaternion rotations. - #[lua(kind = "Method", output(proxy))] - fn as_urect(&self) -> bevy::math::URect; + #[lua(kind = "Method")] + fn dot(self, #[proxy] rhs: bevy::math::DQuat) -> f64; "#, r#" +/// Computes the length of `self`. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_math::Rect) -> bool; + #[lua(kind = "Method")] + fn length(self) -> f64; "#, r#" +/// Computes the squared length of `self`. +/// This is generally faster than `length()` as it avoids a square +/// root operation. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Rect; + #[lua(kind = "Method")] + fn length_squared(self) -> f64; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Rect { - #[lua(output(proxy))] - min: bevy::math::Vec2, - #[lua(output(proxy))] - max: bevy::math::Vec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::URect", - functions[r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::URect; + #[lua(kind = "Method")] + fn length_recip(self) -> f64; "#, 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. -/// # Examples -/// ``` -/// # use bevy_math::URect; -/// let r = URect::new(0, 4, 10, 6); // w=10 h=2 -/// let r = URect::new(2, 4, 5, 0); // w=3 h=4 -/// ``` +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must _not_ be of length zero. +/// Panics +/// Will panic if `self` is zero length when `glam_assert` is enabled. - #[lua(kind = "Function", output(proxy))] - fn new(x0: u32, y0: u32, x1: u32, y1: u32) -> bevy::math::URect; + #[lua(kind = "Method", output(proxy))] + fn normalize(self) -> bevy::math::DQuat; "#, 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. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// // Unit rect from [0,0] to [1,1] -/// let r = URect::from_corners(UVec2::ZERO, UVec2::ONE); // w=1 h=1 -/// // Same; the points do not need to be ordered -/// let r = URect::from_corners(UVec2::ONE, UVec2::ZERO); // w=1 h=1 -/// ``` +/// Returns `true` if, and only if, all elements are finite. +/// If any element is either `NaN`, positive or negative infinity, this will return `false`. - #[lua(kind = "Function", output(proxy))] - fn from_corners( - #[proxy] - p0: bevy::math::UVec2, - #[proxy] - p1: bevy::math::UVec2, - ) -> bevy::math::URect; + #[lua(kind = "Method")] + fn is_finite(self) -> bool; "#, r#" -/// Create a new rectangle from its center and size. -/// # Rounding Behaviour -/// 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. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::from_center_size(UVec2::ONE, UVec2::splat(2)); // w=2 h=2 -/// assert_eq!(r.min, UVec2::splat(0)); -/// assert_eq!(r.max, UVec2::splat(2)); -/// ``` - #[lua(kind = "Function", output(proxy))] - fn from_center_size( - #[proxy] - origin: bevy::math::UVec2, - #[proxy] - size: bevy::math::UVec2, - ) -> bevy::math::URect; + #[lua(kind = "Method")] + fn is_nan(self) -> bool; "#, r#" -/// Create a new rectangle from its center and half-size. -/// # Panics -/// This method panics if any of the components of the half-size is negative or if `origin - half_size` results in any negatives. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::from_center_half_size(UVec2::ONE, UVec2::ONE); // w=2 h=2 -/// assert_eq!(r.min, UVec2::splat(0)); -/// assert_eq!(r.max, UVec2::splat(2)); -/// ``` +/// Returns whether `self` of length `1.0` or not. +/// Uses a precision threshold of `1e-6`. - #[lua(kind = "Function", output(proxy))] - fn from_center_half_size( - #[proxy] - origin: bevy::math::UVec2, - #[proxy] - half_size: bevy::math::UVec2, - ) -> bevy::math::URect; + #[lua(kind = "Method")] + fn is_normalized(self) -> bool; "#, r#" -/// Check if the rectangle is empty. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::from_corners(UVec2::ZERO, UVec2::new(0, 1)); // w=0 h=1 -/// assert!(r.is_empty()); -/// ``` #[lua(kind = "Method")] - fn is_empty(&self) -> bool; + fn is_near_identity(self) -> bool; "#, r#" -/// Rectangle width (max.x - min.x). -/// # Examples -/// ``` -/// # use bevy_math::URect; -/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 -/// assert_eq!(r.width(), 5); -/// ``` +/// Returns the angle (in radians) for the minimal rotation +/// for transforming this quaternion into another. +/// Both quaternions must be normalized. +/// # Panics +/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. #[lua(kind = "Method")] - fn width(&self) -> u32; + fn angle_between(self, #[proxy] rhs: bevy::math::DQuat) -> f64; "#, r#" -/// Rectangle height (max.y - min.y). -/// # Examples -/// ``` -/// # use bevy_math::URect; -/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 -/// assert_eq!(r.height(), 1); -/// ``` +/// Returns true if the absolute difference of all elements between `self` and `rhs` +/// is less than or equal to `max_abs_diff`. +/// This can be used to compare if two quaternions contain similar elements. It works +/// best when comparing with a known value. The `max_abs_diff` that should be used used +/// depends on the values being compared against. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). #[lua(kind = "Method")] - fn height(&self) -> u32; + fn abs_diff_eq(self, #[proxy] rhs: bevy::math::DQuat, max_abs_diff: f64) -> bool; "#, r#" -/// Rectangle size. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 -/// assert_eq!(r.size(), UVec2::new(5, 1)); -/// ``` +/// Performs a linear interpolation between `self` and `rhs` based on +/// the value `s`. +/// When `s` is `0.0`, the result will be equal to `self`. When `s` +/// is `1.0`, the result will be equal to `rhs`. +/// # Panics +/// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn size(&self) -> bevy::math::UVec2; + fn lerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; "#, r#" -/// Rectangle half-size. -/// # Rounding Behaviour -/// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::new(0, 0, 4, 2); // w=4 h=2 -/// assert_eq!(r.half_size(), UVec2::new(2, 1)); -/// ``` +/// Performs a spherical linear interpolation between `self` and `end` +/// based on the value `s`. +/// When `s` is `0.0`, the result will be equal to `self`. When `s` +/// is `1.0`, the result will be equal to `end`. +/// # Panics +/// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] - fn half_size(&self) -> bevy::math::UVec2; + fn slerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; "#, r#" -/// The center point of the rectangle. -/// # Rounding Behaviour -/// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::new(0, 0, 4, 2); // w=4 h=2 -/// assert_eq!(r.center(), UVec2::new(2, 1)); -/// ``` +/// 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(kind = "Method", output(proxy))] - fn center(&self) -> bevy::math::UVec2; + fn mul_vec3(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" -/// Check if a point lies within this rectangle, inclusive of its edges. -/// # Examples -/// ``` -/// # use bevy_math::URect; -/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 -/// assert!(r.contains(r.center())); -/// assert!(r.contains(r.min)); -/// assert!(r.contains(r.max)); -/// ``` +/// 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(kind = "Method")] - fn contains(&self, #[proxy] point: bevy::math::UVec2) -> bool; + #[lua(kind = "Method", output(proxy))] + fn mul_quat(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" -/// Build a new rectangle formed of the union of this rectangle and another rectangle. -/// The union is the smallest rectangle enclosing both rectangles. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r1 = URect::new(0, 0, 5, 1); // w=5 h=1 -/// let r2 = URect::new(1, 0, 3, 8); // w=2 h=4 -/// let r = r1.union(r2); -/// assert_eq!(r.min, UVec2::new(0, 0)); -/// assert_eq!(r.max, UVec2::new(5, 8)); -/// ``` +/// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. - #[lua(kind = "Method", output(proxy))] - fn union(&self, #[proxy] other: bevy::math::URect) -> bevy::math::URect; + #[lua(kind = "Function", output(proxy))] + fn from_affine3(#[proxy] a: &glam::DAffine3) -> bevy::math::DQuat; "#, r#" -/// Build a new rectangle formed of the union of this rectangle and a point. -/// The union is the smallest rectangle enclosing both the rectangle and the point. If the -/// point is already inside the rectangle, this method returns a copy of the rectangle. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::new(0, 0, 5, 1); // w=5 h=1 -/// let u = r.union_point(UVec2::new(3, 6)); -/// assert_eq!(u.min, UVec2::ZERO); -/// assert_eq!(u.max, UVec2::new(5, 6)); -/// ``` #[lua(kind = "Method", output(proxy))] - fn union_point(&self, #[proxy] other: bevy::math::UVec2) -> bevy::math::URect; + fn as_quat(self) -> bevy::math::Quat; "#, r#" -/// Build a new rectangle formed of the intersection of this rectangle and another rectangle. -/// The intersection is the largest rectangle enclosed in both rectangles. If the intersection -/// is empty, this method returns an empty rectangle ([`URect::is_empty()`] returns `true`), but -/// the actual values of [`URect::min`] and [`URect::max`] are implementation-dependent. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r1 = URect::new(0, 0, 2, 2); // w=2 h=2 -/// let r2 = URect::new(1, 1, 3, 3); // w=2 h=2 -/// let r = r1.intersect(r2); -/// assert_eq!(r.min, UVec2::new(1, 1)); -/// assert_eq!(r.max, UVec2::new(2, 2)); -/// ``` #[lua(kind = "Method", output(proxy))] - fn intersect(&self, #[proxy] other: bevy::math::URect) -> bevy::math::URect; + fn as_f32(self) -> bevy::math::Quat; "#, r#" -/// Create a new rectangle with a constant inset. -/// The inset is the extra border on all sides. A positive inset produces a larger rectangle, -/// while a negative inset is allowed and produces a smaller rectangle. If the inset is negative -/// and its absolute value is larger than the rectangle half-size, the created rectangle is empty. -/// # Examples -/// ``` -/// # use bevy_math::{URect, UVec2}; -/// let r = URect::new(4, 4, 6, 6); // w=2 h=2 -/// let r2 = r.inset(1); // w=4 h=4 -/// assert_eq!(r2.min, UVec2::splat(3)); -/// assert_eq!(r2.max, UVec2::splat(7)); -/// let r = URect::new(4, 4, 8, 8); // w=4 h=4 -/// let r2 = r.inset(-1); // w=2 h=2 -/// assert_eq!(r2.min, UVec2::splat(5)); -/// assert_eq!(r2.max, UVec2::splat(7)); -/// ``` +/// Subtracts the `rhs` quaternion from `self`. +/// The difference is not guaranteed to be normalized. - #[lua(kind = "Method", output(proxy))] - fn inset(&self, inset: i32) -> bevy::math::URect; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" -/// Returns self as [`Rect`] (f32) +/// 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(kind = "Method", output(proxy))] - fn as_rect(&self) -> bevy::math::Rect; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" -/// Returns self as [`IRect`] (i32) +/// 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(kind = "Method", output(proxy))] - fn as_irect(&self) -> bevy::math::IRect; + #[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#" +/// 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", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] other: &bevy_math::URect) -> bool; + fn mul(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, 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::DQuat; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{:?}", _self) + format!("{}", _self) } "#] )] -struct URect { - #[lua(output(proxy))] - min: bevy::math::UVec2, - #[lua(output(proxy))] - max: bevy::math::UVec2, +struct DQuat { + x: f64, + y: f64, + z: f64, + w: f64, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "smol_str::SmolStr", + remote = "bevy::math::EulerRot", functions[r#" - #[lua(kind = "Method")] - fn to_string(&self) -> std::string::String; - -"#, - r#" - - #[lua(kind = "Method")] - fn len(&self) -> usize; - -"#, - r#" - - #[lua(kind = "Method")] - fn is_empty(&self) -> bool; - -"#, - r#" - - #[lua(kind = "Method")] - fn is_heap_allocated(&self) -> bool; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::EulerRot; "#, r#" @@ -23170,31 +19316,27 @@ struct URect { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &smol_str::SmolStr) -> bool; + fn eq(&self, #[proxy] other: &glam::EulerRot) -> bool; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> smol_str::SmolStr; + #[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) + format!("{:?}", _self) } "#] )] -struct SmolStr(); +struct EulerRot {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "std::num::NonZeroIsize", + remote = "bevy::math::BVec3A", functions[r#" #[lua( @@ -23203,311 +19345,170 @@ struct SmolStr(); composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &std::num::NonZeroIsize) -> bool; + fn eq(&self, #[proxy] rhs: &glam::BVec3A) -> bool; "#, r#" +/// Creates a new vector mask. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Function", output(proxy))] + fn new(x: bool, y: bool, z: bool) -> bevy::math::BVec3A; "#, r#" -/// Creates a non-zero without checking whether the value is non-zero. -/// This results in undefined behaviour if the value is zero. -/// # Safety -/// The value must not be zero. +/// Creates a vector mask with all elements set to `v`. #[lua(kind = "Function", output(proxy))] - unsafe fn new_unchecked(n: isize) -> std::num::NonZeroIsize; + fn splat(v: bool) -> bevy::math::BVec3A; + +"#, + r#" +/// Creates a new vector mask from a bool array. + + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [bool; 3]) -> bevy::math::BVec3A; "#, r#" -/// Returns the value as a primitive type. +/// Returns a bitmask with the lowest 3 bits set from the elements of `self`. +/// A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes +/// into the first lowest bit, element `y` into the second, etc. #[lua(kind = "Method")] - fn get(self) -> isize; + fn bitmask(self) -> u32; "#, r#" -/// Returns the number of leading zeros in the binary representation of `self`. -/// On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroIsize::new(-1isize).unwrap(); -/// assert_eq!(n.leading_zeros(), 0); -/// ``` +/// Returns true if any of the elements are true, false otherwise. #[lua(kind = "Method")] - fn leading_zeros(self) -> u32; + fn any(self) -> bool; "#, r#" -/// Returns the number of trailing zeros in the binary representation -/// of `self`. -/// On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. -/// # Examples -/// Basic usage: -/// ``` -///let n = std::num::NonZeroIsize::new(0b0101000).unwrap(); -/// assert_eq!(n.trailing_zeros(), 3); -/// ``` +/// Returns true if all the elements are true, false otherwise. #[lua(kind = "Method")] - fn trailing_zeros(self) -> u32; + fn all(self) -> bool; "#, r#" -/// Computes the absolute value of self. -///See [`isize::abs`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroIsize::new(1)?; -///let neg = NonZeroIsize::new(-1)?; -/// assert_eq!(pos, pos.abs()); -/// assert_eq!(pos, neg.abs()); -/// # Some(()) -/// # } -/// ``` +/// Tests the value at `index`. +/// Panics if `index` is greater than 2. - #[lua(kind = "Method", output(proxy))] - fn abs(self) -> std::num::NonZeroIsize; + #[lua(kind = "Method")] + fn test(&self, index: usize) -> bool; "#, r#" -/// Saturating absolute value, see -///[`isize::saturating_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroIsize::new(1)?; -///let neg = NonZeroIsize::new(-1)?; -///let min = NonZeroIsize::new(isize::MIN)?; -///let min_plus = NonZeroIsize::new(isize::MIN + 1)?; -///let max = NonZeroIsize::new(isize::MAX)?; -/// assert_eq!(pos, pos.saturating_abs()); -/// assert_eq!(pos, neg.saturating_abs()); -/// assert_eq!(max, min.saturating_abs()); -/// assert_eq!(max, min_plus.saturating_abs()); -/// # Some(()) -/// # } -/// ``` +/// Sets the element at `index`. +/// Panics if `index` is greater than 2. - #[lua(kind = "Method", output(proxy))] - fn saturating_abs(self) -> std::num::NonZeroIsize; + #[lua(kind = "MutatingMethod")] + fn set(&mut self, index: usize, value: bool) -> (); "#, r#" -/// Wrapping absolute value, see -///[`isize::wrapping_abs`]. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos = NonZeroIsize::new(1)?; -///let neg = NonZeroIsize::new(-1)?; -///let min = NonZeroIsize::new(isize::MIN)?; -///# let max = NonZeroIsize::new(isize::MAX)?; -/// assert_eq!(pos, pos.wrapping_abs()); -/// assert_eq!(pos, neg.wrapping_abs()); -/// assert_eq!(min, min.wrapping_abs()); -/// assert_eq!(max, (-max).wrapping_abs()); -/// # Some(()) -/// # } -/// ``` - #[lua(kind = "Method", output(proxy))] - fn wrapping_abs(self) -> std::num::NonZeroIsize; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec3A; "#, r#" -/// Computes the absolute value of self -/// without any wrapping or panicking. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -///# use std::num::NonZeroUsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let u_pos = NonZeroUsize::new(1)?; -///let i_pos = NonZeroIsize::new(1)?; -///let i_neg = NonZeroIsize::new(-1)?; -///let i_min = NonZeroIsize::new(isize::MIN)?; -///let u_max = NonZeroUsize::new(usize::MAX / 2 + 1)?; -/// assert_eq!(u_pos, i_pos.unsigned_abs()); -/// assert_eq!(u_pos, i_neg.unsigned_abs()); -/// assert_eq!(u_max, i_min.unsigned_abs()); -/// # Some(()) -/// # } -/// ``` +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +struct BVec3A(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::BVec4A", + functions[r#" - #[lua(kind = "Method", output(proxy))] - fn unsigned_abs(self) -> std::num::NonZeroUsize; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec4A; "#, r#" -/// Returns `true` if `self` is positive and `false` if the -/// number is negative. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroIsize::new(5)?; -///let neg_five = NonZeroIsize::new(-5)?; -/// assert!(pos_five.is_positive()); -/// assert!(!neg_five.is_positive()); -/// # Some(()) -/// # } -/// ``` +/// Creates a new vector mask. - #[lua(kind = "Method")] - fn is_positive(self) -> bool; + #[lua(kind = "Function", output(proxy))] + fn new(x: bool, y: bool, z: bool, w: bool) -> bevy::math::BVec4A; "#, r#" -/// Returns `true` if `self` is negative and `false` if the -/// number is positive. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroIsize::new(5)?; -///let neg_five = NonZeroIsize::new(-5)?; -/// assert!(neg_five.is_negative()); -/// assert!(!pos_five.is_negative()); -/// # Some(()) -/// # } -/// ``` +/// Creates a vector mask with all elements set to `v`. - #[lua(kind = "Method")] - fn is_negative(self) -> bool; + #[lua(kind = "Function", output(proxy))] + fn splat(v: bool) -> bevy::math::BVec4A; "#, r#" -/// Saturating negation. Computes `-self`, -///returning [`NonZeroIsize::MAX`] -///if `self == NonZeroIsize::MIN` -/// instead of overflowing. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroIsize::new(5)?; -///let neg_five = NonZeroIsize::new(-5)?; -///let min = NonZeroIsize::new(isize::MIN)?; -///let min_plus_one = NonZeroIsize::new(isize::MIN + 1)?; -///let max = NonZeroIsize::new(isize::MAX)?; -/// assert_eq!(pos_five.saturating_neg(), neg_five); -/// assert_eq!(min.saturating_neg(), max); -/// assert_eq!(max.saturating_neg(), min_plus_one); -/// # Some(()) -/// # } -/// ``` +/// Creates a new vector mask from a bool array. - #[lua(kind = "Method", output(proxy))] - fn saturating_neg(self) -> std::num::NonZeroIsize; + #[lua(kind = "Function", output(proxy))] + fn from_array(a: [bool; 4]) -> bevy::math::BVec4A; "#, r#" -/// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary -/// of the type. -///See [`isize::wrapping_neg`] -/// for documentation on overflow behaviour. -/// # Example -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let pos_five = NonZeroIsize::new(5)?; -///let neg_five = NonZeroIsize::new(-5)?; -///let min = NonZeroIsize::new(isize::MIN)?; -/// assert_eq!(pos_five.wrapping_neg(), neg_five); -/// assert_eq!(min.wrapping_neg(), min); -/// # Some(()) -/// # } -/// ``` +/// Returns a bitmask with the lowest 4 bits set from the elements of `self`. +/// A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes +/// into the first lowest bit, element `y` into the second, etc. - #[lua(kind = "Method", output(proxy))] - fn wrapping_neg(self) -> std::num::NonZeroIsize; + #[lua(kind = "Method")] + fn bitmask(self) -> u32; "#, r#" -/// Multiplies two non-zero integers together. -///Return [`NonZeroIsize::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let two = NonZeroIsize::new(2)?; -///let four = NonZeroIsize::new(4)?; -///let max = NonZeroIsize::new(isize::MAX)?; -/// assert_eq!(four, two.saturating_mul(two)); -/// assert_eq!(max, four.saturating_mul(max)); -/// # Some(()) -/// # } -/// ``` +/// Returns true if any of the elements are true, false otherwise. - #[lua(kind = "Method", output(proxy))] - fn saturating_mul( - self, - #[proxy] - other: std::num::NonZeroIsize, - ) -> std::num::NonZeroIsize; + #[lua(kind = "Method")] + fn any(self) -> bool; "#, r#" -/// Raise non-zero value to an integer power. -///Return [`NonZeroIsize::MIN`] or [`NonZeroIsize::MAX`] on overflow. -/// # Examples -/// ``` -///# use std::num::NonZeroIsize; -/// # fn main() { test().unwrap(); } -/// # fn test() -> Option<()> { -///let three = NonZeroIsize::new(3)?; -///let twenty_seven = NonZeroIsize::new(27)?; -///let max = NonZeroIsize::new(isize::MAX)?; -/// assert_eq!(twenty_seven, three.saturating_pow(3)); -/// assert_eq!(max, max.saturating_pow(3)); -/// # Some(()) -/// # } -/// ``` +/// Returns true if all the elements are true, false otherwise. - #[lua(kind = "Method", output(proxy))] - fn saturating_pow(self, other: u32) -> std::num::NonZeroIsize; + #[lua(kind = "Method")] + fn all(self) -> bool; "#, r#" +/// Tests the value at `index`. +/// Panics if `index` is greater than 3. - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::num::NonZeroIsize; + #[lua(kind = "Method")] + fn test(&self, index: usize) -> bool; + +"#, + r#" +/// Sets the element at `index`. +/// Panics if `index` is greater than 3. + + #[lua(kind = "MutatingMethod")] + fn set(&mut self, index: usize, value: bool) -> (); "#, 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) -> std::num::NonZeroIsize; + fn eq(&self, #[proxy] rhs: &glam::BVec4A) -> bool; "#, r#" @@ -23517,15 +19518,44 @@ fn index(&self) -> String { } "#] )] -struct NonZeroIsize(); +struct BVec4A(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::utils::Uuid", + remote = "smol_str::SmolStr", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method")] + fn to_string(&self) -> std::string::String; + +"#, + r#" + + #[lua(kind = "Method")] + fn len(&self) -> usize; + +"#, + r#" + + #[lua(kind = "Method")] + fn is_empty(&self) -> bool; + +"#, + r#" + + #[lua(kind = "Method")] + fn is_heap_allocated(&self) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &smol_str::SmolStr) -> bool; "#, r#" @@ -23535,10 +19565,22 @@ struct NonZeroIsize(); kind = "Method", output(proxy), )] - fn clone(&self) -> bevy::utils::Uuid; + fn clone(&self) -> smol_str::SmolStr; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +struct SmolStr(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + 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`]. @@ -23553,7 +19595,7 @@ struct NonZeroIsize(); /// # } /// ``` /// # References -/// * [Version in RFC4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.3) +/// * [Version Field in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-4.2) #[lua(kind = "Method")] fn get_version_num(&self) -> usize; @@ -23710,13 +19752,40 @@ struct NonZeroIsize(); #[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) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &uuid::Uuid) -> bool; + "#, 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 RFC4122](https://tools.ietf.org/html/rfc4122.html#section-4.1.7) +/// * [Nil UUID in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-5.9) /// # Examples /// Basic usage: /// ``` @@ -23729,7 +19798,7 @@ struct NonZeroIsize(); /// ``` #[lua(kind = "Function", output(proxy))] - fn nil() -> bevy::utils::Uuid; + fn nil() -> uuid::Uuid; "#, r#" @@ -23737,7 +19806,7 @@ struct NonZeroIsize(); /// The max UUID is a special form of UUID that is specified to have all /// 128 bits set to one. /// # References -/// * [Max UUID in Draft RFC: New UUID Formats, Version 4](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04#section-5.4) +/// * [Max UUID in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-5.10) /// # Examples /// Basic usage: /// ``` @@ -23750,7 +19819,7 @@ struct NonZeroIsize(); /// ``` #[lua(kind = "Function", output(proxy))] - fn max() -> bevy::utils::Uuid; + fn max() -> uuid::Uuid; "#, r#" @@ -23768,7 +19837,7 @@ struct NonZeroIsize(); /// ``` #[lua(kind = "Function", output(proxy))] - fn from_u128(v: u128) -> bevy::utils::Uuid; + fn from_u128(v: u128) -> uuid::Uuid; "#, r#" @@ -23790,7 +19859,7 @@ struct NonZeroIsize(); /// ``` #[lua(kind = "Function", output(proxy))] - fn from_u128_le(v: u128) -> bevy::utils::Uuid; + fn from_u128_le(v: u128) -> uuid::Uuid; "#, r#" @@ -23809,7 +19878,7 @@ struct NonZeroIsize(); /// ``` #[lua(kind = "Function", output(proxy))] - fn from_u64_pair(high_bits: u64, low_bits: u64) -> bevy::utils::Uuid; + fn from_u64_pair(high_bits: u64, low_bits: u64) -> uuid::Uuid; "#, r#" @@ -23835,7 +19904,7 @@ struct NonZeroIsize(); /// ``` #[lua(kind = "Function", output(proxy))] - fn from_bytes(bytes: [u8; 16]) -> bevy::utils::Uuid; + fn from_bytes(bytes: [u8; 16]) -> uuid::Uuid; "#, r#" @@ -23862,7 +19931,17 @@ struct NonZeroIsize(); /// ``` #[lua(kind = "Function", output(proxy))] - fn from_bytes_le(b: [u8; 16]) -> bevy::utils::Uuid; + fn from_bytes_le(b: [u8; 16]) -> uuid::Uuid; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> uuid::Uuid; "#, r#" @@ -23883,23 +19962,12 @@ struct NonZeroIsize(); /// assert_eq!(Some(Version::Random), uuid.get_version()); /// ``` /// # References -/// * [Version 4 UUIDs in RFC4122](https://www.rfc-editor.org/rfc/rfc4122#section-4.4) +/// * [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() -> bevy::utils::Uuid; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &bevy_utils::Uuid) -> bool; + fn new_v4() -> uuid::Uuid; "#, r#" @@ -23927,61 +19995,6 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { "Instant", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, )?; - instances - .add_instance( - "NonZeroI128", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroI16", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroI32", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroI64", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroI8", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroU128", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroU16", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroU32", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroU64", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroU8", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroUsize", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; instances .add_instance( "PathBuf", @@ -24172,113 +20185,6 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { "BVec4A", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, )?; - instances - .add_instance( - "Direction2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Circle", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Ellipse", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Plane2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Segment2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Triangle2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Rectangle", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "RegularPolygon", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaRegularPolygon, - >::new, - )?; - instances - .add_instance( - "Capsule2d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Direction3d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Sphere", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Plane3d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Segment3d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Cuboid", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Cylinder", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Capsule3d", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Torus", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "IRect", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "Rect", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "URect", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances - .add_instance( - "NonZeroIsize", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; instances .add_instance( "Uuid", @@ -24319,72 +20225,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyReflectAPIProvider { .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI128, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI16, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI32, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI64, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroI8, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU128, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU16, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU32, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU64, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroU8, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroUsize, - >, - >() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, @@ -24545,117 +20385,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyReflectAPIProvider { .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaDirection2d, - >, - >() - .process_type::() - .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, - >() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaSegment2d, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaTriangle2d, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaRectangle, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaRegularPolygon, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaCapsule2d, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaDirection3d, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaSegment3d, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaCylinder, - >, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaCapsule3d, - >, - >() - .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, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaNonZeroIsize, - >, - >() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, @@ -24682,17 +20412,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyReflectAPIProvider { 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::(); @@ -24733,32 +20452,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyReflectAPIProvider { 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::(); - 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 c0dee6c0..377313b2 100644 --- a/crates/bevy_script_api/src/providers/bevy_time.rs +++ b/crates/bevy_script_api/src/providers/bevy_time.rs @@ -50,13 +50,8 @@ struct Real {} remote = "bevy::time::prelude::Timer", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &timer::Timer) -> bool; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::time::prelude::Timer; "#, r#" @@ -388,8 +383,13 @@ struct Real {} "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::time::prelude::Timer; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &timer::Timer) -> bool; "#, r#" @@ -465,8 +465,19 @@ struct Virtual {} remote = "bevy::time::Stopwatch", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::time::Stopwatch; + #[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: &stopwatch::Stopwatch) -> bool; "#, r#" @@ -619,19 +630,8 @@ struct Virtual {} "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &stopwatch::Stopwatch) -> bool; - -"#, - 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::time::Stopwatch; "#, r#" diff --git a/crates/bevy_script_api/src/providers/bevy_transform.rs b/crates/bevy_script_api/src/providers/bevy_transform.rs index 6f79491b..0a55f0c6 100644 --- a/crates/bevy_script_api/src/providers/bevy_transform.rs +++ b/crates/bevy_script_api/src/providers/bevy_transform.rs @@ -6,6 +6,7 @@ use super::bevy_ecs::*; use super::bevy_reflect::*; use super::bevy_core::*; use super::bevy_hierarchy::*; +use super::bevy_math::*; extern crate self as bevy_script_api; use bevy_script_api::{ lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, @@ -16,30 +17,8 @@ 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] - 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; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::transform::components::GlobalTransform; "#, r#" @@ -153,42 +132,42 @@ use bevy_script_api::{ ///Return the local right vector (X). #[lua(kind = "Method", output(proxy))] - fn right(&self) -> bevy::math::Vec3; + fn right(&self) -> bevy::math::Dir3; "#, r#" ///Return the local left vector (-X). #[lua(kind = "Method", output(proxy))] - fn left(&self) -> bevy::math::Vec3; + fn left(&self) -> bevy::math::Dir3; "#, r#" ///Return the local up vector (Y). #[lua(kind = "Method", output(proxy))] - fn up(&self) -> bevy::math::Vec3; + fn up(&self) -> bevy::math::Dir3; "#, r#" ///Return the local down vector (-Y). #[lua(kind = "Method", output(proxy))] - fn down(&self) -> bevy::math::Vec3; + fn down(&self) -> bevy::math::Dir3; "#, r#" ///Return the local back vector (Z). #[lua(kind = "Method", output(proxy))] - fn back(&self) -> bevy::math::Vec3; + fn back(&self) -> bevy::math::Dir3; "#, r#" ///Return the local forward vector (-Z). #[lua(kind = "Method", output(proxy))] - fn forward(&self) -> bevy::math::Vec3; + fn forward(&self) -> bevy::math::Dir3; "#, r#" @@ -234,8 +213,18 @@ use bevy_script_api::{ "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::transform::components::GlobalTransform; + #[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#" @@ -250,9 +239,21 @@ use bevy_script_api::{ fn mul( self, #[proxy] - global_transform: bevy::transform::components::GlobalTransform, + 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")] @@ -269,12 +270,51 @@ struct GlobalTransform(); 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] other: &components::transform::Transform) -> bool; + 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#" @@ -293,7 +333,7 @@ struct GlobalTransform(); #[lua(kind = "Function", output(proxy))] fn from_matrix( #[proxy] - matrix: bevy::math::Mat4, + world_from_local: bevy::math::Mat4, ) -> bevy::transform::components::Transform; "#, @@ -329,42 +369,6 @@ struct GlobalTransform(); scale: bevy::math::Vec3, ) -> bevy::transform::components::Transform; -"#, - r#" -/// Returns this [`Transform`] with a new rotation so that [`Transform::forward`] -/// points towards the `target` position and [`Transform::up`] points towards `up`. -/// In some cases it's not possible to construct a rotation. Another axis will be picked in those cases: -/// * if `target` is the same as the transform translation, `Vec3::Z` is used instead -/// * if `up` is zero, `Vec3::Y` is used instead -/// * if the resulting forward direction is parallel with `up`, an orthogonal vector is used as the "right" direction - - #[lua(kind = "Method", output(proxy))] - fn looking_at( - self, - #[proxy] - target: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::transform::components::Transform; - -"#, - r#" -/// Returns this [`Transform`] with a new rotation so that [`Transform::forward`] -/// points in the given `direction` and [`Transform::up`] points towards `up`. -/// In some cases it's not possible to construct a rotation. Another axis will be picked in those cases: -/// * if `direction` is zero, `Vec3::Z` is used instead -/// * if `up` is zero, `Vec3::Y` is used instead -/// * if `direction` is parallel with `up`, an orthogonal vector is used as the "right" direction - - #[lua(kind = "Method", output(proxy))] - fn looking_to( - self, - #[proxy] - direction: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> bevy::transform::components::Transform; - "#, r#" /// Returns this [`Transform`] with a new translation. @@ -414,6 +418,69 @@ struct GlobalTransform(); #[lua(kind = "Method", output(proxy))] fn compute_affine(&self) -> bevy::math::Affine3A; +"#, + r#" +/// Get the unit vector in the local `X` direction. + + #[lua(kind = "Method", output(proxy))] + fn local_x(&self) -> bevy::math::Dir3; + +"#, + r#" +/// Equivalent to [`-local_x()`][Transform::local_x()] + + #[lua(kind = "Method", output(proxy))] + fn left(&self) -> bevy::math::Dir3; + +"#, + r#" +/// Equivalent to [`local_x()`][Transform::local_x()] + + #[lua(kind = "Method", output(proxy))] + fn right(&self) -> bevy::math::Dir3; + +"#, + r#" +/// Get the unit vector in the local `Y` direction. + + #[lua(kind = "Method", output(proxy))] + fn local_y(&self) -> bevy::math::Dir3; + +"#, + r#" +/// Equivalent to [`local_y()`][Transform::local_y] + + #[lua(kind = "Method", output(proxy))] + fn up(&self) -> bevy::math::Dir3; + +"#, + r#" +/// Equivalent to [`-local_y()`][Transform::local_y] + + #[lua(kind = "Method", output(proxy))] + fn down(&self) -> bevy::math::Dir3; + +"#, + r#" +/// Get the unit vector in the local `Z` direction. + + #[lua(kind = "Method", output(proxy))] + fn local_z(&self) -> bevy::math::Dir3; + +"#, + r#" +/// Equivalent to [`-local_z()`][Transform::local_z] + + #[lua(kind = "Method", output(proxy))] + fn forward(&self) -> bevy::math::Dir3; + +"#, + r#" +/// Equivalent to [`local_z()`][Transform::local_z] + + #[lua(kind = "Method", output(proxy))] + fn back(&self) -> bevy::math::Dir3; + "#, r#" /// Rotates this [`Transform`] by the given rotation. @@ -431,7 +498,7 @@ struct GlobalTransform(); /// If this [`Transform`] has a parent, the `axis` is relative to the rotation of the parent. #[lua(kind = "MutatingMethod")] - fn rotate_axis(&mut self, #[proxy] axis: bevy::math::Vec3, angle: f32) -> (); + fn rotate_axis(&mut self, #[proxy] axis: bevy::math::Dir3, angle: f32) -> (); "#, r#" @@ -470,7 +537,7 @@ struct GlobalTransform(); /// Rotates this [`Transform`] around its local `axis` by `angle` (in radians). #[lua(kind = "MutatingMethod")] - fn rotate_local_axis(&mut self, #[proxy] axis: bevy::math::Vec3, angle: f32) -> (); + fn rotate_local_axis(&mut self, #[proxy] axis: bevy::math::Dir3, angle: f32) -> (); "#, r#" @@ -521,42 +588,6 @@ struct GlobalTransform(); rotation: bevy::math::Quat, ) -> (); -"#, - r#" -/// Rotates this [`Transform`] so that [`Transform::forward`] points towards the `target` position, -/// and [`Transform::up`] points towards `up`. -/// In some cases it's not possible to construct a rotation. Another axis will be picked in those cases: -/// * if `target` is the same as the transform translation, `Vec3::Z` is used instead -/// * if `up` is zero, `Vec3::Y` is used instead -/// * if the resulting forward direction is parallel with `up`, an orthogonal vector is used as the "right" direction - - #[lua(kind = "MutatingMethod")] - fn look_at( - &mut self, - #[proxy] - target: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> (); - -"#, - r#" -/// Rotates this [`Transform`] so that [`Transform::forward`] points in the given `direction` -/// and [`Transform::up`] points towards `up`. -/// In some cases it's not possible to construct a rotation. Another axis will be picked in those cases: -/// * if `direction` is zero, `Vec3::NEG_Z` is used instead -/// * if `up` is zero, `Vec3::Y` is used instead -/// * if `direction` is parallel with `up`, an orthogonal vector is used as the "right" direction - - #[lua(kind = "MutatingMethod")] - fn look_to( - &mut self, - #[proxy] - direction: bevy::math::Vec3, - #[proxy] - up: bevy::math::Vec3, - ) -> (); - "#, r#" /// Multiplies `self` with `transform` component by component, returning the @@ -595,51 +626,12 @@ struct 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::Transform; - -"#, - 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", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::transform::components::Transform; + fn eq(&self, #[proxy] other: &components::transform::Transform) -> bool; "#, r#" diff --git a/crates/bevy_script_api/src/providers/bevy_window.rs b/crates/bevy_script_api/src/providers/bevy_window.rs index fd2f7e14..2c002018 100644 --- a/crates/bevy_script_api/src/providers/bevy_window.rs +++ b/crates/bevy_script_api/src/providers/bevy_window.rs @@ -4,7 +4,7 @@ #![cfg_attr(rustfmt, rustfmt_skip)] use super::bevy_ecs::*; use super::bevy_reflect::*; -use super::bevy_input::*; +use super::bevy_math::*; extern crate self as bevy_script_api; use bevy_script_api::{ lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, @@ -15,8 +15,13 @@ use bevy_script_api::{ remote = "bevy::window::prelude::CursorEntered", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::CursorEntered) -> bool; "#, r#" @@ -27,13 +32,8 @@ use bevy_script_api::{ "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::CursorEntered) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -53,12 +53,6 @@ struct CursorEntered { remote = "bevy::window::prelude::CursorIcon", 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::CursorIcon; @@ -73,6 +67,12 @@ struct CursorEntered { )] 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")] @@ -88,25 +88,25 @@ struct CursorIcon {} remote = "bevy::window::prelude::CursorLeft", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::CursorLeft; + #[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::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::window::prelude::CursorLeft; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::CursorLeft) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -161,6 +161,12 @@ struct CursorMoved { 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; @@ -175,12 +181,6 @@ struct CursorMoved { )] fn eq(&self, #[proxy] other: &event::FileDragAndDrop) -> bool; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -196,12 +196,6 @@ struct FileDragAndDrop {} remote = "bevy::window::prelude::Ime", 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", @@ -216,6 +210,12 @@ struct FileDragAndDrop {} #[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")] @@ -231,8 +231,8 @@ struct Ime {} remote = "bevy::window::prelude::MonitorSelection", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::MonitorSelection; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -248,8 +248,8 @@ struct Ime {} "#, 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::window::prelude::MonitorSelection; "#, r#" @@ -269,12 +269,6 @@ struct MonitorSelection {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::prelude::ReceivedCharacter; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" @@ -286,6 +280,12 @@ struct MonitorSelection {} )] 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")] @@ -341,6 +341,14 @@ struct ReceivedCharacter { #[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. @@ -357,6 +365,14 @@ struct ReceivedCharacter { #[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. @@ -399,6 +415,7 @@ struct Window { #[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, @@ -407,6 +424,12 @@ struct Window { 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( @@ -425,14 +448,14 @@ struct Window { "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::WindowMoved; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, 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::window::prelude::WindowMoved; "#, r#" @@ -553,12 +576,6 @@ struct WindowResizeConstraints { remote = "bevy::window::WindowResized", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowResized; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -567,6 +584,12 @@ struct WindowResizeConstraints { )] 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")] @@ -587,6 +610,12 @@ struct WindowResized { 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; @@ -601,6 +630,38 @@ struct WindowResized { )] 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#" @@ -615,7 +676,7 @@ fn index(&self) -> String { } "#] )] -struct WindowCreated { +struct WindowClosing { #[lua(output(proxy))] window: bevy::ecs::entity::Entity, } @@ -628,12 +689,6 @@ struct WindowCreated { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::WindowClosed; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" @@ -645,6 +700,12 @@ struct WindowCreated { )] 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")] @@ -663,13 +724,8 @@ struct WindowClosed { remote = "bevy::window::WindowCloseRequested", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowCloseRequested) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -680,8 +736,13 @@ struct WindowClosed { "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowCloseRequested) -> bool; "#, r#" @@ -701,12 +762,6 @@ struct WindowCloseRequested { remote = "bevy::window::WindowDestroyed", 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::WindowDestroyed; @@ -721,6 +776,12 @@ struct WindowCloseRequested { )] 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")] @@ -739,14 +800,14 @@ struct WindowDestroyed { remote = "bevy::window::RequestRedraw", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::RequestRedraw; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, 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::window::RequestRedraw; "#, r#" @@ -774,12 +835,6 @@ struct RequestRedraw {} remote = "bevy::window::WindowFocused", 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::WindowFocused; @@ -794,6 +849,12 @@ struct RequestRedraw {} )] 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")] @@ -852,6 +913,12 @@ struct WindowOccluded { 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", @@ -860,12 +927,6 @@ struct WindowOccluded { )] fn eq(&self, #[proxy] other: &event::WindowScaleFactorChanged) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowScaleFactorChanged; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -918,12 +979,6 @@ struct WindowBackendScaleFactorChanged { remote = "bevy::window::WindowThemeChanged", 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", @@ -932,6 +987,12 @@ struct WindowBackendScaleFactorChanged { )] 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#" @@ -955,22 +1016,99 @@ struct WindowThemeChanged { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::window::ApplicationLifetime", + remote = "bevy::window::AppLifecycle", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::ApplicationLifetime) -> bool; + #[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::ApplicationLifetime; + 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#" @@ -986,16 +1124,41 @@ fn index(&self) -> String { } "#] )] -struct ApplicationLifetime {} +struct WindowTheme {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::window::PrimaryWindow", + 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#" @@ -1005,13 +1168,13 @@ struct ApplicationLifetime {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &window::PrimaryWindow) -> bool; + fn eq(&self, #[proxy] other: &window::NormalizedWindowRef) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::PrimaryWindow; + fn clone(&self) -> bevy::window::NormalizedWindowRef; "#, r#" @@ -1021,7 +1184,7 @@ fn index(&self) -> String { } "#] )] -struct PrimaryWindow {} +struct NormalizedWindowRef(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), @@ -1050,22 +1213,22 @@ struct Cursor { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::window::CursorGrabMode", + remote = "bevy::window::PresentMode", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::CursorGrabMode; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &window::CursorGrabMode) -> bool; + 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#" @@ -1081,15 +1244,21 @@ fn index(&self) -> String { } "#] )] -struct CursorGrabMode {} +struct PresentMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::window::CompositeAlphaMode", + 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::CompositeAlphaMode; + fn clone(&self) -> bevy::window::WindowMode; "#, r#" @@ -1100,13 +1269,7 @@ struct CursorGrabMode {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &window::CompositeAlphaMode) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + fn eq(&self, #[proxy] other: &window::WindowMode) -> bool; "#, r#" @@ -1116,7 +1279,7 @@ fn index(&self) -> String { } "#] )] -struct CompositeAlphaMode {} +struct WindowMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), @@ -1142,7 +1305,7 @@ struct CompositeAlphaMode {} /// Creates a new [`WindowResolution`]. #[lua(kind = "Function", output(proxy))] - fn new(logical_width: f32, logical_height: f32) -> bevy::window::WindowResolution; + fn new(physical_width: f32, physical_height: f32) -> bevy::window::WindowResolution; "#, r#" @@ -1168,6 +1331,13 @@ struct CompositeAlphaMode {} #[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. @@ -1182,6 +1352,13 @@ struct CompositeAlphaMode {} #[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. @@ -1229,6 +1406,16 @@ struct CompositeAlphaMode {} #[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. @@ -1253,17 +1440,17 @@ struct WindowResolution {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::window::WindowMode", + remote = "bevy::window::CompositeAlphaMode", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowMode; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, 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::window::CompositeAlphaMode; "#, r#" @@ -1274,7 +1461,7 @@ struct WindowResolution {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &window::WindowMode) -> bool; + fn eq(&self, #[proxy] other: &window::CompositeAlphaMode) -> bool; "#, r#" @@ -1284,21 +1471,15 @@ fn index(&self) -> String { } "#] )] -struct WindowMode {} +struct CompositeAlphaMode {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::window::WindowLevel", + remote = "bevy::window::EnabledButtons", 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; + fn clone(&self) -> bevy::window::EnabledButtons; "#, r#" @@ -1309,7 +1490,7 @@ struct WindowMode {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &window::WindowLevel) -> bool; + fn eq(&self, #[proxy] other: &window::EnabledButtons) -> bool; "#, r#" @@ -1319,47 +1500,28 @@ fn index(&self) -> String { } "#] )] -struct WindowLevel {} +struct EnabledButtons { + minimize: bool, + maximize: bool, + close: bool, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::window::PresentMode", + remote = "bevy::window::WindowLevel", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::PresentMode) -> bool; + #[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::PresentMode; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + fn clone(&self) -> bevy::window::WindowLevel; "#, 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::InternalWindowState", - functions[r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -1367,27 +1529,7 @@ struct PresentMode {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &window::InternalWindowState) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::InternalWindowState; - -"#, - 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; + fn eq(&self, #[proxy] other: &window::WindowLevel) -> bool; "#, r#" @@ -1397,15 +1539,15 @@ fn index(&self) -> String { } "#] )] -struct InternalWindowState {} +struct WindowLevel {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::window::WindowTheme", + remote = "bevy::window::InternalWindowState", 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::window::InternalWindowState; "#, r#" @@ -1416,42 +1558,21 @@ struct InternalWindowState {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &window::WindowTheme) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowTheme; + fn eq(&self, #[proxy] other: &window::InternalWindowState) -> bool; "#, 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::EnabledButtons", - functions[r#" +/// Consumes the current maximize request, if it exists. This should only be called by window backends. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::EnabledButtons) -> bool; + #[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(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::EnabledButtons; + #[lua(kind = "MutatingMethod")] + fn take_minimize_request(&mut self) -> std::option::Option; "#, r#" @@ -1461,34 +1582,18 @@ fn index(&self) -> String { } "#] )] -struct EnabledButtons { - minimize: bool, - maximize: bool, - close: bool, -} +struct InternalWindowState {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::window::WindowRef", + remote = "bevy::window::CursorGrabMode", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowRef; + fn clone(&self) -> bevy::window::CursorGrabMode; "#, 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) -> (); @@ -1502,20 +1607,7 @@ struct WindowRef {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &window::NormalizedWindowRef) -> bool; - -"#, - 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::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::NormalizedWindowRef; + fn eq(&self, #[proxy] other: &window::CursorGrabMode) -> bool; "#, r#" @@ -1525,7 +1617,7 @@ fn index(&self) -> String { } "#] )] -struct NormalizedWindowRef(); +struct CursorGrabMode {} #[derive(Default)] pub(crate) struct Globals; impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { @@ -1591,6 +1683,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyWindowAPIProvider { .process_type::() .process_type::() .process_type::() + .process_type::() .process_type::() .process_type::() .process_type::() @@ -1600,25 +1693,25 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyWindowAPIProvider { .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::() .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() + .process_type::() }, ), ) @@ -1655,6 +1748,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyWindowAPIProvider { >(); 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::(); @@ -1664,19 +1758,19 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyWindowAPIProvider { 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 6fd8c881..0f2e29ed 100644 --- a/crates/bevy_script_api/src/providers/mod.rs +++ b/crates/bevy_script_api/src/providers/mod.rs @@ -4,6 +4,7 @@ #![cfg_attr(rustfmt, rustfmt_skip)] pub mod bevy_ecs; pub mod bevy_transform; +pub mod bevy_math; pub mod bevy_input; pub mod bevy_core; pub mod bevy_time; @@ -23,6 +24,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for LuaBevyAPIProvider { ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { bevy_ecs::BevyEcsAPIProvider.attach_api(ctx)?; bevy_transform::BevyTransformAPIProvider.attach_api(ctx)?; + bevy_math::BevyMathAPIProvider.attach_api(ctx)?; bevy_input::BevyInputAPIProvider.attach_api(ctx)?; bevy_core::BevyCoreAPIProvider.attach_api(ctx)?; bevy_time::BevyTimeAPIProvider.attach_api(ctx)?; @@ -35,6 +37,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for LuaBevyAPIProvider { [ bevy_ecs::BevyEcsAPIProvider.get_doc_fragment(), bevy_transform::BevyTransformAPIProvider.get_doc_fragment(), + bevy_math::BevyMathAPIProvider.get_doc_fragment(), bevy_input::BevyInputAPIProvider.get_doc_fragment(), bevy_core::BevyCoreAPIProvider.get_doc_fragment(), bevy_time::BevyTimeAPIProvider.get_doc_fragment(), @@ -70,6 +73,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for LuaBevyAPIProvider { fn register_with_app(&self, app: &mut bevy::app::App) { bevy_ecs::BevyEcsAPIProvider.register_with_app(app); bevy_transform::BevyTransformAPIProvider.register_with_app(app); + bevy_math::BevyMathAPIProvider.register_with_app(app); bevy_input::BevyInputAPIProvider.register_with_app(app); bevy_core::BevyCoreAPIProvider.register_with_app(app); bevy_time::BevyTimeAPIProvider.register_with_app(app); diff --git a/crates/bevy_script_api/src/rhai/mod.rs b/crates/bevy_script_api/src/rhai/mod.rs index d3e50f7d..26d40884 100644 --- a/crates/bevy_script_api/src/rhai/mod.rs +++ b/crates/bevy_script_api/src/rhai/mod.rs @@ -27,7 +27,7 @@ impl RegisterForeignRhaiType for App { &mut self, ) -> &mut Self { { - let registry = self.world.resource_mut::(); + let registry = self.world_mut().resource_mut::(); let mut registry = registry.write(); let rhai_data = >::from_type(); diff --git a/crates/bevy_script_api/src/rhai/std.rs b/crates/bevy_script_api/src/rhai/std.rs index a0bb178b..0ed09d8c 100644 --- a/crates/bevy_script_api/src/rhai/std.rs +++ b/crates/bevy_script_api/src/rhai/std.rs @@ -4,7 +4,7 @@ use std::{ iter::Map, }; -use bevy::reflect::{FromReflect, Reflect, TypePath}; +use bevy::reflect::{FromReflect, GetTypeRegistration, Reflect, TypePath}; #[allow(deprecated)] use bevy_mod_scripting_rhai::rhai::{CustomType, Dynamic, Engine, EvalAltResult, Position}; @@ -114,8 +114,15 @@ impl_rhai_proxy!(f64 as FLOAT); impl_rhai_proxy!(bool as bool); impl_rhai_proxy!(String as Into); -impl RhaiProxyable - for Option +impl< + T: RhaiProxyable + + Reflect + + FromReflect + + TypePath + + Clone + + FromRhaiProxy + + GetTypeRegistration, + > RhaiProxyable for Option { fn ref_to_rhai(self_: crate::ReflectReference) -> Result> { self_.get_typed(|s: &Option| match s { @@ -241,8 +248,14 @@ 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 + TypePath + RhaiProxyable + FromRhaiProxy + Clone {} -impl RhaiVecElem for T {} +pub trait RhaiVecElem: + FromReflect + GetTypeRegistration + TypePath + RhaiProxyable + FromRhaiProxy + Clone +{ +} +impl + RhaiVecElem for T +{ +} /// A ScriptVec wrapper which implements a custom iterator ontop of ScriptVec's pub struct RhaiVec(pub ScriptVec); diff --git a/crates/languages/bevy_mod_scripting_lua/src/assets.rs b/crates/languages/bevy_mod_scripting_lua/src/assets.rs index 8c94f4e5..2b87fcdf 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/assets.rs @@ -135,7 +135,12 @@ impl AssetLoader for LuaLoader { reader: &'a mut Reader, //bytes: &'a [u8], _settings: &'a (), load_context: &'a mut bevy::asset::LoadContext, - ) -> bevy::asset::BoxedFuture<'a, Result> { + ) -> impl bevy::utils::ConditionalSendFuture< + Output = std::result::Result< + ::Asset, + ::Error, + >, + > { bevy::prelude::info!("lua loader invoked: {:#}", load_context.asset_path()); Box::pin(async move { let mut bytes = Vec::new(); diff --git a/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml b/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml index 56104dd0..fbb92b2f 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml @@ -25,7 +25,7 @@ proc-macro = true [dependencies] bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.6.0" } paste = "1.0.7" -darling = "0.20.3" +darling = "0.20" syn = { version = "2.0.38", features = ["full", "fold", "extra-traits"] } quote = "1.0.8" proc-macro2 = "1.0" diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs index 9e0cd6d6..ece327f3 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs +++ b/crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_unwrap_or_default)] // from darling + use std::collections::HashMap; use bevy_mod_scripting_common::input::{SimpleType, VisitSimpleType}; @@ -18,7 +20,7 @@ pub struct ArgAttributes { /// Struct for holding argument/output information in functions passed via `functions[..]` meta #[derive(Debug)] pub struct Arg { - pub attrs: ArgAttributes, + // pub attrs: ArgAttributes, pub mutability: Option, /// the type of the argument, only suported patterns are allowed pub name: Ident, @@ -32,14 +34,14 @@ pub struct Arg { impl Arg { pub fn new( - attrs: ArgAttributes, + // attrs: ArgAttributes, name: Ident, mutability: Option, type_: SimpleType, is_raw: bool, ) -> Self { Self { - attrs, + // attrs, mutability, span: name.span(), name, diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/function.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/function.rs index 631f4216..29241a91 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/function.rs +++ b/crates/languages/bevy_mod_scripting_lua_derive/src/function.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_unwrap_or_default)] // from darling + use bevy_mod_scripting_common::input::{ DuoPath, IdentifierRenamingVisitor, Reference, SimpleType, VisitSimpleType, }; @@ -125,7 +127,6 @@ pub struct FunctionAttributes { /// Useful for binary operators which can accept many types on both sides #[derive(Debug)] pub struct CompositeFunction { - pub id: String, pub functions: Vec1, } diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 439075b9..1b919e15 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -109,8 +109,8 @@ fn extract_composite_functions(functions: &mut Vec) -> Vec { let type_ = SimpleType::new_from_fn_arg(PROXY_PREFIX, &arg, proxied_type_path, &type_map)?; - let attrs = ArgAttributes::from_attributes(&receiver.attrs)?; + // let attrs = ArgAttributes::from_attributes(&receiver.attrs)?; Arg::new( - attrs, + // attrs, Ident::new(SELF_ALIAS, receiver.span()), receiver.mutability, type_, @@ -133,7 +133,7 @@ impl Signature { }; Ok(Arg::new( - attrs, + // attrs, arg_name, mutability, type_, diff --git a/crates/languages/bevy_mod_scripting_rhai/src/assets.rs b/crates/languages/bevy_mod_scripting_rhai/src/assets.rs index 4470cf59..c4d2da90 100644 --- a/crates/languages/bevy_mod_scripting_rhai/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_rhai/src/assets.rs @@ -25,17 +25,15 @@ impl AssetLoader for RhaiLoader { type Asset = RhaiFile; type Settings = (); type Error = anyhow::Error; - fn load<'a>( + async fn load<'a>( &'a self, - reader: &'a mut Reader, + reader: &'a mut Reader<'_>, _: &'a Self::Settings, - _: &'a mut LoadContext, - ) -> bevy::asset::BoxedFuture<'a, Result> { - Box::pin(async move { - let mut bytes = Vec::new(); - reader.read_to_end(&mut bytes).await?; - Ok(RhaiFile { bytes }) - }) + _: &'a mut LoadContext<'_>, + ) -> Result { + let mut bytes = Vec::new(); + reader.read_to_end(&mut bytes).await?; + Ok(RhaiFile { bytes }) } fn extensions(&self) -> &[&str] { diff --git a/crates/languages/bevy_mod_scripting_rune/src/assets.rs b/crates/languages/bevy_mod_scripting_rune/src/assets.rs index 23be9f0f..e0527227 100644 --- a/crates/languages/bevy_mod_scripting_rune/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_rune/src/assets.rs @@ -32,7 +32,12 @@ impl AssetLoader for RuneLoader { reader: &'a mut Reader, _settings: &'a (), _load_context: &'a mut bevy::asset::LoadContext, - ) -> bevy::utils::BoxedFuture<'a, Result> { + ) -> 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?; diff --git a/crates/macro_tests/Cargo.toml b/crates/macro_tests/Cargo.toml index ded3d2b7..969de9f5 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.13.1", default-features = false } +bevy = { version = "0.14", default-features = false } bevy_mod_scripting = { path = "../../", features = [ "lua", "lua_script_api", diff --git a/crates/macro_tests/tests/fail/references/non-proxy-reference.stderr b/crates/macro_tests/tests/fail/references/non-proxy-reference.stderr index c851f3cf..ecb3063b 100644 --- a/crates/macro_tests/tests/fail/references/non-proxy-reference.stderr +++ b/crates/macro_tests/tests/fail/references/non-proxy-reference.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `&str: FromLua<'_>` is not satisfied +error[E0277]: the trait bound `&str: FromLuaMulti<'lua>` is not satisfied --> tests/fail/references/non-proxy-reference.rs:4:10 | 4 | #[derive(LuaProxy, Reflect, Clone)] diff --git a/crates/macro_tests/tests/fail/references/output-with-proxy-reference.stderr b/crates/macro_tests/tests/fail/references/output-with-proxy-reference.stderr index ad00d2e9..7095c444 100644 --- a/crates/macro_tests/tests/fail/references/output-with-proxy-reference.stderr +++ b/crates/macro_tests/tests/fail/references/output-with-proxy-reference.stderr @@ -13,10 +13,6 @@ note: associated function defined here 5 | #[proxy(functions[ | ^ = note: this error originates in the derive macro `LuaProxy` which comes from the expansion of the macro `bevy_script_api::make_script_wrapper` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider using clone here - | -4 | #[derive(LuaProxy.clone(), Reflect, Clone)] - | ++++++++ error[E0308]: mismatched types --> tests/fail/references/output-with-proxy-reference.rs:4:10 @@ -29,7 +25,7 @@ error[E0308]: mismatched types | = note: this error originates in the derive macro `LuaProxy` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `&LuaMyStruct: ToTypename` is not satisfied +error[E0277]: the trait bound `&LuaMyStruct: TealMultiValue` is not satisfied --> tests/fail/references/output-with-proxy-reference.rs:4:10 | 4 | #[derive(LuaProxy, Reflect, Clone)] @@ -47,7 +43,7 @@ note: required by a bound in `bevy_mod_scripting_lua::tealr::mlu::TealDataMethod | ^^^^^^^^^^^^^^ required by this bound in `TealDataMethods::add_function` = note: this error originates in the derive macro `LuaProxy` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `&LuaMyStruct: LuaUserData` is not satisfied +error[E0277]: the trait bound `&LuaMyStruct: IntoLuaMulti<'lua>` is not satisfied --> tests/fail/references/output-with-proxy-reference.rs:4:10 | 4 | #[derive(LuaProxy, Reflect, Clone)] diff --git a/crates/macro_tests/tests/fail/simple/invalid-argument-count.stderr b/crates/macro_tests/tests/fail/simple/invalid-argument-count.stderr index ea9edd30..edce984c 100644 --- a/crates/macro_tests/tests/fail/simple/invalid-argument-count.stderr +++ b/crates/macro_tests/tests/fail/simple/invalid-argument-count.stderr @@ -2,7 +2,7 @@ error[E0061]: this function takes 2 arguments but 1 argument was supplied --> tests/fail/simple/invalid-argument-count.rs:4:10 | 4 | #[derive(LuaProxy, Reflect, Clone)] - | ^^^^^^^^ an argument of type `usize` is missing + | ^^^^^^^^ argument #2 of type `usize` is missing | note: method defined here --> tests/fail/simple/invalid-argument-count.rs:14:12 @@ -10,7 +10,3 @@ note: method defined here 14 | pub fn my_fn(&self, _: usize) {} | ^^^^^ ----- -------- = note: this error originates in the derive macro `LuaProxy` (in Nightly builds, run with -Z macro-backtrace for more info) -help: provide the argument - | -4 | #[derive(LuaProxy(LuaProxy, /* usize */), Reflect, Clone)] - | +++++++++++++++++++++++ diff --git a/examples/lua/bevy_api.rs b/examples/lua/bevy_api.rs index 259081e6..493bec50 100644 --- a/examples/lua/bevy_api.rs +++ b/examples/lua/bevy_api.rs @@ -197,7 +197,7 @@ fn main() -> std::io::Result<()> { .expect("Something went wrong in the script!"); }); - world.send_event(AppExit); + world.send_event(AppExit::Success); }, ); diff --git a/examples/lua/console_integration.rs b/examples/lua/console_integration.rs index 1b64efe3..ca1711d2 100644 --- a/examples/lua/console_integration.rs +++ b/examples/lua/console_integration.rs @@ -32,7 +32,7 @@ impl APIProvider for LuaAPIProvider { let mut events: Mut> = world.get_resource_mut().unwrap(); - events.send(PrintConsoleLine { line: msg.into() }); + events.send(PrintConsoleLine { line: msg }); // return something Ok(()) @@ -71,7 +71,7 @@ pub fn forward_script_err_to_console( ) { for e in r.read() { w.send(PrintConsoleLine { - line: format!("ERROR:{}", e.error).into(), + line: format!("ERROR:{}", e.error), }); } } diff --git a/examples/lua/game_of_life.rs b/examples/lua/game_of_life.rs index ed844775..11482c2f 100644 --- a/examples/lua/game_of_life.rs +++ b/examples/lua/game_of_life.rs @@ -95,7 +95,7 @@ pub fn setup( settings.display_grid_dimensions.0 as f32, settings.display_grid_dimensions.1 as f32, )), - color: Color::TOMATO, + color: Color::srgb(1.0, 0.388, 0.278), // TOMATO ..Default::default() }, ..Default::default() diff --git a/examples/rhai/bevy_api.rs b/examples/rhai/bevy_api.rs index b101f0bb..88dcc65c 100644 --- a/examples/rhai/bevy_api.rs +++ b/examples/rhai/bevy_api.rs @@ -171,7 +171,7 @@ fn main() -> std::io::Result<()> { .expect("Something went wrong in the script!"); }); - world.send_event(AppExit); + world.send_event(AppExit::Success); }); app.run(); diff --git a/examples/rhai/console_integration.rs b/examples/rhai/console_integration.rs index fdb13fda..caeef239 100644 --- a/examples/rhai/console_integration.rs +++ b/examples/rhai/console_integration.rs @@ -27,7 +27,7 @@ impl APIProvider for RhaiAPI { let mut world = world.write(); let mut events: Mut> = world.get_resource_mut().unwrap(); - events.send(PrintConsoleLine { line: msg.into() }); + events.send(PrintConsoleLine { line: msg }); }, ); @@ -63,7 +63,7 @@ pub fn forward_script_err_to_console( ) { for e in r.read() { w.send(PrintConsoleLine { - line: format!("ERROR:{}", e.error).into(), + line: format!("ERROR:{}", e.error), }); } } diff --git a/examples/rhai/game_of_life.rs b/examples/rhai/game_of_life.rs index b9a45401..aa203448 100644 --- a/examples/rhai/game_of_life.rs +++ b/examples/rhai/game_of_life.rs @@ -100,7 +100,7 @@ pub fn setup( settings.display_grid_dimensions.0 as f32, settings.display_grid_dimensions.1 as f32, )), - color: Color::TOMATO, + color: Color::srgb(1.0, 0.388, 0.278), // TOMATO ..Default::default() }, ..Default::default() diff --git a/examples/rune/event_recipients.rs b/examples/rune/event_recipients.rs index d7ec0846..8b469edf 100644 --- a/examples/rune/event_recipients.rs +++ b/examples/rune/event_recipients.rs @@ -115,5 +115,5 @@ fn main() { .add_script_handler::, 0, 0>(PostUpdate) .add_script_host::>(PostUpdate) .add_api_provider::>(Box::new(RuneAPIProvider)) - .run() + .run(); } diff --git a/examples/rune/minimal.rs b/examples/rune/minimal.rs index 3a830307..ff75fbc5 100644 --- a/examples/rune/minimal.rs +++ b/examples/rune/minimal.rs @@ -10,7 +10,7 @@ fn main() { .add_script_host::>(PostUpdate) .add_script_handler::, 0, 1>(PostUpdate) .add_api_provider::>(Box::new(MyAPIProvider)) - .run() + .run(); } struct MyAPIProvider; diff --git a/examples/wrappers.rs b/examples/wrappers.rs index 734c9f9b..fb085ea5 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -111,7 +111,7 @@ fn main() -> std::io::Result<()> { .expect("Could not find MyProxiedStruct Resource"); println!("After the script MyProxiedStruct resource is now: {my_thing:#?}"); // exit app - world.send_event(AppExit); + world.send_event(AppExit::Success); }); app.run(); diff --git a/makefile b/makefile index 2a39b284..74ed9a9f 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-01-24 -BEVY_VERSION=0.13.1 -GLAM_VERSION=0.25.0 +NIGHTLY_VERSION=nightly-2024-05-20 +BEVY_VERSION=0.14.2 +GLAM_VERSION=0.28.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_gltf,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) @@ -48,6 +48,7 @@ valgrind: install_bevy_api_gen: rustup install ${NIGHTLY_VERSION} + rustup component add rust-src rustc-dev llvm-tools-preview --toolchain ${NIGHTLY_VERSION} cargo +${NIGHTLY_VERSION} install --path ./crates/bevy_api_gen prepare_api_gen: @@ -60,7 +61,7 @@ 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} collect_bevy: cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen collect --output ${OUTPUT_PATH} --template-args '{ "self_is_bevy_script_api": true}' diff --git a/readme.md b/readme.md index aa39fe43..fb0dc2cd 100644 --- a/readme.md +++ b/readme.md @@ -201,19 +201,21 @@ Documentation features are exposed at runtime via the `update_documentation` bui use bevy::prelude::*; use bevy_mod_scripting::prelude::*; -#[cfg(feature = "lua")] fn main() -> std::io::Result<()> { let mut app = App::new(); app.add_plugins(DefaultPlugins) - .add_plugins(ScriptingPlugin) - .add_script_host::>(PostUpdate) + .add_plugins(ScriptingPlugin); + #[cfg(feature = "lua")] + { + app.add_script_host::>(PostUpdate) // Note: This is a noop in optimized builds unless the `doc_always` feature is enabled! // this will pickup any API providers added *BEFOREHAND* like this one .add_api_provider::>(Box::new(LuaBevyAPIProvider)) .add_api_provider::>(Box::new(LuaCoreBevyAPIProvider)) .update_documentation::>() .add_script_handler::, 0, 0>(PostUpdate); + } Ok(()) } @@ -268,3 +270,10 @@ To see more complex applications of this library have a look at the examples: Below is a video showcasing the game_of_life example: [![Watch the video](https://img.youtube.com/vi/Mo9gh2g3ZHw/maxresdefault.jpg)](https://www.youtube.com/watch?v=Mo9gh2g3ZHw) + +# Compatibility + +| bevy_mod_scripting | bevy | +|---------------------|--------| +| 0.7 | 0.14 | +| 0.6 | 0.13.1 | diff --git a/wsl.sh b/wsl.sh new file mode 100644 index 00000000..9512e8c7 --- /dev/null +++ b/wsl.sh @@ -0,0 +1,3 @@ +# updating to bevy 0.14 caused issues with WSL for me, these vars help, run source wsl.sh before other cargo commands and it might work, you might need to install mesa/vulkan drivers +export WGPU_BACKEND=vulkan +export WINIT_UNIX_BACKEND=x11 \ No newline at end of file